mutation.go 1.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/addwechatfriendlog"
  10. "wechat-api/ent/agent"
  11. "wechat-api/ent/agentbase"
  12. "wechat-api/ent/aliyunavatar"
  13. "wechat-api/ent/allocagent"
  14. "wechat-api/ent/apikey"
  15. "wechat-api/ent/batchmsg"
  16. "wechat-api/ent/category"
  17. "wechat-api/ent/chatrecords"
  18. "wechat-api/ent/chatsession"
  19. "wechat-api/ent/compapiasynctask"
  20. "wechat-api/ent/contact"
  21. "wechat-api/ent/contactfield"
  22. "wechat-api/ent/contactfieldtemplate"
  23. "wechat-api/ent/creditbalance"
  24. "wechat-api/ent/creditusage"
  25. "wechat-api/ent/custom_types"
  26. "wechat-api/ent/employee"
  27. "wechat-api/ent/employeeconfig"
  28. "wechat-api/ent/label"
  29. "wechat-api/ent/labellog"
  30. "wechat-api/ent/labelrelationship"
  31. "wechat-api/ent/labeltagging"
  32. "wechat-api/ent/message"
  33. "wechat-api/ent/messagerecords"
  34. "wechat-api/ent/msg"
  35. "wechat-api/ent/payrecharge"
  36. "wechat-api/ent/predicate"
  37. "wechat-api/ent/server"
  38. "wechat-api/ent/sopnode"
  39. "wechat-api/ent/sopstage"
  40. "wechat-api/ent/soptask"
  41. "wechat-api/ent/token"
  42. "wechat-api/ent/tutorial"
  43. "wechat-api/ent/usagedetail"
  44. "wechat-api/ent/usagestatisticday"
  45. "wechat-api/ent/usagestatistichour"
  46. "wechat-api/ent/usagestatisticmonth"
  47. "wechat-api/ent/usagetotal"
  48. "wechat-api/ent/whatsapp"
  49. "wechat-api/ent/whatsappchannel"
  50. "wechat-api/ent/workexperience"
  51. "wechat-api/ent/wpchatroom"
  52. "wechat-api/ent/wpchatroommember"
  53. "wechat-api/ent/wx"
  54. "wechat-api/ent/wxcard"
  55. "wechat-api/ent/wxcarduser"
  56. "wechat-api/ent/wxcardvisit"
  57. "wechat-api/ent/xunji"
  58. "wechat-api/ent/xunjiservice"
  59. "entgo.io/ent"
  60. "entgo.io/ent/dialect/sql"
  61. )
  62. const (
  63. // Operation types.
  64. OpCreate = ent.OpCreate
  65. OpDelete = ent.OpDelete
  66. OpDeleteOne = ent.OpDeleteOne
  67. OpUpdate = ent.OpUpdate
  68. OpUpdateOne = ent.OpUpdateOne
  69. // Node types.
  70. TypeAddWechatFriendLog = "AddWechatFriendLog"
  71. TypeAgent = "Agent"
  72. TypeAgentBase = "AgentBase"
  73. TypeAliyunAvatar = "AliyunAvatar"
  74. TypeAllocAgent = "AllocAgent"
  75. TypeApiKey = "ApiKey"
  76. TypeBatchMsg = "BatchMsg"
  77. TypeCategory = "Category"
  78. TypeChatRecords = "ChatRecords"
  79. TypeChatSession = "ChatSession"
  80. TypeCompapiAsynctask = "CompapiAsynctask"
  81. TypeContact = "Contact"
  82. TypeContactField = "ContactField"
  83. TypeContactFieldTemplate = "ContactFieldTemplate"
  84. TypeCreditBalance = "CreditBalance"
  85. TypeCreditUsage = "CreditUsage"
  86. TypeEmployee = "Employee"
  87. TypeEmployeeConfig = "EmployeeConfig"
  88. TypeLabel = "Label"
  89. TypeLabelLog = "LabelLog"
  90. TypeLabelRelationship = "LabelRelationship"
  91. TypeLabelTagging = "LabelTagging"
  92. TypeMessage = "Message"
  93. TypeMessageRecords = "MessageRecords"
  94. TypeMsg = "Msg"
  95. TypePayRecharge = "PayRecharge"
  96. TypeServer = "Server"
  97. TypeSopNode = "SopNode"
  98. TypeSopStage = "SopStage"
  99. TypeSopTask = "SopTask"
  100. TypeToken = "Token"
  101. TypeTutorial = "Tutorial"
  102. TypeUsageDetail = "UsageDetail"
  103. TypeUsageStatisticDay = "UsageStatisticDay"
  104. TypeUsageStatisticHour = "UsageStatisticHour"
  105. TypeUsageStatisticMonth = "UsageStatisticMonth"
  106. TypeUsageTotal = "UsageTotal"
  107. TypeWhatsapp = "Whatsapp"
  108. TypeWhatsappChannel = "WhatsappChannel"
  109. TypeWorkExperience = "WorkExperience"
  110. TypeWpChatroom = "WpChatroom"
  111. TypeWpChatroomMember = "WpChatroomMember"
  112. TypeWx = "Wx"
  113. TypeWxCard = "WxCard"
  114. TypeWxCardUser = "WxCardUser"
  115. TypeWxCardVisit = "WxCardVisit"
  116. TypeXunji = "Xunji"
  117. TypeXunjiService = "XunjiService"
  118. )
  119. // AddWechatFriendLogMutation represents an operation that mutates the AddWechatFriendLog nodes in the graph.
  120. type AddWechatFriendLogMutation struct {
  121. config
  122. op Op
  123. typ string
  124. id *int64
  125. owner_wx_id *string
  126. owner_wx_type *int
  127. addowner_wx_type *int
  128. find_content *string
  129. message *string
  130. find_request *map[string]interface{}
  131. find_result *map[string]interface{}
  132. is_can_add *int
  133. addis_can_add *int
  134. task_count *int
  135. addtask_count *int
  136. task_id *int64
  137. addtask_id *int64
  138. add_request *map[string]interface{}
  139. add_result *map[string]interface{}
  140. created_at *int64
  141. addcreated_at *int64
  142. updated_at *int64
  143. addupdated_at *int64
  144. clearedFields map[string]struct{}
  145. done bool
  146. oldValue func(context.Context) (*AddWechatFriendLog, error)
  147. predicates []predicate.AddWechatFriendLog
  148. }
  149. var _ ent.Mutation = (*AddWechatFriendLogMutation)(nil)
  150. // addwechatfriendlogOption allows management of the mutation configuration using functional options.
  151. type addwechatfriendlogOption func(*AddWechatFriendLogMutation)
  152. // newAddWechatFriendLogMutation creates new mutation for the AddWechatFriendLog entity.
  153. func newAddWechatFriendLogMutation(c config, op Op, opts ...addwechatfriendlogOption) *AddWechatFriendLogMutation {
  154. m := &AddWechatFriendLogMutation{
  155. config: c,
  156. op: op,
  157. typ: TypeAddWechatFriendLog,
  158. clearedFields: make(map[string]struct{}),
  159. }
  160. for _, opt := range opts {
  161. opt(m)
  162. }
  163. return m
  164. }
  165. // withAddWechatFriendLogID sets the ID field of the mutation.
  166. func withAddWechatFriendLogID(id int64) addwechatfriendlogOption {
  167. return func(m *AddWechatFriendLogMutation) {
  168. var (
  169. err error
  170. once sync.Once
  171. value *AddWechatFriendLog
  172. )
  173. m.oldValue = func(ctx context.Context) (*AddWechatFriendLog, error) {
  174. once.Do(func() {
  175. if m.done {
  176. err = errors.New("querying old values post mutation is not allowed")
  177. } else {
  178. value, err = m.Client().AddWechatFriendLog.Get(ctx, id)
  179. }
  180. })
  181. return value, err
  182. }
  183. m.id = &id
  184. }
  185. }
  186. // withAddWechatFriendLog sets the old AddWechatFriendLog of the mutation.
  187. func withAddWechatFriendLog(node *AddWechatFriendLog) addwechatfriendlogOption {
  188. return func(m *AddWechatFriendLogMutation) {
  189. m.oldValue = func(context.Context) (*AddWechatFriendLog, error) {
  190. return node, nil
  191. }
  192. m.id = &node.ID
  193. }
  194. }
  195. // Client returns a new `ent.Client` from the mutation. If the mutation was
  196. // executed in a transaction (ent.Tx), a transactional client is returned.
  197. func (m AddWechatFriendLogMutation) Client() *Client {
  198. client := &Client{config: m.config}
  199. client.init()
  200. return client
  201. }
  202. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  203. // it returns an error otherwise.
  204. func (m AddWechatFriendLogMutation) Tx() (*Tx, error) {
  205. if _, ok := m.driver.(*txDriver); !ok {
  206. return nil, errors.New("ent: mutation is not running in a transaction")
  207. }
  208. tx := &Tx{config: m.config}
  209. tx.init()
  210. return tx, nil
  211. }
  212. // SetID sets the value of the id field. Note that this
  213. // operation is only accepted on creation of AddWechatFriendLog entities.
  214. func (m *AddWechatFriendLogMutation) SetID(id int64) {
  215. m.id = &id
  216. }
  217. // ID returns the ID value in the mutation. Note that the ID is only available
  218. // if it was provided to the builder or after it was returned from the database.
  219. func (m *AddWechatFriendLogMutation) ID() (id int64, exists bool) {
  220. if m.id == nil {
  221. return
  222. }
  223. return *m.id, true
  224. }
  225. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  226. // That means, if the mutation is applied within a transaction with an isolation level such
  227. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  228. // or updated by the mutation.
  229. func (m *AddWechatFriendLogMutation) IDs(ctx context.Context) ([]int64, error) {
  230. switch {
  231. case m.op.Is(OpUpdateOne | OpDeleteOne):
  232. id, exists := m.ID()
  233. if exists {
  234. return []int64{id}, nil
  235. }
  236. fallthrough
  237. case m.op.Is(OpUpdate | OpDelete):
  238. return m.Client().AddWechatFriendLog.Query().Where(m.predicates...).IDs(ctx)
  239. default:
  240. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  241. }
  242. }
  243. // SetOwnerWxID sets the "owner_wx_id" field.
  244. func (m *AddWechatFriendLogMutation) SetOwnerWxID(s string) {
  245. m.owner_wx_id = &s
  246. }
  247. // OwnerWxID returns the value of the "owner_wx_id" field in the mutation.
  248. func (m *AddWechatFriendLogMutation) OwnerWxID() (r string, exists bool) {
  249. v := m.owner_wx_id
  250. if v == nil {
  251. return
  252. }
  253. return *v, true
  254. }
  255. // OldOwnerWxID returns the old "owner_wx_id" field's value of the AddWechatFriendLog entity.
  256. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  258. func (m *AddWechatFriendLogMutation) OldOwnerWxID(ctx context.Context) (v string, err error) {
  259. if !m.op.Is(OpUpdateOne) {
  260. return v, errors.New("OldOwnerWxID is only allowed on UpdateOne operations")
  261. }
  262. if m.id == nil || m.oldValue == nil {
  263. return v, errors.New("OldOwnerWxID requires an ID field in the mutation")
  264. }
  265. oldValue, err := m.oldValue(ctx)
  266. if err != nil {
  267. return v, fmt.Errorf("querying old value for OldOwnerWxID: %w", err)
  268. }
  269. return oldValue.OwnerWxID, nil
  270. }
  271. // ResetOwnerWxID resets all changes to the "owner_wx_id" field.
  272. func (m *AddWechatFriendLogMutation) ResetOwnerWxID() {
  273. m.owner_wx_id = nil
  274. }
  275. // SetOwnerWxType sets the "owner_wx_type" field.
  276. func (m *AddWechatFriendLogMutation) SetOwnerWxType(i int) {
  277. m.owner_wx_type = &i
  278. m.addowner_wx_type = nil
  279. }
  280. // OwnerWxType returns the value of the "owner_wx_type" field in the mutation.
  281. func (m *AddWechatFriendLogMutation) OwnerWxType() (r int, exists bool) {
  282. v := m.owner_wx_type
  283. if v == nil {
  284. return
  285. }
  286. return *v, true
  287. }
  288. // OldOwnerWxType returns the old "owner_wx_type" field's value of the AddWechatFriendLog entity.
  289. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  291. func (m *AddWechatFriendLogMutation) OldOwnerWxType(ctx context.Context) (v int, err error) {
  292. if !m.op.Is(OpUpdateOne) {
  293. return v, errors.New("OldOwnerWxType is only allowed on UpdateOne operations")
  294. }
  295. if m.id == nil || m.oldValue == nil {
  296. return v, errors.New("OldOwnerWxType requires an ID field in the mutation")
  297. }
  298. oldValue, err := m.oldValue(ctx)
  299. if err != nil {
  300. return v, fmt.Errorf("querying old value for OldOwnerWxType: %w", err)
  301. }
  302. return oldValue.OwnerWxType, nil
  303. }
  304. // AddOwnerWxType adds i to the "owner_wx_type" field.
  305. func (m *AddWechatFriendLogMutation) AddOwnerWxType(i int) {
  306. if m.addowner_wx_type != nil {
  307. *m.addowner_wx_type += i
  308. } else {
  309. m.addowner_wx_type = &i
  310. }
  311. }
  312. // AddedOwnerWxType returns the value that was added to the "owner_wx_type" field in this mutation.
  313. func (m *AddWechatFriendLogMutation) AddedOwnerWxType() (r int, exists bool) {
  314. v := m.addowner_wx_type
  315. if v == nil {
  316. return
  317. }
  318. return *v, true
  319. }
  320. // ResetOwnerWxType resets all changes to the "owner_wx_type" field.
  321. func (m *AddWechatFriendLogMutation) ResetOwnerWxType() {
  322. m.owner_wx_type = nil
  323. m.addowner_wx_type = nil
  324. }
  325. // SetFindContent sets the "find_content" field.
  326. func (m *AddWechatFriendLogMutation) SetFindContent(s string) {
  327. m.find_content = &s
  328. }
  329. // FindContent returns the value of the "find_content" field in the mutation.
  330. func (m *AddWechatFriendLogMutation) FindContent() (r string, exists bool) {
  331. v := m.find_content
  332. if v == nil {
  333. return
  334. }
  335. return *v, true
  336. }
  337. // OldFindContent returns the old "find_content" field's value of the AddWechatFriendLog entity.
  338. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  340. func (m *AddWechatFriendLogMutation) OldFindContent(ctx context.Context) (v string, err error) {
  341. if !m.op.Is(OpUpdateOne) {
  342. return v, errors.New("OldFindContent is only allowed on UpdateOne operations")
  343. }
  344. if m.id == nil || m.oldValue == nil {
  345. return v, errors.New("OldFindContent requires an ID field in the mutation")
  346. }
  347. oldValue, err := m.oldValue(ctx)
  348. if err != nil {
  349. return v, fmt.Errorf("querying old value for OldFindContent: %w", err)
  350. }
  351. return oldValue.FindContent, nil
  352. }
  353. // ResetFindContent resets all changes to the "find_content" field.
  354. func (m *AddWechatFriendLogMutation) ResetFindContent() {
  355. m.find_content = nil
  356. }
  357. // SetMessage sets the "message" field.
  358. func (m *AddWechatFriendLogMutation) SetMessage(s string) {
  359. m.message = &s
  360. }
  361. // Message returns the value of the "message" field in the mutation.
  362. func (m *AddWechatFriendLogMutation) Message() (r string, exists bool) {
  363. v := m.message
  364. if v == nil {
  365. return
  366. }
  367. return *v, true
  368. }
  369. // OldMessage returns the old "message" field's value of the AddWechatFriendLog entity.
  370. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  372. func (m *AddWechatFriendLogMutation) OldMessage(ctx context.Context) (v string, err error) {
  373. if !m.op.Is(OpUpdateOne) {
  374. return v, errors.New("OldMessage is only allowed on UpdateOne operations")
  375. }
  376. if m.id == nil || m.oldValue == nil {
  377. return v, errors.New("OldMessage requires an ID field in the mutation")
  378. }
  379. oldValue, err := m.oldValue(ctx)
  380. if err != nil {
  381. return v, fmt.Errorf("querying old value for OldMessage: %w", err)
  382. }
  383. return oldValue.Message, nil
  384. }
  385. // ResetMessage resets all changes to the "message" field.
  386. func (m *AddWechatFriendLogMutation) ResetMessage() {
  387. m.message = nil
  388. }
  389. // SetFindRequest sets the "find_request" field.
  390. func (m *AddWechatFriendLogMutation) SetFindRequest(value map[string]interface{}) {
  391. m.find_request = &value
  392. }
  393. // FindRequest returns the value of the "find_request" field in the mutation.
  394. func (m *AddWechatFriendLogMutation) FindRequest() (r map[string]interface{}, exists bool) {
  395. v := m.find_request
  396. if v == nil {
  397. return
  398. }
  399. return *v, true
  400. }
  401. // OldFindRequest returns the old "find_request" field's value of the AddWechatFriendLog entity.
  402. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  404. func (m *AddWechatFriendLogMutation) OldFindRequest(ctx context.Context) (v map[string]interface{}, err error) {
  405. if !m.op.Is(OpUpdateOne) {
  406. return v, errors.New("OldFindRequest is only allowed on UpdateOne operations")
  407. }
  408. if m.id == nil || m.oldValue == nil {
  409. return v, errors.New("OldFindRequest requires an ID field in the mutation")
  410. }
  411. oldValue, err := m.oldValue(ctx)
  412. if err != nil {
  413. return v, fmt.Errorf("querying old value for OldFindRequest: %w", err)
  414. }
  415. return oldValue.FindRequest, nil
  416. }
  417. // ClearFindRequest clears the value of the "find_request" field.
  418. func (m *AddWechatFriendLogMutation) ClearFindRequest() {
  419. m.find_request = nil
  420. m.clearedFields[addwechatfriendlog.FieldFindRequest] = struct{}{}
  421. }
  422. // FindRequestCleared returns if the "find_request" field was cleared in this mutation.
  423. func (m *AddWechatFriendLogMutation) FindRequestCleared() bool {
  424. _, ok := m.clearedFields[addwechatfriendlog.FieldFindRequest]
  425. return ok
  426. }
  427. // ResetFindRequest resets all changes to the "find_request" field.
  428. func (m *AddWechatFriendLogMutation) ResetFindRequest() {
  429. m.find_request = nil
  430. delete(m.clearedFields, addwechatfriendlog.FieldFindRequest)
  431. }
  432. // SetFindResult sets the "find_result" field.
  433. func (m *AddWechatFriendLogMutation) SetFindResult(value map[string]interface{}) {
  434. m.find_result = &value
  435. }
  436. // FindResult returns the value of the "find_result" field in the mutation.
  437. func (m *AddWechatFriendLogMutation) FindResult() (r map[string]interface{}, exists bool) {
  438. v := m.find_result
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // OldFindResult returns the old "find_result" field's value of the AddWechatFriendLog entity.
  445. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  447. func (m *AddWechatFriendLogMutation) OldFindResult(ctx context.Context) (v map[string]interface{}, err error) {
  448. if !m.op.Is(OpUpdateOne) {
  449. return v, errors.New("OldFindResult is only allowed on UpdateOne operations")
  450. }
  451. if m.id == nil || m.oldValue == nil {
  452. return v, errors.New("OldFindResult requires an ID field in the mutation")
  453. }
  454. oldValue, err := m.oldValue(ctx)
  455. if err != nil {
  456. return v, fmt.Errorf("querying old value for OldFindResult: %w", err)
  457. }
  458. return oldValue.FindResult, nil
  459. }
  460. // ClearFindResult clears the value of the "find_result" field.
  461. func (m *AddWechatFriendLogMutation) ClearFindResult() {
  462. m.find_result = nil
  463. m.clearedFields[addwechatfriendlog.FieldFindResult] = struct{}{}
  464. }
  465. // FindResultCleared returns if the "find_result" field was cleared in this mutation.
  466. func (m *AddWechatFriendLogMutation) FindResultCleared() bool {
  467. _, ok := m.clearedFields[addwechatfriendlog.FieldFindResult]
  468. return ok
  469. }
  470. // ResetFindResult resets all changes to the "find_result" field.
  471. func (m *AddWechatFriendLogMutation) ResetFindResult() {
  472. m.find_result = nil
  473. delete(m.clearedFields, addwechatfriendlog.FieldFindResult)
  474. }
  475. // SetIsCanAdd sets the "is_can_add" field.
  476. func (m *AddWechatFriendLogMutation) SetIsCanAdd(i int) {
  477. m.is_can_add = &i
  478. m.addis_can_add = nil
  479. }
  480. // IsCanAdd returns the value of the "is_can_add" field in the mutation.
  481. func (m *AddWechatFriendLogMutation) IsCanAdd() (r int, exists bool) {
  482. v := m.is_can_add
  483. if v == nil {
  484. return
  485. }
  486. return *v, true
  487. }
  488. // OldIsCanAdd returns the old "is_can_add" field's value of the AddWechatFriendLog entity.
  489. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  491. func (m *AddWechatFriendLogMutation) OldIsCanAdd(ctx context.Context) (v int, err error) {
  492. if !m.op.Is(OpUpdateOne) {
  493. return v, errors.New("OldIsCanAdd is only allowed on UpdateOne operations")
  494. }
  495. if m.id == nil || m.oldValue == nil {
  496. return v, errors.New("OldIsCanAdd requires an ID field in the mutation")
  497. }
  498. oldValue, err := m.oldValue(ctx)
  499. if err != nil {
  500. return v, fmt.Errorf("querying old value for OldIsCanAdd: %w", err)
  501. }
  502. return oldValue.IsCanAdd, nil
  503. }
  504. // AddIsCanAdd adds i to the "is_can_add" field.
  505. func (m *AddWechatFriendLogMutation) AddIsCanAdd(i int) {
  506. if m.addis_can_add != nil {
  507. *m.addis_can_add += i
  508. } else {
  509. m.addis_can_add = &i
  510. }
  511. }
  512. // AddedIsCanAdd returns the value that was added to the "is_can_add" field in this mutation.
  513. func (m *AddWechatFriendLogMutation) AddedIsCanAdd() (r int, exists bool) {
  514. v := m.addis_can_add
  515. if v == nil {
  516. return
  517. }
  518. return *v, true
  519. }
  520. // ResetIsCanAdd resets all changes to the "is_can_add" field.
  521. func (m *AddWechatFriendLogMutation) ResetIsCanAdd() {
  522. m.is_can_add = nil
  523. m.addis_can_add = nil
  524. }
  525. // SetTaskCount sets the "task_count" field.
  526. func (m *AddWechatFriendLogMutation) SetTaskCount(i int) {
  527. m.task_count = &i
  528. m.addtask_count = nil
  529. }
  530. // TaskCount returns the value of the "task_count" field in the mutation.
  531. func (m *AddWechatFriendLogMutation) TaskCount() (r int, exists bool) {
  532. v := m.task_count
  533. if v == nil {
  534. return
  535. }
  536. return *v, true
  537. }
  538. // OldTaskCount returns the old "task_count" field's value of the AddWechatFriendLog entity.
  539. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  541. func (m *AddWechatFriendLogMutation) OldTaskCount(ctx context.Context) (v int, err error) {
  542. if !m.op.Is(OpUpdateOne) {
  543. return v, errors.New("OldTaskCount is only allowed on UpdateOne operations")
  544. }
  545. if m.id == nil || m.oldValue == nil {
  546. return v, errors.New("OldTaskCount requires an ID field in the mutation")
  547. }
  548. oldValue, err := m.oldValue(ctx)
  549. if err != nil {
  550. return v, fmt.Errorf("querying old value for OldTaskCount: %w", err)
  551. }
  552. return oldValue.TaskCount, nil
  553. }
  554. // AddTaskCount adds i to the "task_count" field.
  555. func (m *AddWechatFriendLogMutation) AddTaskCount(i int) {
  556. if m.addtask_count != nil {
  557. *m.addtask_count += i
  558. } else {
  559. m.addtask_count = &i
  560. }
  561. }
  562. // AddedTaskCount returns the value that was added to the "task_count" field in this mutation.
  563. func (m *AddWechatFriendLogMutation) AddedTaskCount() (r int, exists bool) {
  564. v := m.addtask_count
  565. if v == nil {
  566. return
  567. }
  568. return *v, true
  569. }
  570. // ResetTaskCount resets all changes to the "task_count" field.
  571. func (m *AddWechatFriendLogMutation) ResetTaskCount() {
  572. m.task_count = nil
  573. m.addtask_count = nil
  574. }
  575. // SetTaskID sets the "task_id" field.
  576. func (m *AddWechatFriendLogMutation) SetTaskID(i int64) {
  577. m.task_id = &i
  578. m.addtask_id = nil
  579. }
  580. // TaskID returns the value of the "task_id" field in the mutation.
  581. func (m *AddWechatFriendLogMutation) TaskID() (r int64, exists bool) {
  582. v := m.task_id
  583. if v == nil {
  584. return
  585. }
  586. return *v, true
  587. }
  588. // OldTaskID returns the old "task_id" field's value of the AddWechatFriendLog entity.
  589. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  591. func (m *AddWechatFriendLogMutation) OldTaskID(ctx context.Context) (v int64, err error) {
  592. if !m.op.Is(OpUpdateOne) {
  593. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  594. }
  595. if m.id == nil || m.oldValue == nil {
  596. return v, errors.New("OldTaskID requires an ID field in the mutation")
  597. }
  598. oldValue, err := m.oldValue(ctx)
  599. if err != nil {
  600. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  601. }
  602. return oldValue.TaskID, nil
  603. }
  604. // AddTaskID adds i to the "task_id" field.
  605. func (m *AddWechatFriendLogMutation) AddTaskID(i int64) {
  606. if m.addtask_id != nil {
  607. *m.addtask_id += i
  608. } else {
  609. m.addtask_id = &i
  610. }
  611. }
  612. // AddedTaskID returns the value that was added to the "task_id" field in this mutation.
  613. func (m *AddWechatFriendLogMutation) AddedTaskID() (r int64, exists bool) {
  614. v := m.addtask_id
  615. if v == nil {
  616. return
  617. }
  618. return *v, true
  619. }
  620. // ResetTaskID resets all changes to the "task_id" field.
  621. func (m *AddWechatFriendLogMutation) ResetTaskID() {
  622. m.task_id = nil
  623. m.addtask_id = nil
  624. }
  625. // SetAddRequest sets the "add_request" field.
  626. func (m *AddWechatFriendLogMutation) SetAddRequest(value map[string]interface{}) {
  627. m.add_request = &value
  628. }
  629. // AddRequest returns the value of the "add_request" field in the mutation.
  630. func (m *AddWechatFriendLogMutation) AddRequest() (r map[string]interface{}, exists bool) {
  631. v := m.add_request
  632. if v == nil {
  633. return
  634. }
  635. return *v, true
  636. }
  637. // OldAddRequest returns the old "add_request" field's value of the AddWechatFriendLog entity.
  638. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  640. func (m *AddWechatFriendLogMutation) OldAddRequest(ctx context.Context) (v map[string]interface{}, err error) {
  641. if !m.op.Is(OpUpdateOne) {
  642. return v, errors.New("OldAddRequest is only allowed on UpdateOne operations")
  643. }
  644. if m.id == nil || m.oldValue == nil {
  645. return v, errors.New("OldAddRequest requires an ID field in the mutation")
  646. }
  647. oldValue, err := m.oldValue(ctx)
  648. if err != nil {
  649. return v, fmt.Errorf("querying old value for OldAddRequest: %w", err)
  650. }
  651. return oldValue.AddRequest, nil
  652. }
  653. // ClearAddRequest clears the value of the "add_request" field.
  654. func (m *AddWechatFriendLogMutation) ClearAddRequest() {
  655. m.add_request = nil
  656. m.clearedFields[addwechatfriendlog.FieldAddRequest] = struct{}{}
  657. }
  658. // AddRequestCleared returns if the "add_request" field was cleared in this mutation.
  659. func (m *AddWechatFriendLogMutation) AddRequestCleared() bool {
  660. _, ok := m.clearedFields[addwechatfriendlog.FieldAddRequest]
  661. return ok
  662. }
  663. // ResetAddRequest resets all changes to the "add_request" field.
  664. func (m *AddWechatFriendLogMutation) ResetAddRequest() {
  665. m.add_request = nil
  666. delete(m.clearedFields, addwechatfriendlog.FieldAddRequest)
  667. }
  668. // SetAddResult sets the "add_result" field.
  669. func (m *AddWechatFriendLogMutation) SetAddResult(value map[string]interface{}) {
  670. m.add_result = &value
  671. }
  672. // AddResult returns the value of the "add_result" field in the mutation.
  673. func (m *AddWechatFriendLogMutation) AddResult() (r map[string]interface{}, exists bool) {
  674. v := m.add_result
  675. if v == nil {
  676. return
  677. }
  678. return *v, true
  679. }
  680. // OldAddResult returns the old "add_result" field's value of the AddWechatFriendLog entity.
  681. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  683. func (m *AddWechatFriendLogMutation) OldAddResult(ctx context.Context) (v map[string]interface{}, err error) {
  684. if !m.op.Is(OpUpdateOne) {
  685. return v, errors.New("OldAddResult is only allowed on UpdateOne operations")
  686. }
  687. if m.id == nil || m.oldValue == nil {
  688. return v, errors.New("OldAddResult requires an ID field in the mutation")
  689. }
  690. oldValue, err := m.oldValue(ctx)
  691. if err != nil {
  692. return v, fmt.Errorf("querying old value for OldAddResult: %w", err)
  693. }
  694. return oldValue.AddResult, nil
  695. }
  696. // ClearAddResult clears the value of the "add_result" field.
  697. func (m *AddWechatFriendLogMutation) ClearAddResult() {
  698. m.add_result = nil
  699. m.clearedFields[addwechatfriendlog.FieldAddResult] = struct{}{}
  700. }
  701. // AddResultCleared returns if the "add_result" field was cleared in this mutation.
  702. func (m *AddWechatFriendLogMutation) AddResultCleared() bool {
  703. _, ok := m.clearedFields[addwechatfriendlog.FieldAddResult]
  704. return ok
  705. }
  706. // ResetAddResult resets all changes to the "add_result" field.
  707. func (m *AddWechatFriendLogMutation) ResetAddResult() {
  708. m.add_result = nil
  709. delete(m.clearedFields, addwechatfriendlog.FieldAddResult)
  710. }
  711. // SetCreatedAt sets the "created_at" field.
  712. func (m *AddWechatFriendLogMutation) SetCreatedAt(i int64) {
  713. m.created_at = &i
  714. m.addcreated_at = nil
  715. }
  716. // CreatedAt returns the value of the "created_at" field in the mutation.
  717. func (m *AddWechatFriendLogMutation) CreatedAt() (r int64, exists bool) {
  718. v := m.created_at
  719. if v == nil {
  720. return
  721. }
  722. return *v, true
  723. }
  724. // OldCreatedAt returns the old "created_at" field's value of the AddWechatFriendLog entity.
  725. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  727. func (m *AddWechatFriendLogMutation) OldCreatedAt(ctx context.Context) (v int64, err error) {
  728. if !m.op.Is(OpUpdateOne) {
  729. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  730. }
  731. if m.id == nil || m.oldValue == nil {
  732. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  733. }
  734. oldValue, err := m.oldValue(ctx)
  735. if err != nil {
  736. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  737. }
  738. return oldValue.CreatedAt, nil
  739. }
  740. // AddCreatedAt adds i to the "created_at" field.
  741. func (m *AddWechatFriendLogMutation) AddCreatedAt(i int64) {
  742. if m.addcreated_at != nil {
  743. *m.addcreated_at += i
  744. } else {
  745. m.addcreated_at = &i
  746. }
  747. }
  748. // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation.
  749. func (m *AddWechatFriendLogMutation) AddedCreatedAt() (r int64, exists bool) {
  750. v := m.addcreated_at
  751. if v == nil {
  752. return
  753. }
  754. return *v, true
  755. }
  756. // ResetCreatedAt resets all changes to the "created_at" field.
  757. func (m *AddWechatFriendLogMutation) ResetCreatedAt() {
  758. m.created_at = nil
  759. m.addcreated_at = nil
  760. }
  761. // SetUpdatedAt sets the "updated_at" field.
  762. func (m *AddWechatFriendLogMutation) SetUpdatedAt(i int64) {
  763. m.updated_at = &i
  764. m.addupdated_at = nil
  765. }
  766. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  767. func (m *AddWechatFriendLogMutation) UpdatedAt() (r int64, exists bool) {
  768. v := m.updated_at
  769. if v == nil {
  770. return
  771. }
  772. return *v, true
  773. }
  774. // OldUpdatedAt returns the old "updated_at" field's value of the AddWechatFriendLog entity.
  775. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  777. func (m *AddWechatFriendLogMutation) OldUpdatedAt(ctx context.Context) (v int64, err error) {
  778. if !m.op.Is(OpUpdateOne) {
  779. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  780. }
  781. if m.id == nil || m.oldValue == nil {
  782. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  783. }
  784. oldValue, err := m.oldValue(ctx)
  785. if err != nil {
  786. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  787. }
  788. return oldValue.UpdatedAt, nil
  789. }
  790. // AddUpdatedAt adds i to the "updated_at" field.
  791. func (m *AddWechatFriendLogMutation) AddUpdatedAt(i int64) {
  792. if m.addupdated_at != nil {
  793. *m.addupdated_at += i
  794. } else {
  795. m.addupdated_at = &i
  796. }
  797. }
  798. // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation.
  799. func (m *AddWechatFriendLogMutation) AddedUpdatedAt() (r int64, exists bool) {
  800. v := m.addupdated_at
  801. if v == nil {
  802. return
  803. }
  804. return *v, true
  805. }
  806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  807. func (m *AddWechatFriendLogMutation) ResetUpdatedAt() {
  808. m.updated_at = nil
  809. m.addupdated_at = nil
  810. }
  811. // Where appends a list predicates to the AddWechatFriendLogMutation builder.
  812. func (m *AddWechatFriendLogMutation) Where(ps ...predicate.AddWechatFriendLog) {
  813. m.predicates = append(m.predicates, ps...)
  814. }
  815. // WhereP appends storage-level predicates to the AddWechatFriendLogMutation builder. Using this method,
  816. // users can use type-assertion to append predicates that do not depend on any generated package.
  817. func (m *AddWechatFriendLogMutation) WhereP(ps ...func(*sql.Selector)) {
  818. p := make([]predicate.AddWechatFriendLog, len(ps))
  819. for i := range ps {
  820. p[i] = ps[i]
  821. }
  822. m.Where(p...)
  823. }
  824. // Op returns the operation name.
  825. func (m *AddWechatFriendLogMutation) Op() Op {
  826. return m.op
  827. }
  828. // SetOp allows setting the mutation operation.
  829. func (m *AddWechatFriendLogMutation) SetOp(op Op) {
  830. m.op = op
  831. }
  832. // Type returns the node type of this mutation (AddWechatFriendLog).
  833. func (m *AddWechatFriendLogMutation) Type() string {
  834. return m.typ
  835. }
  836. // Fields returns all fields that were changed during this mutation. Note that in
  837. // order to get all numeric fields that were incremented/decremented, call
  838. // AddedFields().
  839. func (m *AddWechatFriendLogMutation) Fields() []string {
  840. fields := make([]string, 0, 13)
  841. if m.owner_wx_id != nil {
  842. fields = append(fields, addwechatfriendlog.FieldOwnerWxID)
  843. }
  844. if m.owner_wx_type != nil {
  845. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  846. }
  847. if m.find_content != nil {
  848. fields = append(fields, addwechatfriendlog.FieldFindContent)
  849. }
  850. if m.message != nil {
  851. fields = append(fields, addwechatfriendlog.FieldMessage)
  852. }
  853. if m.find_request != nil {
  854. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  855. }
  856. if m.find_result != nil {
  857. fields = append(fields, addwechatfriendlog.FieldFindResult)
  858. }
  859. if m.is_can_add != nil {
  860. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  861. }
  862. if m.task_count != nil {
  863. fields = append(fields, addwechatfriendlog.FieldTaskCount)
  864. }
  865. if m.task_id != nil {
  866. fields = append(fields, addwechatfriendlog.FieldTaskID)
  867. }
  868. if m.add_request != nil {
  869. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  870. }
  871. if m.add_result != nil {
  872. fields = append(fields, addwechatfriendlog.FieldAddResult)
  873. }
  874. if m.created_at != nil {
  875. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  876. }
  877. if m.updated_at != nil {
  878. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  879. }
  880. return fields
  881. }
  882. // Field returns the value of a field with the given name. The second boolean
  883. // return value indicates that this field was not set, or was not defined in the
  884. // schema.
  885. func (m *AddWechatFriendLogMutation) Field(name string) (ent.Value, bool) {
  886. switch name {
  887. case addwechatfriendlog.FieldOwnerWxID:
  888. return m.OwnerWxID()
  889. case addwechatfriendlog.FieldOwnerWxType:
  890. return m.OwnerWxType()
  891. case addwechatfriendlog.FieldFindContent:
  892. return m.FindContent()
  893. case addwechatfriendlog.FieldMessage:
  894. return m.Message()
  895. case addwechatfriendlog.FieldFindRequest:
  896. return m.FindRequest()
  897. case addwechatfriendlog.FieldFindResult:
  898. return m.FindResult()
  899. case addwechatfriendlog.FieldIsCanAdd:
  900. return m.IsCanAdd()
  901. case addwechatfriendlog.FieldTaskCount:
  902. return m.TaskCount()
  903. case addwechatfriendlog.FieldTaskID:
  904. return m.TaskID()
  905. case addwechatfriendlog.FieldAddRequest:
  906. return m.AddRequest()
  907. case addwechatfriendlog.FieldAddResult:
  908. return m.AddResult()
  909. case addwechatfriendlog.FieldCreatedAt:
  910. return m.CreatedAt()
  911. case addwechatfriendlog.FieldUpdatedAt:
  912. return m.UpdatedAt()
  913. }
  914. return nil, false
  915. }
  916. // OldField returns the old value of the field from the database. An error is
  917. // returned if the mutation operation is not UpdateOne, or the query to the
  918. // database failed.
  919. func (m *AddWechatFriendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  920. switch name {
  921. case addwechatfriendlog.FieldOwnerWxID:
  922. return m.OldOwnerWxID(ctx)
  923. case addwechatfriendlog.FieldOwnerWxType:
  924. return m.OldOwnerWxType(ctx)
  925. case addwechatfriendlog.FieldFindContent:
  926. return m.OldFindContent(ctx)
  927. case addwechatfriendlog.FieldMessage:
  928. return m.OldMessage(ctx)
  929. case addwechatfriendlog.FieldFindRequest:
  930. return m.OldFindRequest(ctx)
  931. case addwechatfriendlog.FieldFindResult:
  932. return m.OldFindResult(ctx)
  933. case addwechatfriendlog.FieldIsCanAdd:
  934. return m.OldIsCanAdd(ctx)
  935. case addwechatfriendlog.FieldTaskCount:
  936. return m.OldTaskCount(ctx)
  937. case addwechatfriendlog.FieldTaskID:
  938. return m.OldTaskID(ctx)
  939. case addwechatfriendlog.FieldAddRequest:
  940. return m.OldAddRequest(ctx)
  941. case addwechatfriendlog.FieldAddResult:
  942. return m.OldAddResult(ctx)
  943. case addwechatfriendlog.FieldCreatedAt:
  944. return m.OldCreatedAt(ctx)
  945. case addwechatfriendlog.FieldUpdatedAt:
  946. return m.OldUpdatedAt(ctx)
  947. }
  948. return nil, fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  949. }
  950. // SetField sets the value of a field with the given name. It returns an error if
  951. // the field is not defined in the schema, or if the type mismatched the field
  952. // type.
  953. func (m *AddWechatFriendLogMutation) SetField(name string, value ent.Value) error {
  954. switch name {
  955. case addwechatfriendlog.FieldOwnerWxID:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetOwnerWxID(v)
  961. return nil
  962. case addwechatfriendlog.FieldOwnerWxType:
  963. v, ok := value.(int)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetOwnerWxType(v)
  968. return nil
  969. case addwechatfriendlog.FieldFindContent:
  970. v, ok := value.(string)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetFindContent(v)
  975. return nil
  976. case addwechatfriendlog.FieldMessage:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetMessage(v)
  982. return nil
  983. case addwechatfriendlog.FieldFindRequest:
  984. v, ok := value.(map[string]interface{})
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetFindRequest(v)
  989. return nil
  990. case addwechatfriendlog.FieldFindResult:
  991. v, ok := value.(map[string]interface{})
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetFindResult(v)
  996. return nil
  997. case addwechatfriendlog.FieldIsCanAdd:
  998. v, ok := value.(int)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetIsCanAdd(v)
  1003. return nil
  1004. case addwechatfriendlog.FieldTaskCount:
  1005. v, ok := value.(int)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetTaskCount(v)
  1010. return nil
  1011. case addwechatfriendlog.FieldTaskID:
  1012. v, ok := value.(int64)
  1013. if !ok {
  1014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1015. }
  1016. m.SetTaskID(v)
  1017. return nil
  1018. case addwechatfriendlog.FieldAddRequest:
  1019. v, ok := value.(map[string]interface{})
  1020. if !ok {
  1021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1022. }
  1023. m.SetAddRequest(v)
  1024. return nil
  1025. case addwechatfriendlog.FieldAddResult:
  1026. v, ok := value.(map[string]interface{})
  1027. if !ok {
  1028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1029. }
  1030. m.SetAddResult(v)
  1031. return nil
  1032. case addwechatfriendlog.FieldCreatedAt:
  1033. v, ok := value.(int64)
  1034. if !ok {
  1035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1036. }
  1037. m.SetCreatedAt(v)
  1038. return nil
  1039. case addwechatfriendlog.FieldUpdatedAt:
  1040. v, ok := value.(int64)
  1041. if !ok {
  1042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1043. }
  1044. m.SetUpdatedAt(v)
  1045. return nil
  1046. }
  1047. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1048. }
  1049. // AddedFields returns all numeric fields that were incremented/decremented during
  1050. // this mutation.
  1051. func (m *AddWechatFriendLogMutation) AddedFields() []string {
  1052. var fields []string
  1053. if m.addowner_wx_type != nil {
  1054. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  1055. }
  1056. if m.addis_can_add != nil {
  1057. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  1058. }
  1059. if m.addtask_count != nil {
  1060. fields = append(fields, addwechatfriendlog.FieldTaskCount)
  1061. }
  1062. if m.addtask_id != nil {
  1063. fields = append(fields, addwechatfriendlog.FieldTaskID)
  1064. }
  1065. if m.addcreated_at != nil {
  1066. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  1067. }
  1068. if m.addupdated_at != nil {
  1069. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  1070. }
  1071. return fields
  1072. }
  1073. // AddedField returns the numeric value that was incremented/decremented on a field
  1074. // with the given name. The second boolean return value indicates that this field
  1075. // was not set, or was not defined in the schema.
  1076. func (m *AddWechatFriendLogMutation) AddedField(name string) (ent.Value, bool) {
  1077. switch name {
  1078. case addwechatfriendlog.FieldOwnerWxType:
  1079. return m.AddedOwnerWxType()
  1080. case addwechatfriendlog.FieldIsCanAdd:
  1081. return m.AddedIsCanAdd()
  1082. case addwechatfriendlog.FieldTaskCount:
  1083. return m.AddedTaskCount()
  1084. case addwechatfriendlog.FieldTaskID:
  1085. return m.AddedTaskID()
  1086. case addwechatfriendlog.FieldCreatedAt:
  1087. return m.AddedCreatedAt()
  1088. case addwechatfriendlog.FieldUpdatedAt:
  1089. return m.AddedUpdatedAt()
  1090. }
  1091. return nil, false
  1092. }
  1093. // AddField adds the value to the field with the given name. It returns an error if
  1094. // the field is not defined in the schema, or if the type mismatched the field
  1095. // type.
  1096. func (m *AddWechatFriendLogMutation) AddField(name string, value ent.Value) error {
  1097. switch name {
  1098. case addwechatfriendlog.FieldOwnerWxType:
  1099. v, ok := value.(int)
  1100. if !ok {
  1101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1102. }
  1103. m.AddOwnerWxType(v)
  1104. return nil
  1105. case addwechatfriendlog.FieldIsCanAdd:
  1106. v, ok := value.(int)
  1107. if !ok {
  1108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1109. }
  1110. m.AddIsCanAdd(v)
  1111. return nil
  1112. case addwechatfriendlog.FieldTaskCount:
  1113. v, ok := value.(int)
  1114. if !ok {
  1115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1116. }
  1117. m.AddTaskCount(v)
  1118. return nil
  1119. case addwechatfriendlog.FieldTaskID:
  1120. v, ok := value.(int64)
  1121. if !ok {
  1122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1123. }
  1124. m.AddTaskID(v)
  1125. return nil
  1126. case addwechatfriendlog.FieldCreatedAt:
  1127. v, ok := value.(int64)
  1128. if !ok {
  1129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1130. }
  1131. m.AddCreatedAt(v)
  1132. return nil
  1133. case addwechatfriendlog.FieldUpdatedAt:
  1134. v, ok := value.(int64)
  1135. if !ok {
  1136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1137. }
  1138. m.AddUpdatedAt(v)
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown AddWechatFriendLog numeric field %s", name)
  1142. }
  1143. // ClearedFields returns all nullable fields that were cleared during this
  1144. // mutation.
  1145. func (m *AddWechatFriendLogMutation) ClearedFields() []string {
  1146. var fields []string
  1147. if m.FieldCleared(addwechatfriendlog.FieldFindRequest) {
  1148. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  1149. }
  1150. if m.FieldCleared(addwechatfriendlog.FieldFindResult) {
  1151. fields = append(fields, addwechatfriendlog.FieldFindResult)
  1152. }
  1153. if m.FieldCleared(addwechatfriendlog.FieldAddRequest) {
  1154. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  1155. }
  1156. if m.FieldCleared(addwechatfriendlog.FieldAddResult) {
  1157. fields = append(fields, addwechatfriendlog.FieldAddResult)
  1158. }
  1159. return fields
  1160. }
  1161. // FieldCleared returns a boolean indicating if a field with the given name was
  1162. // cleared in this mutation.
  1163. func (m *AddWechatFriendLogMutation) FieldCleared(name string) bool {
  1164. _, ok := m.clearedFields[name]
  1165. return ok
  1166. }
  1167. // ClearField clears the value of the field with the given name. It returns an
  1168. // error if the field is not defined in the schema.
  1169. func (m *AddWechatFriendLogMutation) ClearField(name string) error {
  1170. switch name {
  1171. case addwechatfriendlog.FieldFindRequest:
  1172. m.ClearFindRequest()
  1173. return nil
  1174. case addwechatfriendlog.FieldFindResult:
  1175. m.ClearFindResult()
  1176. return nil
  1177. case addwechatfriendlog.FieldAddRequest:
  1178. m.ClearAddRequest()
  1179. return nil
  1180. case addwechatfriendlog.FieldAddResult:
  1181. m.ClearAddResult()
  1182. return nil
  1183. }
  1184. return fmt.Errorf("unknown AddWechatFriendLog nullable field %s", name)
  1185. }
  1186. // ResetField resets all changes in the mutation for the field with the given name.
  1187. // It returns an error if the field is not defined in the schema.
  1188. func (m *AddWechatFriendLogMutation) ResetField(name string) error {
  1189. switch name {
  1190. case addwechatfriendlog.FieldOwnerWxID:
  1191. m.ResetOwnerWxID()
  1192. return nil
  1193. case addwechatfriendlog.FieldOwnerWxType:
  1194. m.ResetOwnerWxType()
  1195. return nil
  1196. case addwechatfriendlog.FieldFindContent:
  1197. m.ResetFindContent()
  1198. return nil
  1199. case addwechatfriendlog.FieldMessage:
  1200. m.ResetMessage()
  1201. return nil
  1202. case addwechatfriendlog.FieldFindRequest:
  1203. m.ResetFindRequest()
  1204. return nil
  1205. case addwechatfriendlog.FieldFindResult:
  1206. m.ResetFindResult()
  1207. return nil
  1208. case addwechatfriendlog.FieldIsCanAdd:
  1209. m.ResetIsCanAdd()
  1210. return nil
  1211. case addwechatfriendlog.FieldTaskCount:
  1212. m.ResetTaskCount()
  1213. return nil
  1214. case addwechatfriendlog.FieldTaskID:
  1215. m.ResetTaskID()
  1216. return nil
  1217. case addwechatfriendlog.FieldAddRequest:
  1218. m.ResetAddRequest()
  1219. return nil
  1220. case addwechatfriendlog.FieldAddResult:
  1221. m.ResetAddResult()
  1222. return nil
  1223. case addwechatfriendlog.FieldCreatedAt:
  1224. m.ResetCreatedAt()
  1225. return nil
  1226. case addwechatfriendlog.FieldUpdatedAt:
  1227. m.ResetUpdatedAt()
  1228. return nil
  1229. }
  1230. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1231. }
  1232. // AddedEdges returns all edge names that were set/added in this mutation.
  1233. func (m *AddWechatFriendLogMutation) AddedEdges() []string {
  1234. edges := make([]string, 0, 0)
  1235. return edges
  1236. }
  1237. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1238. // name in this mutation.
  1239. func (m *AddWechatFriendLogMutation) AddedIDs(name string) []ent.Value {
  1240. return nil
  1241. }
  1242. // RemovedEdges returns all edge names that were removed in this mutation.
  1243. func (m *AddWechatFriendLogMutation) RemovedEdges() []string {
  1244. edges := make([]string, 0, 0)
  1245. return edges
  1246. }
  1247. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1248. // the given name in this mutation.
  1249. func (m *AddWechatFriendLogMutation) RemovedIDs(name string) []ent.Value {
  1250. return nil
  1251. }
  1252. // ClearedEdges returns all edge names that were cleared in this mutation.
  1253. func (m *AddWechatFriendLogMutation) ClearedEdges() []string {
  1254. edges := make([]string, 0, 0)
  1255. return edges
  1256. }
  1257. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1258. // was cleared in this mutation.
  1259. func (m *AddWechatFriendLogMutation) EdgeCleared(name string) bool {
  1260. return false
  1261. }
  1262. // ClearEdge clears the value of the edge with the given name. It returns an error
  1263. // if that edge is not defined in the schema.
  1264. func (m *AddWechatFriendLogMutation) ClearEdge(name string) error {
  1265. return fmt.Errorf("unknown AddWechatFriendLog unique edge %s", name)
  1266. }
  1267. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1268. // It returns an error if the edge is not defined in the schema.
  1269. func (m *AddWechatFriendLogMutation) ResetEdge(name string) error {
  1270. return fmt.Errorf("unknown AddWechatFriendLog edge %s", name)
  1271. }
  1272. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  1273. type AgentMutation struct {
  1274. config
  1275. op Op
  1276. typ string
  1277. id *uint64
  1278. created_at *time.Time
  1279. updated_at *time.Time
  1280. deleted_at *time.Time
  1281. name *string
  1282. role *string
  1283. status *int
  1284. addstatus *int
  1285. background *string
  1286. examples *string
  1287. organization_id *uint64
  1288. addorganization_id *int64
  1289. dataset_id *string
  1290. collection_id *string
  1291. model *string
  1292. api_base *string
  1293. api_key *string
  1294. _type *int
  1295. add_type *int
  1296. clearedFields map[string]struct{}
  1297. wx_agent map[uint64]struct{}
  1298. removedwx_agent map[uint64]struct{}
  1299. clearedwx_agent bool
  1300. token_agent map[uint64]struct{}
  1301. removedtoken_agent map[uint64]struct{}
  1302. clearedtoken_agent bool
  1303. wa_agent map[uint64]struct{}
  1304. removedwa_agent map[uint64]struct{}
  1305. clearedwa_agent bool
  1306. xjs_agent map[uint64]struct{}
  1307. removedxjs_agent map[uint64]struct{}
  1308. clearedxjs_agent bool
  1309. key_agent map[uint64]struct{}
  1310. removedkey_agent map[uint64]struct{}
  1311. clearedkey_agent bool
  1312. done bool
  1313. oldValue func(context.Context) (*Agent, error)
  1314. predicates []predicate.Agent
  1315. }
  1316. var _ ent.Mutation = (*AgentMutation)(nil)
  1317. // agentOption allows management of the mutation configuration using functional options.
  1318. type agentOption func(*AgentMutation)
  1319. // newAgentMutation creates new mutation for the Agent entity.
  1320. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  1321. m := &AgentMutation{
  1322. config: c,
  1323. op: op,
  1324. typ: TypeAgent,
  1325. clearedFields: make(map[string]struct{}),
  1326. }
  1327. for _, opt := range opts {
  1328. opt(m)
  1329. }
  1330. return m
  1331. }
  1332. // withAgentID sets the ID field of the mutation.
  1333. func withAgentID(id uint64) agentOption {
  1334. return func(m *AgentMutation) {
  1335. var (
  1336. err error
  1337. once sync.Once
  1338. value *Agent
  1339. )
  1340. m.oldValue = func(ctx context.Context) (*Agent, error) {
  1341. once.Do(func() {
  1342. if m.done {
  1343. err = errors.New("querying old values post mutation is not allowed")
  1344. } else {
  1345. value, err = m.Client().Agent.Get(ctx, id)
  1346. }
  1347. })
  1348. return value, err
  1349. }
  1350. m.id = &id
  1351. }
  1352. }
  1353. // withAgent sets the old Agent of the mutation.
  1354. func withAgent(node *Agent) agentOption {
  1355. return func(m *AgentMutation) {
  1356. m.oldValue = func(context.Context) (*Agent, error) {
  1357. return node, nil
  1358. }
  1359. m.id = &node.ID
  1360. }
  1361. }
  1362. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1363. // executed in a transaction (ent.Tx), a transactional client is returned.
  1364. func (m AgentMutation) Client() *Client {
  1365. client := &Client{config: m.config}
  1366. client.init()
  1367. return client
  1368. }
  1369. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1370. // it returns an error otherwise.
  1371. func (m AgentMutation) Tx() (*Tx, error) {
  1372. if _, ok := m.driver.(*txDriver); !ok {
  1373. return nil, errors.New("ent: mutation is not running in a transaction")
  1374. }
  1375. tx := &Tx{config: m.config}
  1376. tx.init()
  1377. return tx, nil
  1378. }
  1379. // SetID sets the value of the id field. Note that this
  1380. // operation is only accepted on creation of Agent entities.
  1381. func (m *AgentMutation) SetID(id uint64) {
  1382. m.id = &id
  1383. }
  1384. // ID returns the ID value in the mutation. Note that the ID is only available
  1385. // if it was provided to the builder or after it was returned from the database.
  1386. func (m *AgentMutation) ID() (id uint64, exists bool) {
  1387. if m.id == nil {
  1388. return
  1389. }
  1390. return *m.id, true
  1391. }
  1392. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1393. // That means, if the mutation is applied within a transaction with an isolation level such
  1394. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1395. // or updated by the mutation.
  1396. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  1397. switch {
  1398. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1399. id, exists := m.ID()
  1400. if exists {
  1401. return []uint64{id}, nil
  1402. }
  1403. fallthrough
  1404. case m.op.Is(OpUpdate | OpDelete):
  1405. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  1406. default:
  1407. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1408. }
  1409. }
  1410. // SetCreatedAt sets the "created_at" field.
  1411. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  1412. m.created_at = &t
  1413. }
  1414. // CreatedAt returns the value of the "created_at" field in the mutation.
  1415. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  1416. v := m.created_at
  1417. if v == nil {
  1418. return
  1419. }
  1420. return *v, true
  1421. }
  1422. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  1423. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1425. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1426. if !m.op.Is(OpUpdateOne) {
  1427. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1428. }
  1429. if m.id == nil || m.oldValue == nil {
  1430. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1431. }
  1432. oldValue, err := m.oldValue(ctx)
  1433. if err != nil {
  1434. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1435. }
  1436. return oldValue.CreatedAt, nil
  1437. }
  1438. // ResetCreatedAt resets all changes to the "created_at" field.
  1439. func (m *AgentMutation) ResetCreatedAt() {
  1440. m.created_at = nil
  1441. }
  1442. // SetUpdatedAt sets the "updated_at" field.
  1443. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  1444. m.updated_at = &t
  1445. }
  1446. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1447. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  1448. v := m.updated_at
  1449. if v == nil {
  1450. return
  1451. }
  1452. return *v, true
  1453. }
  1454. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  1455. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1457. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1458. if !m.op.Is(OpUpdateOne) {
  1459. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1460. }
  1461. if m.id == nil || m.oldValue == nil {
  1462. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1463. }
  1464. oldValue, err := m.oldValue(ctx)
  1465. if err != nil {
  1466. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1467. }
  1468. return oldValue.UpdatedAt, nil
  1469. }
  1470. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1471. func (m *AgentMutation) ResetUpdatedAt() {
  1472. m.updated_at = nil
  1473. }
  1474. // SetDeletedAt sets the "deleted_at" field.
  1475. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  1476. m.deleted_at = &t
  1477. }
  1478. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1479. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  1480. v := m.deleted_at
  1481. if v == nil {
  1482. return
  1483. }
  1484. return *v, true
  1485. }
  1486. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  1487. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1489. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1490. if !m.op.Is(OpUpdateOne) {
  1491. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1492. }
  1493. if m.id == nil || m.oldValue == nil {
  1494. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1495. }
  1496. oldValue, err := m.oldValue(ctx)
  1497. if err != nil {
  1498. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1499. }
  1500. return oldValue.DeletedAt, nil
  1501. }
  1502. // ClearDeletedAt clears the value of the "deleted_at" field.
  1503. func (m *AgentMutation) ClearDeletedAt() {
  1504. m.deleted_at = nil
  1505. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  1506. }
  1507. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1508. func (m *AgentMutation) DeletedAtCleared() bool {
  1509. _, ok := m.clearedFields[agent.FieldDeletedAt]
  1510. return ok
  1511. }
  1512. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1513. func (m *AgentMutation) ResetDeletedAt() {
  1514. m.deleted_at = nil
  1515. delete(m.clearedFields, agent.FieldDeletedAt)
  1516. }
  1517. // SetName sets the "name" field.
  1518. func (m *AgentMutation) SetName(s string) {
  1519. m.name = &s
  1520. }
  1521. // Name returns the value of the "name" field in the mutation.
  1522. func (m *AgentMutation) Name() (r string, exists bool) {
  1523. v := m.name
  1524. if v == nil {
  1525. return
  1526. }
  1527. return *v, true
  1528. }
  1529. // OldName returns the old "name" field's value of the Agent entity.
  1530. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1532. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  1533. if !m.op.Is(OpUpdateOne) {
  1534. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1535. }
  1536. if m.id == nil || m.oldValue == nil {
  1537. return v, errors.New("OldName requires an ID field in the mutation")
  1538. }
  1539. oldValue, err := m.oldValue(ctx)
  1540. if err != nil {
  1541. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1542. }
  1543. return oldValue.Name, nil
  1544. }
  1545. // ResetName resets all changes to the "name" field.
  1546. func (m *AgentMutation) ResetName() {
  1547. m.name = nil
  1548. }
  1549. // SetRole sets the "role" field.
  1550. func (m *AgentMutation) SetRole(s string) {
  1551. m.role = &s
  1552. }
  1553. // Role returns the value of the "role" field in the mutation.
  1554. func (m *AgentMutation) Role() (r string, exists bool) {
  1555. v := m.role
  1556. if v == nil {
  1557. return
  1558. }
  1559. return *v, true
  1560. }
  1561. // OldRole returns the old "role" field's value of the Agent entity.
  1562. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1564. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  1565. if !m.op.Is(OpUpdateOne) {
  1566. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  1567. }
  1568. if m.id == nil || m.oldValue == nil {
  1569. return v, errors.New("OldRole requires an ID field in the mutation")
  1570. }
  1571. oldValue, err := m.oldValue(ctx)
  1572. if err != nil {
  1573. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  1574. }
  1575. return oldValue.Role, nil
  1576. }
  1577. // ClearRole clears the value of the "role" field.
  1578. func (m *AgentMutation) ClearRole() {
  1579. m.role = nil
  1580. m.clearedFields[agent.FieldRole] = struct{}{}
  1581. }
  1582. // RoleCleared returns if the "role" field was cleared in this mutation.
  1583. func (m *AgentMutation) RoleCleared() bool {
  1584. _, ok := m.clearedFields[agent.FieldRole]
  1585. return ok
  1586. }
  1587. // ResetRole resets all changes to the "role" field.
  1588. func (m *AgentMutation) ResetRole() {
  1589. m.role = nil
  1590. delete(m.clearedFields, agent.FieldRole)
  1591. }
  1592. // SetStatus sets the "status" field.
  1593. func (m *AgentMutation) SetStatus(i int) {
  1594. m.status = &i
  1595. m.addstatus = nil
  1596. }
  1597. // Status returns the value of the "status" field in the mutation.
  1598. func (m *AgentMutation) Status() (r int, exists bool) {
  1599. v := m.status
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldStatus returns the old "status" field's value of the Agent entity.
  1606. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldStatus requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1618. }
  1619. return oldValue.Status, nil
  1620. }
  1621. // AddStatus adds i to the "status" field.
  1622. func (m *AgentMutation) AddStatus(i int) {
  1623. if m.addstatus != nil {
  1624. *m.addstatus += i
  1625. } else {
  1626. m.addstatus = &i
  1627. }
  1628. }
  1629. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1630. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  1631. v := m.addstatus
  1632. if v == nil {
  1633. return
  1634. }
  1635. return *v, true
  1636. }
  1637. // ClearStatus clears the value of the "status" field.
  1638. func (m *AgentMutation) ClearStatus() {
  1639. m.status = nil
  1640. m.addstatus = nil
  1641. m.clearedFields[agent.FieldStatus] = struct{}{}
  1642. }
  1643. // StatusCleared returns if the "status" field was cleared in this mutation.
  1644. func (m *AgentMutation) StatusCleared() bool {
  1645. _, ok := m.clearedFields[agent.FieldStatus]
  1646. return ok
  1647. }
  1648. // ResetStatus resets all changes to the "status" field.
  1649. func (m *AgentMutation) ResetStatus() {
  1650. m.status = nil
  1651. m.addstatus = nil
  1652. delete(m.clearedFields, agent.FieldStatus)
  1653. }
  1654. // SetBackground sets the "background" field.
  1655. func (m *AgentMutation) SetBackground(s string) {
  1656. m.background = &s
  1657. }
  1658. // Background returns the value of the "background" field in the mutation.
  1659. func (m *AgentMutation) Background() (r string, exists bool) {
  1660. v := m.background
  1661. if v == nil {
  1662. return
  1663. }
  1664. return *v, true
  1665. }
  1666. // OldBackground returns the old "background" field's value of the Agent entity.
  1667. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1669. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  1670. if !m.op.Is(OpUpdateOne) {
  1671. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  1672. }
  1673. if m.id == nil || m.oldValue == nil {
  1674. return v, errors.New("OldBackground requires an ID field in the mutation")
  1675. }
  1676. oldValue, err := m.oldValue(ctx)
  1677. if err != nil {
  1678. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  1679. }
  1680. return oldValue.Background, nil
  1681. }
  1682. // ClearBackground clears the value of the "background" field.
  1683. func (m *AgentMutation) ClearBackground() {
  1684. m.background = nil
  1685. m.clearedFields[agent.FieldBackground] = struct{}{}
  1686. }
  1687. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  1688. func (m *AgentMutation) BackgroundCleared() bool {
  1689. _, ok := m.clearedFields[agent.FieldBackground]
  1690. return ok
  1691. }
  1692. // ResetBackground resets all changes to the "background" field.
  1693. func (m *AgentMutation) ResetBackground() {
  1694. m.background = nil
  1695. delete(m.clearedFields, agent.FieldBackground)
  1696. }
  1697. // SetExamples sets the "examples" field.
  1698. func (m *AgentMutation) SetExamples(s string) {
  1699. m.examples = &s
  1700. }
  1701. // Examples returns the value of the "examples" field in the mutation.
  1702. func (m *AgentMutation) Examples() (r string, exists bool) {
  1703. v := m.examples
  1704. if v == nil {
  1705. return
  1706. }
  1707. return *v, true
  1708. }
  1709. // OldExamples returns the old "examples" field's value of the Agent entity.
  1710. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1712. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  1713. if !m.op.Is(OpUpdateOne) {
  1714. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  1715. }
  1716. if m.id == nil || m.oldValue == nil {
  1717. return v, errors.New("OldExamples requires an ID field in the mutation")
  1718. }
  1719. oldValue, err := m.oldValue(ctx)
  1720. if err != nil {
  1721. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  1722. }
  1723. return oldValue.Examples, nil
  1724. }
  1725. // ClearExamples clears the value of the "examples" field.
  1726. func (m *AgentMutation) ClearExamples() {
  1727. m.examples = nil
  1728. m.clearedFields[agent.FieldExamples] = struct{}{}
  1729. }
  1730. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  1731. func (m *AgentMutation) ExamplesCleared() bool {
  1732. _, ok := m.clearedFields[agent.FieldExamples]
  1733. return ok
  1734. }
  1735. // ResetExamples resets all changes to the "examples" field.
  1736. func (m *AgentMutation) ResetExamples() {
  1737. m.examples = nil
  1738. delete(m.clearedFields, agent.FieldExamples)
  1739. }
  1740. // SetOrganizationID sets the "organization_id" field.
  1741. func (m *AgentMutation) SetOrganizationID(u uint64) {
  1742. m.organization_id = &u
  1743. m.addorganization_id = nil
  1744. }
  1745. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1746. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  1747. v := m.organization_id
  1748. if v == nil {
  1749. return
  1750. }
  1751. return *v, true
  1752. }
  1753. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  1754. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1756. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1757. if !m.op.Is(OpUpdateOne) {
  1758. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1759. }
  1760. if m.id == nil || m.oldValue == nil {
  1761. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1762. }
  1763. oldValue, err := m.oldValue(ctx)
  1764. if err != nil {
  1765. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1766. }
  1767. return oldValue.OrganizationID, nil
  1768. }
  1769. // AddOrganizationID adds u to the "organization_id" field.
  1770. func (m *AgentMutation) AddOrganizationID(u int64) {
  1771. if m.addorganization_id != nil {
  1772. *m.addorganization_id += u
  1773. } else {
  1774. m.addorganization_id = &u
  1775. }
  1776. }
  1777. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1778. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  1779. v := m.addorganization_id
  1780. if v == nil {
  1781. return
  1782. }
  1783. return *v, true
  1784. }
  1785. // ResetOrganizationID resets all changes to the "organization_id" field.
  1786. func (m *AgentMutation) ResetOrganizationID() {
  1787. m.organization_id = nil
  1788. m.addorganization_id = nil
  1789. }
  1790. // SetDatasetID sets the "dataset_id" field.
  1791. func (m *AgentMutation) SetDatasetID(s string) {
  1792. m.dataset_id = &s
  1793. }
  1794. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1795. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  1796. v := m.dataset_id
  1797. if v == nil {
  1798. return
  1799. }
  1800. return *v, true
  1801. }
  1802. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  1803. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1805. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1806. if !m.op.Is(OpUpdateOne) {
  1807. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1808. }
  1809. if m.id == nil || m.oldValue == nil {
  1810. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1811. }
  1812. oldValue, err := m.oldValue(ctx)
  1813. if err != nil {
  1814. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1815. }
  1816. return oldValue.DatasetID, nil
  1817. }
  1818. // ResetDatasetID resets all changes to the "dataset_id" field.
  1819. func (m *AgentMutation) ResetDatasetID() {
  1820. m.dataset_id = nil
  1821. }
  1822. // SetCollectionID sets the "collection_id" field.
  1823. func (m *AgentMutation) SetCollectionID(s string) {
  1824. m.collection_id = &s
  1825. }
  1826. // CollectionID returns the value of the "collection_id" field in the mutation.
  1827. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  1828. v := m.collection_id
  1829. if v == nil {
  1830. return
  1831. }
  1832. return *v, true
  1833. }
  1834. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  1835. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1837. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1838. if !m.op.Is(OpUpdateOne) {
  1839. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1840. }
  1841. if m.id == nil || m.oldValue == nil {
  1842. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1843. }
  1844. oldValue, err := m.oldValue(ctx)
  1845. if err != nil {
  1846. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1847. }
  1848. return oldValue.CollectionID, nil
  1849. }
  1850. // ResetCollectionID resets all changes to the "collection_id" field.
  1851. func (m *AgentMutation) ResetCollectionID() {
  1852. m.collection_id = nil
  1853. }
  1854. // SetModel sets the "model" field.
  1855. func (m *AgentMutation) SetModel(s string) {
  1856. m.model = &s
  1857. }
  1858. // Model returns the value of the "model" field in the mutation.
  1859. func (m *AgentMutation) Model() (r string, exists bool) {
  1860. v := m.model
  1861. if v == nil {
  1862. return
  1863. }
  1864. return *v, true
  1865. }
  1866. // OldModel returns the old "model" field's value of the Agent entity.
  1867. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1869. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  1870. if !m.op.Is(OpUpdateOne) {
  1871. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  1872. }
  1873. if m.id == nil || m.oldValue == nil {
  1874. return v, errors.New("OldModel requires an ID field in the mutation")
  1875. }
  1876. oldValue, err := m.oldValue(ctx)
  1877. if err != nil {
  1878. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  1879. }
  1880. return oldValue.Model, nil
  1881. }
  1882. // ClearModel clears the value of the "model" field.
  1883. func (m *AgentMutation) ClearModel() {
  1884. m.model = nil
  1885. m.clearedFields[agent.FieldModel] = struct{}{}
  1886. }
  1887. // ModelCleared returns if the "model" field was cleared in this mutation.
  1888. func (m *AgentMutation) ModelCleared() bool {
  1889. _, ok := m.clearedFields[agent.FieldModel]
  1890. return ok
  1891. }
  1892. // ResetModel resets all changes to the "model" field.
  1893. func (m *AgentMutation) ResetModel() {
  1894. m.model = nil
  1895. delete(m.clearedFields, agent.FieldModel)
  1896. }
  1897. // SetAPIBase sets the "api_base" field.
  1898. func (m *AgentMutation) SetAPIBase(s string) {
  1899. m.api_base = &s
  1900. }
  1901. // APIBase returns the value of the "api_base" field in the mutation.
  1902. func (m *AgentMutation) APIBase() (r string, exists bool) {
  1903. v := m.api_base
  1904. if v == nil {
  1905. return
  1906. }
  1907. return *v, true
  1908. }
  1909. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  1910. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1912. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  1913. if !m.op.Is(OpUpdateOne) {
  1914. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  1915. }
  1916. if m.id == nil || m.oldValue == nil {
  1917. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  1918. }
  1919. oldValue, err := m.oldValue(ctx)
  1920. if err != nil {
  1921. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  1922. }
  1923. return oldValue.APIBase, nil
  1924. }
  1925. // ClearAPIBase clears the value of the "api_base" field.
  1926. func (m *AgentMutation) ClearAPIBase() {
  1927. m.api_base = nil
  1928. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  1929. }
  1930. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  1931. func (m *AgentMutation) APIBaseCleared() bool {
  1932. _, ok := m.clearedFields[agent.FieldAPIBase]
  1933. return ok
  1934. }
  1935. // ResetAPIBase resets all changes to the "api_base" field.
  1936. func (m *AgentMutation) ResetAPIBase() {
  1937. m.api_base = nil
  1938. delete(m.clearedFields, agent.FieldAPIBase)
  1939. }
  1940. // SetAPIKey sets the "api_key" field.
  1941. func (m *AgentMutation) SetAPIKey(s string) {
  1942. m.api_key = &s
  1943. }
  1944. // APIKey returns the value of the "api_key" field in the mutation.
  1945. func (m *AgentMutation) APIKey() (r string, exists bool) {
  1946. v := m.api_key
  1947. if v == nil {
  1948. return
  1949. }
  1950. return *v, true
  1951. }
  1952. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  1953. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1955. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  1956. if !m.op.Is(OpUpdateOne) {
  1957. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  1958. }
  1959. if m.id == nil || m.oldValue == nil {
  1960. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  1961. }
  1962. oldValue, err := m.oldValue(ctx)
  1963. if err != nil {
  1964. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  1965. }
  1966. return oldValue.APIKey, nil
  1967. }
  1968. // ClearAPIKey clears the value of the "api_key" field.
  1969. func (m *AgentMutation) ClearAPIKey() {
  1970. m.api_key = nil
  1971. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  1972. }
  1973. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  1974. func (m *AgentMutation) APIKeyCleared() bool {
  1975. _, ok := m.clearedFields[agent.FieldAPIKey]
  1976. return ok
  1977. }
  1978. // ResetAPIKey resets all changes to the "api_key" field.
  1979. func (m *AgentMutation) ResetAPIKey() {
  1980. m.api_key = nil
  1981. delete(m.clearedFields, agent.FieldAPIKey)
  1982. }
  1983. // SetType sets the "type" field.
  1984. func (m *AgentMutation) SetType(i int) {
  1985. m._type = &i
  1986. m.add_type = nil
  1987. }
  1988. // GetType returns the value of the "type" field in the mutation.
  1989. func (m *AgentMutation) GetType() (r int, exists bool) {
  1990. v := m._type
  1991. if v == nil {
  1992. return
  1993. }
  1994. return *v, true
  1995. }
  1996. // OldType returns the old "type" field's value of the Agent entity.
  1997. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1999. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  2000. if !m.op.Is(OpUpdateOne) {
  2001. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2002. }
  2003. if m.id == nil || m.oldValue == nil {
  2004. return v, errors.New("OldType requires an ID field in the mutation")
  2005. }
  2006. oldValue, err := m.oldValue(ctx)
  2007. if err != nil {
  2008. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2009. }
  2010. return oldValue.Type, nil
  2011. }
  2012. // AddType adds i to the "type" field.
  2013. func (m *AgentMutation) AddType(i int) {
  2014. if m.add_type != nil {
  2015. *m.add_type += i
  2016. } else {
  2017. m.add_type = &i
  2018. }
  2019. }
  2020. // AddedType returns the value that was added to the "type" field in this mutation.
  2021. func (m *AgentMutation) AddedType() (r int, exists bool) {
  2022. v := m.add_type
  2023. if v == nil {
  2024. return
  2025. }
  2026. return *v, true
  2027. }
  2028. // ClearType clears the value of the "type" field.
  2029. func (m *AgentMutation) ClearType() {
  2030. m._type = nil
  2031. m.add_type = nil
  2032. m.clearedFields[agent.FieldType] = struct{}{}
  2033. }
  2034. // TypeCleared returns if the "type" field was cleared in this mutation.
  2035. func (m *AgentMutation) TypeCleared() bool {
  2036. _, ok := m.clearedFields[agent.FieldType]
  2037. return ok
  2038. }
  2039. // ResetType resets all changes to the "type" field.
  2040. func (m *AgentMutation) ResetType() {
  2041. m._type = nil
  2042. m.add_type = nil
  2043. delete(m.clearedFields, agent.FieldType)
  2044. }
  2045. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2046. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  2047. if m.wx_agent == nil {
  2048. m.wx_agent = make(map[uint64]struct{})
  2049. }
  2050. for i := range ids {
  2051. m.wx_agent[ids[i]] = struct{}{}
  2052. }
  2053. }
  2054. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2055. func (m *AgentMutation) ClearWxAgent() {
  2056. m.clearedwx_agent = true
  2057. }
  2058. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2059. func (m *AgentMutation) WxAgentCleared() bool {
  2060. return m.clearedwx_agent
  2061. }
  2062. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2063. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  2064. if m.removedwx_agent == nil {
  2065. m.removedwx_agent = make(map[uint64]struct{})
  2066. }
  2067. for i := range ids {
  2068. delete(m.wx_agent, ids[i])
  2069. m.removedwx_agent[ids[i]] = struct{}{}
  2070. }
  2071. }
  2072. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2073. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  2074. for id := range m.removedwx_agent {
  2075. ids = append(ids, id)
  2076. }
  2077. return
  2078. }
  2079. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2080. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  2081. for id := range m.wx_agent {
  2082. ids = append(ids, id)
  2083. }
  2084. return
  2085. }
  2086. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2087. func (m *AgentMutation) ResetWxAgent() {
  2088. m.wx_agent = nil
  2089. m.clearedwx_agent = false
  2090. m.removedwx_agent = nil
  2091. }
  2092. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  2093. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  2094. if m.token_agent == nil {
  2095. m.token_agent = make(map[uint64]struct{})
  2096. }
  2097. for i := range ids {
  2098. m.token_agent[ids[i]] = struct{}{}
  2099. }
  2100. }
  2101. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  2102. func (m *AgentMutation) ClearTokenAgent() {
  2103. m.clearedtoken_agent = true
  2104. }
  2105. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  2106. func (m *AgentMutation) TokenAgentCleared() bool {
  2107. return m.clearedtoken_agent
  2108. }
  2109. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  2110. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  2111. if m.removedtoken_agent == nil {
  2112. m.removedtoken_agent = make(map[uint64]struct{})
  2113. }
  2114. for i := range ids {
  2115. delete(m.token_agent, ids[i])
  2116. m.removedtoken_agent[ids[i]] = struct{}{}
  2117. }
  2118. }
  2119. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  2120. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  2121. for id := range m.removedtoken_agent {
  2122. ids = append(ids, id)
  2123. }
  2124. return
  2125. }
  2126. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  2127. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  2128. for id := range m.token_agent {
  2129. ids = append(ids, id)
  2130. }
  2131. return
  2132. }
  2133. // ResetTokenAgent resets all changes to the "token_agent" edge.
  2134. func (m *AgentMutation) ResetTokenAgent() {
  2135. m.token_agent = nil
  2136. m.clearedtoken_agent = false
  2137. m.removedtoken_agent = nil
  2138. }
  2139. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  2140. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  2141. if m.wa_agent == nil {
  2142. m.wa_agent = make(map[uint64]struct{})
  2143. }
  2144. for i := range ids {
  2145. m.wa_agent[ids[i]] = struct{}{}
  2146. }
  2147. }
  2148. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  2149. func (m *AgentMutation) ClearWaAgent() {
  2150. m.clearedwa_agent = true
  2151. }
  2152. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  2153. func (m *AgentMutation) WaAgentCleared() bool {
  2154. return m.clearedwa_agent
  2155. }
  2156. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  2157. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  2158. if m.removedwa_agent == nil {
  2159. m.removedwa_agent = make(map[uint64]struct{})
  2160. }
  2161. for i := range ids {
  2162. delete(m.wa_agent, ids[i])
  2163. m.removedwa_agent[ids[i]] = struct{}{}
  2164. }
  2165. }
  2166. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  2167. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  2168. for id := range m.removedwa_agent {
  2169. ids = append(ids, id)
  2170. }
  2171. return
  2172. }
  2173. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  2174. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  2175. for id := range m.wa_agent {
  2176. ids = append(ids, id)
  2177. }
  2178. return
  2179. }
  2180. // ResetWaAgent resets all changes to the "wa_agent" edge.
  2181. func (m *AgentMutation) ResetWaAgent() {
  2182. m.wa_agent = nil
  2183. m.clearedwa_agent = false
  2184. m.removedwa_agent = nil
  2185. }
  2186. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  2187. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  2188. if m.xjs_agent == nil {
  2189. m.xjs_agent = make(map[uint64]struct{})
  2190. }
  2191. for i := range ids {
  2192. m.xjs_agent[ids[i]] = struct{}{}
  2193. }
  2194. }
  2195. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  2196. func (m *AgentMutation) ClearXjsAgent() {
  2197. m.clearedxjs_agent = true
  2198. }
  2199. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  2200. func (m *AgentMutation) XjsAgentCleared() bool {
  2201. return m.clearedxjs_agent
  2202. }
  2203. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  2204. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  2205. if m.removedxjs_agent == nil {
  2206. m.removedxjs_agent = make(map[uint64]struct{})
  2207. }
  2208. for i := range ids {
  2209. delete(m.xjs_agent, ids[i])
  2210. m.removedxjs_agent[ids[i]] = struct{}{}
  2211. }
  2212. }
  2213. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  2214. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  2215. for id := range m.removedxjs_agent {
  2216. ids = append(ids, id)
  2217. }
  2218. return
  2219. }
  2220. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  2221. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  2222. for id := range m.xjs_agent {
  2223. ids = append(ids, id)
  2224. }
  2225. return
  2226. }
  2227. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  2228. func (m *AgentMutation) ResetXjsAgent() {
  2229. m.xjs_agent = nil
  2230. m.clearedxjs_agent = false
  2231. m.removedxjs_agent = nil
  2232. }
  2233. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  2234. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  2235. if m.key_agent == nil {
  2236. m.key_agent = make(map[uint64]struct{})
  2237. }
  2238. for i := range ids {
  2239. m.key_agent[ids[i]] = struct{}{}
  2240. }
  2241. }
  2242. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  2243. func (m *AgentMutation) ClearKeyAgent() {
  2244. m.clearedkey_agent = true
  2245. }
  2246. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  2247. func (m *AgentMutation) KeyAgentCleared() bool {
  2248. return m.clearedkey_agent
  2249. }
  2250. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  2251. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  2252. if m.removedkey_agent == nil {
  2253. m.removedkey_agent = make(map[uint64]struct{})
  2254. }
  2255. for i := range ids {
  2256. delete(m.key_agent, ids[i])
  2257. m.removedkey_agent[ids[i]] = struct{}{}
  2258. }
  2259. }
  2260. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  2261. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  2262. for id := range m.removedkey_agent {
  2263. ids = append(ids, id)
  2264. }
  2265. return
  2266. }
  2267. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  2268. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  2269. for id := range m.key_agent {
  2270. ids = append(ids, id)
  2271. }
  2272. return
  2273. }
  2274. // ResetKeyAgent resets all changes to the "key_agent" edge.
  2275. func (m *AgentMutation) ResetKeyAgent() {
  2276. m.key_agent = nil
  2277. m.clearedkey_agent = false
  2278. m.removedkey_agent = nil
  2279. }
  2280. // Where appends a list predicates to the AgentMutation builder.
  2281. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  2282. m.predicates = append(m.predicates, ps...)
  2283. }
  2284. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  2285. // users can use type-assertion to append predicates that do not depend on any generated package.
  2286. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  2287. p := make([]predicate.Agent, len(ps))
  2288. for i := range ps {
  2289. p[i] = ps[i]
  2290. }
  2291. m.Where(p...)
  2292. }
  2293. // Op returns the operation name.
  2294. func (m *AgentMutation) Op() Op {
  2295. return m.op
  2296. }
  2297. // SetOp allows setting the mutation operation.
  2298. func (m *AgentMutation) SetOp(op Op) {
  2299. m.op = op
  2300. }
  2301. // Type returns the node type of this mutation (Agent).
  2302. func (m *AgentMutation) Type() string {
  2303. return m.typ
  2304. }
  2305. // Fields returns all fields that were changed during this mutation. Note that in
  2306. // order to get all numeric fields that were incremented/decremented, call
  2307. // AddedFields().
  2308. func (m *AgentMutation) Fields() []string {
  2309. fields := make([]string, 0, 15)
  2310. if m.created_at != nil {
  2311. fields = append(fields, agent.FieldCreatedAt)
  2312. }
  2313. if m.updated_at != nil {
  2314. fields = append(fields, agent.FieldUpdatedAt)
  2315. }
  2316. if m.deleted_at != nil {
  2317. fields = append(fields, agent.FieldDeletedAt)
  2318. }
  2319. if m.name != nil {
  2320. fields = append(fields, agent.FieldName)
  2321. }
  2322. if m.role != nil {
  2323. fields = append(fields, agent.FieldRole)
  2324. }
  2325. if m.status != nil {
  2326. fields = append(fields, agent.FieldStatus)
  2327. }
  2328. if m.background != nil {
  2329. fields = append(fields, agent.FieldBackground)
  2330. }
  2331. if m.examples != nil {
  2332. fields = append(fields, agent.FieldExamples)
  2333. }
  2334. if m.organization_id != nil {
  2335. fields = append(fields, agent.FieldOrganizationID)
  2336. }
  2337. if m.dataset_id != nil {
  2338. fields = append(fields, agent.FieldDatasetID)
  2339. }
  2340. if m.collection_id != nil {
  2341. fields = append(fields, agent.FieldCollectionID)
  2342. }
  2343. if m.model != nil {
  2344. fields = append(fields, agent.FieldModel)
  2345. }
  2346. if m.api_base != nil {
  2347. fields = append(fields, agent.FieldAPIBase)
  2348. }
  2349. if m.api_key != nil {
  2350. fields = append(fields, agent.FieldAPIKey)
  2351. }
  2352. if m._type != nil {
  2353. fields = append(fields, agent.FieldType)
  2354. }
  2355. return fields
  2356. }
  2357. // Field returns the value of a field with the given name. The second boolean
  2358. // return value indicates that this field was not set, or was not defined in the
  2359. // schema.
  2360. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  2361. switch name {
  2362. case agent.FieldCreatedAt:
  2363. return m.CreatedAt()
  2364. case agent.FieldUpdatedAt:
  2365. return m.UpdatedAt()
  2366. case agent.FieldDeletedAt:
  2367. return m.DeletedAt()
  2368. case agent.FieldName:
  2369. return m.Name()
  2370. case agent.FieldRole:
  2371. return m.Role()
  2372. case agent.FieldStatus:
  2373. return m.Status()
  2374. case agent.FieldBackground:
  2375. return m.Background()
  2376. case agent.FieldExamples:
  2377. return m.Examples()
  2378. case agent.FieldOrganizationID:
  2379. return m.OrganizationID()
  2380. case agent.FieldDatasetID:
  2381. return m.DatasetID()
  2382. case agent.FieldCollectionID:
  2383. return m.CollectionID()
  2384. case agent.FieldModel:
  2385. return m.Model()
  2386. case agent.FieldAPIBase:
  2387. return m.APIBase()
  2388. case agent.FieldAPIKey:
  2389. return m.APIKey()
  2390. case agent.FieldType:
  2391. return m.GetType()
  2392. }
  2393. return nil, false
  2394. }
  2395. // OldField returns the old value of the field from the database. An error is
  2396. // returned if the mutation operation is not UpdateOne, or the query to the
  2397. // database failed.
  2398. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2399. switch name {
  2400. case agent.FieldCreatedAt:
  2401. return m.OldCreatedAt(ctx)
  2402. case agent.FieldUpdatedAt:
  2403. return m.OldUpdatedAt(ctx)
  2404. case agent.FieldDeletedAt:
  2405. return m.OldDeletedAt(ctx)
  2406. case agent.FieldName:
  2407. return m.OldName(ctx)
  2408. case agent.FieldRole:
  2409. return m.OldRole(ctx)
  2410. case agent.FieldStatus:
  2411. return m.OldStatus(ctx)
  2412. case agent.FieldBackground:
  2413. return m.OldBackground(ctx)
  2414. case agent.FieldExamples:
  2415. return m.OldExamples(ctx)
  2416. case agent.FieldOrganizationID:
  2417. return m.OldOrganizationID(ctx)
  2418. case agent.FieldDatasetID:
  2419. return m.OldDatasetID(ctx)
  2420. case agent.FieldCollectionID:
  2421. return m.OldCollectionID(ctx)
  2422. case agent.FieldModel:
  2423. return m.OldModel(ctx)
  2424. case agent.FieldAPIBase:
  2425. return m.OldAPIBase(ctx)
  2426. case agent.FieldAPIKey:
  2427. return m.OldAPIKey(ctx)
  2428. case agent.FieldType:
  2429. return m.OldType(ctx)
  2430. }
  2431. return nil, fmt.Errorf("unknown Agent field %s", name)
  2432. }
  2433. // SetField sets the value of a field with the given name. It returns an error if
  2434. // the field is not defined in the schema, or if the type mismatched the field
  2435. // type.
  2436. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  2437. switch name {
  2438. case agent.FieldCreatedAt:
  2439. v, ok := value.(time.Time)
  2440. if !ok {
  2441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2442. }
  2443. m.SetCreatedAt(v)
  2444. return nil
  2445. case agent.FieldUpdatedAt:
  2446. v, ok := value.(time.Time)
  2447. if !ok {
  2448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2449. }
  2450. m.SetUpdatedAt(v)
  2451. return nil
  2452. case agent.FieldDeletedAt:
  2453. v, ok := value.(time.Time)
  2454. if !ok {
  2455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2456. }
  2457. m.SetDeletedAt(v)
  2458. return nil
  2459. case agent.FieldName:
  2460. v, ok := value.(string)
  2461. if !ok {
  2462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2463. }
  2464. m.SetName(v)
  2465. return nil
  2466. case agent.FieldRole:
  2467. v, ok := value.(string)
  2468. if !ok {
  2469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2470. }
  2471. m.SetRole(v)
  2472. return nil
  2473. case agent.FieldStatus:
  2474. v, ok := value.(int)
  2475. if !ok {
  2476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2477. }
  2478. m.SetStatus(v)
  2479. return nil
  2480. case agent.FieldBackground:
  2481. v, ok := value.(string)
  2482. if !ok {
  2483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2484. }
  2485. m.SetBackground(v)
  2486. return nil
  2487. case agent.FieldExamples:
  2488. v, ok := value.(string)
  2489. if !ok {
  2490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2491. }
  2492. m.SetExamples(v)
  2493. return nil
  2494. case agent.FieldOrganizationID:
  2495. v, ok := value.(uint64)
  2496. if !ok {
  2497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2498. }
  2499. m.SetOrganizationID(v)
  2500. return nil
  2501. case agent.FieldDatasetID:
  2502. v, ok := value.(string)
  2503. if !ok {
  2504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2505. }
  2506. m.SetDatasetID(v)
  2507. return nil
  2508. case agent.FieldCollectionID:
  2509. v, ok := value.(string)
  2510. if !ok {
  2511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2512. }
  2513. m.SetCollectionID(v)
  2514. return nil
  2515. case agent.FieldModel:
  2516. v, ok := value.(string)
  2517. if !ok {
  2518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2519. }
  2520. m.SetModel(v)
  2521. return nil
  2522. case agent.FieldAPIBase:
  2523. v, ok := value.(string)
  2524. if !ok {
  2525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2526. }
  2527. m.SetAPIBase(v)
  2528. return nil
  2529. case agent.FieldAPIKey:
  2530. v, ok := value.(string)
  2531. if !ok {
  2532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2533. }
  2534. m.SetAPIKey(v)
  2535. return nil
  2536. case agent.FieldType:
  2537. v, ok := value.(int)
  2538. if !ok {
  2539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2540. }
  2541. m.SetType(v)
  2542. return nil
  2543. }
  2544. return fmt.Errorf("unknown Agent field %s", name)
  2545. }
  2546. // AddedFields returns all numeric fields that were incremented/decremented during
  2547. // this mutation.
  2548. func (m *AgentMutation) AddedFields() []string {
  2549. var fields []string
  2550. if m.addstatus != nil {
  2551. fields = append(fields, agent.FieldStatus)
  2552. }
  2553. if m.addorganization_id != nil {
  2554. fields = append(fields, agent.FieldOrganizationID)
  2555. }
  2556. if m.add_type != nil {
  2557. fields = append(fields, agent.FieldType)
  2558. }
  2559. return fields
  2560. }
  2561. // AddedField returns the numeric value that was incremented/decremented on a field
  2562. // with the given name. The second boolean return value indicates that this field
  2563. // was not set, or was not defined in the schema.
  2564. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  2565. switch name {
  2566. case agent.FieldStatus:
  2567. return m.AddedStatus()
  2568. case agent.FieldOrganizationID:
  2569. return m.AddedOrganizationID()
  2570. case agent.FieldType:
  2571. return m.AddedType()
  2572. }
  2573. return nil, false
  2574. }
  2575. // AddField adds the value to the field with the given name. It returns an error if
  2576. // the field is not defined in the schema, or if the type mismatched the field
  2577. // type.
  2578. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  2579. switch name {
  2580. case agent.FieldStatus:
  2581. v, ok := value.(int)
  2582. if !ok {
  2583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2584. }
  2585. m.AddStatus(v)
  2586. return nil
  2587. case agent.FieldOrganizationID:
  2588. v, ok := value.(int64)
  2589. if !ok {
  2590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2591. }
  2592. m.AddOrganizationID(v)
  2593. return nil
  2594. case agent.FieldType:
  2595. v, ok := value.(int)
  2596. if !ok {
  2597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2598. }
  2599. m.AddType(v)
  2600. return nil
  2601. }
  2602. return fmt.Errorf("unknown Agent numeric field %s", name)
  2603. }
  2604. // ClearedFields returns all nullable fields that were cleared during this
  2605. // mutation.
  2606. func (m *AgentMutation) ClearedFields() []string {
  2607. var fields []string
  2608. if m.FieldCleared(agent.FieldDeletedAt) {
  2609. fields = append(fields, agent.FieldDeletedAt)
  2610. }
  2611. if m.FieldCleared(agent.FieldRole) {
  2612. fields = append(fields, agent.FieldRole)
  2613. }
  2614. if m.FieldCleared(agent.FieldStatus) {
  2615. fields = append(fields, agent.FieldStatus)
  2616. }
  2617. if m.FieldCleared(agent.FieldBackground) {
  2618. fields = append(fields, agent.FieldBackground)
  2619. }
  2620. if m.FieldCleared(agent.FieldExamples) {
  2621. fields = append(fields, agent.FieldExamples)
  2622. }
  2623. if m.FieldCleared(agent.FieldModel) {
  2624. fields = append(fields, agent.FieldModel)
  2625. }
  2626. if m.FieldCleared(agent.FieldAPIBase) {
  2627. fields = append(fields, agent.FieldAPIBase)
  2628. }
  2629. if m.FieldCleared(agent.FieldAPIKey) {
  2630. fields = append(fields, agent.FieldAPIKey)
  2631. }
  2632. if m.FieldCleared(agent.FieldType) {
  2633. fields = append(fields, agent.FieldType)
  2634. }
  2635. return fields
  2636. }
  2637. // FieldCleared returns a boolean indicating if a field with the given name was
  2638. // cleared in this mutation.
  2639. func (m *AgentMutation) FieldCleared(name string) bool {
  2640. _, ok := m.clearedFields[name]
  2641. return ok
  2642. }
  2643. // ClearField clears the value of the field with the given name. It returns an
  2644. // error if the field is not defined in the schema.
  2645. func (m *AgentMutation) ClearField(name string) error {
  2646. switch name {
  2647. case agent.FieldDeletedAt:
  2648. m.ClearDeletedAt()
  2649. return nil
  2650. case agent.FieldRole:
  2651. m.ClearRole()
  2652. return nil
  2653. case agent.FieldStatus:
  2654. m.ClearStatus()
  2655. return nil
  2656. case agent.FieldBackground:
  2657. m.ClearBackground()
  2658. return nil
  2659. case agent.FieldExamples:
  2660. m.ClearExamples()
  2661. return nil
  2662. case agent.FieldModel:
  2663. m.ClearModel()
  2664. return nil
  2665. case agent.FieldAPIBase:
  2666. m.ClearAPIBase()
  2667. return nil
  2668. case agent.FieldAPIKey:
  2669. m.ClearAPIKey()
  2670. return nil
  2671. case agent.FieldType:
  2672. m.ClearType()
  2673. return nil
  2674. }
  2675. return fmt.Errorf("unknown Agent nullable field %s", name)
  2676. }
  2677. // ResetField resets all changes in the mutation for the field with the given name.
  2678. // It returns an error if the field is not defined in the schema.
  2679. func (m *AgentMutation) ResetField(name string) error {
  2680. switch name {
  2681. case agent.FieldCreatedAt:
  2682. m.ResetCreatedAt()
  2683. return nil
  2684. case agent.FieldUpdatedAt:
  2685. m.ResetUpdatedAt()
  2686. return nil
  2687. case agent.FieldDeletedAt:
  2688. m.ResetDeletedAt()
  2689. return nil
  2690. case agent.FieldName:
  2691. m.ResetName()
  2692. return nil
  2693. case agent.FieldRole:
  2694. m.ResetRole()
  2695. return nil
  2696. case agent.FieldStatus:
  2697. m.ResetStatus()
  2698. return nil
  2699. case agent.FieldBackground:
  2700. m.ResetBackground()
  2701. return nil
  2702. case agent.FieldExamples:
  2703. m.ResetExamples()
  2704. return nil
  2705. case agent.FieldOrganizationID:
  2706. m.ResetOrganizationID()
  2707. return nil
  2708. case agent.FieldDatasetID:
  2709. m.ResetDatasetID()
  2710. return nil
  2711. case agent.FieldCollectionID:
  2712. m.ResetCollectionID()
  2713. return nil
  2714. case agent.FieldModel:
  2715. m.ResetModel()
  2716. return nil
  2717. case agent.FieldAPIBase:
  2718. m.ResetAPIBase()
  2719. return nil
  2720. case agent.FieldAPIKey:
  2721. m.ResetAPIKey()
  2722. return nil
  2723. case agent.FieldType:
  2724. m.ResetType()
  2725. return nil
  2726. }
  2727. return fmt.Errorf("unknown Agent field %s", name)
  2728. }
  2729. // AddedEdges returns all edge names that were set/added in this mutation.
  2730. func (m *AgentMutation) AddedEdges() []string {
  2731. edges := make([]string, 0, 5)
  2732. if m.wx_agent != nil {
  2733. edges = append(edges, agent.EdgeWxAgent)
  2734. }
  2735. if m.token_agent != nil {
  2736. edges = append(edges, agent.EdgeTokenAgent)
  2737. }
  2738. if m.wa_agent != nil {
  2739. edges = append(edges, agent.EdgeWaAgent)
  2740. }
  2741. if m.xjs_agent != nil {
  2742. edges = append(edges, agent.EdgeXjsAgent)
  2743. }
  2744. if m.key_agent != nil {
  2745. edges = append(edges, agent.EdgeKeyAgent)
  2746. }
  2747. return edges
  2748. }
  2749. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2750. // name in this mutation.
  2751. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  2752. switch name {
  2753. case agent.EdgeWxAgent:
  2754. ids := make([]ent.Value, 0, len(m.wx_agent))
  2755. for id := range m.wx_agent {
  2756. ids = append(ids, id)
  2757. }
  2758. return ids
  2759. case agent.EdgeTokenAgent:
  2760. ids := make([]ent.Value, 0, len(m.token_agent))
  2761. for id := range m.token_agent {
  2762. ids = append(ids, id)
  2763. }
  2764. return ids
  2765. case agent.EdgeWaAgent:
  2766. ids := make([]ent.Value, 0, len(m.wa_agent))
  2767. for id := range m.wa_agent {
  2768. ids = append(ids, id)
  2769. }
  2770. return ids
  2771. case agent.EdgeXjsAgent:
  2772. ids := make([]ent.Value, 0, len(m.xjs_agent))
  2773. for id := range m.xjs_agent {
  2774. ids = append(ids, id)
  2775. }
  2776. return ids
  2777. case agent.EdgeKeyAgent:
  2778. ids := make([]ent.Value, 0, len(m.key_agent))
  2779. for id := range m.key_agent {
  2780. ids = append(ids, id)
  2781. }
  2782. return ids
  2783. }
  2784. return nil
  2785. }
  2786. // RemovedEdges returns all edge names that were removed in this mutation.
  2787. func (m *AgentMutation) RemovedEdges() []string {
  2788. edges := make([]string, 0, 5)
  2789. if m.removedwx_agent != nil {
  2790. edges = append(edges, agent.EdgeWxAgent)
  2791. }
  2792. if m.removedtoken_agent != nil {
  2793. edges = append(edges, agent.EdgeTokenAgent)
  2794. }
  2795. if m.removedwa_agent != nil {
  2796. edges = append(edges, agent.EdgeWaAgent)
  2797. }
  2798. if m.removedxjs_agent != nil {
  2799. edges = append(edges, agent.EdgeXjsAgent)
  2800. }
  2801. if m.removedkey_agent != nil {
  2802. edges = append(edges, agent.EdgeKeyAgent)
  2803. }
  2804. return edges
  2805. }
  2806. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2807. // the given name in this mutation.
  2808. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  2809. switch name {
  2810. case agent.EdgeWxAgent:
  2811. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2812. for id := range m.removedwx_agent {
  2813. ids = append(ids, id)
  2814. }
  2815. return ids
  2816. case agent.EdgeTokenAgent:
  2817. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  2818. for id := range m.removedtoken_agent {
  2819. ids = append(ids, id)
  2820. }
  2821. return ids
  2822. case agent.EdgeWaAgent:
  2823. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  2824. for id := range m.removedwa_agent {
  2825. ids = append(ids, id)
  2826. }
  2827. return ids
  2828. case agent.EdgeXjsAgent:
  2829. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  2830. for id := range m.removedxjs_agent {
  2831. ids = append(ids, id)
  2832. }
  2833. return ids
  2834. case agent.EdgeKeyAgent:
  2835. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  2836. for id := range m.removedkey_agent {
  2837. ids = append(ids, id)
  2838. }
  2839. return ids
  2840. }
  2841. return nil
  2842. }
  2843. // ClearedEdges returns all edge names that were cleared in this mutation.
  2844. func (m *AgentMutation) ClearedEdges() []string {
  2845. edges := make([]string, 0, 5)
  2846. if m.clearedwx_agent {
  2847. edges = append(edges, agent.EdgeWxAgent)
  2848. }
  2849. if m.clearedtoken_agent {
  2850. edges = append(edges, agent.EdgeTokenAgent)
  2851. }
  2852. if m.clearedwa_agent {
  2853. edges = append(edges, agent.EdgeWaAgent)
  2854. }
  2855. if m.clearedxjs_agent {
  2856. edges = append(edges, agent.EdgeXjsAgent)
  2857. }
  2858. if m.clearedkey_agent {
  2859. edges = append(edges, agent.EdgeKeyAgent)
  2860. }
  2861. return edges
  2862. }
  2863. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2864. // was cleared in this mutation.
  2865. func (m *AgentMutation) EdgeCleared(name string) bool {
  2866. switch name {
  2867. case agent.EdgeWxAgent:
  2868. return m.clearedwx_agent
  2869. case agent.EdgeTokenAgent:
  2870. return m.clearedtoken_agent
  2871. case agent.EdgeWaAgent:
  2872. return m.clearedwa_agent
  2873. case agent.EdgeXjsAgent:
  2874. return m.clearedxjs_agent
  2875. case agent.EdgeKeyAgent:
  2876. return m.clearedkey_agent
  2877. }
  2878. return false
  2879. }
  2880. // ClearEdge clears the value of the edge with the given name. It returns an error
  2881. // if that edge is not defined in the schema.
  2882. func (m *AgentMutation) ClearEdge(name string) error {
  2883. switch name {
  2884. }
  2885. return fmt.Errorf("unknown Agent unique edge %s", name)
  2886. }
  2887. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2888. // It returns an error if the edge is not defined in the schema.
  2889. func (m *AgentMutation) ResetEdge(name string) error {
  2890. switch name {
  2891. case agent.EdgeWxAgent:
  2892. m.ResetWxAgent()
  2893. return nil
  2894. case agent.EdgeTokenAgent:
  2895. m.ResetTokenAgent()
  2896. return nil
  2897. case agent.EdgeWaAgent:
  2898. m.ResetWaAgent()
  2899. return nil
  2900. case agent.EdgeXjsAgent:
  2901. m.ResetXjsAgent()
  2902. return nil
  2903. case agent.EdgeKeyAgent:
  2904. m.ResetKeyAgent()
  2905. return nil
  2906. }
  2907. return fmt.Errorf("unknown Agent edge %s", name)
  2908. }
  2909. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  2910. type AgentBaseMutation struct {
  2911. config
  2912. op Op
  2913. typ string
  2914. id *string
  2915. q *string
  2916. a *string
  2917. chunk_index *uint64
  2918. addchunk_index *int64
  2919. indexes *[]string
  2920. appendindexes []string
  2921. dataset_id *string
  2922. collection_id *string
  2923. source_name *string
  2924. can_write *[]bool
  2925. appendcan_write []bool
  2926. is_owner *[]bool
  2927. appendis_owner []bool
  2928. clearedFields map[string]struct{}
  2929. wx_agent map[uint64]struct{}
  2930. removedwx_agent map[uint64]struct{}
  2931. clearedwx_agent bool
  2932. done bool
  2933. oldValue func(context.Context) (*AgentBase, error)
  2934. predicates []predicate.AgentBase
  2935. }
  2936. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  2937. // agentbaseOption allows management of the mutation configuration using functional options.
  2938. type agentbaseOption func(*AgentBaseMutation)
  2939. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  2940. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  2941. m := &AgentBaseMutation{
  2942. config: c,
  2943. op: op,
  2944. typ: TypeAgentBase,
  2945. clearedFields: make(map[string]struct{}),
  2946. }
  2947. for _, opt := range opts {
  2948. opt(m)
  2949. }
  2950. return m
  2951. }
  2952. // withAgentBaseID sets the ID field of the mutation.
  2953. func withAgentBaseID(id string) agentbaseOption {
  2954. return func(m *AgentBaseMutation) {
  2955. var (
  2956. err error
  2957. once sync.Once
  2958. value *AgentBase
  2959. )
  2960. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  2961. once.Do(func() {
  2962. if m.done {
  2963. err = errors.New("querying old values post mutation is not allowed")
  2964. } else {
  2965. value, err = m.Client().AgentBase.Get(ctx, id)
  2966. }
  2967. })
  2968. return value, err
  2969. }
  2970. m.id = &id
  2971. }
  2972. }
  2973. // withAgentBase sets the old AgentBase of the mutation.
  2974. func withAgentBase(node *AgentBase) agentbaseOption {
  2975. return func(m *AgentBaseMutation) {
  2976. m.oldValue = func(context.Context) (*AgentBase, error) {
  2977. return node, nil
  2978. }
  2979. m.id = &node.ID
  2980. }
  2981. }
  2982. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2983. // executed in a transaction (ent.Tx), a transactional client is returned.
  2984. func (m AgentBaseMutation) Client() *Client {
  2985. client := &Client{config: m.config}
  2986. client.init()
  2987. return client
  2988. }
  2989. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2990. // it returns an error otherwise.
  2991. func (m AgentBaseMutation) Tx() (*Tx, error) {
  2992. if _, ok := m.driver.(*txDriver); !ok {
  2993. return nil, errors.New("ent: mutation is not running in a transaction")
  2994. }
  2995. tx := &Tx{config: m.config}
  2996. tx.init()
  2997. return tx, nil
  2998. }
  2999. // SetID sets the value of the id field. Note that this
  3000. // operation is only accepted on creation of AgentBase entities.
  3001. func (m *AgentBaseMutation) SetID(id string) {
  3002. m.id = &id
  3003. }
  3004. // ID returns the ID value in the mutation. Note that the ID is only available
  3005. // if it was provided to the builder or after it was returned from the database.
  3006. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  3007. if m.id == nil {
  3008. return
  3009. }
  3010. return *m.id, true
  3011. }
  3012. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3013. // That means, if the mutation is applied within a transaction with an isolation level such
  3014. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3015. // or updated by the mutation.
  3016. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  3017. switch {
  3018. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3019. id, exists := m.ID()
  3020. if exists {
  3021. return []string{id}, nil
  3022. }
  3023. fallthrough
  3024. case m.op.Is(OpUpdate | OpDelete):
  3025. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  3026. default:
  3027. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3028. }
  3029. }
  3030. // SetQ sets the "q" field.
  3031. func (m *AgentBaseMutation) SetQ(s string) {
  3032. m.q = &s
  3033. }
  3034. // Q returns the value of the "q" field in the mutation.
  3035. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  3036. v := m.q
  3037. if v == nil {
  3038. return
  3039. }
  3040. return *v, true
  3041. }
  3042. // OldQ returns the old "q" field's value of the AgentBase entity.
  3043. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3045. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  3046. if !m.op.Is(OpUpdateOne) {
  3047. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  3048. }
  3049. if m.id == nil || m.oldValue == nil {
  3050. return v, errors.New("OldQ requires an ID field in the mutation")
  3051. }
  3052. oldValue, err := m.oldValue(ctx)
  3053. if err != nil {
  3054. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  3055. }
  3056. return oldValue.Q, nil
  3057. }
  3058. // ClearQ clears the value of the "q" field.
  3059. func (m *AgentBaseMutation) ClearQ() {
  3060. m.q = nil
  3061. m.clearedFields[agentbase.FieldQ] = struct{}{}
  3062. }
  3063. // QCleared returns if the "q" field was cleared in this mutation.
  3064. func (m *AgentBaseMutation) QCleared() bool {
  3065. _, ok := m.clearedFields[agentbase.FieldQ]
  3066. return ok
  3067. }
  3068. // ResetQ resets all changes to the "q" field.
  3069. func (m *AgentBaseMutation) ResetQ() {
  3070. m.q = nil
  3071. delete(m.clearedFields, agentbase.FieldQ)
  3072. }
  3073. // SetA sets the "a" field.
  3074. func (m *AgentBaseMutation) SetA(s string) {
  3075. m.a = &s
  3076. }
  3077. // A returns the value of the "a" field in the mutation.
  3078. func (m *AgentBaseMutation) A() (r string, exists bool) {
  3079. v := m.a
  3080. if v == nil {
  3081. return
  3082. }
  3083. return *v, true
  3084. }
  3085. // OldA returns the old "a" field's value of the AgentBase entity.
  3086. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3088. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  3089. if !m.op.Is(OpUpdateOne) {
  3090. return v, errors.New("OldA is only allowed on UpdateOne operations")
  3091. }
  3092. if m.id == nil || m.oldValue == nil {
  3093. return v, errors.New("OldA requires an ID field in the mutation")
  3094. }
  3095. oldValue, err := m.oldValue(ctx)
  3096. if err != nil {
  3097. return v, fmt.Errorf("querying old value for OldA: %w", err)
  3098. }
  3099. return oldValue.A, nil
  3100. }
  3101. // ClearA clears the value of the "a" field.
  3102. func (m *AgentBaseMutation) ClearA() {
  3103. m.a = nil
  3104. m.clearedFields[agentbase.FieldA] = struct{}{}
  3105. }
  3106. // ACleared returns if the "a" field was cleared in this mutation.
  3107. func (m *AgentBaseMutation) ACleared() bool {
  3108. _, ok := m.clearedFields[agentbase.FieldA]
  3109. return ok
  3110. }
  3111. // ResetA resets all changes to the "a" field.
  3112. func (m *AgentBaseMutation) ResetA() {
  3113. m.a = nil
  3114. delete(m.clearedFields, agentbase.FieldA)
  3115. }
  3116. // SetChunkIndex sets the "chunk_index" field.
  3117. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  3118. m.chunk_index = &u
  3119. m.addchunk_index = nil
  3120. }
  3121. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  3122. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  3123. v := m.chunk_index
  3124. if v == nil {
  3125. return
  3126. }
  3127. return *v, true
  3128. }
  3129. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  3130. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3132. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  3133. if !m.op.Is(OpUpdateOne) {
  3134. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  3135. }
  3136. if m.id == nil || m.oldValue == nil {
  3137. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  3138. }
  3139. oldValue, err := m.oldValue(ctx)
  3140. if err != nil {
  3141. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  3142. }
  3143. return oldValue.ChunkIndex, nil
  3144. }
  3145. // AddChunkIndex adds u to the "chunk_index" field.
  3146. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  3147. if m.addchunk_index != nil {
  3148. *m.addchunk_index += u
  3149. } else {
  3150. m.addchunk_index = &u
  3151. }
  3152. }
  3153. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  3154. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  3155. v := m.addchunk_index
  3156. if v == nil {
  3157. return
  3158. }
  3159. return *v, true
  3160. }
  3161. // ResetChunkIndex resets all changes to the "chunk_index" field.
  3162. func (m *AgentBaseMutation) ResetChunkIndex() {
  3163. m.chunk_index = nil
  3164. m.addchunk_index = nil
  3165. }
  3166. // SetIndexes sets the "indexes" field.
  3167. func (m *AgentBaseMutation) SetIndexes(s []string) {
  3168. m.indexes = &s
  3169. m.appendindexes = nil
  3170. }
  3171. // Indexes returns the value of the "indexes" field in the mutation.
  3172. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  3173. v := m.indexes
  3174. if v == nil {
  3175. return
  3176. }
  3177. return *v, true
  3178. }
  3179. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  3180. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3182. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  3183. if !m.op.Is(OpUpdateOne) {
  3184. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  3185. }
  3186. if m.id == nil || m.oldValue == nil {
  3187. return v, errors.New("OldIndexes requires an ID field in the mutation")
  3188. }
  3189. oldValue, err := m.oldValue(ctx)
  3190. if err != nil {
  3191. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  3192. }
  3193. return oldValue.Indexes, nil
  3194. }
  3195. // AppendIndexes adds s to the "indexes" field.
  3196. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  3197. m.appendindexes = append(m.appendindexes, s...)
  3198. }
  3199. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  3200. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  3201. if len(m.appendindexes) == 0 {
  3202. return nil, false
  3203. }
  3204. return m.appendindexes, true
  3205. }
  3206. // ClearIndexes clears the value of the "indexes" field.
  3207. func (m *AgentBaseMutation) ClearIndexes() {
  3208. m.indexes = nil
  3209. m.appendindexes = nil
  3210. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  3211. }
  3212. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  3213. func (m *AgentBaseMutation) IndexesCleared() bool {
  3214. _, ok := m.clearedFields[agentbase.FieldIndexes]
  3215. return ok
  3216. }
  3217. // ResetIndexes resets all changes to the "indexes" field.
  3218. func (m *AgentBaseMutation) ResetIndexes() {
  3219. m.indexes = nil
  3220. m.appendindexes = nil
  3221. delete(m.clearedFields, agentbase.FieldIndexes)
  3222. }
  3223. // SetDatasetID sets the "dataset_id" field.
  3224. func (m *AgentBaseMutation) SetDatasetID(s string) {
  3225. m.dataset_id = &s
  3226. }
  3227. // DatasetID returns the value of the "dataset_id" field in the mutation.
  3228. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  3229. v := m.dataset_id
  3230. if v == nil {
  3231. return
  3232. }
  3233. return *v, true
  3234. }
  3235. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  3236. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3238. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  3239. if !m.op.Is(OpUpdateOne) {
  3240. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  3241. }
  3242. if m.id == nil || m.oldValue == nil {
  3243. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  3244. }
  3245. oldValue, err := m.oldValue(ctx)
  3246. if err != nil {
  3247. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  3248. }
  3249. return oldValue.DatasetID, nil
  3250. }
  3251. // ClearDatasetID clears the value of the "dataset_id" field.
  3252. func (m *AgentBaseMutation) ClearDatasetID() {
  3253. m.dataset_id = nil
  3254. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  3255. }
  3256. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  3257. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  3258. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  3259. return ok
  3260. }
  3261. // ResetDatasetID resets all changes to the "dataset_id" field.
  3262. func (m *AgentBaseMutation) ResetDatasetID() {
  3263. m.dataset_id = nil
  3264. delete(m.clearedFields, agentbase.FieldDatasetID)
  3265. }
  3266. // SetCollectionID sets the "collection_id" field.
  3267. func (m *AgentBaseMutation) SetCollectionID(s string) {
  3268. m.collection_id = &s
  3269. }
  3270. // CollectionID returns the value of the "collection_id" field in the mutation.
  3271. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  3272. v := m.collection_id
  3273. if v == nil {
  3274. return
  3275. }
  3276. return *v, true
  3277. }
  3278. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  3279. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3281. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  3282. if !m.op.Is(OpUpdateOne) {
  3283. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  3284. }
  3285. if m.id == nil || m.oldValue == nil {
  3286. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  3287. }
  3288. oldValue, err := m.oldValue(ctx)
  3289. if err != nil {
  3290. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  3291. }
  3292. return oldValue.CollectionID, nil
  3293. }
  3294. // ClearCollectionID clears the value of the "collection_id" field.
  3295. func (m *AgentBaseMutation) ClearCollectionID() {
  3296. m.collection_id = nil
  3297. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  3298. }
  3299. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  3300. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  3301. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  3302. return ok
  3303. }
  3304. // ResetCollectionID resets all changes to the "collection_id" field.
  3305. func (m *AgentBaseMutation) ResetCollectionID() {
  3306. m.collection_id = nil
  3307. delete(m.clearedFields, agentbase.FieldCollectionID)
  3308. }
  3309. // SetSourceName sets the "source_name" field.
  3310. func (m *AgentBaseMutation) SetSourceName(s string) {
  3311. m.source_name = &s
  3312. }
  3313. // SourceName returns the value of the "source_name" field in the mutation.
  3314. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  3315. v := m.source_name
  3316. if v == nil {
  3317. return
  3318. }
  3319. return *v, true
  3320. }
  3321. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  3322. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3324. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  3325. if !m.op.Is(OpUpdateOne) {
  3326. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  3327. }
  3328. if m.id == nil || m.oldValue == nil {
  3329. return v, errors.New("OldSourceName requires an ID field in the mutation")
  3330. }
  3331. oldValue, err := m.oldValue(ctx)
  3332. if err != nil {
  3333. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  3334. }
  3335. return oldValue.SourceName, nil
  3336. }
  3337. // ClearSourceName clears the value of the "source_name" field.
  3338. func (m *AgentBaseMutation) ClearSourceName() {
  3339. m.source_name = nil
  3340. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  3341. }
  3342. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  3343. func (m *AgentBaseMutation) SourceNameCleared() bool {
  3344. _, ok := m.clearedFields[agentbase.FieldSourceName]
  3345. return ok
  3346. }
  3347. // ResetSourceName resets all changes to the "source_name" field.
  3348. func (m *AgentBaseMutation) ResetSourceName() {
  3349. m.source_name = nil
  3350. delete(m.clearedFields, agentbase.FieldSourceName)
  3351. }
  3352. // SetCanWrite sets the "can_write" field.
  3353. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  3354. m.can_write = &b
  3355. m.appendcan_write = nil
  3356. }
  3357. // CanWrite returns the value of the "can_write" field in the mutation.
  3358. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  3359. v := m.can_write
  3360. if v == nil {
  3361. return
  3362. }
  3363. return *v, true
  3364. }
  3365. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  3366. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3368. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  3369. if !m.op.Is(OpUpdateOne) {
  3370. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  3371. }
  3372. if m.id == nil || m.oldValue == nil {
  3373. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  3374. }
  3375. oldValue, err := m.oldValue(ctx)
  3376. if err != nil {
  3377. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  3378. }
  3379. return oldValue.CanWrite, nil
  3380. }
  3381. // AppendCanWrite adds b to the "can_write" field.
  3382. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  3383. m.appendcan_write = append(m.appendcan_write, b...)
  3384. }
  3385. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  3386. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  3387. if len(m.appendcan_write) == 0 {
  3388. return nil, false
  3389. }
  3390. return m.appendcan_write, true
  3391. }
  3392. // ClearCanWrite clears the value of the "can_write" field.
  3393. func (m *AgentBaseMutation) ClearCanWrite() {
  3394. m.can_write = nil
  3395. m.appendcan_write = nil
  3396. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  3397. }
  3398. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  3399. func (m *AgentBaseMutation) CanWriteCleared() bool {
  3400. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  3401. return ok
  3402. }
  3403. // ResetCanWrite resets all changes to the "can_write" field.
  3404. func (m *AgentBaseMutation) ResetCanWrite() {
  3405. m.can_write = nil
  3406. m.appendcan_write = nil
  3407. delete(m.clearedFields, agentbase.FieldCanWrite)
  3408. }
  3409. // SetIsOwner sets the "is_owner" field.
  3410. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  3411. m.is_owner = &b
  3412. m.appendis_owner = nil
  3413. }
  3414. // IsOwner returns the value of the "is_owner" field in the mutation.
  3415. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  3416. v := m.is_owner
  3417. if v == nil {
  3418. return
  3419. }
  3420. return *v, true
  3421. }
  3422. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  3423. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3425. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  3426. if !m.op.Is(OpUpdateOne) {
  3427. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  3428. }
  3429. if m.id == nil || m.oldValue == nil {
  3430. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  3431. }
  3432. oldValue, err := m.oldValue(ctx)
  3433. if err != nil {
  3434. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  3435. }
  3436. return oldValue.IsOwner, nil
  3437. }
  3438. // AppendIsOwner adds b to the "is_owner" field.
  3439. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  3440. m.appendis_owner = append(m.appendis_owner, b...)
  3441. }
  3442. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  3443. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  3444. if len(m.appendis_owner) == 0 {
  3445. return nil, false
  3446. }
  3447. return m.appendis_owner, true
  3448. }
  3449. // ClearIsOwner clears the value of the "is_owner" field.
  3450. func (m *AgentBaseMutation) ClearIsOwner() {
  3451. m.is_owner = nil
  3452. m.appendis_owner = nil
  3453. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  3454. }
  3455. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  3456. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  3457. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  3458. return ok
  3459. }
  3460. // ResetIsOwner resets all changes to the "is_owner" field.
  3461. func (m *AgentBaseMutation) ResetIsOwner() {
  3462. m.is_owner = nil
  3463. m.appendis_owner = nil
  3464. delete(m.clearedFields, agentbase.FieldIsOwner)
  3465. }
  3466. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  3467. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  3468. if m.wx_agent == nil {
  3469. m.wx_agent = make(map[uint64]struct{})
  3470. }
  3471. for i := range ids {
  3472. m.wx_agent[ids[i]] = struct{}{}
  3473. }
  3474. }
  3475. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  3476. func (m *AgentBaseMutation) ClearWxAgent() {
  3477. m.clearedwx_agent = true
  3478. }
  3479. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  3480. func (m *AgentBaseMutation) WxAgentCleared() bool {
  3481. return m.clearedwx_agent
  3482. }
  3483. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  3484. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  3485. if m.removedwx_agent == nil {
  3486. m.removedwx_agent = make(map[uint64]struct{})
  3487. }
  3488. for i := range ids {
  3489. delete(m.wx_agent, ids[i])
  3490. m.removedwx_agent[ids[i]] = struct{}{}
  3491. }
  3492. }
  3493. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  3494. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  3495. for id := range m.removedwx_agent {
  3496. ids = append(ids, id)
  3497. }
  3498. return
  3499. }
  3500. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  3501. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  3502. for id := range m.wx_agent {
  3503. ids = append(ids, id)
  3504. }
  3505. return
  3506. }
  3507. // ResetWxAgent resets all changes to the "wx_agent" edge.
  3508. func (m *AgentBaseMutation) ResetWxAgent() {
  3509. m.wx_agent = nil
  3510. m.clearedwx_agent = false
  3511. m.removedwx_agent = nil
  3512. }
  3513. // Where appends a list predicates to the AgentBaseMutation builder.
  3514. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  3515. m.predicates = append(m.predicates, ps...)
  3516. }
  3517. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  3518. // users can use type-assertion to append predicates that do not depend on any generated package.
  3519. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  3520. p := make([]predicate.AgentBase, len(ps))
  3521. for i := range ps {
  3522. p[i] = ps[i]
  3523. }
  3524. m.Where(p...)
  3525. }
  3526. // Op returns the operation name.
  3527. func (m *AgentBaseMutation) Op() Op {
  3528. return m.op
  3529. }
  3530. // SetOp allows setting the mutation operation.
  3531. func (m *AgentBaseMutation) SetOp(op Op) {
  3532. m.op = op
  3533. }
  3534. // Type returns the node type of this mutation (AgentBase).
  3535. func (m *AgentBaseMutation) Type() string {
  3536. return m.typ
  3537. }
  3538. // Fields returns all fields that were changed during this mutation. Note that in
  3539. // order to get all numeric fields that were incremented/decremented, call
  3540. // AddedFields().
  3541. func (m *AgentBaseMutation) Fields() []string {
  3542. fields := make([]string, 0, 9)
  3543. if m.q != nil {
  3544. fields = append(fields, agentbase.FieldQ)
  3545. }
  3546. if m.a != nil {
  3547. fields = append(fields, agentbase.FieldA)
  3548. }
  3549. if m.chunk_index != nil {
  3550. fields = append(fields, agentbase.FieldChunkIndex)
  3551. }
  3552. if m.indexes != nil {
  3553. fields = append(fields, agentbase.FieldIndexes)
  3554. }
  3555. if m.dataset_id != nil {
  3556. fields = append(fields, agentbase.FieldDatasetID)
  3557. }
  3558. if m.collection_id != nil {
  3559. fields = append(fields, agentbase.FieldCollectionID)
  3560. }
  3561. if m.source_name != nil {
  3562. fields = append(fields, agentbase.FieldSourceName)
  3563. }
  3564. if m.can_write != nil {
  3565. fields = append(fields, agentbase.FieldCanWrite)
  3566. }
  3567. if m.is_owner != nil {
  3568. fields = append(fields, agentbase.FieldIsOwner)
  3569. }
  3570. return fields
  3571. }
  3572. // Field returns the value of a field with the given name. The second boolean
  3573. // return value indicates that this field was not set, or was not defined in the
  3574. // schema.
  3575. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  3576. switch name {
  3577. case agentbase.FieldQ:
  3578. return m.Q()
  3579. case agentbase.FieldA:
  3580. return m.A()
  3581. case agentbase.FieldChunkIndex:
  3582. return m.ChunkIndex()
  3583. case agentbase.FieldIndexes:
  3584. return m.Indexes()
  3585. case agentbase.FieldDatasetID:
  3586. return m.DatasetID()
  3587. case agentbase.FieldCollectionID:
  3588. return m.CollectionID()
  3589. case agentbase.FieldSourceName:
  3590. return m.SourceName()
  3591. case agentbase.FieldCanWrite:
  3592. return m.CanWrite()
  3593. case agentbase.FieldIsOwner:
  3594. return m.IsOwner()
  3595. }
  3596. return nil, false
  3597. }
  3598. // OldField returns the old value of the field from the database. An error is
  3599. // returned if the mutation operation is not UpdateOne, or the query to the
  3600. // database failed.
  3601. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3602. switch name {
  3603. case agentbase.FieldQ:
  3604. return m.OldQ(ctx)
  3605. case agentbase.FieldA:
  3606. return m.OldA(ctx)
  3607. case agentbase.FieldChunkIndex:
  3608. return m.OldChunkIndex(ctx)
  3609. case agentbase.FieldIndexes:
  3610. return m.OldIndexes(ctx)
  3611. case agentbase.FieldDatasetID:
  3612. return m.OldDatasetID(ctx)
  3613. case agentbase.FieldCollectionID:
  3614. return m.OldCollectionID(ctx)
  3615. case agentbase.FieldSourceName:
  3616. return m.OldSourceName(ctx)
  3617. case agentbase.FieldCanWrite:
  3618. return m.OldCanWrite(ctx)
  3619. case agentbase.FieldIsOwner:
  3620. return m.OldIsOwner(ctx)
  3621. }
  3622. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  3623. }
  3624. // SetField sets the value of a field with the given name. It returns an error if
  3625. // the field is not defined in the schema, or if the type mismatched the field
  3626. // type.
  3627. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  3628. switch name {
  3629. case agentbase.FieldQ:
  3630. v, ok := value.(string)
  3631. if !ok {
  3632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3633. }
  3634. m.SetQ(v)
  3635. return nil
  3636. case agentbase.FieldA:
  3637. v, ok := value.(string)
  3638. if !ok {
  3639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3640. }
  3641. m.SetA(v)
  3642. return nil
  3643. case agentbase.FieldChunkIndex:
  3644. v, ok := value.(uint64)
  3645. if !ok {
  3646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3647. }
  3648. m.SetChunkIndex(v)
  3649. return nil
  3650. case agentbase.FieldIndexes:
  3651. v, ok := value.([]string)
  3652. if !ok {
  3653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3654. }
  3655. m.SetIndexes(v)
  3656. return nil
  3657. case agentbase.FieldDatasetID:
  3658. v, ok := value.(string)
  3659. if !ok {
  3660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3661. }
  3662. m.SetDatasetID(v)
  3663. return nil
  3664. case agentbase.FieldCollectionID:
  3665. v, ok := value.(string)
  3666. if !ok {
  3667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3668. }
  3669. m.SetCollectionID(v)
  3670. return nil
  3671. case agentbase.FieldSourceName:
  3672. v, ok := value.(string)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetSourceName(v)
  3677. return nil
  3678. case agentbase.FieldCanWrite:
  3679. v, ok := value.([]bool)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetCanWrite(v)
  3684. return nil
  3685. case agentbase.FieldIsOwner:
  3686. v, ok := value.([]bool)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetIsOwner(v)
  3691. return nil
  3692. }
  3693. return fmt.Errorf("unknown AgentBase field %s", name)
  3694. }
  3695. // AddedFields returns all numeric fields that were incremented/decremented during
  3696. // this mutation.
  3697. func (m *AgentBaseMutation) AddedFields() []string {
  3698. var fields []string
  3699. if m.addchunk_index != nil {
  3700. fields = append(fields, agentbase.FieldChunkIndex)
  3701. }
  3702. return fields
  3703. }
  3704. // AddedField returns the numeric value that was incremented/decremented on a field
  3705. // with the given name. The second boolean return value indicates that this field
  3706. // was not set, or was not defined in the schema.
  3707. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  3708. switch name {
  3709. case agentbase.FieldChunkIndex:
  3710. return m.AddedChunkIndex()
  3711. }
  3712. return nil, false
  3713. }
  3714. // AddField adds the value to the field with the given name. It returns an error if
  3715. // the field is not defined in the schema, or if the type mismatched the field
  3716. // type.
  3717. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  3718. switch name {
  3719. case agentbase.FieldChunkIndex:
  3720. v, ok := value.(int64)
  3721. if !ok {
  3722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3723. }
  3724. m.AddChunkIndex(v)
  3725. return nil
  3726. }
  3727. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  3728. }
  3729. // ClearedFields returns all nullable fields that were cleared during this
  3730. // mutation.
  3731. func (m *AgentBaseMutation) ClearedFields() []string {
  3732. var fields []string
  3733. if m.FieldCleared(agentbase.FieldQ) {
  3734. fields = append(fields, agentbase.FieldQ)
  3735. }
  3736. if m.FieldCleared(agentbase.FieldA) {
  3737. fields = append(fields, agentbase.FieldA)
  3738. }
  3739. if m.FieldCleared(agentbase.FieldIndexes) {
  3740. fields = append(fields, agentbase.FieldIndexes)
  3741. }
  3742. if m.FieldCleared(agentbase.FieldDatasetID) {
  3743. fields = append(fields, agentbase.FieldDatasetID)
  3744. }
  3745. if m.FieldCleared(agentbase.FieldCollectionID) {
  3746. fields = append(fields, agentbase.FieldCollectionID)
  3747. }
  3748. if m.FieldCleared(agentbase.FieldSourceName) {
  3749. fields = append(fields, agentbase.FieldSourceName)
  3750. }
  3751. if m.FieldCleared(agentbase.FieldCanWrite) {
  3752. fields = append(fields, agentbase.FieldCanWrite)
  3753. }
  3754. if m.FieldCleared(agentbase.FieldIsOwner) {
  3755. fields = append(fields, agentbase.FieldIsOwner)
  3756. }
  3757. return fields
  3758. }
  3759. // FieldCleared returns a boolean indicating if a field with the given name was
  3760. // cleared in this mutation.
  3761. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  3762. _, ok := m.clearedFields[name]
  3763. return ok
  3764. }
  3765. // ClearField clears the value of the field with the given name. It returns an
  3766. // error if the field is not defined in the schema.
  3767. func (m *AgentBaseMutation) ClearField(name string) error {
  3768. switch name {
  3769. case agentbase.FieldQ:
  3770. m.ClearQ()
  3771. return nil
  3772. case agentbase.FieldA:
  3773. m.ClearA()
  3774. return nil
  3775. case agentbase.FieldIndexes:
  3776. m.ClearIndexes()
  3777. return nil
  3778. case agentbase.FieldDatasetID:
  3779. m.ClearDatasetID()
  3780. return nil
  3781. case agentbase.FieldCollectionID:
  3782. m.ClearCollectionID()
  3783. return nil
  3784. case agentbase.FieldSourceName:
  3785. m.ClearSourceName()
  3786. return nil
  3787. case agentbase.FieldCanWrite:
  3788. m.ClearCanWrite()
  3789. return nil
  3790. case agentbase.FieldIsOwner:
  3791. m.ClearIsOwner()
  3792. return nil
  3793. }
  3794. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  3795. }
  3796. // ResetField resets all changes in the mutation for the field with the given name.
  3797. // It returns an error if the field is not defined in the schema.
  3798. func (m *AgentBaseMutation) ResetField(name string) error {
  3799. switch name {
  3800. case agentbase.FieldQ:
  3801. m.ResetQ()
  3802. return nil
  3803. case agentbase.FieldA:
  3804. m.ResetA()
  3805. return nil
  3806. case agentbase.FieldChunkIndex:
  3807. m.ResetChunkIndex()
  3808. return nil
  3809. case agentbase.FieldIndexes:
  3810. m.ResetIndexes()
  3811. return nil
  3812. case agentbase.FieldDatasetID:
  3813. m.ResetDatasetID()
  3814. return nil
  3815. case agentbase.FieldCollectionID:
  3816. m.ResetCollectionID()
  3817. return nil
  3818. case agentbase.FieldSourceName:
  3819. m.ResetSourceName()
  3820. return nil
  3821. case agentbase.FieldCanWrite:
  3822. m.ResetCanWrite()
  3823. return nil
  3824. case agentbase.FieldIsOwner:
  3825. m.ResetIsOwner()
  3826. return nil
  3827. }
  3828. return fmt.Errorf("unknown AgentBase field %s", name)
  3829. }
  3830. // AddedEdges returns all edge names that were set/added in this mutation.
  3831. func (m *AgentBaseMutation) AddedEdges() []string {
  3832. edges := make([]string, 0, 1)
  3833. if m.wx_agent != nil {
  3834. edges = append(edges, agentbase.EdgeWxAgent)
  3835. }
  3836. return edges
  3837. }
  3838. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3839. // name in this mutation.
  3840. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  3841. switch name {
  3842. case agentbase.EdgeWxAgent:
  3843. ids := make([]ent.Value, 0, len(m.wx_agent))
  3844. for id := range m.wx_agent {
  3845. ids = append(ids, id)
  3846. }
  3847. return ids
  3848. }
  3849. return nil
  3850. }
  3851. // RemovedEdges returns all edge names that were removed in this mutation.
  3852. func (m *AgentBaseMutation) RemovedEdges() []string {
  3853. edges := make([]string, 0, 1)
  3854. if m.removedwx_agent != nil {
  3855. edges = append(edges, agentbase.EdgeWxAgent)
  3856. }
  3857. return edges
  3858. }
  3859. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3860. // the given name in this mutation.
  3861. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  3862. switch name {
  3863. case agentbase.EdgeWxAgent:
  3864. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  3865. for id := range m.removedwx_agent {
  3866. ids = append(ids, id)
  3867. }
  3868. return ids
  3869. }
  3870. return nil
  3871. }
  3872. // ClearedEdges returns all edge names that were cleared in this mutation.
  3873. func (m *AgentBaseMutation) ClearedEdges() []string {
  3874. edges := make([]string, 0, 1)
  3875. if m.clearedwx_agent {
  3876. edges = append(edges, agentbase.EdgeWxAgent)
  3877. }
  3878. return edges
  3879. }
  3880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3881. // was cleared in this mutation.
  3882. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  3883. switch name {
  3884. case agentbase.EdgeWxAgent:
  3885. return m.clearedwx_agent
  3886. }
  3887. return false
  3888. }
  3889. // ClearEdge clears the value of the edge with the given name. It returns an error
  3890. // if that edge is not defined in the schema.
  3891. func (m *AgentBaseMutation) ClearEdge(name string) error {
  3892. switch name {
  3893. }
  3894. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  3895. }
  3896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3897. // It returns an error if the edge is not defined in the schema.
  3898. func (m *AgentBaseMutation) ResetEdge(name string) error {
  3899. switch name {
  3900. case agentbase.EdgeWxAgent:
  3901. m.ResetWxAgent()
  3902. return nil
  3903. }
  3904. return fmt.Errorf("unknown AgentBase edge %s", name)
  3905. }
  3906. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  3907. type AliyunAvatarMutation struct {
  3908. config
  3909. op Op
  3910. typ string
  3911. id *uint64
  3912. created_at *time.Time
  3913. updated_at *time.Time
  3914. deleted_at *time.Time
  3915. user_id *uint64
  3916. adduser_id *int64
  3917. biz_id *string
  3918. access_key_id *string
  3919. access_key_secret *string
  3920. app_id *string
  3921. tenant_id *uint64
  3922. addtenant_id *int64
  3923. response *string
  3924. token *string
  3925. session_id *string
  3926. clearedFields map[string]struct{}
  3927. done bool
  3928. oldValue func(context.Context) (*AliyunAvatar, error)
  3929. predicates []predicate.AliyunAvatar
  3930. }
  3931. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  3932. // aliyunavatarOption allows management of the mutation configuration using functional options.
  3933. type aliyunavatarOption func(*AliyunAvatarMutation)
  3934. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  3935. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  3936. m := &AliyunAvatarMutation{
  3937. config: c,
  3938. op: op,
  3939. typ: TypeAliyunAvatar,
  3940. clearedFields: make(map[string]struct{}),
  3941. }
  3942. for _, opt := range opts {
  3943. opt(m)
  3944. }
  3945. return m
  3946. }
  3947. // withAliyunAvatarID sets the ID field of the mutation.
  3948. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  3949. return func(m *AliyunAvatarMutation) {
  3950. var (
  3951. err error
  3952. once sync.Once
  3953. value *AliyunAvatar
  3954. )
  3955. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  3956. once.Do(func() {
  3957. if m.done {
  3958. err = errors.New("querying old values post mutation is not allowed")
  3959. } else {
  3960. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  3961. }
  3962. })
  3963. return value, err
  3964. }
  3965. m.id = &id
  3966. }
  3967. }
  3968. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  3969. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  3970. return func(m *AliyunAvatarMutation) {
  3971. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  3972. return node, nil
  3973. }
  3974. m.id = &node.ID
  3975. }
  3976. }
  3977. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3978. // executed in a transaction (ent.Tx), a transactional client is returned.
  3979. func (m AliyunAvatarMutation) Client() *Client {
  3980. client := &Client{config: m.config}
  3981. client.init()
  3982. return client
  3983. }
  3984. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3985. // it returns an error otherwise.
  3986. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  3987. if _, ok := m.driver.(*txDriver); !ok {
  3988. return nil, errors.New("ent: mutation is not running in a transaction")
  3989. }
  3990. tx := &Tx{config: m.config}
  3991. tx.init()
  3992. return tx, nil
  3993. }
  3994. // SetID sets the value of the id field. Note that this
  3995. // operation is only accepted on creation of AliyunAvatar entities.
  3996. func (m *AliyunAvatarMutation) SetID(id uint64) {
  3997. m.id = &id
  3998. }
  3999. // ID returns the ID value in the mutation. Note that the ID is only available
  4000. // if it was provided to the builder or after it was returned from the database.
  4001. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  4002. if m.id == nil {
  4003. return
  4004. }
  4005. return *m.id, true
  4006. }
  4007. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4008. // That means, if the mutation is applied within a transaction with an isolation level such
  4009. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4010. // or updated by the mutation.
  4011. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  4012. switch {
  4013. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4014. id, exists := m.ID()
  4015. if exists {
  4016. return []uint64{id}, nil
  4017. }
  4018. fallthrough
  4019. case m.op.Is(OpUpdate | OpDelete):
  4020. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  4021. default:
  4022. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4023. }
  4024. }
  4025. // SetCreatedAt sets the "created_at" field.
  4026. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  4027. m.created_at = &t
  4028. }
  4029. // CreatedAt returns the value of the "created_at" field in the mutation.
  4030. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  4031. v := m.created_at
  4032. if v == nil {
  4033. return
  4034. }
  4035. return *v, true
  4036. }
  4037. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  4038. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4040. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4041. if !m.op.Is(OpUpdateOne) {
  4042. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4043. }
  4044. if m.id == nil || m.oldValue == nil {
  4045. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4046. }
  4047. oldValue, err := m.oldValue(ctx)
  4048. if err != nil {
  4049. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4050. }
  4051. return oldValue.CreatedAt, nil
  4052. }
  4053. // ResetCreatedAt resets all changes to the "created_at" field.
  4054. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  4055. m.created_at = nil
  4056. }
  4057. // SetUpdatedAt sets the "updated_at" field.
  4058. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  4059. m.updated_at = &t
  4060. }
  4061. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4062. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  4063. v := m.updated_at
  4064. if v == nil {
  4065. return
  4066. }
  4067. return *v, true
  4068. }
  4069. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  4070. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4072. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4073. if !m.op.Is(OpUpdateOne) {
  4074. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4075. }
  4076. if m.id == nil || m.oldValue == nil {
  4077. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4078. }
  4079. oldValue, err := m.oldValue(ctx)
  4080. if err != nil {
  4081. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4082. }
  4083. return oldValue.UpdatedAt, nil
  4084. }
  4085. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4086. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  4087. m.updated_at = nil
  4088. }
  4089. // SetDeletedAt sets the "deleted_at" field.
  4090. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  4091. m.deleted_at = &t
  4092. }
  4093. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4094. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  4095. v := m.deleted_at
  4096. if v == nil {
  4097. return
  4098. }
  4099. return *v, true
  4100. }
  4101. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  4102. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4104. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4105. if !m.op.Is(OpUpdateOne) {
  4106. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4107. }
  4108. if m.id == nil || m.oldValue == nil {
  4109. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4110. }
  4111. oldValue, err := m.oldValue(ctx)
  4112. if err != nil {
  4113. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4114. }
  4115. return oldValue.DeletedAt, nil
  4116. }
  4117. // ClearDeletedAt clears the value of the "deleted_at" field.
  4118. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  4119. m.deleted_at = nil
  4120. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  4121. }
  4122. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4123. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  4124. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  4125. return ok
  4126. }
  4127. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4128. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  4129. m.deleted_at = nil
  4130. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  4131. }
  4132. // SetUserID sets the "user_id" field.
  4133. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  4134. m.user_id = &u
  4135. m.adduser_id = nil
  4136. }
  4137. // UserID returns the value of the "user_id" field in the mutation.
  4138. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  4139. v := m.user_id
  4140. if v == nil {
  4141. return
  4142. }
  4143. return *v, true
  4144. }
  4145. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  4146. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4148. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  4149. if !m.op.Is(OpUpdateOne) {
  4150. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4151. }
  4152. if m.id == nil || m.oldValue == nil {
  4153. return v, errors.New("OldUserID requires an ID field in the mutation")
  4154. }
  4155. oldValue, err := m.oldValue(ctx)
  4156. if err != nil {
  4157. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4158. }
  4159. return oldValue.UserID, nil
  4160. }
  4161. // AddUserID adds u to the "user_id" field.
  4162. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  4163. if m.adduser_id != nil {
  4164. *m.adduser_id += u
  4165. } else {
  4166. m.adduser_id = &u
  4167. }
  4168. }
  4169. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  4170. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  4171. v := m.adduser_id
  4172. if v == nil {
  4173. return
  4174. }
  4175. return *v, true
  4176. }
  4177. // ResetUserID resets all changes to the "user_id" field.
  4178. func (m *AliyunAvatarMutation) ResetUserID() {
  4179. m.user_id = nil
  4180. m.adduser_id = nil
  4181. }
  4182. // SetBizID sets the "biz_id" field.
  4183. func (m *AliyunAvatarMutation) SetBizID(s string) {
  4184. m.biz_id = &s
  4185. }
  4186. // BizID returns the value of the "biz_id" field in the mutation.
  4187. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  4188. v := m.biz_id
  4189. if v == nil {
  4190. return
  4191. }
  4192. return *v, true
  4193. }
  4194. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  4195. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4197. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  4198. if !m.op.Is(OpUpdateOne) {
  4199. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  4200. }
  4201. if m.id == nil || m.oldValue == nil {
  4202. return v, errors.New("OldBizID requires an ID field in the mutation")
  4203. }
  4204. oldValue, err := m.oldValue(ctx)
  4205. if err != nil {
  4206. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  4207. }
  4208. return oldValue.BizID, nil
  4209. }
  4210. // ResetBizID resets all changes to the "biz_id" field.
  4211. func (m *AliyunAvatarMutation) ResetBizID() {
  4212. m.biz_id = nil
  4213. }
  4214. // SetAccessKeyID sets the "access_key_id" field.
  4215. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  4216. m.access_key_id = &s
  4217. }
  4218. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  4219. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  4220. v := m.access_key_id
  4221. if v == nil {
  4222. return
  4223. }
  4224. return *v, true
  4225. }
  4226. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  4227. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4229. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  4230. if !m.op.Is(OpUpdateOne) {
  4231. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  4232. }
  4233. if m.id == nil || m.oldValue == nil {
  4234. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  4235. }
  4236. oldValue, err := m.oldValue(ctx)
  4237. if err != nil {
  4238. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  4239. }
  4240. return oldValue.AccessKeyID, nil
  4241. }
  4242. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  4243. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  4244. m.access_key_id = nil
  4245. }
  4246. // SetAccessKeySecret sets the "access_key_secret" field.
  4247. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  4248. m.access_key_secret = &s
  4249. }
  4250. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  4251. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  4252. v := m.access_key_secret
  4253. if v == nil {
  4254. return
  4255. }
  4256. return *v, true
  4257. }
  4258. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  4259. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4261. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  4262. if !m.op.Is(OpUpdateOne) {
  4263. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  4264. }
  4265. if m.id == nil || m.oldValue == nil {
  4266. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  4267. }
  4268. oldValue, err := m.oldValue(ctx)
  4269. if err != nil {
  4270. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  4271. }
  4272. return oldValue.AccessKeySecret, nil
  4273. }
  4274. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  4275. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  4276. m.access_key_secret = nil
  4277. }
  4278. // SetAppID sets the "app_id" field.
  4279. func (m *AliyunAvatarMutation) SetAppID(s string) {
  4280. m.app_id = &s
  4281. }
  4282. // AppID returns the value of the "app_id" field in the mutation.
  4283. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  4284. v := m.app_id
  4285. if v == nil {
  4286. return
  4287. }
  4288. return *v, true
  4289. }
  4290. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  4291. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4293. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  4294. if !m.op.Is(OpUpdateOne) {
  4295. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  4296. }
  4297. if m.id == nil || m.oldValue == nil {
  4298. return v, errors.New("OldAppID requires an ID field in the mutation")
  4299. }
  4300. oldValue, err := m.oldValue(ctx)
  4301. if err != nil {
  4302. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  4303. }
  4304. return oldValue.AppID, nil
  4305. }
  4306. // ClearAppID clears the value of the "app_id" field.
  4307. func (m *AliyunAvatarMutation) ClearAppID() {
  4308. m.app_id = nil
  4309. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  4310. }
  4311. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  4312. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  4313. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  4314. return ok
  4315. }
  4316. // ResetAppID resets all changes to the "app_id" field.
  4317. func (m *AliyunAvatarMutation) ResetAppID() {
  4318. m.app_id = nil
  4319. delete(m.clearedFields, aliyunavatar.FieldAppID)
  4320. }
  4321. // SetTenantID sets the "tenant_id" field.
  4322. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  4323. m.tenant_id = &u
  4324. m.addtenant_id = nil
  4325. }
  4326. // TenantID returns the value of the "tenant_id" field in the mutation.
  4327. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  4328. v := m.tenant_id
  4329. if v == nil {
  4330. return
  4331. }
  4332. return *v, true
  4333. }
  4334. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  4335. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4337. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  4338. if !m.op.Is(OpUpdateOne) {
  4339. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  4340. }
  4341. if m.id == nil || m.oldValue == nil {
  4342. return v, errors.New("OldTenantID requires an ID field in the mutation")
  4343. }
  4344. oldValue, err := m.oldValue(ctx)
  4345. if err != nil {
  4346. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  4347. }
  4348. return oldValue.TenantID, nil
  4349. }
  4350. // AddTenantID adds u to the "tenant_id" field.
  4351. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  4352. if m.addtenant_id != nil {
  4353. *m.addtenant_id += u
  4354. } else {
  4355. m.addtenant_id = &u
  4356. }
  4357. }
  4358. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  4359. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  4360. v := m.addtenant_id
  4361. if v == nil {
  4362. return
  4363. }
  4364. return *v, true
  4365. }
  4366. // ResetTenantID resets all changes to the "tenant_id" field.
  4367. func (m *AliyunAvatarMutation) ResetTenantID() {
  4368. m.tenant_id = nil
  4369. m.addtenant_id = nil
  4370. }
  4371. // SetResponse sets the "response" field.
  4372. func (m *AliyunAvatarMutation) SetResponse(s string) {
  4373. m.response = &s
  4374. }
  4375. // Response returns the value of the "response" field in the mutation.
  4376. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  4377. v := m.response
  4378. if v == nil {
  4379. return
  4380. }
  4381. return *v, true
  4382. }
  4383. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  4384. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4386. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  4387. if !m.op.Is(OpUpdateOne) {
  4388. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  4389. }
  4390. if m.id == nil || m.oldValue == nil {
  4391. return v, errors.New("OldResponse requires an ID field in the mutation")
  4392. }
  4393. oldValue, err := m.oldValue(ctx)
  4394. if err != nil {
  4395. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  4396. }
  4397. return oldValue.Response, nil
  4398. }
  4399. // ResetResponse resets all changes to the "response" field.
  4400. func (m *AliyunAvatarMutation) ResetResponse() {
  4401. m.response = nil
  4402. }
  4403. // SetToken sets the "token" field.
  4404. func (m *AliyunAvatarMutation) SetToken(s string) {
  4405. m.token = &s
  4406. }
  4407. // Token returns the value of the "token" field in the mutation.
  4408. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  4409. v := m.token
  4410. if v == nil {
  4411. return
  4412. }
  4413. return *v, true
  4414. }
  4415. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  4416. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4418. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  4419. if !m.op.Is(OpUpdateOne) {
  4420. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  4421. }
  4422. if m.id == nil || m.oldValue == nil {
  4423. return v, errors.New("OldToken requires an ID field in the mutation")
  4424. }
  4425. oldValue, err := m.oldValue(ctx)
  4426. if err != nil {
  4427. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  4428. }
  4429. return oldValue.Token, nil
  4430. }
  4431. // ResetToken resets all changes to the "token" field.
  4432. func (m *AliyunAvatarMutation) ResetToken() {
  4433. m.token = nil
  4434. }
  4435. // SetSessionID sets the "session_id" field.
  4436. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  4437. m.session_id = &s
  4438. }
  4439. // SessionID returns the value of the "session_id" field in the mutation.
  4440. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  4441. v := m.session_id
  4442. if v == nil {
  4443. return
  4444. }
  4445. return *v, true
  4446. }
  4447. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  4448. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4450. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  4451. if !m.op.Is(OpUpdateOne) {
  4452. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  4453. }
  4454. if m.id == nil || m.oldValue == nil {
  4455. return v, errors.New("OldSessionID requires an ID field in the mutation")
  4456. }
  4457. oldValue, err := m.oldValue(ctx)
  4458. if err != nil {
  4459. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  4460. }
  4461. return oldValue.SessionID, nil
  4462. }
  4463. // ResetSessionID resets all changes to the "session_id" field.
  4464. func (m *AliyunAvatarMutation) ResetSessionID() {
  4465. m.session_id = nil
  4466. }
  4467. // Where appends a list predicates to the AliyunAvatarMutation builder.
  4468. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  4469. m.predicates = append(m.predicates, ps...)
  4470. }
  4471. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  4472. // users can use type-assertion to append predicates that do not depend on any generated package.
  4473. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  4474. p := make([]predicate.AliyunAvatar, len(ps))
  4475. for i := range ps {
  4476. p[i] = ps[i]
  4477. }
  4478. m.Where(p...)
  4479. }
  4480. // Op returns the operation name.
  4481. func (m *AliyunAvatarMutation) Op() Op {
  4482. return m.op
  4483. }
  4484. // SetOp allows setting the mutation operation.
  4485. func (m *AliyunAvatarMutation) SetOp(op Op) {
  4486. m.op = op
  4487. }
  4488. // Type returns the node type of this mutation (AliyunAvatar).
  4489. func (m *AliyunAvatarMutation) Type() string {
  4490. return m.typ
  4491. }
  4492. // Fields returns all fields that were changed during this mutation. Note that in
  4493. // order to get all numeric fields that were incremented/decremented, call
  4494. // AddedFields().
  4495. func (m *AliyunAvatarMutation) Fields() []string {
  4496. fields := make([]string, 0, 12)
  4497. if m.created_at != nil {
  4498. fields = append(fields, aliyunavatar.FieldCreatedAt)
  4499. }
  4500. if m.updated_at != nil {
  4501. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  4502. }
  4503. if m.deleted_at != nil {
  4504. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4505. }
  4506. if m.user_id != nil {
  4507. fields = append(fields, aliyunavatar.FieldUserID)
  4508. }
  4509. if m.biz_id != nil {
  4510. fields = append(fields, aliyunavatar.FieldBizID)
  4511. }
  4512. if m.access_key_id != nil {
  4513. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  4514. }
  4515. if m.access_key_secret != nil {
  4516. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  4517. }
  4518. if m.app_id != nil {
  4519. fields = append(fields, aliyunavatar.FieldAppID)
  4520. }
  4521. if m.tenant_id != nil {
  4522. fields = append(fields, aliyunavatar.FieldTenantID)
  4523. }
  4524. if m.response != nil {
  4525. fields = append(fields, aliyunavatar.FieldResponse)
  4526. }
  4527. if m.token != nil {
  4528. fields = append(fields, aliyunavatar.FieldToken)
  4529. }
  4530. if m.session_id != nil {
  4531. fields = append(fields, aliyunavatar.FieldSessionID)
  4532. }
  4533. return fields
  4534. }
  4535. // Field returns the value of a field with the given name. The second boolean
  4536. // return value indicates that this field was not set, or was not defined in the
  4537. // schema.
  4538. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  4539. switch name {
  4540. case aliyunavatar.FieldCreatedAt:
  4541. return m.CreatedAt()
  4542. case aliyunavatar.FieldUpdatedAt:
  4543. return m.UpdatedAt()
  4544. case aliyunavatar.FieldDeletedAt:
  4545. return m.DeletedAt()
  4546. case aliyunavatar.FieldUserID:
  4547. return m.UserID()
  4548. case aliyunavatar.FieldBizID:
  4549. return m.BizID()
  4550. case aliyunavatar.FieldAccessKeyID:
  4551. return m.AccessKeyID()
  4552. case aliyunavatar.FieldAccessKeySecret:
  4553. return m.AccessKeySecret()
  4554. case aliyunavatar.FieldAppID:
  4555. return m.AppID()
  4556. case aliyunavatar.FieldTenantID:
  4557. return m.TenantID()
  4558. case aliyunavatar.FieldResponse:
  4559. return m.Response()
  4560. case aliyunavatar.FieldToken:
  4561. return m.Token()
  4562. case aliyunavatar.FieldSessionID:
  4563. return m.SessionID()
  4564. }
  4565. return nil, false
  4566. }
  4567. // OldField returns the old value of the field from the database. An error is
  4568. // returned if the mutation operation is not UpdateOne, or the query to the
  4569. // database failed.
  4570. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4571. switch name {
  4572. case aliyunavatar.FieldCreatedAt:
  4573. return m.OldCreatedAt(ctx)
  4574. case aliyunavatar.FieldUpdatedAt:
  4575. return m.OldUpdatedAt(ctx)
  4576. case aliyunavatar.FieldDeletedAt:
  4577. return m.OldDeletedAt(ctx)
  4578. case aliyunavatar.FieldUserID:
  4579. return m.OldUserID(ctx)
  4580. case aliyunavatar.FieldBizID:
  4581. return m.OldBizID(ctx)
  4582. case aliyunavatar.FieldAccessKeyID:
  4583. return m.OldAccessKeyID(ctx)
  4584. case aliyunavatar.FieldAccessKeySecret:
  4585. return m.OldAccessKeySecret(ctx)
  4586. case aliyunavatar.FieldAppID:
  4587. return m.OldAppID(ctx)
  4588. case aliyunavatar.FieldTenantID:
  4589. return m.OldTenantID(ctx)
  4590. case aliyunavatar.FieldResponse:
  4591. return m.OldResponse(ctx)
  4592. case aliyunavatar.FieldToken:
  4593. return m.OldToken(ctx)
  4594. case aliyunavatar.FieldSessionID:
  4595. return m.OldSessionID(ctx)
  4596. }
  4597. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  4598. }
  4599. // SetField sets the value of a field with the given name. It returns an error if
  4600. // the field is not defined in the schema, or if the type mismatched the field
  4601. // type.
  4602. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  4603. switch name {
  4604. case aliyunavatar.FieldCreatedAt:
  4605. v, ok := value.(time.Time)
  4606. if !ok {
  4607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4608. }
  4609. m.SetCreatedAt(v)
  4610. return nil
  4611. case aliyunavatar.FieldUpdatedAt:
  4612. v, ok := value.(time.Time)
  4613. if !ok {
  4614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4615. }
  4616. m.SetUpdatedAt(v)
  4617. return nil
  4618. case aliyunavatar.FieldDeletedAt:
  4619. v, ok := value.(time.Time)
  4620. if !ok {
  4621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4622. }
  4623. m.SetDeletedAt(v)
  4624. return nil
  4625. case aliyunavatar.FieldUserID:
  4626. v, ok := value.(uint64)
  4627. if !ok {
  4628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4629. }
  4630. m.SetUserID(v)
  4631. return nil
  4632. case aliyunavatar.FieldBizID:
  4633. v, ok := value.(string)
  4634. if !ok {
  4635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4636. }
  4637. m.SetBizID(v)
  4638. return nil
  4639. case aliyunavatar.FieldAccessKeyID:
  4640. v, ok := value.(string)
  4641. if !ok {
  4642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4643. }
  4644. m.SetAccessKeyID(v)
  4645. return nil
  4646. case aliyunavatar.FieldAccessKeySecret:
  4647. v, ok := value.(string)
  4648. if !ok {
  4649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4650. }
  4651. m.SetAccessKeySecret(v)
  4652. return nil
  4653. case aliyunavatar.FieldAppID:
  4654. v, ok := value.(string)
  4655. if !ok {
  4656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4657. }
  4658. m.SetAppID(v)
  4659. return nil
  4660. case aliyunavatar.FieldTenantID:
  4661. v, ok := value.(uint64)
  4662. if !ok {
  4663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4664. }
  4665. m.SetTenantID(v)
  4666. return nil
  4667. case aliyunavatar.FieldResponse:
  4668. v, ok := value.(string)
  4669. if !ok {
  4670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4671. }
  4672. m.SetResponse(v)
  4673. return nil
  4674. case aliyunavatar.FieldToken:
  4675. v, ok := value.(string)
  4676. if !ok {
  4677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4678. }
  4679. m.SetToken(v)
  4680. return nil
  4681. case aliyunavatar.FieldSessionID:
  4682. v, ok := value.(string)
  4683. if !ok {
  4684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4685. }
  4686. m.SetSessionID(v)
  4687. return nil
  4688. }
  4689. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4690. }
  4691. // AddedFields returns all numeric fields that were incremented/decremented during
  4692. // this mutation.
  4693. func (m *AliyunAvatarMutation) AddedFields() []string {
  4694. var fields []string
  4695. if m.adduser_id != nil {
  4696. fields = append(fields, aliyunavatar.FieldUserID)
  4697. }
  4698. if m.addtenant_id != nil {
  4699. fields = append(fields, aliyunavatar.FieldTenantID)
  4700. }
  4701. return fields
  4702. }
  4703. // AddedField returns the numeric value that was incremented/decremented on a field
  4704. // with the given name. The second boolean return value indicates that this field
  4705. // was not set, or was not defined in the schema.
  4706. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  4707. switch name {
  4708. case aliyunavatar.FieldUserID:
  4709. return m.AddedUserID()
  4710. case aliyunavatar.FieldTenantID:
  4711. return m.AddedTenantID()
  4712. }
  4713. return nil, false
  4714. }
  4715. // AddField adds the value to the field with the given name. It returns an error if
  4716. // the field is not defined in the schema, or if the type mismatched the field
  4717. // type.
  4718. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  4719. switch name {
  4720. case aliyunavatar.FieldUserID:
  4721. v, ok := value.(int64)
  4722. if !ok {
  4723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4724. }
  4725. m.AddUserID(v)
  4726. return nil
  4727. case aliyunavatar.FieldTenantID:
  4728. v, ok := value.(int64)
  4729. if !ok {
  4730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4731. }
  4732. m.AddTenantID(v)
  4733. return nil
  4734. }
  4735. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  4736. }
  4737. // ClearedFields returns all nullable fields that were cleared during this
  4738. // mutation.
  4739. func (m *AliyunAvatarMutation) ClearedFields() []string {
  4740. var fields []string
  4741. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  4742. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4743. }
  4744. if m.FieldCleared(aliyunavatar.FieldAppID) {
  4745. fields = append(fields, aliyunavatar.FieldAppID)
  4746. }
  4747. return fields
  4748. }
  4749. // FieldCleared returns a boolean indicating if a field with the given name was
  4750. // cleared in this mutation.
  4751. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  4752. _, ok := m.clearedFields[name]
  4753. return ok
  4754. }
  4755. // ClearField clears the value of the field with the given name. It returns an
  4756. // error if the field is not defined in the schema.
  4757. func (m *AliyunAvatarMutation) ClearField(name string) error {
  4758. switch name {
  4759. case aliyunavatar.FieldDeletedAt:
  4760. m.ClearDeletedAt()
  4761. return nil
  4762. case aliyunavatar.FieldAppID:
  4763. m.ClearAppID()
  4764. return nil
  4765. }
  4766. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  4767. }
  4768. // ResetField resets all changes in the mutation for the field with the given name.
  4769. // It returns an error if the field is not defined in the schema.
  4770. func (m *AliyunAvatarMutation) ResetField(name string) error {
  4771. switch name {
  4772. case aliyunavatar.FieldCreatedAt:
  4773. m.ResetCreatedAt()
  4774. return nil
  4775. case aliyunavatar.FieldUpdatedAt:
  4776. m.ResetUpdatedAt()
  4777. return nil
  4778. case aliyunavatar.FieldDeletedAt:
  4779. m.ResetDeletedAt()
  4780. return nil
  4781. case aliyunavatar.FieldUserID:
  4782. m.ResetUserID()
  4783. return nil
  4784. case aliyunavatar.FieldBizID:
  4785. m.ResetBizID()
  4786. return nil
  4787. case aliyunavatar.FieldAccessKeyID:
  4788. m.ResetAccessKeyID()
  4789. return nil
  4790. case aliyunavatar.FieldAccessKeySecret:
  4791. m.ResetAccessKeySecret()
  4792. return nil
  4793. case aliyunavatar.FieldAppID:
  4794. m.ResetAppID()
  4795. return nil
  4796. case aliyunavatar.FieldTenantID:
  4797. m.ResetTenantID()
  4798. return nil
  4799. case aliyunavatar.FieldResponse:
  4800. m.ResetResponse()
  4801. return nil
  4802. case aliyunavatar.FieldToken:
  4803. m.ResetToken()
  4804. return nil
  4805. case aliyunavatar.FieldSessionID:
  4806. m.ResetSessionID()
  4807. return nil
  4808. }
  4809. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4810. }
  4811. // AddedEdges returns all edge names that were set/added in this mutation.
  4812. func (m *AliyunAvatarMutation) AddedEdges() []string {
  4813. edges := make([]string, 0, 0)
  4814. return edges
  4815. }
  4816. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4817. // name in this mutation.
  4818. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  4819. return nil
  4820. }
  4821. // RemovedEdges returns all edge names that were removed in this mutation.
  4822. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  4823. edges := make([]string, 0, 0)
  4824. return edges
  4825. }
  4826. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4827. // the given name in this mutation.
  4828. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  4829. return nil
  4830. }
  4831. // ClearedEdges returns all edge names that were cleared in this mutation.
  4832. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  4833. edges := make([]string, 0, 0)
  4834. return edges
  4835. }
  4836. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4837. // was cleared in this mutation.
  4838. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  4839. return false
  4840. }
  4841. // ClearEdge clears the value of the edge with the given name. It returns an error
  4842. // if that edge is not defined in the schema.
  4843. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  4844. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  4845. }
  4846. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4847. // It returns an error if the edge is not defined in the schema.
  4848. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  4849. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  4850. }
  4851. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  4852. type AllocAgentMutation struct {
  4853. config
  4854. op Op
  4855. typ string
  4856. id *uint64
  4857. created_at *time.Time
  4858. updated_at *time.Time
  4859. deleted_at *time.Time
  4860. user_id *string
  4861. organization_id *uint64
  4862. addorganization_id *int64
  4863. agents *[]uint64
  4864. appendagents []uint64
  4865. status *int
  4866. addstatus *int
  4867. clearedFields map[string]struct{}
  4868. done bool
  4869. oldValue func(context.Context) (*AllocAgent, error)
  4870. predicates []predicate.AllocAgent
  4871. }
  4872. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  4873. // allocagentOption allows management of the mutation configuration using functional options.
  4874. type allocagentOption func(*AllocAgentMutation)
  4875. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  4876. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  4877. m := &AllocAgentMutation{
  4878. config: c,
  4879. op: op,
  4880. typ: TypeAllocAgent,
  4881. clearedFields: make(map[string]struct{}),
  4882. }
  4883. for _, opt := range opts {
  4884. opt(m)
  4885. }
  4886. return m
  4887. }
  4888. // withAllocAgentID sets the ID field of the mutation.
  4889. func withAllocAgentID(id uint64) allocagentOption {
  4890. return func(m *AllocAgentMutation) {
  4891. var (
  4892. err error
  4893. once sync.Once
  4894. value *AllocAgent
  4895. )
  4896. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  4897. once.Do(func() {
  4898. if m.done {
  4899. err = errors.New("querying old values post mutation is not allowed")
  4900. } else {
  4901. value, err = m.Client().AllocAgent.Get(ctx, id)
  4902. }
  4903. })
  4904. return value, err
  4905. }
  4906. m.id = &id
  4907. }
  4908. }
  4909. // withAllocAgent sets the old AllocAgent of the mutation.
  4910. func withAllocAgent(node *AllocAgent) allocagentOption {
  4911. return func(m *AllocAgentMutation) {
  4912. m.oldValue = func(context.Context) (*AllocAgent, error) {
  4913. return node, nil
  4914. }
  4915. m.id = &node.ID
  4916. }
  4917. }
  4918. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4919. // executed in a transaction (ent.Tx), a transactional client is returned.
  4920. func (m AllocAgentMutation) Client() *Client {
  4921. client := &Client{config: m.config}
  4922. client.init()
  4923. return client
  4924. }
  4925. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4926. // it returns an error otherwise.
  4927. func (m AllocAgentMutation) Tx() (*Tx, error) {
  4928. if _, ok := m.driver.(*txDriver); !ok {
  4929. return nil, errors.New("ent: mutation is not running in a transaction")
  4930. }
  4931. tx := &Tx{config: m.config}
  4932. tx.init()
  4933. return tx, nil
  4934. }
  4935. // SetID sets the value of the id field. Note that this
  4936. // operation is only accepted on creation of AllocAgent entities.
  4937. func (m *AllocAgentMutation) SetID(id uint64) {
  4938. m.id = &id
  4939. }
  4940. // ID returns the ID value in the mutation. Note that the ID is only available
  4941. // if it was provided to the builder or after it was returned from the database.
  4942. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  4943. if m.id == nil {
  4944. return
  4945. }
  4946. return *m.id, true
  4947. }
  4948. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4949. // That means, if the mutation is applied within a transaction with an isolation level such
  4950. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4951. // or updated by the mutation.
  4952. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  4953. switch {
  4954. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4955. id, exists := m.ID()
  4956. if exists {
  4957. return []uint64{id}, nil
  4958. }
  4959. fallthrough
  4960. case m.op.Is(OpUpdate | OpDelete):
  4961. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  4962. default:
  4963. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4964. }
  4965. }
  4966. // SetCreatedAt sets the "created_at" field.
  4967. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  4968. m.created_at = &t
  4969. }
  4970. // CreatedAt returns the value of the "created_at" field in the mutation.
  4971. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  4972. v := m.created_at
  4973. if v == nil {
  4974. return
  4975. }
  4976. return *v, true
  4977. }
  4978. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  4979. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4981. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4982. if !m.op.Is(OpUpdateOne) {
  4983. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4984. }
  4985. if m.id == nil || m.oldValue == nil {
  4986. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4987. }
  4988. oldValue, err := m.oldValue(ctx)
  4989. if err != nil {
  4990. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4991. }
  4992. return oldValue.CreatedAt, nil
  4993. }
  4994. // ResetCreatedAt resets all changes to the "created_at" field.
  4995. func (m *AllocAgentMutation) ResetCreatedAt() {
  4996. m.created_at = nil
  4997. }
  4998. // SetUpdatedAt sets the "updated_at" field.
  4999. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  5000. m.updated_at = &t
  5001. }
  5002. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5003. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  5004. v := m.updated_at
  5005. if v == nil {
  5006. return
  5007. }
  5008. return *v, true
  5009. }
  5010. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  5011. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5013. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5014. if !m.op.Is(OpUpdateOne) {
  5015. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5016. }
  5017. if m.id == nil || m.oldValue == nil {
  5018. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5019. }
  5020. oldValue, err := m.oldValue(ctx)
  5021. if err != nil {
  5022. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5023. }
  5024. return oldValue.UpdatedAt, nil
  5025. }
  5026. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5027. func (m *AllocAgentMutation) ResetUpdatedAt() {
  5028. m.updated_at = nil
  5029. }
  5030. // SetDeletedAt sets the "deleted_at" field.
  5031. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  5032. m.deleted_at = &t
  5033. }
  5034. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5035. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  5036. v := m.deleted_at
  5037. if v == nil {
  5038. return
  5039. }
  5040. return *v, true
  5041. }
  5042. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  5043. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5045. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5046. if !m.op.Is(OpUpdateOne) {
  5047. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5048. }
  5049. if m.id == nil || m.oldValue == nil {
  5050. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5051. }
  5052. oldValue, err := m.oldValue(ctx)
  5053. if err != nil {
  5054. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5055. }
  5056. return oldValue.DeletedAt, nil
  5057. }
  5058. // ClearDeletedAt clears the value of the "deleted_at" field.
  5059. func (m *AllocAgentMutation) ClearDeletedAt() {
  5060. m.deleted_at = nil
  5061. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  5062. }
  5063. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5064. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  5065. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  5066. return ok
  5067. }
  5068. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5069. func (m *AllocAgentMutation) ResetDeletedAt() {
  5070. m.deleted_at = nil
  5071. delete(m.clearedFields, allocagent.FieldDeletedAt)
  5072. }
  5073. // SetUserID sets the "user_id" field.
  5074. func (m *AllocAgentMutation) SetUserID(s string) {
  5075. m.user_id = &s
  5076. }
  5077. // UserID returns the value of the "user_id" field in the mutation.
  5078. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  5079. v := m.user_id
  5080. if v == nil {
  5081. return
  5082. }
  5083. return *v, true
  5084. }
  5085. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  5086. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5088. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  5089. if !m.op.Is(OpUpdateOne) {
  5090. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5091. }
  5092. if m.id == nil || m.oldValue == nil {
  5093. return v, errors.New("OldUserID requires an ID field in the mutation")
  5094. }
  5095. oldValue, err := m.oldValue(ctx)
  5096. if err != nil {
  5097. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5098. }
  5099. return oldValue.UserID, nil
  5100. }
  5101. // ClearUserID clears the value of the "user_id" field.
  5102. func (m *AllocAgentMutation) ClearUserID() {
  5103. m.user_id = nil
  5104. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  5105. }
  5106. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  5107. func (m *AllocAgentMutation) UserIDCleared() bool {
  5108. _, ok := m.clearedFields[allocagent.FieldUserID]
  5109. return ok
  5110. }
  5111. // ResetUserID resets all changes to the "user_id" field.
  5112. func (m *AllocAgentMutation) ResetUserID() {
  5113. m.user_id = nil
  5114. delete(m.clearedFields, allocagent.FieldUserID)
  5115. }
  5116. // SetOrganizationID sets the "organization_id" field.
  5117. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  5118. m.organization_id = &u
  5119. m.addorganization_id = nil
  5120. }
  5121. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5122. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  5123. v := m.organization_id
  5124. if v == nil {
  5125. return
  5126. }
  5127. return *v, true
  5128. }
  5129. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  5130. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5132. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5133. if !m.op.Is(OpUpdateOne) {
  5134. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5135. }
  5136. if m.id == nil || m.oldValue == nil {
  5137. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5138. }
  5139. oldValue, err := m.oldValue(ctx)
  5140. if err != nil {
  5141. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5142. }
  5143. return oldValue.OrganizationID, nil
  5144. }
  5145. // AddOrganizationID adds u to the "organization_id" field.
  5146. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  5147. if m.addorganization_id != nil {
  5148. *m.addorganization_id += u
  5149. } else {
  5150. m.addorganization_id = &u
  5151. }
  5152. }
  5153. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5154. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  5155. v := m.addorganization_id
  5156. if v == nil {
  5157. return
  5158. }
  5159. return *v, true
  5160. }
  5161. // ClearOrganizationID clears the value of the "organization_id" field.
  5162. func (m *AllocAgentMutation) ClearOrganizationID() {
  5163. m.organization_id = nil
  5164. m.addorganization_id = nil
  5165. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  5166. }
  5167. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5168. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  5169. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  5170. return ok
  5171. }
  5172. // ResetOrganizationID resets all changes to the "organization_id" field.
  5173. func (m *AllocAgentMutation) ResetOrganizationID() {
  5174. m.organization_id = nil
  5175. m.addorganization_id = nil
  5176. delete(m.clearedFields, allocagent.FieldOrganizationID)
  5177. }
  5178. // SetAgents sets the "agents" field.
  5179. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  5180. m.agents = &u
  5181. m.appendagents = nil
  5182. }
  5183. // Agents returns the value of the "agents" field in the mutation.
  5184. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  5185. v := m.agents
  5186. if v == nil {
  5187. return
  5188. }
  5189. return *v, true
  5190. }
  5191. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  5192. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5194. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  5195. if !m.op.Is(OpUpdateOne) {
  5196. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  5197. }
  5198. if m.id == nil || m.oldValue == nil {
  5199. return v, errors.New("OldAgents requires an ID field in the mutation")
  5200. }
  5201. oldValue, err := m.oldValue(ctx)
  5202. if err != nil {
  5203. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  5204. }
  5205. return oldValue.Agents, nil
  5206. }
  5207. // AppendAgents adds u to the "agents" field.
  5208. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  5209. m.appendagents = append(m.appendagents, u...)
  5210. }
  5211. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  5212. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  5213. if len(m.appendagents) == 0 {
  5214. return nil, false
  5215. }
  5216. return m.appendagents, true
  5217. }
  5218. // ResetAgents resets all changes to the "agents" field.
  5219. func (m *AllocAgentMutation) ResetAgents() {
  5220. m.agents = nil
  5221. m.appendagents = nil
  5222. }
  5223. // SetStatus sets the "status" field.
  5224. func (m *AllocAgentMutation) SetStatus(i int) {
  5225. m.status = &i
  5226. m.addstatus = nil
  5227. }
  5228. // Status returns the value of the "status" field in the mutation.
  5229. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  5230. v := m.status
  5231. if v == nil {
  5232. return
  5233. }
  5234. return *v, true
  5235. }
  5236. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  5237. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5239. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  5240. if !m.op.Is(OpUpdateOne) {
  5241. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5242. }
  5243. if m.id == nil || m.oldValue == nil {
  5244. return v, errors.New("OldStatus requires an ID field in the mutation")
  5245. }
  5246. oldValue, err := m.oldValue(ctx)
  5247. if err != nil {
  5248. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5249. }
  5250. return oldValue.Status, nil
  5251. }
  5252. // AddStatus adds i to the "status" field.
  5253. func (m *AllocAgentMutation) AddStatus(i int) {
  5254. if m.addstatus != nil {
  5255. *m.addstatus += i
  5256. } else {
  5257. m.addstatus = &i
  5258. }
  5259. }
  5260. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5261. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  5262. v := m.addstatus
  5263. if v == nil {
  5264. return
  5265. }
  5266. return *v, true
  5267. }
  5268. // ClearStatus clears the value of the "status" field.
  5269. func (m *AllocAgentMutation) ClearStatus() {
  5270. m.status = nil
  5271. m.addstatus = nil
  5272. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  5273. }
  5274. // StatusCleared returns if the "status" field was cleared in this mutation.
  5275. func (m *AllocAgentMutation) StatusCleared() bool {
  5276. _, ok := m.clearedFields[allocagent.FieldStatus]
  5277. return ok
  5278. }
  5279. // ResetStatus resets all changes to the "status" field.
  5280. func (m *AllocAgentMutation) ResetStatus() {
  5281. m.status = nil
  5282. m.addstatus = nil
  5283. delete(m.clearedFields, allocagent.FieldStatus)
  5284. }
  5285. // Where appends a list predicates to the AllocAgentMutation builder.
  5286. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  5287. m.predicates = append(m.predicates, ps...)
  5288. }
  5289. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  5290. // users can use type-assertion to append predicates that do not depend on any generated package.
  5291. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  5292. p := make([]predicate.AllocAgent, len(ps))
  5293. for i := range ps {
  5294. p[i] = ps[i]
  5295. }
  5296. m.Where(p...)
  5297. }
  5298. // Op returns the operation name.
  5299. func (m *AllocAgentMutation) Op() Op {
  5300. return m.op
  5301. }
  5302. // SetOp allows setting the mutation operation.
  5303. func (m *AllocAgentMutation) SetOp(op Op) {
  5304. m.op = op
  5305. }
  5306. // Type returns the node type of this mutation (AllocAgent).
  5307. func (m *AllocAgentMutation) Type() string {
  5308. return m.typ
  5309. }
  5310. // Fields returns all fields that were changed during this mutation. Note that in
  5311. // order to get all numeric fields that were incremented/decremented, call
  5312. // AddedFields().
  5313. func (m *AllocAgentMutation) Fields() []string {
  5314. fields := make([]string, 0, 7)
  5315. if m.created_at != nil {
  5316. fields = append(fields, allocagent.FieldCreatedAt)
  5317. }
  5318. if m.updated_at != nil {
  5319. fields = append(fields, allocagent.FieldUpdatedAt)
  5320. }
  5321. if m.deleted_at != nil {
  5322. fields = append(fields, allocagent.FieldDeletedAt)
  5323. }
  5324. if m.user_id != nil {
  5325. fields = append(fields, allocagent.FieldUserID)
  5326. }
  5327. if m.organization_id != nil {
  5328. fields = append(fields, allocagent.FieldOrganizationID)
  5329. }
  5330. if m.agents != nil {
  5331. fields = append(fields, allocagent.FieldAgents)
  5332. }
  5333. if m.status != nil {
  5334. fields = append(fields, allocagent.FieldStatus)
  5335. }
  5336. return fields
  5337. }
  5338. // Field returns the value of a field with the given name. The second boolean
  5339. // return value indicates that this field was not set, or was not defined in the
  5340. // schema.
  5341. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  5342. switch name {
  5343. case allocagent.FieldCreatedAt:
  5344. return m.CreatedAt()
  5345. case allocagent.FieldUpdatedAt:
  5346. return m.UpdatedAt()
  5347. case allocagent.FieldDeletedAt:
  5348. return m.DeletedAt()
  5349. case allocagent.FieldUserID:
  5350. return m.UserID()
  5351. case allocagent.FieldOrganizationID:
  5352. return m.OrganizationID()
  5353. case allocagent.FieldAgents:
  5354. return m.Agents()
  5355. case allocagent.FieldStatus:
  5356. return m.Status()
  5357. }
  5358. return nil, false
  5359. }
  5360. // OldField returns the old value of the field from the database. An error is
  5361. // returned if the mutation operation is not UpdateOne, or the query to the
  5362. // database failed.
  5363. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5364. switch name {
  5365. case allocagent.FieldCreatedAt:
  5366. return m.OldCreatedAt(ctx)
  5367. case allocagent.FieldUpdatedAt:
  5368. return m.OldUpdatedAt(ctx)
  5369. case allocagent.FieldDeletedAt:
  5370. return m.OldDeletedAt(ctx)
  5371. case allocagent.FieldUserID:
  5372. return m.OldUserID(ctx)
  5373. case allocagent.FieldOrganizationID:
  5374. return m.OldOrganizationID(ctx)
  5375. case allocagent.FieldAgents:
  5376. return m.OldAgents(ctx)
  5377. case allocagent.FieldStatus:
  5378. return m.OldStatus(ctx)
  5379. }
  5380. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  5381. }
  5382. // SetField sets the value of a field with the given name. It returns an error if
  5383. // the field is not defined in the schema, or if the type mismatched the field
  5384. // type.
  5385. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  5386. switch name {
  5387. case allocagent.FieldCreatedAt:
  5388. v, ok := value.(time.Time)
  5389. if !ok {
  5390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5391. }
  5392. m.SetCreatedAt(v)
  5393. return nil
  5394. case allocagent.FieldUpdatedAt:
  5395. v, ok := value.(time.Time)
  5396. if !ok {
  5397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5398. }
  5399. m.SetUpdatedAt(v)
  5400. return nil
  5401. case allocagent.FieldDeletedAt:
  5402. v, ok := value.(time.Time)
  5403. if !ok {
  5404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5405. }
  5406. m.SetDeletedAt(v)
  5407. return nil
  5408. case allocagent.FieldUserID:
  5409. v, ok := value.(string)
  5410. if !ok {
  5411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5412. }
  5413. m.SetUserID(v)
  5414. return nil
  5415. case allocagent.FieldOrganizationID:
  5416. v, ok := value.(uint64)
  5417. if !ok {
  5418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5419. }
  5420. m.SetOrganizationID(v)
  5421. return nil
  5422. case allocagent.FieldAgents:
  5423. v, ok := value.([]uint64)
  5424. if !ok {
  5425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5426. }
  5427. m.SetAgents(v)
  5428. return nil
  5429. case allocagent.FieldStatus:
  5430. v, ok := value.(int)
  5431. if !ok {
  5432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5433. }
  5434. m.SetStatus(v)
  5435. return nil
  5436. }
  5437. return fmt.Errorf("unknown AllocAgent field %s", name)
  5438. }
  5439. // AddedFields returns all numeric fields that were incremented/decremented during
  5440. // this mutation.
  5441. func (m *AllocAgentMutation) AddedFields() []string {
  5442. var fields []string
  5443. if m.addorganization_id != nil {
  5444. fields = append(fields, allocagent.FieldOrganizationID)
  5445. }
  5446. if m.addstatus != nil {
  5447. fields = append(fields, allocagent.FieldStatus)
  5448. }
  5449. return fields
  5450. }
  5451. // AddedField returns the numeric value that was incremented/decremented on a field
  5452. // with the given name. The second boolean return value indicates that this field
  5453. // was not set, or was not defined in the schema.
  5454. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  5455. switch name {
  5456. case allocagent.FieldOrganizationID:
  5457. return m.AddedOrganizationID()
  5458. case allocagent.FieldStatus:
  5459. return m.AddedStatus()
  5460. }
  5461. return nil, false
  5462. }
  5463. // AddField adds the value to the field with the given name. It returns an error if
  5464. // the field is not defined in the schema, or if the type mismatched the field
  5465. // type.
  5466. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  5467. switch name {
  5468. case allocagent.FieldOrganizationID:
  5469. v, ok := value.(int64)
  5470. if !ok {
  5471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5472. }
  5473. m.AddOrganizationID(v)
  5474. return nil
  5475. case allocagent.FieldStatus:
  5476. v, ok := value.(int)
  5477. if !ok {
  5478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5479. }
  5480. m.AddStatus(v)
  5481. return nil
  5482. }
  5483. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  5484. }
  5485. // ClearedFields returns all nullable fields that were cleared during this
  5486. // mutation.
  5487. func (m *AllocAgentMutation) ClearedFields() []string {
  5488. var fields []string
  5489. if m.FieldCleared(allocagent.FieldDeletedAt) {
  5490. fields = append(fields, allocagent.FieldDeletedAt)
  5491. }
  5492. if m.FieldCleared(allocagent.FieldUserID) {
  5493. fields = append(fields, allocagent.FieldUserID)
  5494. }
  5495. if m.FieldCleared(allocagent.FieldOrganizationID) {
  5496. fields = append(fields, allocagent.FieldOrganizationID)
  5497. }
  5498. if m.FieldCleared(allocagent.FieldStatus) {
  5499. fields = append(fields, allocagent.FieldStatus)
  5500. }
  5501. return fields
  5502. }
  5503. // FieldCleared returns a boolean indicating if a field with the given name was
  5504. // cleared in this mutation.
  5505. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  5506. _, ok := m.clearedFields[name]
  5507. return ok
  5508. }
  5509. // ClearField clears the value of the field with the given name. It returns an
  5510. // error if the field is not defined in the schema.
  5511. func (m *AllocAgentMutation) ClearField(name string) error {
  5512. switch name {
  5513. case allocagent.FieldDeletedAt:
  5514. m.ClearDeletedAt()
  5515. return nil
  5516. case allocagent.FieldUserID:
  5517. m.ClearUserID()
  5518. return nil
  5519. case allocagent.FieldOrganizationID:
  5520. m.ClearOrganizationID()
  5521. return nil
  5522. case allocagent.FieldStatus:
  5523. m.ClearStatus()
  5524. return nil
  5525. }
  5526. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  5527. }
  5528. // ResetField resets all changes in the mutation for the field with the given name.
  5529. // It returns an error if the field is not defined in the schema.
  5530. func (m *AllocAgentMutation) ResetField(name string) error {
  5531. switch name {
  5532. case allocagent.FieldCreatedAt:
  5533. m.ResetCreatedAt()
  5534. return nil
  5535. case allocagent.FieldUpdatedAt:
  5536. m.ResetUpdatedAt()
  5537. return nil
  5538. case allocagent.FieldDeletedAt:
  5539. m.ResetDeletedAt()
  5540. return nil
  5541. case allocagent.FieldUserID:
  5542. m.ResetUserID()
  5543. return nil
  5544. case allocagent.FieldOrganizationID:
  5545. m.ResetOrganizationID()
  5546. return nil
  5547. case allocagent.FieldAgents:
  5548. m.ResetAgents()
  5549. return nil
  5550. case allocagent.FieldStatus:
  5551. m.ResetStatus()
  5552. return nil
  5553. }
  5554. return fmt.Errorf("unknown AllocAgent field %s", name)
  5555. }
  5556. // AddedEdges returns all edge names that were set/added in this mutation.
  5557. func (m *AllocAgentMutation) AddedEdges() []string {
  5558. edges := make([]string, 0, 0)
  5559. return edges
  5560. }
  5561. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5562. // name in this mutation.
  5563. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  5564. return nil
  5565. }
  5566. // RemovedEdges returns all edge names that were removed in this mutation.
  5567. func (m *AllocAgentMutation) RemovedEdges() []string {
  5568. edges := make([]string, 0, 0)
  5569. return edges
  5570. }
  5571. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5572. // the given name in this mutation.
  5573. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  5574. return nil
  5575. }
  5576. // ClearedEdges returns all edge names that were cleared in this mutation.
  5577. func (m *AllocAgentMutation) ClearedEdges() []string {
  5578. edges := make([]string, 0, 0)
  5579. return edges
  5580. }
  5581. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5582. // was cleared in this mutation.
  5583. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  5584. return false
  5585. }
  5586. // ClearEdge clears the value of the edge with the given name. It returns an error
  5587. // if that edge is not defined in the schema.
  5588. func (m *AllocAgentMutation) ClearEdge(name string) error {
  5589. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  5590. }
  5591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5592. // It returns an error if the edge is not defined in the schema.
  5593. func (m *AllocAgentMutation) ResetEdge(name string) error {
  5594. return fmt.Errorf("unknown AllocAgent edge %s", name)
  5595. }
  5596. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  5597. type ApiKeyMutation struct {
  5598. config
  5599. op Op
  5600. typ string
  5601. id *uint64
  5602. created_at *time.Time
  5603. updated_at *time.Time
  5604. deleted_at *time.Time
  5605. title *string
  5606. key *string
  5607. organization_id *uint64
  5608. addorganization_id *int64
  5609. custom_agent_base *string
  5610. custom_agent_key *string
  5611. openai_base *string
  5612. openai_key *string
  5613. clearedFields map[string]struct{}
  5614. agent *uint64
  5615. clearedagent bool
  5616. done bool
  5617. oldValue func(context.Context) (*ApiKey, error)
  5618. predicates []predicate.ApiKey
  5619. }
  5620. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  5621. // apikeyOption allows management of the mutation configuration using functional options.
  5622. type apikeyOption func(*ApiKeyMutation)
  5623. // newApiKeyMutation creates new mutation for the ApiKey entity.
  5624. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  5625. m := &ApiKeyMutation{
  5626. config: c,
  5627. op: op,
  5628. typ: TypeApiKey,
  5629. clearedFields: make(map[string]struct{}),
  5630. }
  5631. for _, opt := range opts {
  5632. opt(m)
  5633. }
  5634. return m
  5635. }
  5636. // withApiKeyID sets the ID field of the mutation.
  5637. func withApiKeyID(id uint64) apikeyOption {
  5638. return func(m *ApiKeyMutation) {
  5639. var (
  5640. err error
  5641. once sync.Once
  5642. value *ApiKey
  5643. )
  5644. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  5645. once.Do(func() {
  5646. if m.done {
  5647. err = errors.New("querying old values post mutation is not allowed")
  5648. } else {
  5649. value, err = m.Client().ApiKey.Get(ctx, id)
  5650. }
  5651. })
  5652. return value, err
  5653. }
  5654. m.id = &id
  5655. }
  5656. }
  5657. // withApiKey sets the old ApiKey of the mutation.
  5658. func withApiKey(node *ApiKey) apikeyOption {
  5659. return func(m *ApiKeyMutation) {
  5660. m.oldValue = func(context.Context) (*ApiKey, error) {
  5661. return node, nil
  5662. }
  5663. m.id = &node.ID
  5664. }
  5665. }
  5666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5667. // executed in a transaction (ent.Tx), a transactional client is returned.
  5668. func (m ApiKeyMutation) Client() *Client {
  5669. client := &Client{config: m.config}
  5670. client.init()
  5671. return client
  5672. }
  5673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5674. // it returns an error otherwise.
  5675. func (m ApiKeyMutation) Tx() (*Tx, error) {
  5676. if _, ok := m.driver.(*txDriver); !ok {
  5677. return nil, errors.New("ent: mutation is not running in a transaction")
  5678. }
  5679. tx := &Tx{config: m.config}
  5680. tx.init()
  5681. return tx, nil
  5682. }
  5683. // SetID sets the value of the id field. Note that this
  5684. // operation is only accepted on creation of ApiKey entities.
  5685. func (m *ApiKeyMutation) SetID(id uint64) {
  5686. m.id = &id
  5687. }
  5688. // ID returns the ID value in the mutation. Note that the ID is only available
  5689. // if it was provided to the builder or after it was returned from the database.
  5690. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  5691. if m.id == nil {
  5692. return
  5693. }
  5694. return *m.id, true
  5695. }
  5696. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5697. // That means, if the mutation is applied within a transaction with an isolation level such
  5698. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5699. // or updated by the mutation.
  5700. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  5701. switch {
  5702. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5703. id, exists := m.ID()
  5704. if exists {
  5705. return []uint64{id}, nil
  5706. }
  5707. fallthrough
  5708. case m.op.Is(OpUpdate | OpDelete):
  5709. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  5710. default:
  5711. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5712. }
  5713. }
  5714. // SetCreatedAt sets the "created_at" field.
  5715. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  5716. m.created_at = &t
  5717. }
  5718. // CreatedAt returns the value of the "created_at" field in the mutation.
  5719. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  5720. v := m.created_at
  5721. if v == nil {
  5722. return
  5723. }
  5724. return *v, true
  5725. }
  5726. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  5727. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5729. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5730. if !m.op.Is(OpUpdateOne) {
  5731. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5732. }
  5733. if m.id == nil || m.oldValue == nil {
  5734. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5735. }
  5736. oldValue, err := m.oldValue(ctx)
  5737. if err != nil {
  5738. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5739. }
  5740. return oldValue.CreatedAt, nil
  5741. }
  5742. // ResetCreatedAt resets all changes to the "created_at" field.
  5743. func (m *ApiKeyMutation) ResetCreatedAt() {
  5744. m.created_at = nil
  5745. }
  5746. // SetUpdatedAt sets the "updated_at" field.
  5747. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  5748. m.updated_at = &t
  5749. }
  5750. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5751. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  5752. v := m.updated_at
  5753. if v == nil {
  5754. return
  5755. }
  5756. return *v, true
  5757. }
  5758. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  5759. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5761. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5762. if !m.op.Is(OpUpdateOne) {
  5763. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5764. }
  5765. if m.id == nil || m.oldValue == nil {
  5766. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5767. }
  5768. oldValue, err := m.oldValue(ctx)
  5769. if err != nil {
  5770. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5771. }
  5772. return oldValue.UpdatedAt, nil
  5773. }
  5774. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5775. func (m *ApiKeyMutation) ResetUpdatedAt() {
  5776. m.updated_at = nil
  5777. }
  5778. // SetDeletedAt sets the "deleted_at" field.
  5779. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  5780. m.deleted_at = &t
  5781. }
  5782. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5783. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  5784. v := m.deleted_at
  5785. if v == nil {
  5786. return
  5787. }
  5788. return *v, true
  5789. }
  5790. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  5791. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5793. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5794. if !m.op.Is(OpUpdateOne) {
  5795. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5796. }
  5797. if m.id == nil || m.oldValue == nil {
  5798. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5799. }
  5800. oldValue, err := m.oldValue(ctx)
  5801. if err != nil {
  5802. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5803. }
  5804. return oldValue.DeletedAt, nil
  5805. }
  5806. // ClearDeletedAt clears the value of the "deleted_at" field.
  5807. func (m *ApiKeyMutation) ClearDeletedAt() {
  5808. m.deleted_at = nil
  5809. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  5810. }
  5811. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5812. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  5813. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  5814. return ok
  5815. }
  5816. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5817. func (m *ApiKeyMutation) ResetDeletedAt() {
  5818. m.deleted_at = nil
  5819. delete(m.clearedFields, apikey.FieldDeletedAt)
  5820. }
  5821. // SetTitle sets the "title" field.
  5822. func (m *ApiKeyMutation) SetTitle(s string) {
  5823. m.title = &s
  5824. }
  5825. // Title returns the value of the "title" field in the mutation.
  5826. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  5827. v := m.title
  5828. if v == nil {
  5829. return
  5830. }
  5831. return *v, true
  5832. }
  5833. // OldTitle returns the old "title" field's value of the ApiKey entity.
  5834. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5836. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  5837. if !m.op.Is(OpUpdateOne) {
  5838. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5839. }
  5840. if m.id == nil || m.oldValue == nil {
  5841. return v, errors.New("OldTitle requires an ID field in the mutation")
  5842. }
  5843. oldValue, err := m.oldValue(ctx)
  5844. if err != nil {
  5845. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5846. }
  5847. return oldValue.Title, nil
  5848. }
  5849. // ClearTitle clears the value of the "title" field.
  5850. func (m *ApiKeyMutation) ClearTitle() {
  5851. m.title = nil
  5852. m.clearedFields[apikey.FieldTitle] = struct{}{}
  5853. }
  5854. // TitleCleared returns if the "title" field was cleared in this mutation.
  5855. func (m *ApiKeyMutation) TitleCleared() bool {
  5856. _, ok := m.clearedFields[apikey.FieldTitle]
  5857. return ok
  5858. }
  5859. // ResetTitle resets all changes to the "title" field.
  5860. func (m *ApiKeyMutation) ResetTitle() {
  5861. m.title = nil
  5862. delete(m.clearedFields, apikey.FieldTitle)
  5863. }
  5864. // SetKey sets the "key" field.
  5865. func (m *ApiKeyMutation) SetKey(s string) {
  5866. m.key = &s
  5867. }
  5868. // Key returns the value of the "key" field in the mutation.
  5869. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  5870. v := m.key
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // OldKey returns the old "key" field's value of the ApiKey entity.
  5877. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5879. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  5880. if !m.op.Is(OpUpdateOne) {
  5881. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  5882. }
  5883. if m.id == nil || m.oldValue == nil {
  5884. return v, errors.New("OldKey requires an ID field in the mutation")
  5885. }
  5886. oldValue, err := m.oldValue(ctx)
  5887. if err != nil {
  5888. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  5889. }
  5890. return oldValue.Key, nil
  5891. }
  5892. // ClearKey clears the value of the "key" field.
  5893. func (m *ApiKeyMutation) ClearKey() {
  5894. m.key = nil
  5895. m.clearedFields[apikey.FieldKey] = struct{}{}
  5896. }
  5897. // KeyCleared returns if the "key" field was cleared in this mutation.
  5898. func (m *ApiKeyMutation) KeyCleared() bool {
  5899. _, ok := m.clearedFields[apikey.FieldKey]
  5900. return ok
  5901. }
  5902. // ResetKey resets all changes to the "key" field.
  5903. func (m *ApiKeyMutation) ResetKey() {
  5904. m.key = nil
  5905. delete(m.clearedFields, apikey.FieldKey)
  5906. }
  5907. // SetOrganizationID sets the "organization_id" field.
  5908. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  5909. m.organization_id = &u
  5910. m.addorganization_id = nil
  5911. }
  5912. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5913. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  5914. v := m.organization_id
  5915. if v == nil {
  5916. return
  5917. }
  5918. return *v, true
  5919. }
  5920. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  5921. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5923. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5924. if !m.op.Is(OpUpdateOne) {
  5925. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5926. }
  5927. if m.id == nil || m.oldValue == nil {
  5928. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5929. }
  5930. oldValue, err := m.oldValue(ctx)
  5931. if err != nil {
  5932. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5933. }
  5934. return oldValue.OrganizationID, nil
  5935. }
  5936. // AddOrganizationID adds u to the "organization_id" field.
  5937. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  5938. if m.addorganization_id != nil {
  5939. *m.addorganization_id += u
  5940. } else {
  5941. m.addorganization_id = &u
  5942. }
  5943. }
  5944. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5945. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  5946. v := m.addorganization_id
  5947. if v == nil {
  5948. return
  5949. }
  5950. return *v, true
  5951. }
  5952. // ResetOrganizationID resets all changes to the "organization_id" field.
  5953. func (m *ApiKeyMutation) ResetOrganizationID() {
  5954. m.organization_id = nil
  5955. m.addorganization_id = nil
  5956. }
  5957. // SetAgentID sets the "agent_id" field.
  5958. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  5959. m.agent = &u
  5960. }
  5961. // AgentID returns the value of the "agent_id" field in the mutation.
  5962. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  5963. v := m.agent
  5964. if v == nil {
  5965. return
  5966. }
  5967. return *v, true
  5968. }
  5969. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  5970. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5972. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  5973. if !m.op.Is(OpUpdateOne) {
  5974. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  5975. }
  5976. if m.id == nil || m.oldValue == nil {
  5977. return v, errors.New("OldAgentID requires an ID field in the mutation")
  5978. }
  5979. oldValue, err := m.oldValue(ctx)
  5980. if err != nil {
  5981. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  5982. }
  5983. return oldValue.AgentID, nil
  5984. }
  5985. // ResetAgentID resets all changes to the "agent_id" field.
  5986. func (m *ApiKeyMutation) ResetAgentID() {
  5987. m.agent = nil
  5988. }
  5989. // SetCustomAgentBase sets the "custom_agent_base" field.
  5990. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  5991. m.custom_agent_base = &s
  5992. }
  5993. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  5994. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  5995. v := m.custom_agent_base
  5996. if v == nil {
  5997. return
  5998. }
  5999. return *v, true
  6000. }
  6001. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  6002. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6004. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  6005. if !m.op.Is(OpUpdateOne) {
  6006. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  6007. }
  6008. if m.id == nil || m.oldValue == nil {
  6009. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  6010. }
  6011. oldValue, err := m.oldValue(ctx)
  6012. if err != nil {
  6013. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  6014. }
  6015. return oldValue.CustomAgentBase, nil
  6016. }
  6017. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  6018. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  6019. m.custom_agent_base = nil
  6020. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  6021. }
  6022. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  6023. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  6024. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  6025. return ok
  6026. }
  6027. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  6028. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  6029. m.custom_agent_base = nil
  6030. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  6031. }
  6032. // SetCustomAgentKey sets the "custom_agent_key" field.
  6033. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  6034. m.custom_agent_key = &s
  6035. }
  6036. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  6037. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  6038. v := m.custom_agent_key
  6039. if v == nil {
  6040. return
  6041. }
  6042. return *v, true
  6043. }
  6044. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  6045. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6047. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  6048. if !m.op.Is(OpUpdateOne) {
  6049. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  6050. }
  6051. if m.id == nil || m.oldValue == nil {
  6052. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  6053. }
  6054. oldValue, err := m.oldValue(ctx)
  6055. if err != nil {
  6056. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  6057. }
  6058. return oldValue.CustomAgentKey, nil
  6059. }
  6060. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  6061. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  6062. m.custom_agent_key = nil
  6063. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  6064. }
  6065. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  6066. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  6067. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  6068. return ok
  6069. }
  6070. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  6071. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  6072. m.custom_agent_key = nil
  6073. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  6074. }
  6075. // SetOpenaiBase sets the "openai_base" field.
  6076. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  6077. m.openai_base = &s
  6078. }
  6079. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  6080. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  6081. v := m.openai_base
  6082. if v == nil {
  6083. return
  6084. }
  6085. return *v, true
  6086. }
  6087. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  6088. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6090. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  6091. if !m.op.Is(OpUpdateOne) {
  6092. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  6093. }
  6094. if m.id == nil || m.oldValue == nil {
  6095. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  6096. }
  6097. oldValue, err := m.oldValue(ctx)
  6098. if err != nil {
  6099. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  6100. }
  6101. return oldValue.OpenaiBase, nil
  6102. }
  6103. // ClearOpenaiBase clears the value of the "openai_base" field.
  6104. func (m *ApiKeyMutation) ClearOpenaiBase() {
  6105. m.openai_base = nil
  6106. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  6107. }
  6108. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  6109. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  6110. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  6111. return ok
  6112. }
  6113. // ResetOpenaiBase resets all changes to the "openai_base" field.
  6114. func (m *ApiKeyMutation) ResetOpenaiBase() {
  6115. m.openai_base = nil
  6116. delete(m.clearedFields, apikey.FieldOpenaiBase)
  6117. }
  6118. // SetOpenaiKey sets the "openai_key" field.
  6119. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  6120. m.openai_key = &s
  6121. }
  6122. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  6123. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  6124. v := m.openai_key
  6125. if v == nil {
  6126. return
  6127. }
  6128. return *v, true
  6129. }
  6130. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  6131. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6133. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  6134. if !m.op.Is(OpUpdateOne) {
  6135. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  6136. }
  6137. if m.id == nil || m.oldValue == nil {
  6138. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  6139. }
  6140. oldValue, err := m.oldValue(ctx)
  6141. if err != nil {
  6142. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  6143. }
  6144. return oldValue.OpenaiKey, nil
  6145. }
  6146. // ClearOpenaiKey clears the value of the "openai_key" field.
  6147. func (m *ApiKeyMutation) ClearOpenaiKey() {
  6148. m.openai_key = nil
  6149. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  6150. }
  6151. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  6152. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  6153. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  6154. return ok
  6155. }
  6156. // ResetOpenaiKey resets all changes to the "openai_key" field.
  6157. func (m *ApiKeyMutation) ResetOpenaiKey() {
  6158. m.openai_key = nil
  6159. delete(m.clearedFields, apikey.FieldOpenaiKey)
  6160. }
  6161. // ClearAgent clears the "agent" edge to the Agent entity.
  6162. func (m *ApiKeyMutation) ClearAgent() {
  6163. m.clearedagent = true
  6164. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  6165. }
  6166. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  6167. func (m *ApiKeyMutation) AgentCleared() bool {
  6168. return m.clearedagent
  6169. }
  6170. // AgentIDs returns the "agent" edge IDs in the mutation.
  6171. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6172. // AgentID instead. It exists only for internal usage by the builders.
  6173. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  6174. if id := m.agent; id != nil {
  6175. ids = append(ids, *id)
  6176. }
  6177. return
  6178. }
  6179. // ResetAgent resets all changes to the "agent" edge.
  6180. func (m *ApiKeyMutation) ResetAgent() {
  6181. m.agent = nil
  6182. m.clearedagent = false
  6183. }
  6184. // Where appends a list predicates to the ApiKeyMutation builder.
  6185. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  6186. m.predicates = append(m.predicates, ps...)
  6187. }
  6188. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  6189. // users can use type-assertion to append predicates that do not depend on any generated package.
  6190. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  6191. p := make([]predicate.ApiKey, len(ps))
  6192. for i := range ps {
  6193. p[i] = ps[i]
  6194. }
  6195. m.Where(p...)
  6196. }
  6197. // Op returns the operation name.
  6198. func (m *ApiKeyMutation) Op() Op {
  6199. return m.op
  6200. }
  6201. // SetOp allows setting the mutation operation.
  6202. func (m *ApiKeyMutation) SetOp(op Op) {
  6203. m.op = op
  6204. }
  6205. // Type returns the node type of this mutation (ApiKey).
  6206. func (m *ApiKeyMutation) Type() string {
  6207. return m.typ
  6208. }
  6209. // Fields returns all fields that were changed during this mutation. Note that in
  6210. // order to get all numeric fields that were incremented/decremented, call
  6211. // AddedFields().
  6212. func (m *ApiKeyMutation) Fields() []string {
  6213. fields := make([]string, 0, 11)
  6214. if m.created_at != nil {
  6215. fields = append(fields, apikey.FieldCreatedAt)
  6216. }
  6217. if m.updated_at != nil {
  6218. fields = append(fields, apikey.FieldUpdatedAt)
  6219. }
  6220. if m.deleted_at != nil {
  6221. fields = append(fields, apikey.FieldDeletedAt)
  6222. }
  6223. if m.title != nil {
  6224. fields = append(fields, apikey.FieldTitle)
  6225. }
  6226. if m.key != nil {
  6227. fields = append(fields, apikey.FieldKey)
  6228. }
  6229. if m.organization_id != nil {
  6230. fields = append(fields, apikey.FieldOrganizationID)
  6231. }
  6232. if m.agent != nil {
  6233. fields = append(fields, apikey.FieldAgentID)
  6234. }
  6235. if m.custom_agent_base != nil {
  6236. fields = append(fields, apikey.FieldCustomAgentBase)
  6237. }
  6238. if m.custom_agent_key != nil {
  6239. fields = append(fields, apikey.FieldCustomAgentKey)
  6240. }
  6241. if m.openai_base != nil {
  6242. fields = append(fields, apikey.FieldOpenaiBase)
  6243. }
  6244. if m.openai_key != nil {
  6245. fields = append(fields, apikey.FieldOpenaiKey)
  6246. }
  6247. return fields
  6248. }
  6249. // Field returns the value of a field with the given name. The second boolean
  6250. // return value indicates that this field was not set, or was not defined in the
  6251. // schema.
  6252. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  6253. switch name {
  6254. case apikey.FieldCreatedAt:
  6255. return m.CreatedAt()
  6256. case apikey.FieldUpdatedAt:
  6257. return m.UpdatedAt()
  6258. case apikey.FieldDeletedAt:
  6259. return m.DeletedAt()
  6260. case apikey.FieldTitle:
  6261. return m.Title()
  6262. case apikey.FieldKey:
  6263. return m.Key()
  6264. case apikey.FieldOrganizationID:
  6265. return m.OrganizationID()
  6266. case apikey.FieldAgentID:
  6267. return m.AgentID()
  6268. case apikey.FieldCustomAgentBase:
  6269. return m.CustomAgentBase()
  6270. case apikey.FieldCustomAgentKey:
  6271. return m.CustomAgentKey()
  6272. case apikey.FieldOpenaiBase:
  6273. return m.OpenaiBase()
  6274. case apikey.FieldOpenaiKey:
  6275. return m.OpenaiKey()
  6276. }
  6277. return nil, false
  6278. }
  6279. // OldField returns the old value of the field from the database. An error is
  6280. // returned if the mutation operation is not UpdateOne, or the query to the
  6281. // database failed.
  6282. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6283. switch name {
  6284. case apikey.FieldCreatedAt:
  6285. return m.OldCreatedAt(ctx)
  6286. case apikey.FieldUpdatedAt:
  6287. return m.OldUpdatedAt(ctx)
  6288. case apikey.FieldDeletedAt:
  6289. return m.OldDeletedAt(ctx)
  6290. case apikey.FieldTitle:
  6291. return m.OldTitle(ctx)
  6292. case apikey.FieldKey:
  6293. return m.OldKey(ctx)
  6294. case apikey.FieldOrganizationID:
  6295. return m.OldOrganizationID(ctx)
  6296. case apikey.FieldAgentID:
  6297. return m.OldAgentID(ctx)
  6298. case apikey.FieldCustomAgentBase:
  6299. return m.OldCustomAgentBase(ctx)
  6300. case apikey.FieldCustomAgentKey:
  6301. return m.OldCustomAgentKey(ctx)
  6302. case apikey.FieldOpenaiBase:
  6303. return m.OldOpenaiBase(ctx)
  6304. case apikey.FieldOpenaiKey:
  6305. return m.OldOpenaiKey(ctx)
  6306. }
  6307. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  6308. }
  6309. // SetField sets the value of a field with the given name. It returns an error if
  6310. // the field is not defined in the schema, or if the type mismatched the field
  6311. // type.
  6312. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  6313. switch name {
  6314. case apikey.FieldCreatedAt:
  6315. v, ok := value.(time.Time)
  6316. if !ok {
  6317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6318. }
  6319. m.SetCreatedAt(v)
  6320. return nil
  6321. case apikey.FieldUpdatedAt:
  6322. v, ok := value.(time.Time)
  6323. if !ok {
  6324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6325. }
  6326. m.SetUpdatedAt(v)
  6327. return nil
  6328. case apikey.FieldDeletedAt:
  6329. v, ok := value.(time.Time)
  6330. if !ok {
  6331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6332. }
  6333. m.SetDeletedAt(v)
  6334. return nil
  6335. case apikey.FieldTitle:
  6336. v, ok := value.(string)
  6337. if !ok {
  6338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6339. }
  6340. m.SetTitle(v)
  6341. return nil
  6342. case apikey.FieldKey:
  6343. v, ok := value.(string)
  6344. if !ok {
  6345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6346. }
  6347. m.SetKey(v)
  6348. return nil
  6349. case apikey.FieldOrganizationID:
  6350. v, ok := value.(uint64)
  6351. if !ok {
  6352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6353. }
  6354. m.SetOrganizationID(v)
  6355. return nil
  6356. case apikey.FieldAgentID:
  6357. v, ok := value.(uint64)
  6358. if !ok {
  6359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6360. }
  6361. m.SetAgentID(v)
  6362. return nil
  6363. case apikey.FieldCustomAgentBase:
  6364. v, ok := value.(string)
  6365. if !ok {
  6366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6367. }
  6368. m.SetCustomAgentBase(v)
  6369. return nil
  6370. case apikey.FieldCustomAgentKey:
  6371. v, ok := value.(string)
  6372. if !ok {
  6373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6374. }
  6375. m.SetCustomAgentKey(v)
  6376. return nil
  6377. case apikey.FieldOpenaiBase:
  6378. v, ok := value.(string)
  6379. if !ok {
  6380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6381. }
  6382. m.SetOpenaiBase(v)
  6383. return nil
  6384. case apikey.FieldOpenaiKey:
  6385. v, ok := value.(string)
  6386. if !ok {
  6387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6388. }
  6389. m.SetOpenaiKey(v)
  6390. return nil
  6391. }
  6392. return fmt.Errorf("unknown ApiKey field %s", name)
  6393. }
  6394. // AddedFields returns all numeric fields that were incremented/decremented during
  6395. // this mutation.
  6396. func (m *ApiKeyMutation) AddedFields() []string {
  6397. var fields []string
  6398. if m.addorganization_id != nil {
  6399. fields = append(fields, apikey.FieldOrganizationID)
  6400. }
  6401. return fields
  6402. }
  6403. // AddedField returns the numeric value that was incremented/decremented on a field
  6404. // with the given name. The second boolean return value indicates that this field
  6405. // was not set, or was not defined in the schema.
  6406. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  6407. switch name {
  6408. case apikey.FieldOrganizationID:
  6409. return m.AddedOrganizationID()
  6410. }
  6411. return nil, false
  6412. }
  6413. // AddField adds the value to the field with the given name. It returns an error if
  6414. // the field is not defined in the schema, or if the type mismatched the field
  6415. // type.
  6416. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  6417. switch name {
  6418. case apikey.FieldOrganizationID:
  6419. v, ok := value.(int64)
  6420. if !ok {
  6421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6422. }
  6423. m.AddOrganizationID(v)
  6424. return nil
  6425. }
  6426. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  6427. }
  6428. // ClearedFields returns all nullable fields that were cleared during this
  6429. // mutation.
  6430. func (m *ApiKeyMutation) ClearedFields() []string {
  6431. var fields []string
  6432. if m.FieldCleared(apikey.FieldDeletedAt) {
  6433. fields = append(fields, apikey.FieldDeletedAt)
  6434. }
  6435. if m.FieldCleared(apikey.FieldTitle) {
  6436. fields = append(fields, apikey.FieldTitle)
  6437. }
  6438. if m.FieldCleared(apikey.FieldKey) {
  6439. fields = append(fields, apikey.FieldKey)
  6440. }
  6441. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  6442. fields = append(fields, apikey.FieldCustomAgentBase)
  6443. }
  6444. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  6445. fields = append(fields, apikey.FieldCustomAgentKey)
  6446. }
  6447. if m.FieldCleared(apikey.FieldOpenaiBase) {
  6448. fields = append(fields, apikey.FieldOpenaiBase)
  6449. }
  6450. if m.FieldCleared(apikey.FieldOpenaiKey) {
  6451. fields = append(fields, apikey.FieldOpenaiKey)
  6452. }
  6453. return fields
  6454. }
  6455. // FieldCleared returns a boolean indicating if a field with the given name was
  6456. // cleared in this mutation.
  6457. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  6458. _, ok := m.clearedFields[name]
  6459. return ok
  6460. }
  6461. // ClearField clears the value of the field with the given name. It returns an
  6462. // error if the field is not defined in the schema.
  6463. func (m *ApiKeyMutation) ClearField(name string) error {
  6464. switch name {
  6465. case apikey.FieldDeletedAt:
  6466. m.ClearDeletedAt()
  6467. return nil
  6468. case apikey.FieldTitle:
  6469. m.ClearTitle()
  6470. return nil
  6471. case apikey.FieldKey:
  6472. m.ClearKey()
  6473. return nil
  6474. case apikey.FieldCustomAgentBase:
  6475. m.ClearCustomAgentBase()
  6476. return nil
  6477. case apikey.FieldCustomAgentKey:
  6478. m.ClearCustomAgentKey()
  6479. return nil
  6480. case apikey.FieldOpenaiBase:
  6481. m.ClearOpenaiBase()
  6482. return nil
  6483. case apikey.FieldOpenaiKey:
  6484. m.ClearOpenaiKey()
  6485. return nil
  6486. }
  6487. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  6488. }
  6489. // ResetField resets all changes in the mutation for the field with the given name.
  6490. // It returns an error if the field is not defined in the schema.
  6491. func (m *ApiKeyMutation) ResetField(name string) error {
  6492. switch name {
  6493. case apikey.FieldCreatedAt:
  6494. m.ResetCreatedAt()
  6495. return nil
  6496. case apikey.FieldUpdatedAt:
  6497. m.ResetUpdatedAt()
  6498. return nil
  6499. case apikey.FieldDeletedAt:
  6500. m.ResetDeletedAt()
  6501. return nil
  6502. case apikey.FieldTitle:
  6503. m.ResetTitle()
  6504. return nil
  6505. case apikey.FieldKey:
  6506. m.ResetKey()
  6507. return nil
  6508. case apikey.FieldOrganizationID:
  6509. m.ResetOrganizationID()
  6510. return nil
  6511. case apikey.FieldAgentID:
  6512. m.ResetAgentID()
  6513. return nil
  6514. case apikey.FieldCustomAgentBase:
  6515. m.ResetCustomAgentBase()
  6516. return nil
  6517. case apikey.FieldCustomAgentKey:
  6518. m.ResetCustomAgentKey()
  6519. return nil
  6520. case apikey.FieldOpenaiBase:
  6521. m.ResetOpenaiBase()
  6522. return nil
  6523. case apikey.FieldOpenaiKey:
  6524. m.ResetOpenaiKey()
  6525. return nil
  6526. }
  6527. return fmt.Errorf("unknown ApiKey field %s", name)
  6528. }
  6529. // AddedEdges returns all edge names that were set/added in this mutation.
  6530. func (m *ApiKeyMutation) AddedEdges() []string {
  6531. edges := make([]string, 0, 1)
  6532. if m.agent != nil {
  6533. edges = append(edges, apikey.EdgeAgent)
  6534. }
  6535. return edges
  6536. }
  6537. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6538. // name in this mutation.
  6539. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  6540. switch name {
  6541. case apikey.EdgeAgent:
  6542. if id := m.agent; id != nil {
  6543. return []ent.Value{*id}
  6544. }
  6545. }
  6546. return nil
  6547. }
  6548. // RemovedEdges returns all edge names that were removed in this mutation.
  6549. func (m *ApiKeyMutation) RemovedEdges() []string {
  6550. edges := make([]string, 0, 1)
  6551. return edges
  6552. }
  6553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6554. // the given name in this mutation.
  6555. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  6556. return nil
  6557. }
  6558. // ClearedEdges returns all edge names that were cleared in this mutation.
  6559. func (m *ApiKeyMutation) ClearedEdges() []string {
  6560. edges := make([]string, 0, 1)
  6561. if m.clearedagent {
  6562. edges = append(edges, apikey.EdgeAgent)
  6563. }
  6564. return edges
  6565. }
  6566. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6567. // was cleared in this mutation.
  6568. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  6569. switch name {
  6570. case apikey.EdgeAgent:
  6571. return m.clearedagent
  6572. }
  6573. return false
  6574. }
  6575. // ClearEdge clears the value of the edge with the given name. It returns an error
  6576. // if that edge is not defined in the schema.
  6577. func (m *ApiKeyMutation) ClearEdge(name string) error {
  6578. switch name {
  6579. case apikey.EdgeAgent:
  6580. m.ClearAgent()
  6581. return nil
  6582. }
  6583. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  6584. }
  6585. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6586. // It returns an error if the edge is not defined in the schema.
  6587. func (m *ApiKeyMutation) ResetEdge(name string) error {
  6588. switch name {
  6589. case apikey.EdgeAgent:
  6590. m.ResetAgent()
  6591. return nil
  6592. }
  6593. return fmt.Errorf("unknown ApiKey edge %s", name)
  6594. }
  6595. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  6596. type BatchMsgMutation struct {
  6597. config
  6598. op Op
  6599. typ string
  6600. id *uint64
  6601. created_at *time.Time
  6602. updated_at *time.Time
  6603. deleted_at *time.Time
  6604. status *uint8
  6605. addstatus *int8
  6606. batch_no *string
  6607. task_name *string
  6608. fromwxid *string
  6609. msg *string
  6610. tag *string
  6611. tagids *string
  6612. total *int32
  6613. addtotal *int32
  6614. success *int32
  6615. addsuccess *int32
  6616. fail *int32
  6617. addfail *int32
  6618. start_time *time.Time
  6619. stop_time *time.Time
  6620. send_time *time.Time
  6621. _type *int32
  6622. add_type *int32
  6623. organization_id *uint64
  6624. addorganization_id *int64
  6625. ctype *uint64
  6626. addctype *int64
  6627. cc *string
  6628. phone *string
  6629. template_name *string
  6630. template_code *string
  6631. lang *string
  6632. clearedFields map[string]struct{}
  6633. done bool
  6634. oldValue func(context.Context) (*BatchMsg, error)
  6635. predicates []predicate.BatchMsg
  6636. }
  6637. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  6638. // batchmsgOption allows management of the mutation configuration using functional options.
  6639. type batchmsgOption func(*BatchMsgMutation)
  6640. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  6641. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  6642. m := &BatchMsgMutation{
  6643. config: c,
  6644. op: op,
  6645. typ: TypeBatchMsg,
  6646. clearedFields: make(map[string]struct{}),
  6647. }
  6648. for _, opt := range opts {
  6649. opt(m)
  6650. }
  6651. return m
  6652. }
  6653. // withBatchMsgID sets the ID field of the mutation.
  6654. func withBatchMsgID(id uint64) batchmsgOption {
  6655. return func(m *BatchMsgMutation) {
  6656. var (
  6657. err error
  6658. once sync.Once
  6659. value *BatchMsg
  6660. )
  6661. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  6662. once.Do(func() {
  6663. if m.done {
  6664. err = errors.New("querying old values post mutation is not allowed")
  6665. } else {
  6666. value, err = m.Client().BatchMsg.Get(ctx, id)
  6667. }
  6668. })
  6669. return value, err
  6670. }
  6671. m.id = &id
  6672. }
  6673. }
  6674. // withBatchMsg sets the old BatchMsg of the mutation.
  6675. func withBatchMsg(node *BatchMsg) batchmsgOption {
  6676. return func(m *BatchMsgMutation) {
  6677. m.oldValue = func(context.Context) (*BatchMsg, error) {
  6678. return node, nil
  6679. }
  6680. m.id = &node.ID
  6681. }
  6682. }
  6683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6684. // executed in a transaction (ent.Tx), a transactional client is returned.
  6685. func (m BatchMsgMutation) Client() *Client {
  6686. client := &Client{config: m.config}
  6687. client.init()
  6688. return client
  6689. }
  6690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6691. // it returns an error otherwise.
  6692. func (m BatchMsgMutation) Tx() (*Tx, error) {
  6693. if _, ok := m.driver.(*txDriver); !ok {
  6694. return nil, errors.New("ent: mutation is not running in a transaction")
  6695. }
  6696. tx := &Tx{config: m.config}
  6697. tx.init()
  6698. return tx, nil
  6699. }
  6700. // SetID sets the value of the id field. Note that this
  6701. // operation is only accepted on creation of BatchMsg entities.
  6702. func (m *BatchMsgMutation) SetID(id uint64) {
  6703. m.id = &id
  6704. }
  6705. // ID returns the ID value in the mutation. Note that the ID is only available
  6706. // if it was provided to the builder or after it was returned from the database.
  6707. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  6708. if m.id == nil {
  6709. return
  6710. }
  6711. return *m.id, true
  6712. }
  6713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6714. // That means, if the mutation is applied within a transaction with an isolation level such
  6715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6716. // or updated by the mutation.
  6717. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  6718. switch {
  6719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6720. id, exists := m.ID()
  6721. if exists {
  6722. return []uint64{id}, nil
  6723. }
  6724. fallthrough
  6725. case m.op.Is(OpUpdate | OpDelete):
  6726. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  6727. default:
  6728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6729. }
  6730. }
  6731. // SetCreatedAt sets the "created_at" field.
  6732. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  6733. m.created_at = &t
  6734. }
  6735. // CreatedAt returns the value of the "created_at" field in the mutation.
  6736. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  6737. v := m.created_at
  6738. if v == nil {
  6739. return
  6740. }
  6741. return *v, true
  6742. }
  6743. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  6744. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6746. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6747. if !m.op.Is(OpUpdateOne) {
  6748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6749. }
  6750. if m.id == nil || m.oldValue == nil {
  6751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6752. }
  6753. oldValue, err := m.oldValue(ctx)
  6754. if err != nil {
  6755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6756. }
  6757. return oldValue.CreatedAt, nil
  6758. }
  6759. // ResetCreatedAt resets all changes to the "created_at" field.
  6760. func (m *BatchMsgMutation) ResetCreatedAt() {
  6761. m.created_at = nil
  6762. }
  6763. // SetUpdatedAt sets the "updated_at" field.
  6764. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  6765. m.updated_at = &t
  6766. }
  6767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6768. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  6769. v := m.updated_at
  6770. if v == nil {
  6771. return
  6772. }
  6773. return *v, true
  6774. }
  6775. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  6776. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6778. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6779. if !m.op.Is(OpUpdateOne) {
  6780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6781. }
  6782. if m.id == nil || m.oldValue == nil {
  6783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6784. }
  6785. oldValue, err := m.oldValue(ctx)
  6786. if err != nil {
  6787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6788. }
  6789. return oldValue.UpdatedAt, nil
  6790. }
  6791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6792. func (m *BatchMsgMutation) ResetUpdatedAt() {
  6793. m.updated_at = nil
  6794. }
  6795. // SetDeletedAt sets the "deleted_at" field.
  6796. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  6797. m.deleted_at = &t
  6798. }
  6799. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6800. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  6801. v := m.deleted_at
  6802. if v == nil {
  6803. return
  6804. }
  6805. return *v, true
  6806. }
  6807. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  6808. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6810. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6811. if !m.op.Is(OpUpdateOne) {
  6812. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6813. }
  6814. if m.id == nil || m.oldValue == nil {
  6815. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6816. }
  6817. oldValue, err := m.oldValue(ctx)
  6818. if err != nil {
  6819. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6820. }
  6821. return oldValue.DeletedAt, nil
  6822. }
  6823. // ClearDeletedAt clears the value of the "deleted_at" field.
  6824. func (m *BatchMsgMutation) ClearDeletedAt() {
  6825. m.deleted_at = nil
  6826. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  6827. }
  6828. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6829. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  6830. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  6831. return ok
  6832. }
  6833. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6834. func (m *BatchMsgMutation) ResetDeletedAt() {
  6835. m.deleted_at = nil
  6836. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  6837. }
  6838. // SetStatus sets the "status" field.
  6839. func (m *BatchMsgMutation) SetStatus(u uint8) {
  6840. m.status = &u
  6841. m.addstatus = nil
  6842. }
  6843. // Status returns the value of the "status" field in the mutation.
  6844. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  6845. v := m.status
  6846. if v == nil {
  6847. return
  6848. }
  6849. return *v, true
  6850. }
  6851. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  6852. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6854. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6855. if !m.op.Is(OpUpdateOne) {
  6856. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6857. }
  6858. if m.id == nil || m.oldValue == nil {
  6859. return v, errors.New("OldStatus requires an ID field in the mutation")
  6860. }
  6861. oldValue, err := m.oldValue(ctx)
  6862. if err != nil {
  6863. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6864. }
  6865. return oldValue.Status, nil
  6866. }
  6867. // AddStatus adds u to the "status" field.
  6868. func (m *BatchMsgMutation) AddStatus(u int8) {
  6869. if m.addstatus != nil {
  6870. *m.addstatus += u
  6871. } else {
  6872. m.addstatus = &u
  6873. }
  6874. }
  6875. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6876. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  6877. v := m.addstatus
  6878. if v == nil {
  6879. return
  6880. }
  6881. return *v, true
  6882. }
  6883. // ClearStatus clears the value of the "status" field.
  6884. func (m *BatchMsgMutation) ClearStatus() {
  6885. m.status = nil
  6886. m.addstatus = nil
  6887. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  6888. }
  6889. // StatusCleared returns if the "status" field was cleared in this mutation.
  6890. func (m *BatchMsgMutation) StatusCleared() bool {
  6891. _, ok := m.clearedFields[batchmsg.FieldStatus]
  6892. return ok
  6893. }
  6894. // ResetStatus resets all changes to the "status" field.
  6895. func (m *BatchMsgMutation) ResetStatus() {
  6896. m.status = nil
  6897. m.addstatus = nil
  6898. delete(m.clearedFields, batchmsg.FieldStatus)
  6899. }
  6900. // SetBatchNo sets the "batch_no" field.
  6901. func (m *BatchMsgMutation) SetBatchNo(s string) {
  6902. m.batch_no = &s
  6903. }
  6904. // BatchNo returns the value of the "batch_no" field in the mutation.
  6905. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  6906. v := m.batch_no
  6907. if v == nil {
  6908. return
  6909. }
  6910. return *v, true
  6911. }
  6912. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  6913. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6915. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  6916. if !m.op.Is(OpUpdateOne) {
  6917. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  6918. }
  6919. if m.id == nil || m.oldValue == nil {
  6920. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  6921. }
  6922. oldValue, err := m.oldValue(ctx)
  6923. if err != nil {
  6924. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  6925. }
  6926. return oldValue.BatchNo, nil
  6927. }
  6928. // ClearBatchNo clears the value of the "batch_no" field.
  6929. func (m *BatchMsgMutation) ClearBatchNo() {
  6930. m.batch_no = nil
  6931. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  6932. }
  6933. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  6934. func (m *BatchMsgMutation) BatchNoCleared() bool {
  6935. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  6936. return ok
  6937. }
  6938. // ResetBatchNo resets all changes to the "batch_no" field.
  6939. func (m *BatchMsgMutation) ResetBatchNo() {
  6940. m.batch_no = nil
  6941. delete(m.clearedFields, batchmsg.FieldBatchNo)
  6942. }
  6943. // SetTaskName sets the "task_name" field.
  6944. func (m *BatchMsgMutation) SetTaskName(s string) {
  6945. m.task_name = &s
  6946. }
  6947. // TaskName returns the value of the "task_name" field in the mutation.
  6948. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  6949. v := m.task_name
  6950. if v == nil {
  6951. return
  6952. }
  6953. return *v, true
  6954. }
  6955. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  6956. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6958. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  6959. if !m.op.Is(OpUpdateOne) {
  6960. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  6961. }
  6962. if m.id == nil || m.oldValue == nil {
  6963. return v, errors.New("OldTaskName requires an ID field in the mutation")
  6964. }
  6965. oldValue, err := m.oldValue(ctx)
  6966. if err != nil {
  6967. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  6968. }
  6969. return oldValue.TaskName, nil
  6970. }
  6971. // ClearTaskName clears the value of the "task_name" field.
  6972. func (m *BatchMsgMutation) ClearTaskName() {
  6973. m.task_name = nil
  6974. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  6975. }
  6976. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  6977. func (m *BatchMsgMutation) TaskNameCleared() bool {
  6978. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  6979. return ok
  6980. }
  6981. // ResetTaskName resets all changes to the "task_name" field.
  6982. func (m *BatchMsgMutation) ResetTaskName() {
  6983. m.task_name = nil
  6984. delete(m.clearedFields, batchmsg.FieldTaskName)
  6985. }
  6986. // SetFromwxid sets the "fromwxid" field.
  6987. func (m *BatchMsgMutation) SetFromwxid(s string) {
  6988. m.fromwxid = &s
  6989. }
  6990. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  6991. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  6992. v := m.fromwxid
  6993. if v == nil {
  6994. return
  6995. }
  6996. return *v, true
  6997. }
  6998. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  6999. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7001. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  7002. if !m.op.Is(OpUpdateOne) {
  7003. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  7004. }
  7005. if m.id == nil || m.oldValue == nil {
  7006. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  7007. }
  7008. oldValue, err := m.oldValue(ctx)
  7009. if err != nil {
  7010. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  7011. }
  7012. return oldValue.Fromwxid, nil
  7013. }
  7014. // ClearFromwxid clears the value of the "fromwxid" field.
  7015. func (m *BatchMsgMutation) ClearFromwxid() {
  7016. m.fromwxid = nil
  7017. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  7018. }
  7019. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  7020. func (m *BatchMsgMutation) FromwxidCleared() bool {
  7021. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  7022. return ok
  7023. }
  7024. // ResetFromwxid resets all changes to the "fromwxid" field.
  7025. func (m *BatchMsgMutation) ResetFromwxid() {
  7026. m.fromwxid = nil
  7027. delete(m.clearedFields, batchmsg.FieldFromwxid)
  7028. }
  7029. // SetMsg sets the "msg" field.
  7030. func (m *BatchMsgMutation) SetMsg(s string) {
  7031. m.msg = &s
  7032. }
  7033. // Msg returns the value of the "msg" field in the mutation.
  7034. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  7035. v := m.msg
  7036. if v == nil {
  7037. return
  7038. }
  7039. return *v, true
  7040. }
  7041. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  7042. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7044. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  7045. if !m.op.Is(OpUpdateOne) {
  7046. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  7047. }
  7048. if m.id == nil || m.oldValue == nil {
  7049. return v, errors.New("OldMsg requires an ID field in the mutation")
  7050. }
  7051. oldValue, err := m.oldValue(ctx)
  7052. if err != nil {
  7053. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  7054. }
  7055. return oldValue.Msg, nil
  7056. }
  7057. // ClearMsg clears the value of the "msg" field.
  7058. func (m *BatchMsgMutation) ClearMsg() {
  7059. m.msg = nil
  7060. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  7061. }
  7062. // MsgCleared returns if the "msg" field was cleared in this mutation.
  7063. func (m *BatchMsgMutation) MsgCleared() bool {
  7064. _, ok := m.clearedFields[batchmsg.FieldMsg]
  7065. return ok
  7066. }
  7067. // ResetMsg resets all changes to the "msg" field.
  7068. func (m *BatchMsgMutation) ResetMsg() {
  7069. m.msg = nil
  7070. delete(m.clearedFields, batchmsg.FieldMsg)
  7071. }
  7072. // SetTag sets the "tag" field.
  7073. func (m *BatchMsgMutation) SetTag(s string) {
  7074. m.tag = &s
  7075. }
  7076. // Tag returns the value of the "tag" field in the mutation.
  7077. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  7078. v := m.tag
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  7085. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldTag requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  7097. }
  7098. return oldValue.Tag, nil
  7099. }
  7100. // ClearTag clears the value of the "tag" field.
  7101. func (m *BatchMsgMutation) ClearTag() {
  7102. m.tag = nil
  7103. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  7104. }
  7105. // TagCleared returns if the "tag" field was cleared in this mutation.
  7106. func (m *BatchMsgMutation) TagCleared() bool {
  7107. _, ok := m.clearedFields[batchmsg.FieldTag]
  7108. return ok
  7109. }
  7110. // ResetTag resets all changes to the "tag" field.
  7111. func (m *BatchMsgMutation) ResetTag() {
  7112. m.tag = nil
  7113. delete(m.clearedFields, batchmsg.FieldTag)
  7114. }
  7115. // SetTagids sets the "tagids" field.
  7116. func (m *BatchMsgMutation) SetTagids(s string) {
  7117. m.tagids = &s
  7118. }
  7119. // Tagids returns the value of the "tagids" field in the mutation.
  7120. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  7121. v := m.tagids
  7122. if v == nil {
  7123. return
  7124. }
  7125. return *v, true
  7126. }
  7127. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  7128. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7130. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  7131. if !m.op.Is(OpUpdateOne) {
  7132. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  7133. }
  7134. if m.id == nil || m.oldValue == nil {
  7135. return v, errors.New("OldTagids requires an ID field in the mutation")
  7136. }
  7137. oldValue, err := m.oldValue(ctx)
  7138. if err != nil {
  7139. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  7140. }
  7141. return oldValue.Tagids, nil
  7142. }
  7143. // ClearTagids clears the value of the "tagids" field.
  7144. func (m *BatchMsgMutation) ClearTagids() {
  7145. m.tagids = nil
  7146. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  7147. }
  7148. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  7149. func (m *BatchMsgMutation) TagidsCleared() bool {
  7150. _, ok := m.clearedFields[batchmsg.FieldTagids]
  7151. return ok
  7152. }
  7153. // ResetTagids resets all changes to the "tagids" field.
  7154. func (m *BatchMsgMutation) ResetTagids() {
  7155. m.tagids = nil
  7156. delete(m.clearedFields, batchmsg.FieldTagids)
  7157. }
  7158. // SetTotal sets the "total" field.
  7159. func (m *BatchMsgMutation) SetTotal(i int32) {
  7160. m.total = &i
  7161. m.addtotal = nil
  7162. }
  7163. // Total returns the value of the "total" field in the mutation.
  7164. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  7165. v := m.total
  7166. if v == nil {
  7167. return
  7168. }
  7169. return *v, true
  7170. }
  7171. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  7172. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7174. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  7175. if !m.op.Is(OpUpdateOne) {
  7176. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  7177. }
  7178. if m.id == nil || m.oldValue == nil {
  7179. return v, errors.New("OldTotal requires an ID field in the mutation")
  7180. }
  7181. oldValue, err := m.oldValue(ctx)
  7182. if err != nil {
  7183. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  7184. }
  7185. return oldValue.Total, nil
  7186. }
  7187. // AddTotal adds i to the "total" field.
  7188. func (m *BatchMsgMutation) AddTotal(i int32) {
  7189. if m.addtotal != nil {
  7190. *m.addtotal += i
  7191. } else {
  7192. m.addtotal = &i
  7193. }
  7194. }
  7195. // AddedTotal returns the value that was added to the "total" field in this mutation.
  7196. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  7197. v := m.addtotal
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // ClearTotal clears the value of the "total" field.
  7204. func (m *BatchMsgMutation) ClearTotal() {
  7205. m.total = nil
  7206. m.addtotal = nil
  7207. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  7208. }
  7209. // TotalCleared returns if the "total" field was cleared in this mutation.
  7210. func (m *BatchMsgMutation) TotalCleared() bool {
  7211. _, ok := m.clearedFields[batchmsg.FieldTotal]
  7212. return ok
  7213. }
  7214. // ResetTotal resets all changes to the "total" field.
  7215. func (m *BatchMsgMutation) ResetTotal() {
  7216. m.total = nil
  7217. m.addtotal = nil
  7218. delete(m.clearedFields, batchmsg.FieldTotal)
  7219. }
  7220. // SetSuccess sets the "success" field.
  7221. func (m *BatchMsgMutation) SetSuccess(i int32) {
  7222. m.success = &i
  7223. m.addsuccess = nil
  7224. }
  7225. // Success returns the value of the "success" field in the mutation.
  7226. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  7227. v := m.success
  7228. if v == nil {
  7229. return
  7230. }
  7231. return *v, true
  7232. }
  7233. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  7234. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7236. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  7237. if !m.op.Is(OpUpdateOne) {
  7238. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  7239. }
  7240. if m.id == nil || m.oldValue == nil {
  7241. return v, errors.New("OldSuccess requires an ID field in the mutation")
  7242. }
  7243. oldValue, err := m.oldValue(ctx)
  7244. if err != nil {
  7245. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  7246. }
  7247. return oldValue.Success, nil
  7248. }
  7249. // AddSuccess adds i to the "success" field.
  7250. func (m *BatchMsgMutation) AddSuccess(i int32) {
  7251. if m.addsuccess != nil {
  7252. *m.addsuccess += i
  7253. } else {
  7254. m.addsuccess = &i
  7255. }
  7256. }
  7257. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  7258. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  7259. v := m.addsuccess
  7260. if v == nil {
  7261. return
  7262. }
  7263. return *v, true
  7264. }
  7265. // ClearSuccess clears the value of the "success" field.
  7266. func (m *BatchMsgMutation) ClearSuccess() {
  7267. m.success = nil
  7268. m.addsuccess = nil
  7269. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  7270. }
  7271. // SuccessCleared returns if the "success" field was cleared in this mutation.
  7272. func (m *BatchMsgMutation) SuccessCleared() bool {
  7273. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  7274. return ok
  7275. }
  7276. // ResetSuccess resets all changes to the "success" field.
  7277. func (m *BatchMsgMutation) ResetSuccess() {
  7278. m.success = nil
  7279. m.addsuccess = nil
  7280. delete(m.clearedFields, batchmsg.FieldSuccess)
  7281. }
  7282. // SetFail sets the "fail" field.
  7283. func (m *BatchMsgMutation) SetFail(i int32) {
  7284. m.fail = &i
  7285. m.addfail = nil
  7286. }
  7287. // Fail returns the value of the "fail" field in the mutation.
  7288. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  7289. v := m.fail
  7290. if v == nil {
  7291. return
  7292. }
  7293. return *v, true
  7294. }
  7295. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  7296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7298. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  7299. if !m.op.Is(OpUpdateOne) {
  7300. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  7301. }
  7302. if m.id == nil || m.oldValue == nil {
  7303. return v, errors.New("OldFail requires an ID field in the mutation")
  7304. }
  7305. oldValue, err := m.oldValue(ctx)
  7306. if err != nil {
  7307. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  7308. }
  7309. return oldValue.Fail, nil
  7310. }
  7311. // AddFail adds i to the "fail" field.
  7312. func (m *BatchMsgMutation) AddFail(i int32) {
  7313. if m.addfail != nil {
  7314. *m.addfail += i
  7315. } else {
  7316. m.addfail = &i
  7317. }
  7318. }
  7319. // AddedFail returns the value that was added to the "fail" field in this mutation.
  7320. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  7321. v := m.addfail
  7322. if v == nil {
  7323. return
  7324. }
  7325. return *v, true
  7326. }
  7327. // ClearFail clears the value of the "fail" field.
  7328. func (m *BatchMsgMutation) ClearFail() {
  7329. m.fail = nil
  7330. m.addfail = nil
  7331. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  7332. }
  7333. // FailCleared returns if the "fail" field was cleared in this mutation.
  7334. func (m *BatchMsgMutation) FailCleared() bool {
  7335. _, ok := m.clearedFields[batchmsg.FieldFail]
  7336. return ok
  7337. }
  7338. // ResetFail resets all changes to the "fail" field.
  7339. func (m *BatchMsgMutation) ResetFail() {
  7340. m.fail = nil
  7341. m.addfail = nil
  7342. delete(m.clearedFields, batchmsg.FieldFail)
  7343. }
  7344. // SetStartTime sets the "start_time" field.
  7345. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  7346. m.start_time = &t
  7347. }
  7348. // StartTime returns the value of the "start_time" field in the mutation.
  7349. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  7350. v := m.start_time
  7351. if v == nil {
  7352. return
  7353. }
  7354. return *v, true
  7355. }
  7356. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  7357. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7359. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  7360. if !m.op.Is(OpUpdateOne) {
  7361. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  7362. }
  7363. if m.id == nil || m.oldValue == nil {
  7364. return v, errors.New("OldStartTime requires an ID field in the mutation")
  7365. }
  7366. oldValue, err := m.oldValue(ctx)
  7367. if err != nil {
  7368. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  7369. }
  7370. return oldValue.StartTime, nil
  7371. }
  7372. // ClearStartTime clears the value of the "start_time" field.
  7373. func (m *BatchMsgMutation) ClearStartTime() {
  7374. m.start_time = nil
  7375. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  7376. }
  7377. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  7378. func (m *BatchMsgMutation) StartTimeCleared() bool {
  7379. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  7380. return ok
  7381. }
  7382. // ResetStartTime resets all changes to the "start_time" field.
  7383. func (m *BatchMsgMutation) ResetStartTime() {
  7384. m.start_time = nil
  7385. delete(m.clearedFields, batchmsg.FieldStartTime)
  7386. }
  7387. // SetStopTime sets the "stop_time" field.
  7388. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  7389. m.stop_time = &t
  7390. }
  7391. // StopTime returns the value of the "stop_time" field in the mutation.
  7392. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  7393. v := m.stop_time
  7394. if v == nil {
  7395. return
  7396. }
  7397. return *v, true
  7398. }
  7399. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  7400. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7402. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  7403. if !m.op.Is(OpUpdateOne) {
  7404. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  7405. }
  7406. if m.id == nil || m.oldValue == nil {
  7407. return v, errors.New("OldStopTime requires an ID field in the mutation")
  7408. }
  7409. oldValue, err := m.oldValue(ctx)
  7410. if err != nil {
  7411. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  7412. }
  7413. return oldValue.StopTime, nil
  7414. }
  7415. // ClearStopTime clears the value of the "stop_time" field.
  7416. func (m *BatchMsgMutation) ClearStopTime() {
  7417. m.stop_time = nil
  7418. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  7419. }
  7420. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  7421. func (m *BatchMsgMutation) StopTimeCleared() bool {
  7422. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  7423. return ok
  7424. }
  7425. // ResetStopTime resets all changes to the "stop_time" field.
  7426. func (m *BatchMsgMutation) ResetStopTime() {
  7427. m.stop_time = nil
  7428. delete(m.clearedFields, batchmsg.FieldStopTime)
  7429. }
  7430. // SetSendTime sets the "send_time" field.
  7431. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  7432. m.send_time = &t
  7433. }
  7434. // SendTime returns the value of the "send_time" field in the mutation.
  7435. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  7436. v := m.send_time
  7437. if v == nil {
  7438. return
  7439. }
  7440. return *v, true
  7441. }
  7442. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  7443. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7445. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  7446. if !m.op.Is(OpUpdateOne) {
  7447. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  7448. }
  7449. if m.id == nil || m.oldValue == nil {
  7450. return v, errors.New("OldSendTime requires an ID field in the mutation")
  7451. }
  7452. oldValue, err := m.oldValue(ctx)
  7453. if err != nil {
  7454. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  7455. }
  7456. return oldValue.SendTime, nil
  7457. }
  7458. // ClearSendTime clears the value of the "send_time" field.
  7459. func (m *BatchMsgMutation) ClearSendTime() {
  7460. m.send_time = nil
  7461. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  7462. }
  7463. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  7464. func (m *BatchMsgMutation) SendTimeCleared() bool {
  7465. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  7466. return ok
  7467. }
  7468. // ResetSendTime resets all changes to the "send_time" field.
  7469. func (m *BatchMsgMutation) ResetSendTime() {
  7470. m.send_time = nil
  7471. delete(m.clearedFields, batchmsg.FieldSendTime)
  7472. }
  7473. // SetType sets the "type" field.
  7474. func (m *BatchMsgMutation) SetType(i int32) {
  7475. m._type = &i
  7476. m.add_type = nil
  7477. }
  7478. // GetType returns the value of the "type" field in the mutation.
  7479. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  7480. v := m._type
  7481. if v == nil {
  7482. return
  7483. }
  7484. return *v, true
  7485. }
  7486. // OldType returns the old "type" field's value of the BatchMsg entity.
  7487. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7489. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  7490. if !m.op.Is(OpUpdateOne) {
  7491. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7492. }
  7493. if m.id == nil || m.oldValue == nil {
  7494. return v, errors.New("OldType requires an ID field in the mutation")
  7495. }
  7496. oldValue, err := m.oldValue(ctx)
  7497. if err != nil {
  7498. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7499. }
  7500. return oldValue.Type, nil
  7501. }
  7502. // AddType adds i to the "type" field.
  7503. func (m *BatchMsgMutation) AddType(i int32) {
  7504. if m.add_type != nil {
  7505. *m.add_type += i
  7506. } else {
  7507. m.add_type = &i
  7508. }
  7509. }
  7510. // AddedType returns the value that was added to the "type" field in this mutation.
  7511. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  7512. v := m.add_type
  7513. if v == nil {
  7514. return
  7515. }
  7516. return *v, true
  7517. }
  7518. // ClearType clears the value of the "type" field.
  7519. func (m *BatchMsgMutation) ClearType() {
  7520. m._type = nil
  7521. m.add_type = nil
  7522. m.clearedFields[batchmsg.FieldType] = struct{}{}
  7523. }
  7524. // TypeCleared returns if the "type" field was cleared in this mutation.
  7525. func (m *BatchMsgMutation) TypeCleared() bool {
  7526. _, ok := m.clearedFields[batchmsg.FieldType]
  7527. return ok
  7528. }
  7529. // ResetType resets all changes to the "type" field.
  7530. func (m *BatchMsgMutation) ResetType() {
  7531. m._type = nil
  7532. m.add_type = nil
  7533. delete(m.clearedFields, batchmsg.FieldType)
  7534. }
  7535. // SetOrganizationID sets the "organization_id" field.
  7536. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  7537. m.organization_id = &u
  7538. m.addorganization_id = nil
  7539. }
  7540. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7541. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  7542. v := m.organization_id
  7543. if v == nil {
  7544. return
  7545. }
  7546. return *v, true
  7547. }
  7548. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  7549. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7551. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7552. if !m.op.Is(OpUpdateOne) {
  7553. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7554. }
  7555. if m.id == nil || m.oldValue == nil {
  7556. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7557. }
  7558. oldValue, err := m.oldValue(ctx)
  7559. if err != nil {
  7560. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7561. }
  7562. return oldValue.OrganizationID, nil
  7563. }
  7564. // AddOrganizationID adds u to the "organization_id" field.
  7565. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  7566. if m.addorganization_id != nil {
  7567. *m.addorganization_id += u
  7568. } else {
  7569. m.addorganization_id = &u
  7570. }
  7571. }
  7572. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7573. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  7574. v := m.addorganization_id
  7575. if v == nil {
  7576. return
  7577. }
  7578. return *v, true
  7579. }
  7580. // ResetOrganizationID resets all changes to the "organization_id" field.
  7581. func (m *BatchMsgMutation) ResetOrganizationID() {
  7582. m.organization_id = nil
  7583. m.addorganization_id = nil
  7584. }
  7585. // SetCtype sets the "ctype" field.
  7586. func (m *BatchMsgMutation) SetCtype(u uint64) {
  7587. m.ctype = &u
  7588. m.addctype = nil
  7589. }
  7590. // Ctype returns the value of the "ctype" field in the mutation.
  7591. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  7592. v := m.ctype
  7593. if v == nil {
  7594. return
  7595. }
  7596. return *v, true
  7597. }
  7598. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  7599. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7601. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  7602. if !m.op.Is(OpUpdateOne) {
  7603. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  7604. }
  7605. if m.id == nil || m.oldValue == nil {
  7606. return v, errors.New("OldCtype requires an ID field in the mutation")
  7607. }
  7608. oldValue, err := m.oldValue(ctx)
  7609. if err != nil {
  7610. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  7611. }
  7612. return oldValue.Ctype, nil
  7613. }
  7614. // AddCtype adds u to the "ctype" field.
  7615. func (m *BatchMsgMutation) AddCtype(u int64) {
  7616. if m.addctype != nil {
  7617. *m.addctype += u
  7618. } else {
  7619. m.addctype = &u
  7620. }
  7621. }
  7622. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  7623. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  7624. v := m.addctype
  7625. if v == nil {
  7626. return
  7627. }
  7628. return *v, true
  7629. }
  7630. // ResetCtype resets all changes to the "ctype" field.
  7631. func (m *BatchMsgMutation) ResetCtype() {
  7632. m.ctype = nil
  7633. m.addctype = nil
  7634. }
  7635. // SetCc sets the "cc" field.
  7636. func (m *BatchMsgMutation) SetCc(s string) {
  7637. m.cc = &s
  7638. }
  7639. // Cc returns the value of the "cc" field in the mutation.
  7640. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  7641. v := m.cc
  7642. if v == nil {
  7643. return
  7644. }
  7645. return *v, true
  7646. }
  7647. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  7648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7650. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  7651. if !m.op.Is(OpUpdateOne) {
  7652. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  7653. }
  7654. if m.id == nil || m.oldValue == nil {
  7655. return v, errors.New("OldCc requires an ID field in the mutation")
  7656. }
  7657. oldValue, err := m.oldValue(ctx)
  7658. if err != nil {
  7659. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  7660. }
  7661. return oldValue.Cc, nil
  7662. }
  7663. // ClearCc clears the value of the "cc" field.
  7664. func (m *BatchMsgMutation) ClearCc() {
  7665. m.cc = nil
  7666. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  7667. }
  7668. // CcCleared returns if the "cc" field was cleared in this mutation.
  7669. func (m *BatchMsgMutation) CcCleared() bool {
  7670. _, ok := m.clearedFields[batchmsg.FieldCc]
  7671. return ok
  7672. }
  7673. // ResetCc resets all changes to the "cc" field.
  7674. func (m *BatchMsgMutation) ResetCc() {
  7675. m.cc = nil
  7676. delete(m.clearedFields, batchmsg.FieldCc)
  7677. }
  7678. // SetPhone sets the "phone" field.
  7679. func (m *BatchMsgMutation) SetPhone(s string) {
  7680. m.phone = &s
  7681. }
  7682. // Phone returns the value of the "phone" field in the mutation.
  7683. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  7684. v := m.phone
  7685. if v == nil {
  7686. return
  7687. }
  7688. return *v, true
  7689. }
  7690. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  7691. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7693. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  7694. if !m.op.Is(OpUpdateOne) {
  7695. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  7696. }
  7697. if m.id == nil || m.oldValue == nil {
  7698. return v, errors.New("OldPhone requires an ID field in the mutation")
  7699. }
  7700. oldValue, err := m.oldValue(ctx)
  7701. if err != nil {
  7702. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  7703. }
  7704. return oldValue.Phone, nil
  7705. }
  7706. // ClearPhone clears the value of the "phone" field.
  7707. func (m *BatchMsgMutation) ClearPhone() {
  7708. m.phone = nil
  7709. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  7710. }
  7711. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  7712. func (m *BatchMsgMutation) PhoneCleared() bool {
  7713. _, ok := m.clearedFields[batchmsg.FieldPhone]
  7714. return ok
  7715. }
  7716. // ResetPhone resets all changes to the "phone" field.
  7717. func (m *BatchMsgMutation) ResetPhone() {
  7718. m.phone = nil
  7719. delete(m.clearedFields, batchmsg.FieldPhone)
  7720. }
  7721. // SetTemplateName sets the "template_name" field.
  7722. func (m *BatchMsgMutation) SetTemplateName(s string) {
  7723. m.template_name = &s
  7724. }
  7725. // TemplateName returns the value of the "template_name" field in the mutation.
  7726. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  7727. v := m.template_name
  7728. if v == nil {
  7729. return
  7730. }
  7731. return *v, true
  7732. }
  7733. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  7734. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7736. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  7737. if !m.op.Is(OpUpdateOne) {
  7738. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  7739. }
  7740. if m.id == nil || m.oldValue == nil {
  7741. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  7742. }
  7743. oldValue, err := m.oldValue(ctx)
  7744. if err != nil {
  7745. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  7746. }
  7747. return oldValue.TemplateName, nil
  7748. }
  7749. // ClearTemplateName clears the value of the "template_name" field.
  7750. func (m *BatchMsgMutation) ClearTemplateName() {
  7751. m.template_name = nil
  7752. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  7753. }
  7754. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  7755. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  7756. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  7757. return ok
  7758. }
  7759. // ResetTemplateName resets all changes to the "template_name" field.
  7760. func (m *BatchMsgMutation) ResetTemplateName() {
  7761. m.template_name = nil
  7762. delete(m.clearedFields, batchmsg.FieldTemplateName)
  7763. }
  7764. // SetTemplateCode sets the "template_code" field.
  7765. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  7766. m.template_code = &s
  7767. }
  7768. // TemplateCode returns the value of the "template_code" field in the mutation.
  7769. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  7770. v := m.template_code
  7771. if v == nil {
  7772. return
  7773. }
  7774. return *v, true
  7775. }
  7776. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  7777. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7779. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  7780. if !m.op.Is(OpUpdateOne) {
  7781. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  7782. }
  7783. if m.id == nil || m.oldValue == nil {
  7784. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  7785. }
  7786. oldValue, err := m.oldValue(ctx)
  7787. if err != nil {
  7788. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  7789. }
  7790. return oldValue.TemplateCode, nil
  7791. }
  7792. // ClearTemplateCode clears the value of the "template_code" field.
  7793. func (m *BatchMsgMutation) ClearTemplateCode() {
  7794. m.template_code = nil
  7795. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  7796. }
  7797. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  7798. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  7799. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  7800. return ok
  7801. }
  7802. // ResetTemplateCode resets all changes to the "template_code" field.
  7803. func (m *BatchMsgMutation) ResetTemplateCode() {
  7804. m.template_code = nil
  7805. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  7806. }
  7807. // SetLang sets the "lang" field.
  7808. func (m *BatchMsgMutation) SetLang(s string) {
  7809. m.lang = &s
  7810. }
  7811. // Lang returns the value of the "lang" field in the mutation.
  7812. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  7813. v := m.lang
  7814. if v == nil {
  7815. return
  7816. }
  7817. return *v, true
  7818. }
  7819. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  7820. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7822. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  7823. if !m.op.Is(OpUpdateOne) {
  7824. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  7825. }
  7826. if m.id == nil || m.oldValue == nil {
  7827. return v, errors.New("OldLang requires an ID field in the mutation")
  7828. }
  7829. oldValue, err := m.oldValue(ctx)
  7830. if err != nil {
  7831. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  7832. }
  7833. return oldValue.Lang, nil
  7834. }
  7835. // ClearLang clears the value of the "lang" field.
  7836. func (m *BatchMsgMutation) ClearLang() {
  7837. m.lang = nil
  7838. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  7839. }
  7840. // LangCleared returns if the "lang" field was cleared in this mutation.
  7841. func (m *BatchMsgMutation) LangCleared() bool {
  7842. _, ok := m.clearedFields[batchmsg.FieldLang]
  7843. return ok
  7844. }
  7845. // ResetLang resets all changes to the "lang" field.
  7846. func (m *BatchMsgMutation) ResetLang() {
  7847. m.lang = nil
  7848. delete(m.clearedFields, batchmsg.FieldLang)
  7849. }
  7850. // Where appends a list predicates to the BatchMsgMutation builder.
  7851. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  7852. m.predicates = append(m.predicates, ps...)
  7853. }
  7854. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  7855. // users can use type-assertion to append predicates that do not depend on any generated package.
  7856. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  7857. p := make([]predicate.BatchMsg, len(ps))
  7858. for i := range ps {
  7859. p[i] = ps[i]
  7860. }
  7861. m.Where(p...)
  7862. }
  7863. // Op returns the operation name.
  7864. func (m *BatchMsgMutation) Op() Op {
  7865. return m.op
  7866. }
  7867. // SetOp allows setting the mutation operation.
  7868. func (m *BatchMsgMutation) SetOp(op Op) {
  7869. m.op = op
  7870. }
  7871. // Type returns the node type of this mutation (BatchMsg).
  7872. func (m *BatchMsgMutation) Type() string {
  7873. return m.typ
  7874. }
  7875. // Fields returns all fields that were changed during this mutation. Note that in
  7876. // order to get all numeric fields that were incremented/decremented, call
  7877. // AddedFields().
  7878. func (m *BatchMsgMutation) Fields() []string {
  7879. fields := make([]string, 0, 24)
  7880. if m.created_at != nil {
  7881. fields = append(fields, batchmsg.FieldCreatedAt)
  7882. }
  7883. if m.updated_at != nil {
  7884. fields = append(fields, batchmsg.FieldUpdatedAt)
  7885. }
  7886. if m.deleted_at != nil {
  7887. fields = append(fields, batchmsg.FieldDeletedAt)
  7888. }
  7889. if m.status != nil {
  7890. fields = append(fields, batchmsg.FieldStatus)
  7891. }
  7892. if m.batch_no != nil {
  7893. fields = append(fields, batchmsg.FieldBatchNo)
  7894. }
  7895. if m.task_name != nil {
  7896. fields = append(fields, batchmsg.FieldTaskName)
  7897. }
  7898. if m.fromwxid != nil {
  7899. fields = append(fields, batchmsg.FieldFromwxid)
  7900. }
  7901. if m.msg != nil {
  7902. fields = append(fields, batchmsg.FieldMsg)
  7903. }
  7904. if m.tag != nil {
  7905. fields = append(fields, batchmsg.FieldTag)
  7906. }
  7907. if m.tagids != nil {
  7908. fields = append(fields, batchmsg.FieldTagids)
  7909. }
  7910. if m.total != nil {
  7911. fields = append(fields, batchmsg.FieldTotal)
  7912. }
  7913. if m.success != nil {
  7914. fields = append(fields, batchmsg.FieldSuccess)
  7915. }
  7916. if m.fail != nil {
  7917. fields = append(fields, batchmsg.FieldFail)
  7918. }
  7919. if m.start_time != nil {
  7920. fields = append(fields, batchmsg.FieldStartTime)
  7921. }
  7922. if m.stop_time != nil {
  7923. fields = append(fields, batchmsg.FieldStopTime)
  7924. }
  7925. if m.send_time != nil {
  7926. fields = append(fields, batchmsg.FieldSendTime)
  7927. }
  7928. if m._type != nil {
  7929. fields = append(fields, batchmsg.FieldType)
  7930. }
  7931. if m.organization_id != nil {
  7932. fields = append(fields, batchmsg.FieldOrganizationID)
  7933. }
  7934. if m.ctype != nil {
  7935. fields = append(fields, batchmsg.FieldCtype)
  7936. }
  7937. if m.cc != nil {
  7938. fields = append(fields, batchmsg.FieldCc)
  7939. }
  7940. if m.phone != nil {
  7941. fields = append(fields, batchmsg.FieldPhone)
  7942. }
  7943. if m.template_name != nil {
  7944. fields = append(fields, batchmsg.FieldTemplateName)
  7945. }
  7946. if m.template_code != nil {
  7947. fields = append(fields, batchmsg.FieldTemplateCode)
  7948. }
  7949. if m.lang != nil {
  7950. fields = append(fields, batchmsg.FieldLang)
  7951. }
  7952. return fields
  7953. }
  7954. // Field returns the value of a field with the given name. The second boolean
  7955. // return value indicates that this field was not set, or was not defined in the
  7956. // schema.
  7957. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  7958. switch name {
  7959. case batchmsg.FieldCreatedAt:
  7960. return m.CreatedAt()
  7961. case batchmsg.FieldUpdatedAt:
  7962. return m.UpdatedAt()
  7963. case batchmsg.FieldDeletedAt:
  7964. return m.DeletedAt()
  7965. case batchmsg.FieldStatus:
  7966. return m.Status()
  7967. case batchmsg.FieldBatchNo:
  7968. return m.BatchNo()
  7969. case batchmsg.FieldTaskName:
  7970. return m.TaskName()
  7971. case batchmsg.FieldFromwxid:
  7972. return m.Fromwxid()
  7973. case batchmsg.FieldMsg:
  7974. return m.Msg()
  7975. case batchmsg.FieldTag:
  7976. return m.Tag()
  7977. case batchmsg.FieldTagids:
  7978. return m.Tagids()
  7979. case batchmsg.FieldTotal:
  7980. return m.Total()
  7981. case batchmsg.FieldSuccess:
  7982. return m.Success()
  7983. case batchmsg.FieldFail:
  7984. return m.Fail()
  7985. case batchmsg.FieldStartTime:
  7986. return m.StartTime()
  7987. case batchmsg.FieldStopTime:
  7988. return m.StopTime()
  7989. case batchmsg.FieldSendTime:
  7990. return m.SendTime()
  7991. case batchmsg.FieldType:
  7992. return m.GetType()
  7993. case batchmsg.FieldOrganizationID:
  7994. return m.OrganizationID()
  7995. case batchmsg.FieldCtype:
  7996. return m.Ctype()
  7997. case batchmsg.FieldCc:
  7998. return m.Cc()
  7999. case batchmsg.FieldPhone:
  8000. return m.Phone()
  8001. case batchmsg.FieldTemplateName:
  8002. return m.TemplateName()
  8003. case batchmsg.FieldTemplateCode:
  8004. return m.TemplateCode()
  8005. case batchmsg.FieldLang:
  8006. return m.Lang()
  8007. }
  8008. return nil, false
  8009. }
  8010. // OldField returns the old value of the field from the database. An error is
  8011. // returned if the mutation operation is not UpdateOne, or the query to the
  8012. // database failed.
  8013. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8014. switch name {
  8015. case batchmsg.FieldCreatedAt:
  8016. return m.OldCreatedAt(ctx)
  8017. case batchmsg.FieldUpdatedAt:
  8018. return m.OldUpdatedAt(ctx)
  8019. case batchmsg.FieldDeletedAt:
  8020. return m.OldDeletedAt(ctx)
  8021. case batchmsg.FieldStatus:
  8022. return m.OldStatus(ctx)
  8023. case batchmsg.FieldBatchNo:
  8024. return m.OldBatchNo(ctx)
  8025. case batchmsg.FieldTaskName:
  8026. return m.OldTaskName(ctx)
  8027. case batchmsg.FieldFromwxid:
  8028. return m.OldFromwxid(ctx)
  8029. case batchmsg.FieldMsg:
  8030. return m.OldMsg(ctx)
  8031. case batchmsg.FieldTag:
  8032. return m.OldTag(ctx)
  8033. case batchmsg.FieldTagids:
  8034. return m.OldTagids(ctx)
  8035. case batchmsg.FieldTotal:
  8036. return m.OldTotal(ctx)
  8037. case batchmsg.FieldSuccess:
  8038. return m.OldSuccess(ctx)
  8039. case batchmsg.FieldFail:
  8040. return m.OldFail(ctx)
  8041. case batchmsg.FieldStartTime:
  8042. return m.OldStartTime(ctx)
  8043. case batchmsg.FieldStopTime:
  8044. return m.OldStopTime(ctx)
  8045. case batchmsg.FieldSendTime:
  8046. return m.OldSendTime(ctx)
  8047. case batchmsg.FieldType:
  8048. return m.OldType(ctx)
  8049. case batchmsg.FieldOrganizationID:
  8050. return m.OldOrganizationID(ctx)
  8051. case batchmsg.FieldCtype:
  8052. return m.OldCtype(ctx)
  8053. case batchmsg.FieldCc:
  8054. return m.OldCc(ctx)
  8055. case batchmsg.FieldPhone:
  8056. return m.OldPhone(ctx)
  8057. case batchmsg.FieldTemplateName:
  8058. return m.OldTemplateName(ctx)
  8059. case batchmsg.FieldTemplateCode:
  8060. return m.OldTemplateCode(ctx)
  8061. case batchmsg.FieldLang:
  8062. return m.OldLang(ctx)
  8063. }
  8064. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  8065. }
  8066. // SetField sets the value of a field with the given name. It returns an error if
  8067. // the field is not defined in the schema, or if the type mismatched the field
  8068. // type.
  8069. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  8070. switch name {
  8071. case batchmsg.FieldCreatedAt:
  8072. v, ok := value.(time.Time)
  8073. if !ok {
  8074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8075. }
  8076. m.SetCreatedAt(v)
  8077. return nil
  8078. case batchmsg.FieldUpdatedAt:
  8079. v, ok := value.(time.Time)
  8080. if !ok {
  8081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8082. }
  8083. m.SetUpdatedAt(v)
  8084. return nil
  8085. case batchmsg.FieldDeletedAt:
  8086. v, ok := value.(time.Time)
  8087. if !ok {
  8088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8089. }
  8090. m.SetDeletedAt(v)
  8091. return nil
  8092. case batchmsg.FieldStatus:
  8093. v, ok := value.(uint8)
  8094. if !ok {
  8095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8096. }
  8097. m.SetStatus(v)
  8098. return nil
  8099. case batchmsg.FieldBatchNo:
  8100. v, ok := value.(string)
  8101. if !ok {
  8102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8103. }
  8104. m.SetBatchNo(v)
  8105. return nil
  8106. case batchmsg.FieldTaskName:
  8107. v, ok := value.(string)
  8108. if !ok {
  8109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8110. }
  8111. m.SetTaskName(v)
  8112. return nil
  8113. case batchmsg.FieldFromwxid:
  8114. v, ok := value.(string)
  8115. if !ok {
  8116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8117. }
  8118. m.SetFromwxid(v)
  8119. return nil
  8120. case batchmsg.FieldMsg:
  8121. v, ok := value.(string)
  8122. if !ok {
  8123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8124. }
  8125. m.SetMsg(v)
  8126. return nil
  8127. case batchmsg.FieldTag:
  8128. v, ok := value.(string)
  8129. if !ok {
  8130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8131. }
  8132. m.SetTag(v)
  8133. return nil
  8134. case batchmsg.FieldTagids:
  8135. v, ok := value.(string)
  8136. if !ok {
  8137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8138. }
  8139. m.SetTagids(v)
  8140. return nil
  8141. case batchmsg.FieldTotal:
  8142. v, ok := value.(int32)
  8143. if !ok {
  8144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8145. }
  8146. m.SetTotal(v)
  8147. return nil
  8148. case batchmsg.FieldSuccess:
  8149. v, ok := value.(int32)
  8150. if !ok {
  8151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8152. }
  8153. m.SetSuccess(v)
  8154. return nil
  8155. case batchmsg.FieldFail:
  8156. v, ok := value.(int32)
  8157. if !ok {
  8158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8159. }
  8160. m.SetFail(v)
  8161. return nil
  8162. case batchmsg.FieldStartTime:
  8163. v, ok := value.(time.Time)
  8164. if !ok {
  8165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8166. }
  8167. m.SetStartTime(v)
  8168. return nil
  8169. case batchmsg.FieldStopTime:
  8170. v, ok := value.(time.Time)
  8171. if !ok {
  8172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8173. }
  8174. m.SetStopTime(v)
  8175. return nil
  8176. case batchmsg.FieldSendTime:
  8177. v, ok := value.(time.Time)
  8178. if !ok {
  8179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8180. }
  8181. m.SetSendTime(v)
  8182. return nil
  8183. case batchmsg.FieldType:
  8184. v, ok := value.(int32)
  8185. if !ok {
  8186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8187. }
  8188. m.SetType(v)
  8189. return nil
  8190. case batchmsg.FieldOrganizationID:
  8191. v, ok := value.(uint64)
  8192. if !ok {
  8193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8194. }
  8195. m.SetOrganizationID(v)
  8196. return nil
  8197. case batchmsg.FieldCtype:
  8198. v, ok := value.(uint64)
  8199. if !ok {
  8200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8201. }
  8202. m.SetCtype(v)
  8203. return nil
  8204. case batchmsg.FieldCc:
  8205. v, ok := value.(string)
  8206. if !ok {
  8207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8208. }
  8209. m.SetCc(v)
  8210. return nil
  8211. case batchmsg.FieldPhone:
  8212. v, ok := value.(string)
  8213. if !ok {
  8214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8215. }
  8216. m.SetPhone(v)
  8217. return nil
  8218. case batchmsg.FieldTemplateName:
  8219. v, ok := value.(string)
  8220. if !ok {
  8221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8222. }
  8223. m.SetTemplateName(v)
  8224. return nil
  8225. case batchmsg.FieldTemplateCode:
  8226. v, ok := value.(string)
  8227. if !ok {
  8228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8229. }
  8230. m.SetTemplateCode(v)
  8231. return nil
  8232. case batchmsg.FieldLang:
  8233. v, ok := value.(string)
  8234. if !ok {
  8235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8236. }
  8237. m.SetLang(v)
  8238. return nil
  8239. }
  8240. return fmt.Errorf("unknown BatchMsg field %s", name)
  8241. }
  8242. // AddedFields returns all numeric fields that were incremented/decremented during
  8243. // this mutation.
  8244. func (m *BatchMsgMutation) AddedFields() []string {
  8245. var fields []string
  8246. if m.addstatus != nil {
  8247. fields = append(fields, batchmsg.FieldStatus)
  8248. }
  8249. if m.addtotal != nil {
  8250. fields = append(fields, batchmsg.FieldTotal)
  8251. }
  8252. if m.addsuccess != nil {
  8253. fields = append(fields, batchmsg.FieldSuccess)
  8254. }
  8255. if m.addfail != nil {
  8256. fields = append(fields, batchmsg.FieldFail)
  8257. }
  8258. if m.add_type != nil {
  8259. fields = append(fields, batchmsg.FieldType)
  8260. }
  8261. if m.addorganization_id != nil {
  8262. fields = append(fields, batchmsg.FieldOrganizationID)
  8263. }
  8264. if m.addctype != nil {
  8265. fields = append(fields, batchmsg.FieldCtype)
  8266. }
  8267. return fields
  8268. }
  8269. // AddedField returns the numeric value that was incremented/decremented on a field
  8270. // with the given name. The second boolean return value indicates that this field
  8271. // was not set, or was not defined in the schema.
  8272. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  8273. switch name {
  8274. case batchmsg.FieldStatus:
  8275. return m.AddedStatus()
  8276. case batchmsg.FieldTotal:
  8277. return m.AddedTotal()
  8278. case batchmsg.FieldSuccess:
  8279. return m.AddedSuccess()
  8280. case batchmsg.FieldFail:
  8281. return m.AddedFail()
  8282. case batchmsg.FieldType:
  8283. return m.AddedType()
  8284. case batchmsg.FieldOrganizationID:
  8285. return m.AddedOrganizationID()
  8286. case batchmsg.FieldCtype:
  8287. return m.AddedCtype()
  8288. }
  8289. return nil, false
  8290. }
  8291. // AddField adds the value to the field with the given name. It returns an error if
  8292. // the field is not defined in the schema, or if the type mismatched the field
  8293. // type.
  8294. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  8295. switch name {
  8296. case batchmsg.FieldStatus:
  8297. v, ok := value.(int8)
  8298. if !ok {
  8299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8300. }
  8301. m.AddStatus(v)
  8302. return nil
  8303. case batchmsg.FieldTotal:
  8304. v, ok := value.(int32)
  8305. if !ok {
  8306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8307. }
  8308. m.AddTotal(v)
  8309. return nil
  8310. case batchmsg.FieldSuccess:
  8311. v, ok := value.(int32)
  8312. if !ok {
  8313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8314. }
  8315. m.AddSuccess(v)
  8316. return nil
  8317. case batchmsg.FieldFail:
  8318. v, ok := value.(int32)
  8319. if !ok {
  8320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8321. }
  8322. m.AddFail(v)
  8323. return nil
  8324. case batchmsg.FieldType:
  8325. v, ok := value.(int32)
  8326. if !ok {
  8327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8328. }
  8329. m.AddType(v)
  8330. return nil
  8331. case batchmsg.FieldOrganizationID:
  8332. v, ok := value.(int64)
  8333. if !ok {
  8334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8335. }
  8336. m.AddOrganizationID(v)
  8337. return nil
  8338. case batchmsg.FieldCtype:
  8339. v, ok := value.(int64)
  8340. if !ok {
  8341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8342. }
  8343. m.AddCtype(v)
  8344. return nil
  8345. }
  8346. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  8347. }
  8348. // ClearedFields returns all nullable fields that were cleared during this
  8349. // mutation.
  8350. func (m *BatchMsgMutation) ClearedFields() []string {
  8351. var fields []string
  8352. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  8353. fields = append(fields, batchmsg.FieldDeletedAt)
  8354. }
  8355. if m.FieldCleared(batchmsg.FieldStatus) {
  8356. fields = append(fields, batchmsg.FieldStatus)
  8357. }
  8358. if m.FieldCleared(batchmsg.FieldBatchNo) {
  8359. fields = append(fields, batchmsg.FieldBatchNo)
  8360. }
  8361. if m.FieldCleared(batchmsg.FieldTaskName) {
  8362. fields = append(fields, batchmsg.FieldTaskName)
  8363. }
  8364. if m.FieldCleared(batchmsg.FieldFromwxid) {
  8365. fields = append(fields, batchmsg.FieldFromwxid)
  8366. }
  8367. if m.FieldCleared(batchmsg.FieldMsg) {
  8368. fields = append(fields, batchmsg.FieldMsg)
  8369. }
  8370. if m.FieldCleared(batchmsg.FieldTag) {
  8371. fields = append(fields, batchmsg.FieldTag)
  8372. }
  8373. if m.FieldCleared(batchmsg.FieldTagids) {
  8374. fields = append(fields, batchmsg.FieldTagids)
  8375. }
  8376. if m.FieldCleared(batchmsg.FieldTotal) {
  8377. fields = append(fields, batchmsg.FieldTotal)
  8378. }
  8379. if m.FieldCleared(batchmsg.FieldSuccess) {
  8380. fields = append(fields, batchmsg.FieldSuccess)
  8381. }
  8382. if m.FieldCleared(batchmsg.FieldFail) {
  8383. fields = append(fields, batchmsg.FieldFail)
  8384. }
  8385. if m.FieldCleared(batchmsg.FieldStartTime) {
  8386. fields = append(fields, batchmsg.FieldStartTime)
  8387. }
  8388. if m.FieldCleared(batchmsg.FieldStopTime) {
  8389. fields = append(fields, batchmsg.FieldStopTime)
  8390. }
  8391. if m.FieldCleared(batchmsg.FieldSendTime) {
  8392. fields = append(fields, batchmsg.FieldSendTime)
  8393. }
  8394. if m.FieldCleared(batchmsg.FieldType) {
  8395. fields = append(fields, batchmsg.FieldType)
  8396. }
  8397. if m.FieldCleared(batchmsg.FieldCc) {
  8398. fields = append(fields, batchmsg.FieldCc)
  8399. }
  8400. if m.FieldCleared(batchmsg.FieldPhone) {
  8401. fields = append(fields, batchmsg.FieldPhone)
  8402. }
  8403. if m.FieldCleared(batchmsg.FieldTemplateName) {
  8404. fields = append(fields, batchmsg.FieldTemplateName)
  8405. }
  8406. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  8407. fields = append(fields, batchmsg.FieldTemplateCode)
  8408. }
  8409. if m.FieldCleared(batchmsg.FieldLang) {
  8410. fields = append(fields, batchmsg.FieldLang)
  8411. }
  8412. return fields
  8413. }
  8414. // FieldCleared returns a boolean indicating if a field with the given name was
  8415. // cleared in this mutation.
  8416. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  8417. _, ok := m.clearedFields[name]
  8418. return ok
  8419. }
  8420. // ClearField clears the value of the field with the given name. It returns an
  8421. // error if the field is not defined in the schema.
  8422. func (m *BatchMsgMutation) ClearField(name string) error {
  8423. switch name {
  8424. case batchmsg.FieldDeletedAt:
  8425. m.ClearDeletedAt()
  8426. return nil
  8427. case batchmsg.FieldStatus:
  8428. m.ClearStatus()
  8429. return nil
  8430. case batchmsg.FieldBatchNo:
  8431. m.ClearBatchNo()
  8432. return nil
  8433. case batchmsg.FieldTaskName:
  8434. m.ClearTaskName()
  8435. return nil
  8436. case batchmsg.FieldFromwxid:
  8437. m.ClearFromwxid()
  8438. return nil
  8439. case batchmsg.FieldMsg:
  8440. m.ClearMsg()
  8441. return nil
  8442. case batchmsg.FieldTag:
  8443. m.ClearTag()
  8444. return nil
  8445. case batchmsg.FieldTagids:
  8446. m.ClearTagids()
  8447. return nil
  8448. case batchmsg.FieldTotal:
  8449. m.ClearTotal()
  8450. return nil
  8451. case batchmsg.FieldSuccess:
  8452. m.ClearSuccess()
  8453. return nil
  8454. case batchmsg.FieldFail:
  8455. m.ClearFail()
  8456. return nil
  8457. case batchmsg.FieldStartTime:
  8458. m.ClearStartTime()
  8459. return nil
  8460. case batchmsg.FieldStopTime:
  8461. m.ClearStopTime()
  8462. return nil
  8463. case batchmsg.FieldSendTime:
  8464. m.ClearSendTime()
  8465. return nil
  8466. case batchmsg.FieldType:
  8467. m.ClearType()
  8468. return nil
  8469. case batchmsg.FieldCc:
  8470. m.ClearCc()
  8471. return nil
  8472. case batchmsg.FieldPhone:
  8473. m.ClearPhone()
  8474. return nil
  8475. case batchmsg.FieldTemplateName:
  8476. m.ClearTemplateName()
  8477. return nil
  8478. case batchmsg.FieldTemplateCode:
  8479. m.ClearTemplateCode()
  8480. return nil
  8481. case batchmsg.FieldLang:
  8482. m.ClearLang()
  8483. return nil
  8484. }
  8485. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  8486. }
  8487. // ResetField resets all changes in the mutation for the field with the given name.
  8488. // It returns an error if the field is not defined in the schema.
  8489. func (m *BatchMsgMutation) ResetField(name string) error {
  8490. switch name {
  8491. case batchmsg.FieldCreatedAt:
  8492. m.ResetCreatedAt()
  8493. return nil
  8494. case batchmsg.FieldUpdatedAt:
  8495. m.ResetUpdatedAt()
  8496. return nil
  8497. case batchmsg.FieldDeletedAt:
  8498. m.ResetDeletedAt()
  8499. return nil
  8500. case batchmsg.FieldStatus:
  8501. m.ResetStatus()
  8502. return nil
  8503. case batchmsg.FieldBatchNo:
  8504. m.ResetBatchNo()
  8505. return nil
  8506. case batchmsg.FieldTaskName:
  8507. m.ResetTaskName()
  8508. return nil
  8509. case batchmsg.FieldFromwxid:
  8510. m.ResetFromwxid()
  8511. return nil
  8512. case batchmsg.FieldMsg:
  8513. m.ResetMsg()
  8514. return nil
  8515. case batchmsg.FieldTag:
  8516. m.ResetTag()
  8517. return nil
  8518. case batchmsg.FieldTagids:
  8519. m.ResetTagids()
  8520. return nil
  8521. case batchmsg.FieldTotal:
  8522. m.ResetTotal()
  8523. return nil
  8524. case batchmsg.FieldSuccess:
  8525. m.ResetSuccess()
  8526. return nil
  8527. case batchmsg.FieldFail:
  8528. m.ResetFail()
  8529. return nil
  8530. case batchmsg.FieldStartTime:
  8531. m.ResetStartTime()
  8532. return nil
  8533. case batchmsg.FieldStopTime:
  8534. m.ResetStopTime()
  8535. return nil
  8536. case batchmsg.FieldSendTime:
  8537. m.ResetSendTime()
  8538. return nil
  8539. case batchmsg.FieldType:
  8540. m.ResetType()
  8541. return nil
  8542. case batchmsg.FieldOrganizationID:
  8543. m.ResetOrganizationID()
  8544. return nil
  8545. case batchmsg.FieldCtype:
  8546. m.ResetCtype()
  8547. return nil
  8548. case batchmsg.FieldCc:
  8549. m.ResetCc()
  8550. return nil
  8551. case batchmsg.FieldPhone:
  8552. m.ResetPhone()
  8553. return nil
  8554. case batchmsg.FieldTemplateName:
  8555. m.ResetTemplateName()
  8556. return nil
  8557. case batchmsg.FieldTemplateCode:
  8558. m.ResetTemplateCode()
  8559. return nil
  8560. case batchmsg.FieldLang:
  8561. m.ResetLang()
  8562. return nil
  8563. }
  8564. return fmt.Errorf("unknown BatchMsg field %s", name)
  8565. }
  8566. // AddedEdges returns all edge names that were set/added in this mutation.
  8567. func (m *BatchMsgMutation) AddedEdges() []string {
  8568. edges := make([]string, 0, 0)
  8569. return edges
  8570. }
  8571. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8572. // name in this mutation.
  8573. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  8574. return nil
  8575. }
  8576. // RemovedEdges returns all edge names that were removed in this mutation.
  8577. func (m *BatchMsgMutation) RemovedEdges() []string {
  8578. edges := make([]string, 0, 0)
  8579. return edges
  8580. }
  8581. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8582. // the given name in this mutation.
  8583. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  8584. return nil
  8585. }
  8586. // ClearedEdges returns all edge names that were cleared in this mutation.
  8587. func (m *BatchMsgMutation) ClearedEdges() []string {
  8588. edges := make([]string, 0, 0)
  8589. return edges
  8590. }
  8591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8592. // was cleared in this mutation.
  8593. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  8594. return false
  8595. }
  8596. // ClearEdge clears the value of the edge with the given name. It returns an error
  8597. // if that edge is not defined in the schema.
  8598. func (m *BatchMsgMutation) ClearEdge(name string) error {
  8599. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  8600. }
  8601. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8602. // It returns an error if the edge is not defined in the schema.
  8603. func (m *BatchMsgMutation) ResetEdge(name string) error {
  8604. return fmt.Errorf("unknown BatchMsg edge %s", name)
  8605. }
  8606. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  8607. type CategoryMutation struct {
  8608. config
  8609. op Op
  8610. typ string
  8611. id *uint64
  8612. created_at *time.Time
  8613. updated_at *time.Time
  8614. deleted_at *time.Time
  8615. name *string
  8616. organization_id *uint64
  8617. addorganization_id *int64
  8618. clearedFields map[string]struct{}
  8619. done bool
  8620. oldValue func(context.Context) (*Category, error)
  8621. predicates []predicate.Category
  8622. }
  8623. var _ ent.Mutation = (*CategoryMutation)(nil)
  8624. // categoryOption allows management of the mutation configuration using functional options.
  8625. type categoryOption func(*CategoryMutation)
  8626. // newCategoryMutation creates new mutation for the Category entity.
  8627. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  8628. m := &CategoryMutation{
  8629. config: c,
  8630. op: op,
  8631. typ: TypeCategory,
  8632. clearedFields: make(map[string]struct{}),
  8633. }
  8634. for _, opt := range opts {
  8635. opt(m)
  8636. }
  8637. return m
  8638. }
  8639. // withCategoryID sets the ID field of the mutation.
  8640. func withCategoryID(id uint64) categoryOption {
  8641. return func(m *CategoryMutation) {
  8642. var (
  8643. err error
  8644. once sync.Once
  8645. value *Category
  8646. )
  8647. m.oldValue = func(ctx context.Context) (*Category, error) {
  8648. once.Do(func() {
  8649. if m.done {
  8650. err = errors.New("querying old values post mutation is not allowed")
  8651. } else {
  8652. value, err = m.Client().Category.Get(ctx, id)
  8653. }
  8654. })
  8655. return value, err
  8656. }
  8657. m.id = &id
  8658. }
  8659. }
  8660. // withCategory sets the old Category of the mutation.
  8661. func withCategory(node *Category) categoryOption {
  8662. return func(m *CategoryMutation) {
  8663. m.oldValue = func(context.Context) (*Category, error) {
  8664. return node, nil
  8665. }
  8666. m.id = &node.ID
  8667. }
  8668. }
  8669. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8670. // executed in a transaction (ent.Tx), a transactional client is returned.
  8671. func (m CategoryMutation) Client() *Client {
  8672. client := &Client{config: m.config}
  8673. client.init()
  8674. return client
  8675. }
  8676. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8677. // it returns an error otherwise.
  8678. func (m CategoryMutation) Tx() (*Tx, error) {
  8679. if _, ok := m.driver.(*txDriver); !ok {
  8680. return nil, errors.New("ent: mutation is not running in a transaction")
  8681. }
  8682. tx := &Tx{config: m.config}
  8683. tx.init()
  8684. return tx, nil
  8685. }
  8686. // SetID sets the value of the id field. Note that this
  8687. // operation is only accepted on creation of Category entities.
  8688. func (m *CategoryMutation) SetID(id uint64) {
  8689. m.id = &id
  8690. }
  8691. // ID returns the ID value in the mutation. Note that the ID is only available
  8692. // if it was provided to the builder or after it was returned from the database.
  8693. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  8694. if m.id == nil {
  8695. return
  8696. }
  8697. return *m.id, true
  8698. }
  8699. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8700. // That means, if the mutation is applied within a transaction with an isolation level such
  8701. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8702. // or updated by the mutation.
  8703. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  8704. switch {
  8705. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8706. id, exists := m.ID()
  8707. if exists {
  8708. return []uint64{id}, nil
  8709. }
  8710. fallthrough
  8711. case m.op.Is(OpUpdate | OpDelete):
  8712. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  8713. default:
  8714. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8715. }
  8716. }
  8717. // SetCreatedAt sets the "created_at" field.
  8718. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  8719. m.created_at = &t
  8720. }
  8721. // CreatedAt returns the value of the "created_at" field in the mutation.
  8722. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  8723. v := m.created_at
  8724. if v == nil {
  8725. return
  8726. }
  8727. return *v, true
  8728. }
  8729. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  8730. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8732. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8733. if !m.op.Is(OpUpdateOne) {
  8734. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8735. }
  8736. if m.id == nil || m.oldValue == nil {
  8737. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8738. }
  8739. oldValue, err := m.oldValue(ctx)
  8740. if err != nil {
  8741. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8742. }
  8743. return oldValue.CreatedAt, nil
  8744. }
  8745. // ResetCreatedAt resets all changes to the "created_at" field.
  8746. func (m *CategoryMutation) ResetCreatedAt() {
  8747. m.created_at = nil
  8748. }
  8749. // SetUpdatedAt sets the "updated_at" field.
  8750. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  8751. m.updated_at = &t
  8752. }
  8753. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8754. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  8755. v := m.updated_at
  8756. if v == nil {
  8757. return
  8758. }
  8759. return *v, true
  8760. }
  8761. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  8762. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8764. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8765. if !m.op.Is(OpUpdateOne) {
  8766. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8767. }
  8768. if m.id == nil || m.oldValue == nil {
  8769. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8770. }
  8771. oldValue, err := m.oldValue(ctx)
  8772. if err != nil {
  8773. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8774. }
  8775. return oldValue.UpdatedAt, nil
  8776. }
  8777. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8778. func (m *CategoryMutation) ResetUpdatedAt() {
  8779. m.updated_at = nil
  8780. }
  8781. // SetDeletedAt sets the "deleted_at" field.
  8782. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  8783. m.deleted_at = &t
  8784. }
  8785. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8786. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  8787. v := m.deleted_at
  8788. if v == nil {
  8789. return
  8790. }
  8791. return *v, true
  8792. }
  8793. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  8794. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8796. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8797. if !m.op.Is(OpUpdateOne) {
  8798. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8799. }
  8800. if m.id == nil || m.oldValue == nil {
  8801. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8802. }
  8803. oldValue, err := m.oldValue(ctx)
  8804. if err != nil {
  8805. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8806. }
  8807. return oldValue.DeletedAt, nil
  8808. }
  8809. // ClearDeletedAt clears the value of the "deleted_at" field.
  8810. func (m *CategoryMutation) ClearDeletedAt() {
  8811. m.deleted_at = nil
  8812. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  8813. }
  8814. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8815. func (m *CategoryMutation) DeletedAtCleared() bool {
  8816. _, ok := m.clearedFields[category.FieldDeletedAt]
  8817. return ok
  8818. }
  8819. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8820. func (m *CategoryMutation) ResetDeletedAt() {
  8821. m.deleted_at = nil
  8822. delete(m.clearedFields, category.FieldDeletedAt)
  8823. }
  8824. // SetName sets the "name" field.
  8825. func (m *CategoryMutation) SetName(s string) {
  8826. m.name = &s
  8827. }
  8828. // Name returns the value of the "name" field in the mutation.
  8829. func (m *CategoryMutation) Name() (r string, exists bool) {
  8830. v := m.name
  8831. if v == nil {
  8832. return
  8833. }
  8834. return *v, true
  8835. }
  8836. // OldName returns the old "name" field's value of the Category entity.
  8837. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8839. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  8840. if !m.op.Is(OpUpdateOne) {
  8841. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8842. }
  8843. if m.id == nil || m.oldValue == nil {
  8844. return v, errors.New("OldName requires an ID field in the mutation")
  8845. }
  8846. oldValue, err := m.oldValue(ctx)
  8847. if err != nil {
  8848. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8849. }
  8850. return oldValue.Name, nil
  8851. }
  8852. // ResetName resets all changes to the "name" field.
  8853. func (m *CategoryMutation) ResetName() {
  8854. m.name = nil
  8855. }
  8856. // SetOrganizationID sets the "organization_id" field.
  8857. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  8858. m.organization_id = &u
  8859. m.addorganization_id = nil
  8860. }
  8861. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8862. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  8863. v := m.organization_id
  8864. if v == nil {
  8865. return
  8866. }
  8867. return *v, true
  8868. }
  8869. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  8870. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8872. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8873. if !m.op.Is(OpUpdateOne) {
  8874. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8875. }
  8876. if m.id == nil || m.oldValue == nil {
  8877. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8878. }
  8879. oldValue, err := m.oldValue(ctx)
  8880. if err != nil {
  8881. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8882. }
  8883. return oldValue.OrganizationID, nil
  8884. }
  8885. // AddOrganizationID adds u to the "organization_id" field.
  8886. func (m *CategoryMutation) AddOrganizationID(u int64) {
  8887. if m.addorganization_id != nil {
  8888. *m.addorganization_id += u
  8889. } else {
  8890. m.addorganization_id = &u
  8891. }
  8892. }
  8893. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8894. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  8895. v := m.addorganization_id
  8896. if v == nil {
  8897. return
  8898. }
  8899. return *v, true
  8900. }
  8901. // ResetOrganizationID resets all changes to the "organization_id" field.
  8902. func (m *CategoryMutation) ResetOrganizationID() {
  8903. m.organization_id = nil
  8904. m.addorganization_id = nil
  8905. }
  8906. // Where appends a list predicates to the CategoryMutation builder.
  8907. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  8908. m.predicates = append(m.predicates, ps...)
  8909. }
  8910. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  8911. // users can use type-assertion to append predicates that do not depend on any generated package.
  8912. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  8913. p := make([]predicate.Category, len(ps))
  8914. for i := range ps {
  8915. p[i] = ps[i]
  8916. }
  8917. m.Where(p...)
  8918. }
  8919. // Op returns the operation name.
  8920. func (m *CategoryMutation) Op() Op {
  8921. return m.op
  8922. }
  8923. // SetOp allows setting the mutation operation.
  8924. func (m *CategoryMutation) SetOp(op Op) {
  8925. m.op = op
  8926. }
  8927. // Type returns the node type of this mutation (Category).
  8928. func (m *CategoryMutation) Type() string {
  8929. return m.typ
  8930. }
  8931. // Fields returns all fields that were changed during this mutation. Note that in
  8932. // order to get all numeric fields that were incremented/decremented, call
  8933. // AddedFields().
  8934. func (m *CategoryMutation) Fields() []string {
  8935. fields := make([]string, 0, 5)
  8936. if m.created_at != nil {
  8937. fields = append(fields, category.FieldCreatedAt)
  8938. }
  8939. if m.updated_at != nil {
  8940. fields = append(fields, category.FieldUpdatedAt)
  8941. }
  8942. if m.deleted_at != nil {
  8943. fields = append(fields, category.FieldDeletedAt)
  8944. }
  8945. if m.name != nil {
  8946. fields = append(fields, category.FieldName)
  8947. }
  8948. if m.organization_id != nil {
  8949. fields = append(fields, category.FieldOrganizationID)
  8950. }
  8951. return fields
  8952. }
  8953. // Field returns the value of a field with the given name. The second boolean
  8954. // return value indicates that this field was not set, or was not defined in the
  8955. // schema.
  8956. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  8957. switch name {
  8958. case category.FieldCreatedAt:
  8959. return m.CreatedAt()
  8960. case category.FieldUpdatedAt:
  8961. return m.UpdatedAt()
  8962. case category.FieldDeletedAt:
  8963. return m.DeletedAt()
  8964. case category.FieldName:
  8965. return m.Name()
  8966. case category.FieldOrganizationID:
  8967. return m.OrganizationID()
  8968. }
  8969. return nil, false
  8970. }
  8971. // OldField returns the old value of the field from the database. An error is
  8972. // returned if the mutation operation is not UpdateOne, or the query to the
  8973. // database failed.
  8974. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8975. switch name {
  8976. case category.FieldCreatedAt:
  8977. return m.OldCreatedAt(ctx)
  8978. case category.FieldUpdatedAt:
  8979. return m.OldUpdatedAt(ctx)
  8980. case category.FieldDeletedAt:
  8981. return m.OldDeletedAt(ctx)
  8982. case category.FieldName:
  8983. return m.OldName(ctx)
  8984. case category.FieldOrganizationID:
  8985. return m.OldOrganizationID(ctx)
  8986. }
  8987. return nil, fmt.Errorf("unknown Category field %s", name)
  8988. }
  8989. // SetField sets the value of a field with the given name. It returns an error if
  8990. // the field is not defined in the schema, or if the type mismatched the field
  8991. // type.
  8992. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  8993. switch name {
  8994. case category.FieldCreatedAt:
  8995. v, ok := value.(time.Time)
  8996. if !ok {
  8997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8998. }
  8999. m.SetCreatedAt(v)
  9000. return nil
  9001. case category.FieldUpdatedAt:
  9002. v, ok := value.(time.Time)
  9003. if !ok {
  9004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9005. }
  9006. m.SetUpdatedAt(v)
  9007. return nil
  9008. case category.FieldDeletedAt:
  9009. v, ok := value.(time.Time)
  9010. if !ok {
  9011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9012. }
  9013. m.SetDeletedAt(v)
  9014. return nil
  9015. case category.FieldName:
  9016. v, ok := value.(string)
  9017. if !ok {
  9018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9019. }
  9020. m.SetName(v)
  9021. return nil
  9022. case category.FieldOrganizationID:
  9023. v, ok := value.(uint64)
  9024. if !ok {
  9025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9026. }
  9027. m.SetOrganizationID(v)
  9028. return nil
  9029. }
  9030. return fmt.Errorf("unknown Category field %s", name)
  9031. }
  9032. // AddedFields returns all numeric fields that were incremented/decremented during
  9033. // this mutation.
  9034. func (m *CategoryMutation) AddedFields() []string {
  9035. var fields []string
  9036. if m.addorganization_id != nil {
  9037. fields = append(fields, category.FieldOrganizationID)
  9038. }
  9039. return fields
  9040. }
  9041. // AddedField returns the numeric value that was incremented/decremented on a field
  9042. // with the given name. The second boolean return value indicates that this field
  9043. // was not set, or was not defined in the schema.
  9044. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  9045. switch name {
  9046. case category.FieldOrganizationID:
  9047. return m.AddedOrganizationID()
  9048. }
  9049. return nil, false
  9050. }
  9051. // AddField adds the value to the field with the given name. It returns an error if
  9052. // the field is not defined in the schema, or if the type mismatched the field
  9053. // type.
  9054. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  9055. switch name {
  9056. case category.FieldOrganizationID:
  9057. v, ok := value.(int64)
  9058. if !ok {
  9059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9060. }
  9061. m.AddOrganizationID(v)
  9062. return nil
  9063. }
  9064. return fmt.Errorf("unknown Category numeric field %s", name)
  9065. }
  9066. // ClearedFields returns all nullable fields that were cleared during this
  9067. // mutation.
  9068. func (m *CategoryMutation) ClearedFields() []string {
  9069. var fields []string
  9070. if m.FieldCleared(category.FieldDeletedAt) {
  9071. fields = append(fields, category.FieldDeletedAt)
  9072. }
  9073. return fields
  9074. }
  9075. // FieldCleared returns a boolean indicating if a field with the given name was
  9076. // cleared in this mutation.
  9077. func (m *CategoryMutation) FieldCleared(name string) bool {
  9078. _, ok := m.clearedFields[name]
  9079. return ok
  9080. }
  9081. // ClearField clears the value of the field with the given name. It returns an
  9082. // error if the field is not defined in the schema.
  9083. func (m *CategoryMutation) ClearField(name string) error {
  9084. switch name {
  9085. case category.FieldDeletedAt:
  9086. m.ClearDeletedAt()
  9087. return nil
  9088. }
  9089. return fmt.Errorf("unknown Category nullable field %s", name)
  9090. }
  9091. // ResetField resets all changes in the mutation for the field with the given name.
  9092. // It returns an error if the field is not defined in the schema.
  9093. func (m *CategoryMutation) ResetField(name string) error {
  9094. switch name {
  9095. case category.FieldCreatedAt:
  9096. m.ResetCreatedAt()
  9097. return nil
  9098. case category.FieldUpdatedAt:
  9099. m.ResetUpdatedAt()
  9100. return nil
  9101. case category.FieldDeletedAt:
  9102. m.ResetDeletedAt()
  9103. return nil
  9104. case category.FieldName:
  9105. m.ResetName()
  9106. return nil
  9107. case category.FieldOrganizationID:
  9108. m.ResetOrganizationID()
  9109. return nil
  9110. }
  9111. return fmt.Errorf("unknown Category field %s", name)
  9112. }
  9113. // AddedEdges returns all edge names that were set/added in this mutation.
  9114. func (m *CategoryMutation) AddedEdges() []string {
  9115. edges := make([]string, 0, 0)
  9116. return edges
  9117. }
  9118. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9119. // name in this mutation.
  9120. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  9121. return nil
  9122. }
  9123. // RemovedEdges returns all edge names that were removed in this mutation.
  9124. func (m *CategoryMutation) RemovedEdges() []string {
  9125. edges := make([]string, 0, 0)
  9126. return edges
  9127. }
  9128. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9129. // the given name in this mutation.
  9130. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  9131. return nil
  9132. }
  9133. // ClearedEdges returns all edge names that were cleared in this mutation.
  9134. func (m *CategoryMutation) ClearedEdges() []string {
  9135. edges := make([]string, 0, 0)
  9136. return edges
  9137. }
  9138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9139. // was cleared in this mutation.
  9140. func (m *CategoryMutation) EdgeCleared(name string) bool {
  9141. return false
  9142. }
  9143. // ClearEdge clears the value of the edge with the given name. It returns an error
  9144. // if that edge is not defined in the schema.
  9145. func (m *CategoryMutation) ClearEdge(name string) error {
  9146. return fmt.Errorf("unknown Category unique edge %s", name)
  9147. }
  9148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9149. // It returns an error if the edge is not defined in the schema.
  9150. func (m *CategoryMutation) ResetEdge(name string) error {
  9151. return fmt.Errorf("unknown Category edge %s", name)
  9152. }
  9153. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  9154. type ChatRecordsMutation struct {
  9155. config
  9156. op Op
  9157. typ string
  9158. id *uint64
  9159. created_at *time.Time
  9160. updated_at *time.Time
  9161. deleted_at *time.Time
  9162. content *string
  9163. content_type *uint8
  9164. addcontent_type *int8
  9165. session_id *uint64
  9166. addsession_id *int64
  9167. user_id *uint64
  9168. adduser_id *int64
  9169. bot_id *uint64
  9170. addbot_id *int64
  9171. bot_type *uint8
  9172. addbot_type *int8
  9173. clearedFields map[string]struct{}
  9174. done bool
  9175. oldValue func(context.Context) (*ChatRecords, error)
  9176. predicates []predicate.ChatRecords
  9177. }
  9178. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  9179. // chatrecordsOption allows management of the mutation configuration using functional options.
  9180. type chatrecordsOption func(*ChatRecordsMutation)
  9181. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  9182. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  9183. m := &ChatRecordsMutation{
  9184. config: c,
  9185. op: op,
  9186. typ: TypeChatRecords,
  9187. clearedFields: make(map[string]struct{}),
  9188. }
  9189. for _, opt := range opts {
  9190. opt(m)
  9191. }
  9192. return m
  9193. }
  9194. // withChatRecordsID sets the ID field of the mutation.
  9195. func withChatRecordsID(id uint64) chatrecordsOption {
  9196. return func(m *ChatRecordsMutation) {
  9197. var (
  9198. err error
  9199. once sync.Once
  9200. value *ChatRecords
  9201. )
  9202. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  9203. once.Do(func() {
  9204. if m.done {
  9205. err = errors.New("querying old values post mutation is not allowed")
  9206. } else {
  9207. value, err = m.Client().ChatRecords.Get(ctx, id)
  9208. }
  9209. })
  9210. return value, err
  9211. }
  9212. m.id = &id
  9213. }
  9214. }
  9215. // withChatRecords sets the old ChatRecords of the mutation.
  9216. func withChatRecords(node *ChatRecords) chatrecordsOption {
  9217. return func(m *ChatRecordsMutation) {
  9218. m.oldValue = func(context.Context) (*ChatRecords, error) {
  9219. return node, nil
  9220. }
  9221. m.id = &node.ID
  9222. }
  9223. }
  9224. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9225. // executed in a transaction (ent.Tx), a transactional client is returned.
  9226. func (m ChatRecordsMutation) Client() *Client {
  9227. client := &Client{config: m.config}
  9228. client.init()
  9229. return client
  9230. }
  9231. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9232. // it returns an error otherwise.
  9233. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  9234. if _, ok := m.driver.(*txDriver); !ok {
  9235. return nil, errors.New("ent: mutation is not running in a transaction")
  9236. }
  9237. tx := &Tx{config: m.config}
  9238. tx.init()
  9239. return tx, nil
  9240. }
  9241. // SetID sets the value of the id field. Note that this
  9242. // operation is only accepted on creation of ChatRecords entities.
  9243. func (m *ChatRecordsMutation) SetID(id uint64) {
  9244. m.id = &id
  9245. }
  9246. // ID returns the ID value in the mutation. Note that the ID is only available
  9247. // if it was provided to the builder or after it was returned from the database.
  9248. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  9249. if m.id == nil {
  9250. return
  9251. }
  9252. return *m.id, true
  9253. }
  9254. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9255. // That means, if the mutation is applied within a transaction with an isolation level such
  9256. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9257. // or updated by the mutation.
  9258. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9259. switch {
  9260. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9261. id, exists := m.ID()
  9262. if exists {
  9263. return []uint64{id}, nil
  9264. }
  9265. fallthrough
  9266. case m.op.Is(OpUpdate | OpDelete):
  9267. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  9268. default:
  9269. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9270. }
  9271. }
  9272. // SetCreatedAt sets the "created_at" field.
  9273. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  9274. m.created_at = &t
  9275. }
  9276. // CreatedAt returns the value of the "created_at" field in the mutation.
  9277. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9278. v := m.created_at
  9279. if v == nil {
  9280. return
  9281. }
  9282. return *v, true
  9283. }
  9284. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  9285. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9287. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9288. if !m.op.Is(OpUpdateOne) {
  9289. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9290. }
  9291. if m.id == nil || m.oldValue == nil {
  9292. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9293. }
  9294. oldValue, err := m.oldValue(ctx)
  9295. if err != nil {
  9296. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9297. }
  9298. return oldValue.CreatedAt, nil
  9299. }
  9300. // ResetCreatedAt resets all changes to the "created_at" field.
  9301. func (m *ChatRecordsMutation) ResetCreatedAt() {
  9302. m.created_at = nil
  9303. }
  9304. // SetUpdatedAt sets the "updated_at" field.
  9305. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  9306. m.updated_at = &t
  9307. }
  9308. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9309. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9310. v := m.updated_at
  9311. if v == nil {
  9312. return
  9313. }
  9314. return *v, true
  9315. }
  9316. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  9317. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9319. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9320. if !m.op.Is(OpUpdateOne) {
  9321. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9322. }
  9323. if m.id == nil || m.oldValue == nil {
  9324. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9325. }
  9326. oldValue, err := m.oldValue(ctx)
  9327. if err != nil {
  9328. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9329. }
  9330. return oldValue.UpdatedAt, nil
  9331. }
  9332. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9333. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  9334. m.updated_at = nil
  9335. }
  9336. // SetDeletedAt sets the "deleted_at" field.
  9337. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  9338. m.deleted_at = &t
  9339. }
  9340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9341. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9342. v := m.deleted_at
  9343. if v == nil {
  9344. return
  9345. }
  9346. return *v, true
  9347. }
  9348. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  9349. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9351. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9352. if !m.op.Is(OpUpdateOne) {
  9353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9354. }
  9355. if m.id == nil || m.oldValue == nil {
  9356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9357. }
  9358. oldValue, err := m.oldValue(ctx)
  9359. if err != nil {
  9360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9361. }
  9362. return oldValue.DeletedAt, nil
  9363. }
  9364. // ClearDeletedAt clears the value of the "deleted_at" field.
  9365. func (m *ChatRecordsMutation) ClearDeletedAt() {
  9366. m.deleted_at = nil
  9367. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  9368. }
  9369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9370. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  9371. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  9372. return ok
  9373. }
  9374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9375. func (m *ChatRecordsMutation) ResetDeletedAt() {
  9376. m.deleted_at = nil
  9377. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  9378. }
  9379. // SetContent sets the "content" field.
  9380. func (m *ChatRecordsMutation) SetContent(s string) {
  9381. m.content = &s
  9382. }
  9383. // Content returns the value of the "content" field in the mutation.
  9384. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  9385. v := m.content
  9386. if v == nil {
  9387. return
  9388. }
  9389. return *v, true
  9390. }
  9391. // OldContent returns the old "content" field's value of the ChatRecords entity.
  9392. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9394. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9395. if !m.op.Is(OpUpdateOne) {
  9396. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9397. }
  9398. if m.id == nil || m.oldValue == nil {
  9399. return v, errors.New("OldContent requires an ID field in the mutation")
  9400. }
  9401. oldValue, err := m.oldValue(ctx)
  9402. if err != nil {
  9403. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9404. }
  9405. return oldValue.Content, nil
  9406. }
  9407. // ResetContent resets all changes to the "content" field.
  9408. func (m *ChatRecordsMutation) ResetContent() {
  9409. m.content = nil
  9410. }
  9411. // SetContentType sets the "content_type" field.
  9412. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  9413. m.content_type = &u
  9414. m.addcontent_type = nil
  9415. }
  9416. // ContentType returns the value of the "content_type" field in the mutation.
  9417. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  9418. v := m.content_type
  9419. if v == nil {
  9420. return
  9421. }
  9422. return *v, true
  9423. }
  9424. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  9425. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9427. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  9428. if !m.op.Is(OpUpdateOne) {
  9429. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9430. }
  9431. if m.id == nil || m.oldValue == nil {
  9432. return v, errors.New("OldContentType requires an ID field in the mutation")
  9433. }
  9434. oldValue, err := m.oldValue(ctx)
  9435. if err != nil {
  9436. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9437. }
  9438. return oldValue.ContentType, nil
  9439. }
  9440. // AddContentType adds u to the "content_type" field.
  9441. func (m *ChatRecordsMutation) AddContentType(u int8) {
  9442. if m.addcontent_type != nil {
  9443. *m.addcontent_type += u
  9444. } else {
  9445. m.addcontent_type = &u
  9446. }
  9447. }
  9448. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9449. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  9450. v := m.addcontent_type
  9451. if v == nil {
  9452. return
  9453. }
  9454. return *v, true
  9455. }
  9456. // ResetContentType resets all changes to the "content_type" field.
  9457. func (m *ChatRecordsMutation) ResetContentType() {
  9458. m.content_type = nil
  9459. m.addcontent_type = nil
  9460. }
  9461. // SetSessionID sets the "session_id" field.
  9462. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  9463. m.session_id = &u
  9464. m.addsession_id = nil
  9465. }
  9466. // SessionID returns the value of the "session_id" field in the mutation.
  9467. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  9468. v := m.session_id
  9469. if v == nil {
  9470. return
  9471. }
  9472. return *v, true
  9473. }
  9474. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  9475. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9477. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  9478. if !m.op.Is(OpUpdateOne) {
  9479. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  9480. }
  9481. if m.id == nil || m.oldValue == nil {
  9482. return v, errors.New("OldSessionID requires an ID field in the mutation")
  9483. }
  9484. oldValue, err := m.oldValue(ctx)
  9485. if err != nil {
  9486. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  9487. }
  9488. return oldValue.SessionID, nil
  9489. }
  9490. // AddSessionID adds u to the "session_id" field.
  9491. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  9492. if m.addsession_id != nil {
  9493. *m.addsession_id += u
  9494. } else {
  9495. m.addsession_id = &u
  9496. }
  9497. }
  9498. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  9499. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  9500. v := m.addsession_id
  9501. if v == nil {
  9502. return
  9503. }
  9504. return *v, true
  9505. }
  9506. // ResetSessionID resets all changes to the "session_id" field.
  9507. func (m *ChatRecordsMutation) ResetSessionID() {
  9508. m.session_id = nil
  9509. m.addsession_id = nil
  9510. }
  9511. // SetUserID sets the "user_id" field.
  9512. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  9513. m.user_id = &u
  9514. m.adduser_id = nil
  9515. }
  9516. // UserID returns the value of the "user_id" field in the mutation.
  9517. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  9518. v := m.user_id
  9519. if v == nil {
  9520. return
  9521. }
  9522. return *v, true
  9523. }
  9524. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  9525. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9527. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9528. if !m.op.Is(OpUpdateOne) {
  9529. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9530. }
  9531. if m.id == nil || m.oldValue == nil {
  9532. return v, errors.New("OldUserID requires an ID field in the mutation")
  9533. }
  9534. oldValue, err := m.oldValue(ctx)
  9535. if err != nil {
  9536. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9537. }
  9538. return oldValue.UserID, nil
  9539. }
  9540. // AddUserID adds u to the "user_id" field.
  9541. func (m *ChatRecordsMutation) AddUserID(u int64) {
  9542. if m.adduser_id != nil {
  9543. *m.adduser_id += u
  9544. } else {
  9545. m.adduser_id = &u
  9546. }
  9547. }
  9548. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9549. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  9550. v := m.adduser_id
  9551. if v == nil {
  9552. return
  9553. }
  9554. return *v, true
  9555. }
  9556. // ResetUserID resets all changes to the "user_id" field.
  9557. func (m *ChatRecordsMutation) ResetUserID() {
  9558. m.user_id = nil
  9559. m.adduser_id = nil
  9560. }
  9561. // SetBotID sets the "bot_id" field.
  9562. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  9563. m.bot_id = &u
  9564. m.addbot_id = nil
  9565. }
  9566. // BotID returns the value of the "bot_id" field in the mutation.
  9567. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  9568. v := m.bot_id
  9569. if v == nil {
  9570. return
  9571. }
  9572. return *v, true
  9573. }
  9574. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  9575. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9577. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9578. if !m.op.Is(OpUpdateOne) {
  9579. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9580. }
  9581. if m.id == nil || m.oldValue == nil {
  9582. return v, errors.New("OldBotID requires an ID field in the mutation")
  9583. }
  9584. oldValue, err := m.oldValue(ctx)
  9585. if err != nil {
  9586. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9587. }
  9588. return oldValue.BotID, nil
  9589. }
  9590. // AddBotID adds u to the "bot_id" field.
  9591. func (m *ChatRecordsMutation) AddBotID(u int64) {
  9592. if m.addbot_id != nil {
  9593. *m.addbot_id += u
  9594. } else {
  9595. m.addbot_id = &u
  9596. }
  9597. }
  9598. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9599. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  9600. v := m.addbot_id
  9601. if v == nil {
  9602. return
  9603. }
  9604. return *v, true
  9605. }
  9606. // ResetBotID resets all changes to the "bot_id" field.
  9607. func (m *ChatRecordsMutation) ResetBotID() {
  9608. m.bot_id = nil
  9609. m.addbot_id = nil
  9610. }
  9611. // SetBotType sets the "bot_type" field.
  9612. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  9613. m.bot_type = &u
  9614. m.addbot_type = nil
  9615. }
  9616. // BotType returns the value of the "bot_type" field in the mutation.
  9617. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  9618. v := m.bot_type
  9619. if v == nil {
  9620. return
  9621. }
  9622. return *v, true
  9623. }
  9624. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  9625. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9627. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9628. if !m.op.Is(OpUpdateOne) {
  9629. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9630. }
  9631. if m.id == nil || m.oldValue == nil {
  9632. return v, errors.New("OldBotType requires an ID field in the mutation")
  9633. }
  9634. oldValue, err := m.oldValue(ctx)
  9635. if err != nil {
  9636. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9637. }
  9638. return oldValue.BotType, nil
  9639. }
  9640. // AddBotType adds u to the "bot_type" field.
  9641. func (m *ChatRecordsMutation) AddBotType(u int8) {
  9642. if m.addbot_type != nil {
  9643. *m.addbot_type += u
  9644. } else {
  9645. m.addbot_type = &u
  9646. }
  9647. }
  9648. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9649. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  9650. v := m.addbot_type
  9651. if v == nil {
  9652. return
  9653. }
  9654. return *v, true
  9655. }
  9656. // ResetBotType resets all changes to the "bot_type" field.
  9657. func (m *ChatRecordsMutation) ResetBotType() {
  9658. m.bot_type = nil
  9659. m.addbot_type = nil
  9660. }
  9661. // Where appends a list predicates to the ChatRecordsMutation builder.
  9662. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  9663. m.predicates = append(m.predicates, ps...)
  9664. }
  9665. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  9666. // users can use type-assertion to append predicates that do not depend on any generated package.
  9667. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  9668. p := make([]predicate.ChatRecords, len(ps))
  9669. for i := range ps {
  9670. p[i] = ps[i]
  9671. }
  9672. m.Where(p...)
  9673. }
  9674. // Op returns the operation name.
  9675. func (m *ChatRecordsMutation) Op() Op {
  9676. return m.op
  9677. }
  9678. // SetOp allows setting the mutation operation.
  9679. func (m *ChatRecordsMutation) SetOp(op Op) {
  9680. m.op = op
  9681. }
  9682. // Type returns the node type of this mutation (ChatRecords).
  9683. func (m *ChatRecordsMutation) Type() string {
  9684. return m.typ
  9685. }
  9686. // Fields returns all fields that were changed during this mutation. Note that in
  9687. // order to get all numeric fields that were incremented/decremented, call
  9688. // AddedFields().
  9689. func (m *ChatRecordsMutation) Fields() []string {
  9690. fields := make([]string, 0, 9)
  9691. if m.created_at != nil {
  9692. fields = append(fields, chatrecords.FieldCreatedAt)
  9693. }
  9694. if m.updated_at != nil {
  9695. fields = append(fields, chatrecords.FieldUpdatedAt)
  9696. }
  9697. if m.deleted_at != nil {
  9698. fields = append(fields, chatrecords.FieldDeletedAt)
  9699. }
  9700. if m.content != nil {
  9701. fields = append(fields, chatrecords.FieldContent)
  9702. }
  9703. if m.content_type != nil {
  9704. fields = append(fields, chatrecords.FieldContentType)
  9705. }
  9706. if m.session_id != nil {
  9707. fields = append(fields, chatrecords.FieldSessionID)
  9708. }
  9709. if m.user_id != nil {
  9710. fields = append(fields, chatrecords.FieldUserID)
  9711. }
  9712. if m.bot_id != nil {
  9713. fields = append(fields, chatrecords.FieldBotID)
  9714. }
  9715. if m.bot_type != nil {
  9716. fields = append(fields, chatrecords.FieldBotType)
  9717. }
  9718. return fields
  9719. }
  9720. // Field returns the value of a field with the given name. The second boolean
  9721. // return value indicates that this field was not set, or was not defined in the
  9722. // schema.
  9723. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  9724. switch name {
  9725. case chatrecords.FieldCreatedAt:
  9726. return m.CreatedAt()
  9727. case chatrecords.FieldUpdatedAt:
  9728. return m.UpdatedAt()
  9729. case chatrecords.FieldDeletedAt:
  9730. return m.DeletedAt()
  9731. case chatrecords.FieldContent:
  9732. return m.Content()
  9733. case chatrecords.FieldContentType:
  9734. return m.ContentType()
  9735. case chatrecords.FieldSessionID:
  9736. return m.SessionID()
  9737. case chatrecords.FieldUserID:
  9738. return m.UserID()
  9739. case chatrecords.FieldBotID:
  9740. return m.BotID()
  9741. case chatrecords.FieldBotType:
  9742. return m.BotType()
  9743. }
  9744. return nil, false
  9745. }
  9746. // OldField returns the old value of the field from the database. An error is
  9747. // returned if the mutation operation is not UpdateOne, or the query to the
  9748. // database failed.
  9749. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9750. switch name {
  9751. case chatrecords.FieldCreatedAt:
  9752. return m.OldCreatedAt(ctx)
  9753. case chatrecords.FieldUpdatedAt:
  9754. return m.OldUpdatedAt(ctx)
  9755. case chatrecords.FieldDeletedAt:
  9756. return m.OldDeletedAt(ctx)
  9757. case chatrecords.FieldContent:
  9758. return m.OldContent(ctx)
  9759. case chatrecords.FieldContentType:
  9760. return m.OldContentType(ctx)
  9761. case chatrecords.FieldSessionID:
  9762. return m.OldSessionID(ctx)
  9763. case chatrecords.FieldUserID:
  9764. return m.OldUserID(ctx)
  9765. case chatrecords.FieldBotID:
  9766. return m.OldBotID(ctx)
  9767. case chatrecords.FieldBotType:
  9768. return m.OldBotType(ctx)
  9769. }
  9770. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  9771. }
  9772. // SetField sets the value of a field with the given name. It returns an error if
  9773. // the field is not defined in the schema, or if the type mismatched the field
  9774. // type.
  9775. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  9776. switch name {
  9777. case chatrecords.FieldCreatedAt:
  9778. v, ok := value.(time.Time)
  9779. if !ok {
  9780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9781. }
  9782. m.SetCreatedAt(v)
  9783. return nil
  9784. case chatrecords.FieldUpdatedAt:
  9785. v, ok := value.(time.Time)
  9786. if !ok {
  9787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9788. }
  9789. m.SetUpdatedAt(v)
  9790. return nil
  9791. case chatrecords.FieldDeletedAt:
  9792. v, ok := value.(time.Time)
  9793. if !ok {
  9794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9795. }
  9796. m.SetDeletedAt(v)
  9797. return nil
  9798. case chatrecords.FieldContent:
  9799. v, ok := value.(string)
  9800. if !ok {
  9801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9802. }
  9803. m.SetContent(v)
  9804. return nil
  9805. case chatrecords.FieldContentType:
  9806. v, ok := value.(uint8)
  9807. if !ok {
  9808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9809. }
  9810. m.SetContentType(v)
  9811. return nil
  9812. case chatrecords.FieldSessionID:
  9813. v, ok := value.(uint64)
  9814. if !ok {
  9815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9816. }
  9817. m.SetSessionID(v)
  9818. return nil
  9819. case chatrecords.FieldUserID:
  9820. v, ok := value.(uint64)
  9821. if !ok {
  9822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9823. }
  9824. m.SetUserID(v)
  9825. return nil
  9826. case chatrecords.FieldBotID:
  9827. v, ok := value.(uint64)
  9828. if !ok {
  9829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9830. }
  9831. m.SetBotID(v)
  9832. return nil
  9833. case chatrecords.FieldBotType:
  9834. v, ok := value.(uint8)
  9835. if !ok {
  9836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9837. }
  9838. m.SetBotType(v)
  9839. return nil
  9840. }
  9841. return fmt.Errorf("unknown ChatRecords field %s", name)
  9842. }
  9843. // AddedFields returns all numeric fields that were incremented/decremented during
  9844. // this mutation.
  9845. func (m *ChatRecordsMutation) AddedFields() []string {
  9846. var fields []string
  9847. if m.addcontent_type != nil {
  9848. fields = append(fields, chatrecords.FieldContentType)
  9849. }
  9850. if m.addsession_id != nil {
  9851. fields = append(fields, chatrecords.FieldSessionID)
  9852. }
  9853. if m.adduser_id != nil {
  9854. fields = append(fields, chatrecords.FieldUserID)
  9855. }
  9856. if m.addbot_id != nil {
  9857. fields = append(fields, chatrecords.FieldBotID)
  9858. }
  9859. if m.addbot_type != nil {
  9860. fields = append(fields, chatrecords.FieldBotType)
  9861. }
  9862. return fields
  9863. }
  9864. // AddedField returns the numeric value that was incremented/decremented on a field
  9865. // with the given name. The second boolean return value indicates that this field
  9866. // was not set, or was not defined in the schema.
  9867. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9868. switch name {
  9869. case chatrecords.FieldContentType:
  9870. return m.AddedContentType()
  9871. case chatrecords.FieldSessionID:
  9872. return m.AddedSessionID()
  9873. case chatrecords.FieldUserID:
  9874. return m.AddedUserID()
  9875. case chatrecords.FieldBotID:
  9876. return m.AddedBotID()
  9877. case chatrecords.FieldBotType:
  9878. return m.AddedBotType()
  9879. }
  9880. return nil, false
  9881. }
  9882. // AddField adds the value to the field with the given name. It returns an error if
  9883. // the field is not defined in the schema, or if the type mismatched the field
  9884. // type.
  9885. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  9886. switch name {
  9887. case chatrecords.FieldContentType:
  9888. v, ok := value.(int8)
  9889. if !ok {
  9890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9891. }
  9892. m.AddContentType(v)
  9893. return nil
  9894. case chatrecords.FieldSessionID:
  9895. v, ok := value.(int64)
  9896. if !ok {
  9897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9898. }
  9899. m.AddSessionID(v)
  9900. return nil
  9901. case chatrecords.FieldUserID:
  9902. v, ok := value.(int64)
  9903. if !ok {
  9904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9905. }
  9906. m.AddUserID(v)
  9907. return nil
  9908. case chatrecords.FieldBotID:
  9909. v, ok := value.(int64)
  9910. if !ok {
  9911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9912. }
  9913. m.AddBotID(v)
  9914. return nil
  9915. case chatrecords.FieldBotType:
  9916. v, ok := value.(int8)
  9917. if !ok {
  9918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9919. }
  9920. m.AddBotType(v)
  9921. return nil
  9922. }
  9923. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  9924. }
  9925. // ClearedFields returns all nullable fields that were cleared during this
  9926. // mutation.
  9927. func (m *ChatRecordsMutation) ClearedFields() []string {
  9928. var fields []string
  9929. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  9930. fields = append(fields, chatrecords.FieldDeletedAt)
  9931. }
  9932. return fields
  9933. }
  9934. // FieldCleared returns a boolean indicating if a field with the given name was
  9935. // cleared in this mutation.
  9936. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  9937. _, ok := m.clearedFields[name]
  9938. return ok
  9939. }
  9940. // ClearField clears the value of the field with the given name. It returns an
  9941. // error if the field is not defined in the schema.
  9942. func (m *ChatRecordsMutation) ClearField(name string) error {
  9943. switch name {
  9944. case chatrecords.FieldDeletedAt:
  9945. m.ClearDeletedAt()
  9946. return nil
  9947. }
  9948. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  9949. }
  9950. // ResetField resets all changes in the mutation for the field with the given name.
  9951. // It returns an error if the field is not defined in the schema.
  9952. func (m *ChatRecordsMutation) ResetField(name string) error {
  9953. switch name {
  9954. case chatrecords.FieldCreatedAt:
  9955. m.ResetCreatedAt()
  9956. return nil
  9957. case chatrecords.FieldUpdatedAt:
  9958. m.ResetUpdatedAt()
  9959. return nil
  9960. case chatrecords.FieldDeletedAt:
  9961. m.ResetDeletedAt()
  9962. return nil
  9963. case chatrecords.FieldContent:
  9964. m.ResetContent()
  9965. return nil
  9966. case chatrecords.FieldContentType:
  9967. m.ResetContentType()
  9968. return nil
  9969. case chatrecords.FieldSessionID:
  9970. m.ResetSessionID()
  9971. return nil
  9972. case chatrecords.FieldUserID:
  9973. m.ResetUserID()
  9974. return nil
  9975. case chatrecords.FieldBotID:
  9976. m.ResetBotID()
  9977. return nil
  9978. case chatrecords.FieldBotType:
  9979. m.ResetBotType()
  9980. return nil
  9981. }
  9982. return fmt.Errorf("unknown ChatRecords field %s", name)
  9983. }
  9984. // AddedEdges returns all edge names that were set/added in this mutation.
  9985. func (m *ChatRecordsMutation) AddedEdges() []string {
  9986. edges := make([]string, 0, 0)
  9987. return edges
  9988. }
  9989. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9990. // name in this mutation.
  9991. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  9992. return nil
  9993. }
  9994. // RemovedEdges returns all edge names that were removed in this mutation.
  9995. func (m *ChatRecordsMutation) RemovedEdges() []string {
  9996. edges := make([]string, 0, 0)
  9997. return edges
  9998. }
  9999. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10000. // the given name in this mutation.
  10001. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  10002. return nil
  10003. }
  10004. // ClearedEdges returns all edge names that were cleared in this mutation.
  10005. func (m *ChatRecordsMutation) ClearedEdges() []string {
  10006. edges := make([]string, 0, 0)
  10007. return edges
  10008. }
  10009. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10010. // was cleared in this mutation.
  10011. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  10012. return false
  10013. }
  10014. // ClearEdge clears the value of the edge with the given name. It returns an error
  10015. // if that edge is not defined in the schema.
  10016. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  10017. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  10018. }
  10019. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10020. // It returns an error if the edge is not defined in the schema.
  10021. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  10022. return fmt.Errorf("unknown ChatRecords edge %s", name)
  10023. }
  10024. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  10025. type ChatSessionMutation struct {
  10026. config
  10027. op Op
  10028. typ string
  10029. id *uint64
  10030. created_at *time.Time
  10031. updated_at *time.Time
  10032. deleted_at *time.Time
  10033. name *string
  10034. user_id *uint64
  10035. adduser_id *int64
  10036. bot_id *uint64
  10037. addbot_id *int64
  10038. bot_type *uint8
  10039. addbot_type *int8
  10040. clearedFields map[string]struct{}
  10041. done bool
  10042. oldValue func(context.Context) (*ChatSession, error)
  10043. predicates []predicate.ChatSession
  10044. }
  10045. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  10046. // chatsessionOption allows management of the mutation configuration using functional options.
  10047. type chatsessionOption func(*ChatSessionMutation)
  10048. // newChatSessionMutation creates new mutation for the ChatSession entity.
  10049. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  10050. m := &ChatSessionMutation{
  10051. config: c,
  10052. op: op,
  10053. typ: TypeChatSession,
  10054. clearedFields: make(map[string]struct{}),
  10055. }
  10056. for _, opt := range opts {
  10057. opt(m)
  10058. }
  10059. return m
  10060. }
  10061. // withChatSessionID sets the ID field of the mutation.
  10062. func withChatSessionID(id uint64) chatsessionOption {
  10063. return func(m *ChatSessionMutation) {
  10064. var (
  10065. err error
  10066. once sync.Once
  10067. value *ChatSession
  10068. )
  10069. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  10070. once.Do(func() {
  10071. if m.done {
  10072. err = errors.New("querying old values post mutation is not allowed")
  10073. } else {
  10074. value, err = m.Client().ChatSession.Get(ctx, id)
  10075. }
  10076. })
  10077. return value, err
  10078. }
  10079. m.id = &id
  10080. }
  10081. }
  10082. // withChatSession sets the old ChatSession of the mutation.
  10083. func withChatSession(node *ChatSession) chatsessionOption {
  10084. return func(m *ChatSessionMutation) {
  10085. m.oldValue = func(context.Context) (*ChatSession, error) {
  10086. return node, nil
  10087. }
  10088. m.id = &node.ID
  10089. }
  10090. }
  10091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10092. // executed in a transaction (ent.Tx), a transactional client is returned.
  10093. func (m ChatSessionMutation) Client() *Client {
  10094. client := &Client{config: m.config}
  10095. client.init()
  10096. return client
  10097. }
  10098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10099. // it returns an error otherwise.
  10100. func (m ChatSessionMutation) Tx() (*Tx, error) {
  10101. if _, ok := m.driver.(*txDriver); !ok {
  10102. return nil, errors.New("ent: mutation is not running in a transaction")
  10103. }
  10104. tx := &Tx{config: m.config}
  10105. tx.init()
  10106. return tx, nil
  10107. }
  10108. // SetID sets the value of the id field. Note that this
  10109. // operation is only accepted on creation of ChatSession entities.
  10110. func (m *ChatSessionMutation) SetID(id uint64) {
  10111. m.id = &id
  10112. }
  10113. // ID returns the ID value in the mutation. Note that the ID is only available
  10114. // if it was provided to the builder or after it was returned from the database.
  10115. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  10116. if m.id == nil {
  10117. return
  10118. }
  10119. return *m.id, true
  10120. }
  10121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10122. // That means, if the mutation is applied within a transaction with an isolation level such
  10123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10124. // or updated by the mutation.
  10125. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  10126. switch {
  10127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10128. id, exists := m.ID()
  10129. if exists {
  10130. return []uint64{id}, nil
  10131. }
  10132. fallthrough
  10133. case m.op.Is(OpUpdate | OpDelete):
  10134. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  10135. default:
  10136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10137. }
  10138. }
  10139. // SetCreatedAt sets the "created_at" field.
  10140. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  10141. m.created_at = &t
  10142. }
  10143. // CreatedAt returns the value of the "created_at" field in the mutation.
  10144. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  10145. v := m.created_at
  10146. if v == nil {
  10147. return
  10148. }
  10149. return *v, true
  10150. }
  10151. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  10152. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10154. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10155. if !m.op.Is(OpUpdateOne) {
  10156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10157. }
  10158. if m.id == nil || m.oldValue == nil {
  10159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10160. }
  10161. oldValue, err := m.oldValue(ctx)
  10162. if err != nil {
  10163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10164. }
  10165. return oldValue.CreatedAt, nil
  10166. }
  10167. // ResetCreatedAt resets all changes to the "created_at" field.
  10168. func (m *ChatSessionMutation) ResetCreatedAt() {
  10169. m.created_at = nil
  10170. }
  10171. // SetUpdatedAt sets the "updated_at" field.
  10172. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  10173. m.updated_at = &t
  10174. }
  10175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10176. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  10177. v := m.updated_at
  10178. if v == nil {
  10179. return
  10180. }
  10181. return *v, true
  10182. }
  10183. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  10184. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10186. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10187. if !m.op.Is(OpUpdateOne) {
  10188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10189. }
  10190. if m.id == nil || m.oldValue == nil {
  10191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10192. }
  10193. oldValue, err := m.oldValue(ctx)
  10194. if err != nil {
  10195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10196. }
  10197. return oldValue.UpdatedAt, nil
  10198. }
  10199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10200. func (m *ChatSessionMutation) ResetUpdatedAt() {
  10201. m.updated_at = nil
  10202. }
  10203. // SetDeletedAt sets the "deleted_at" field.
  10204. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  10205. m.deleted_at = &t
  10206. }
  10207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10208. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  10209. v := m.deleted_at
  10210. if v == nil {
  10211. return
  10212. }
  10213. return *v, true
  10214. }
  10215. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  10216. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10218. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10219. if !m.op.Is(OpUpdateOne) {
  10220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10221. }
  10222. if m.id == nil || m.oldValue == nil {
  10223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10224. }
  10225. oldValue, err := m.oldValue(ctx)
  10226. if err != nil {
  10227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10228. }
  10229. return oldValue.DeletedAt, nil
  10230. }
  10231. // ClearDeletedAt clears the value of the "deleted_at" field.
  10232. func (m *ChatSessionMutation) ClearDeletedAt() {
  10233. m.deleted_at = nil
  10234. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  10235. }
  10236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10237. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  10238. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  10239. return ok
  10240. }
  10241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10242. func (m *ChatSessionMutation) ResetDeletedAt() {
  10243. m.deleted_at = nil
  10244. delete(m.clearedFields, chatsession.FieldDeletedAt)
  10245. }
  10246. // SetName sets the "name" field.
  10247. func (m *ChatSessionMutation) SetName(s string) {
  10248. m.name = &s
  10249. }
  10250. // Name returns the value of the "name" field in the mutation.
  10251. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  10252. v := m.name
  10253. if v == nil {
  10254. return
  10255. }
  10256. return *v, true
  10257. }
  10258. // OldName returns the old "name" field's value of the ChatSession entity.
  10259. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10261. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  10262. if !m.op.Is(OpUpdateOne) {
  10263. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10264. }
  10265. if m.id == nil || m.oldValue == nil {
  10266. return v, errors.New("OldName requires an ID field in the mutation")
  10267. }
  10268. oldValue, err := m.oldValue(ctx)
  10269. if err != nil {
  10270. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10271. }
  10272. return oldValue.Name, nil
  10273. }
  10274. // ResetName resets all changes to the "name" field.
  10275. func (m *ChatSessionMutation) ResetName() {
  10276. m.name = nil
  10277. }
  10278. // SetUserID sets the "user_id" field.
  10279. func (m *ChatSessionMutation) SetUserID(u uint64) {
  10280. m.user_id = &u
  10281. m.adduser_id = nil
  10282. }
  10283. // UserID returns the value of the "user_id" field in the mutation.
  10284. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  10285. v := m.user_id
  10286. if v == nil {
  10287. return
  10288. }
  10289. return *v, true
  10290. }
  10291. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  10292. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10294. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  10295. if !m.op.Is(OpUpdateOne) {
  10296. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10297. }
  10298. if m.id == nil || m.oldValue == nil {
  10299. return v, errors.New("OldUserID requires an ID field in the mutation")
  10300. }
  10301. oldValue, err := m.oldValue(ctx)
  10302. if err != nil {
  10303. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10304. }
  10305. return oldValue.UserID, nil
  10306. }
  10307. // AddUserID adds u to the "user_id" field.
  10308. func (m *ChatSessionMutation) AddUserID(u int64) {
  10309. if m.adduser_id != nil {
  10310. *m.adduser_id += u
  10311. } else {
  10312. m.adduser_id = &u
  10313. }
  10314. }
  10315. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  10316. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  10317. v := m.adduser_id
  10318. if v == nil {
  10319. return
  10320. }
  10321. return *v, true
  10322. }
  10323. // ResetUserID resets all changes to the "user_id" field.
  10324. func (m *ChatSessionMutation) ResetUserID() {
  10325. m.user_id = nil
  10326. m.adduser_id = nil
  10327. }
  10328. // SetBotID sets the "bot_id" field.
  10329. func (m *ChatSessionMutation) SetBotID(u uint64) {
  10330. m.bot_id = &u
  10331. m.addbot_id = nil
  10332. }
  10333. // BotID returns the value of the "bot_id" field in the mutation.
  10334. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  10335. v := m.bot_id
  10336. if v == nil {
  10337. return
  10338. }
  10339. return *v, true
  10340. }
  10341. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  10342. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10344. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  10345. if !m.op.Is(OpUpdateOne) {
  10346. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  10347. }
  10348. if m.id == nil || m.oldValue == nil {
  10349. return v, errors.New("OldBotID requires an ID field in the mutation")
  10350. }
  10351. oldValue, err := m.oldValue(ctx)
  10352. if err != nil {
  10353. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  10354. }
  10355. return oldValue.BotID, nil
  10356. }
  10357. // AddBotID adds u to the "bot_id" field.
  10358. func (m *ChatSessionMutation) AddBotID(u int64) {
  10359. if m.addbot_id != nil {
  10360. *m.addbot_id += u
  10361. } else {
  10362. m.addbot_id = &u
  10363. }
  10364. }
  10365. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  10366. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  10367. v := m.addbot_id
  10368. if v == nil {
  10369. return
  10370. }
  10371. return *v, true
  10372. }
  10373. // ResetBotID resets all changes to the "bot_id" field.
  10374. func (m *ChatSessionMutation) ResetBotID() {
  10375. m.bot_id = nil
  10376. m.addbot_id = nil
  10377. }
  10378. // SetBotType sets the "bot_type" field.
  10379. func (m *ChatSessionMutation) SetBotType(u uint8) {
  10380. m.bot_type = &u
  10381. m.addbot_type = nil
  10382. }
  10383. // BotType returns the value of the "bot_type" field in the mutation.
  10384. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  10385. v := m.bot_type
  10386. if v == nil {
  10387. return
  10388. }
  10389. return *v, true
  10390. }
  10391. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  10392. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10394. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  10395. if !m.op.Is(OpUpdateOne) {
  10396. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  10397. }
  10398. if m.id == nil || m.oldValue == nil {
  10399. return v, errors.New("OldBotType requires an ID field in the mutation")
  10400. }
  10401. oldValue, err := m.oldValue(ctx)
  10402. if err != nil {
  10403. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  10404. }
  10405. return oldValue.BotType, nil
  10406. }
  10407. // AddBotType adds u to the "bot_type" field.
  10408. func (m *ChatSessionMutation) AddBotType(u int8) {
  10409. if m.addbot_type != nil {
  10410. *m.addbot_type += u
  10411. } else {
  10412. m.addbot_type = &u
  10413. }
  10414. }
  10415. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  10416. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  10417. v := m.addbot_type
  10418. if v == nil {
  10419. return
  10420. }
  10421. return *v, true
  10422. }
  10423. // ResetBotType resets all changes to the "bot_type" field.
  10424. func (m *ChatSessionMutation) ResetBotType() {
  10425. m.bot_type = nil
  10426. m.addbot_type = nil
  10427. }
  10428. // Where appends a list predicates to the ChatSessionMutation builder.
  10429. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  10430. m.predicates = append(m.predicates, ps...)
  10431. }
  10432. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  10433. // users can use type-assertion to append predicates that do not depend on any generated package.
  10434. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  10435. p := make([]predicate.ChatSession, len(ps))
  10436. for i := range ps {
  10437. p[i] = ps[i]
  10438. }
  10439. m.Where(p...)
  10440. }
  10441. // Op returns the operation name.
  10442. func (m *ChatSessionMutation) Op() Op {
  10443. return m.op
  10444. }
  10445. // SetOp allows setting the mutation operation.
  10446. func (m *ChatSessionMutation) SetOp(op Op) {
  10447. m.op = op
  10448. }
  10449. // Type returns the node type of this mutation (ChatSession).
  10450. func (m *ChatSessionMutation) Type() string {
  10451. return m.typ
  10452. }
  10453. // Fields returns all fields that were changed during this mutation. Note that in
  10454. // order to get all numeric fields that were incremented/decremented, call
  10455. // AddedFields().
  10456. func (m *ChatSessionMutation) Fields() []string {
  10457. fields := make([]string, 0, 7)
  10458. if m.created_at != nil {
  10459. fields = append(fields, chatsession.FieldCreatedAt)
  10460. }
  10461. if m.updated_at != nil {
  10462. fields = append(fields, chatsession.FieldUpdatedAt)
  10463. }
  10464. if m.deleted_at != nil {
  10465. fields = append(fields, chatsession.FieldDeletedAt)
  10466. }
  10467. if m.name != nil {
  10468. fields = append(fields, chatsession.FieldName)
  10469. }
  10470. if m.user_id != nil {
  10471. fields = append(fields, chatsession.FieldUserID)
  10472. }
  10473. if m.bot_id != nil {
  10474. fields = append(fields, chatsession.FieldBotID)
  10475. }
  10476. if m.bot_type != nil {
  10477. fields = append(fields, chatsession.FieldBotType)
  10478. }
  10479. return fields
  10480. }
  10481. // Field returns the value of a field with the given name. The second boolean
  10482. // return value indicates that this field was not set, or was not defined in the
  10483. // schema.
  10484. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  10485. switch name {
  10486. case chatsession.FieldCreatedAt:
  10487. return m.CreatedAt()
  10488. case chatsession.FieldUpdatedAt:
  10489. return m.UpdatedAt()
  10490. case chatsession.FieldDeletedAt:
  10491. return m.DeletedAt()
  10492. case chatsession.FieldName:
  10493. return m.Name()
  10494. case chatsession.FieldUserID:
  10495. return m.UserID()
  10496. case chatsession.FieldBotID:
  10497. return m.BotID()
  10498. case chatsession.FieldBotType:
  10499. return m.BotType()
  10500. }
  10501. return nil, false
  10502. }
  10503. // OldField returns the old value of the field from the database. An error is
  10504. // returned if the mutation operation is not UpdateOne, or the query to the
  10505. // database failed.
  10506. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10507. switch name {
  10508. case chatsession.FieldCreatedAt:
  10509. return m.OldCreatedAt(ctx)
  10510. case chatsession.FieldUpdatedAt:
  10511. return m.OldUpdatedAt(ctx)
  10512. case chatsession.FieldDeletedAt:
  10513. return m.OldDeletedAt(ctx)
  10514. case chatsession.FieldName:
  10515. return m.OldName(ctx)
  10516. case chatsession.FieldUserID:
  10517. return m.OldUserID(ctx)
  10518. case chatsession.FieldBotID:
  10519. return m.OldBotID(ctx)
  10520. case chatsession.FieldBotType:
  10521. return m.OldBotType(ctx)
  10522. }
  10523. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  10524. }
  10525. // SetField sets the value of a field with the given name. It returns an error if
  10526. // the field is not defined in the schema, or if the type mismatched the field
  10527. // type.
  10528. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  10529. switch name {
  10530. case chatsession.FieldCreatedAt:
  10531. v, ok := value.(time.Time)
  10532. if !ok {
  10533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10534. }
  10535. m.SetCreatedAt(v)
  10536. return nil
  10537. case chatsession.FieldUpdatedAt:
  10538. v, ok := value.(time.Time)
  10539. if !ok {
  10540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10541. }
  10542. m.SetUpdatedAt(v)
  10543. return nil
  10544. case chatsession.FieldDeletedAt:
  10545. v, ok := value.(time.Time)
  10546. if !ok {
  10547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10548. }
  10549. m.SetDeletedAt(v)
  10550. return nil
  10551. case chatsession.FieldName:
  10552. v, ok := value.(string)
  10553. if !ok {
  10554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10555. }
  10556. m.SetName(v)
  10557. return nil
  10558. case chatsession.FieldUserID:
  10559. v, ok := value.(uint64)
  10560. if !ok {
  10561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10562. }
  10563. m.SetUserID(v)
  10564. return nil
  10565. case chatsession.FieldBotID:
  10566. v, ok := value.(uint64)
  10567. if !ok {
  10568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10569. }
  10570. m.SetBotID(v)
  10571. return nil
  10572. case chatsession.FieldBotType:
  10573. v, ok := value.(uint8)
  10574. if !ok {
  10575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10576. }
  10577. m.SetBotType(v)
  10578. return nil
  10579. }
  10580. return fmt.Errorf("unknown ChatSession field %s", name)
  10581. }
  10582. // AddedFields returns all numeric fields that were incremented/decremented during
  10583. // this mutation.
  10584. func (m *ChatSessionMutation) AddedFields() []string {
  10585. var fields []string
  10586. if m.adduser_id != nil {
  10587. fields = append(fields, chatsession.FieldUserID)
  10588. }
  10589. if m.addbot_id != nil {
  10590. fields = append(fields, chatsession.FieldBotID)
  10591. }
  10592. if m.addbot_type != nil {
  10593. fields = append(fields, chatsession.FieldBotType)
  10594. }
  10595. return fields
  10596. }
  10597. // AddedField returns the numeric value that was incremented/decremented on a field
  10598. // with the given name. The second boolean return value indicates that this field
  10599. // was not set, or was not defined in the schema.
  10600. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  10601. switch name {
  10602. case chatsession.FieldUserID:
  10603. return m.AddedUserID()
  10604. case chatsession.FieldBotID:
  10605. return m.AddedBotID()
  10606. case chatsession.FieldBotType:
  10607. return m.AddedBotType()
  10608. }
  10609. return nil, false
  10610. }
  10611. // AddField adds the value to the field with the given name. It returns an error if
  10612. // the field is not defined in the schema, or if the type mismatched the field
  10613. // type.
  10614. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  10615. switch name {
  10616. case chatsession.FieldUserID:
  10617. v, ok := value.(int64)
  10618. if !ok {
  10619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10620. }
  10621. m.AddUserID(v)
  10622. return nil
  10623. case chatsession.FieldBotID:
  10624. v, ok := value.(int64)
  10625. if !ok {
  10626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10627. }
  10628. m.AddBotID(v)
  10629. return nil
  10630. case chatsession.FieldBotType:
  10631. v, ok := value.(int8)
  10632. if !ok {
  10633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10634. }
  10635. m.AddBotType(v)
  10636. return nil
  10637. }
  10638. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  10639. }
  10640. // ClearedFields returns all nullable fields that were cleared during this
  10641. // mutation.
  10642. func (m *ChatSessionMutation) ClearedFields() []string {
  10643. var fields []string
  10644. if m.FieldCleared(chatsession.FieldDeletedAt) {
  10645. fields = append(fields, chatsession.FieldDeletedAt)
  10646. }
  10647. return fields
  10648. }
  10649. // FieldCleared returns a boolean indicating if a field with the given name was
  10650. // cleared in this mutation.
  10651. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  10652. _, ok := m.clearedFields[name]
  10653. return ok
  10654. }
  10655. // ClearField clears the value of the field with the given name. It returns an
  10656. // error if the field is not defined in the schema.
  10657. func (m *ChatSessionMutation) ClearField(name string) error {
  10658. switch name {
  10659. case chatsession.FieldDeletedAt:
  10660. m.ClearDeletedAt()
  10661. return nil
  10662. }
  10663. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  10664. }
  10665. // ResetField resets all changes in the mutation for the field with the given name.
  10666. // It returns an error if the field is not defined in the schema.
  10667. func (m *ChatSessionMutation) ResetField(name string) error {
  10668. switch name {
  10669. case chatsession.FieldCreatedAt:
  10670. m.ResetCreatedAt()
  10671. return nil
  10672. case chatsession.FieldUpdatedAt:
  10673. m.ResetUpdatedAt()
  10674. return nil
  10675. case chatsession.FieldDeletedAt:
  10676. m.ResetDeletedAt()
  10677. return nil
  10678. case chatsession.FieldName:
  10679. m.ResetName()
  10680. return nil
  10681. case chatsession.FieldUserID:
  10682. m.ResetUserID()
  10683. return nil
  10684. case chatsession.FieldBotID:
  10685. m.ResetBotID()
  10686. return nil
  10687. case chatsession.FieldBotType:
  10688. m.ResetBotType()
  10689. return nil
  10690. }
  10691. return fmt.Errorf("unknown ChatSession field %s", name)
  10692. }
  10693. // AddedEdges returns all edge names that were set/added in this mutation.
  10694. func (m *ChatSessionMutation) AddedEdges() []string {
  10695. edges := make([]string, 0, 0)
  10696. return edges
  10697. }
  10698. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10699. // name in this mutation.
  10700. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  10701. return nil
  10702. }
  10703. // RemovedEdges returns all edge names that were removed in this mutation.
  10704. func (m *ChatSessionMutation) RemovedEdges() []string {
  10705. edges := make([]string, 0, 0)
  10706. return edges
  10707. }
  10708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10709. // the given name in this mutation.
  10710. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  10711. return nil
  10712. }
  10713. // ClearedEdges returns all edge names that were cleared in this mutation.
  10714. func (m *ChatSessionMutation) ClearedEdges() []string {
  10715. edges := make([]string, 0, 0)
  10716. return edges
  10717. }
  10718. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10719. // was cleared in this mutation.
  10720. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  10721. return false
  10722. }
  10723. // ClearEdge clears the value of the edge with the given name. It returns an error
  10724. // if that edge is not defined in the schema.
  10725. func (m *ChatSessionMutation) ClearEdge(name string) error {
  10726. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  10727. }
  10728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10729. // It returns an error if the edge is not defined in the schema.
  10730. func (m *ChatSessionMutation) ResetEdge(name string) error {
  10731. return fmt.Errorf("unknown ChatSession edge %s", name)
  10732. }
  10733. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  10734. type CompapiAsynctaskMutation struct {
  10735. config
  10736. op Op
  10737. typ string
  10738. id *uint64
  10739. created_at *time.Time
  10740. updated_at *time.Time
  10741. auth_token *string
  10742. event_type *string
  10743. chat_id *string
  10744. response_chat_item_id *string
  10745. organization_id *uint64
  10746. addorganization_id *int64
  10747. openai_base *string
  10748. openai_key *string
  10749. request_raw *string
  10750. response_raw *string
  10751. callback_url *string
  10752. callback_response_raw *string
  10753. model *string
  10754. task_status *int8
  10755. addtask_status *int8
  10756. retry_count *int8
  10757. addretry_count *int8
  10758. last_error *string
  10759. clearedFields map[string]struct{}
  10760. done bool
  10761. oldValue func(context.Context) (*CompapiAsynctask, error)
  10762. predicates []predicate.CompapiAsynctask
  10763. }
  10764. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  10765. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  10766. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  10767. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  10768. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  10769. m := &CompapiAsynctaskMutation{
  10770. config: c,
  10771. op: op,
  10772. typ: TypeCompapiAsynctask,
  10773. clearedFields: make(map[string]struct{}),
  10774. }
  10775. for _, opt := range opts {
  10776. opt(m)
  10777. }
  10778. return m
  10779. }
  10780. // withCompapiAsynctaskID sets the ID field of the mutation.
  10781. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  10782. return func(m *CompapiAsynctaskMutation) {
  10783. var (
  10784. err error
  10785. once sync.Once
  10786. value *CompapiAsynctask
  10787. )
  10788. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  10789. once.Do(func() {
  10790. if m.done {
  10791. err = errors.New("querying old values post mutation is not allowed")
  10792. } else {
  10793. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  10794. }
  10795. })
  10796. return value, err
  10797. }
  10798. m.id = &id
  10799. }
  10800. }
  10801. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  10802. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  10803. return func(m *CompapiAsynctaskMutation) {
  10804. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  10805. return node, nil
  10806. }
  10807. m.id = &node.ID
  10808. }
  10809. }
  10810. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10811. // executed in a transaction (ent.Tx), a transactional client is returned.
  10812. func (m CompapiAsynctaskMutation) Client() *Client {
  10813. client := &Client{config: m.config}
  10814. client.init()
  10815. return client
  10816. }
  10817. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10818. // it returns an error otherwise.
  10819. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  10820. if _, ok := m.driver.(*txDriver); !ok {
  10821. return nil, errors.New("ent: mutation is not running in a transaction")
  10822. }
  10823. tx := &Tx{config: m.config}
  10824. tx.init()
  10825. return tx, nil
  10826. }
  10827. // SetID sets the value of the id field. Note that this
  10828. // operation is only accepted on creation of CompapiAsynctask entities.
  10829. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  10830. m.id = &id
  10831. }
  10832. // ID returns the ID value in the mutation. Note that the ID is only available
  10833. // if it was provided to the builder or after it was returned from the database.
  10834. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  10835. if m.id == nil {
  10836. return
  10837. }
  10838. return *m.id, true
  10839. }
  10840. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10841. // That means, if the mutation is applied within a transaction with an isolation level such
  10842. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10843. // or updated by the mutation.
  10844. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  10845. switch {
  10846. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10847. id, exists := m.ID()
  10848. if exists {
  10849. return []uint64{id}, nil
  10850. }
  10851. fallthrough
  10852. case m.op.Is(OpUpdate | OpDelete):
  10853. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  10854. default:
  10855. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10856. }
  10857. }
  10858. // SetCreatedAt sets the "created_at" field.
  10859. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  10860. m.created_at = &t
  10861. }
  10862. // CreatedAt returns the value of the "created_at" field in the mutation.
  10863. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  10864. v := m.created_at
  10865. if v == nil {
  10866. return
  10867. }
  10868. return *v, true
  10869. }
  10870. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  10871. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10873. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10874. if !m.op.Is(OpUpdateOne) {
  10875. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10876. }
  10877. if m.id == nil || m.oldValue == nil {
  10878. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10879. }
  10880. oldValue, err := m.oldValue(ctx)
  10881. if err != nil {
  10882. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10883. }
  10884. return oldValue.CreatedAt, nil
  10885. }
  10886. // ResetCreatedAt resets all changes to the "created_at" field.
  10887. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  10888. m.created_at = nil
  10889. }
  10890. // SetUpdatedAt sets the "updated_at" field.
  10891. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  10892. m.updated_at = &t
  10893. }
  10894. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10895. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  10896. v := m.updated_at
  10897. if v == nil {
  10898. return
  10899. }
  10900. return *v, true
  10901. }
  10902. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  10903. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10905. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10906. if !m.op.Is(OpUpdateOne) {
  10907. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10908. }
  10909. if m.id == nil || m.oldValue == nil {
  10910. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10911. }
  10912. oldValue, err := m.oldValue(ctx)
  10913. if err != nil {
  10914. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10915. }
  10916. return oldValue.UpdatedAt, nil
  10917. }
  10918. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10919. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  10920. m.updated_at = nil
  10921. }
  10922. // SetAuthToken sets the "auth_token" field.
  10923. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  10924. m.auth_token = &s
  10925. }
  10926. // AuthToken returns the value of the "auth_token" field in the mutation.
  10927. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  10928. v := m.auth_token
  10929. if v == nil {
  10930. return
  10931. }
  10932. return *v, true
  10933. }
  10934. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  10935. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10937. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  10938. if !m.op.Is(OpUpdateOne) {
  10939. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  10940. }
  10941. if m.id == nil || m.oldValue == nil {
  10942. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  10943. }
  10944. oldValue, err := m.oldValue(ctx)
  10945. if err != nil {
  10946. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  10947. }
  10948. return oldValue.AuthToken, nil
  10949. }
  10950. // ResetAuthToken resets all changes to the "auth_token" field.
  10951. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  10952. m.auth_token = nil
  10953. }
  10954. // SetEventType sets the "event_type" field.
  10955. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  10956. m.event_type = &s
  10957. }
  10958. // EventType returns the value of the "event_type" field in the mutation.
  10959. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  10960. v := m.event_type
  10961. if v == nil {
  10962. return
  10963. }
  10964. return *v, true
  10965. }
  10966. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  10967. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10969. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  10970. if !m.op.Is(OpUpdateOne) {
  10971. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  10972. }
  10973. if m.id == nil || m.oldValue == nil {
  10974. return v, errors.New("OldEventType requires an ID field in the mutation")
  10975. }
  10976. oldValue, err := m.oldValue(ctx)
  10977. if err != nil {
  10978. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  10979. }
  10980. return oldValue.EventType, nil
  10981. }
  10982. // ResetEventType resets all changes to the "event_type" field.
  10983. func (m *CompapiAsynctaskMutation) ResetEventType() {
  10984. m.event_type = nil
  10985. }
  10986. // SetChatID sets the "chat_id" field.
  10987. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  10988. m.chat_id = &s
  10989. }
  10990. // ChatID returns the value of the "chat_id" field in the mutation.
  10991. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  10992. v := m.chat_id
  10993. if v == nil {
  10994. return
  10995. }
  10996. return *v, true
  10997. }
  10998. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  10999. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11001. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  11002. if !m.op.Is(OpUpdateOne) {
  11003. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  11004. }
  11005. if m.id == nil || m.oldValue == nil {
  11006. return v, errors.New("OldChatID requires an ID field in the mutation")
  11007. }
  11008. oldValue, err := m.oldValue(ctx)
  11009. if err != nil {
  11010. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  11011. }
  11012. return oldValue.ChatID, nil
  11013. }
  11014. // ClearChatID clears the value of the "chat_id" field.
  11015. func (m *CompapiAsynctaskMutation) ClearChatID() {
  11016. m.chat_id = nil
  11017. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  11018. }
  11019. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  11020. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  11021. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  11022. return ok
  11023. }
  11024. // ResetChatID resets all changes to the "chat_id" field.
  11025. func (m *CompapiAsynctaskMutation) ResetChatID() {
  11026. m.chat_id = nil
  11027. delete(m.clearedFields, compapiasynctask.FieldChatID)
  11028. }
  11029. // SetResponseChatItemID sets the "response_chat_item_id" field.
  11030. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  11031. m.response_chat_item_id = &s
  11032. }
  11033. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  11034. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  11035. v := m.response_chat_item_id
  11036. if v == nil {
  11037. return
  11038. }
  11039. return *v, true
  11040. }
  11041. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  11042. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11044. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  11045. if !m.op.Is(OpUpdateOne) {
  11046. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  11047. }
  11048. if m.id == nil || m.oldValue == nil {
  11049. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  11050. }
  11051. oldValue, err := m.oldValue(ctx)
  11052. if err != nil {
  11053. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  11054. }
  11055. return oldValue.ResponseChatItemID, nil
  11056. }
  11057. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  11058. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  11059. m.response_chat_item_id = nil
  11060. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  11061. }
  11062. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  11063. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  11064. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  11065. return ok
  11066. }
  11067. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  11068. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  11069. m.response_chat_item_id = nil
  11070. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  11071. }
  11072. // SetOrganizationID sets the "organization_id" field.
  11073. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  11074. m.organization_id = &u
  11075. m.addorganization_id = nil
  11076. }
  11077. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11078. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  11079. v := m.organization_id
  11080. if v == nil {
  11081. return
  11082. }
  11083. return *v, true
  11084. }
  11085. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  11086. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11088. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11089. if !m.op.Is(OpUpdateOne) {
  11090. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11091. }
  11092. if m.id == nil || m.oldValue == nil {
  11093. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11094. }
  11095. oldValue, err := m.oldValue(ctx)
  11096. if err != nil {
  11097. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11098. }
  11099. return oldValue.OrganizationID, nil
  11100. }
  11101. // AddOrganizationID adds u to the "organization_id" field.
  11102. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  11103. if m.addorganization_id != nil {
  11104. *m.addorganization_id += u
  11105. } else {
  11106. m.addorganization_id = &u
  11107. }
  11108. }
  11109. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11110. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  11111. v := m.addorganization_id
  11112. if v == nil {
  11113. return
  11114. }
  11115. return *v, true
  11116. }
  11117. // ResetOrganizationID resets all changes to the "organization_id" field.
  11118. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  11119. m.organization_id = nil
  11120. m.addorganization_id = nil
  11121. }
  11122. // SetOpenaiBase sets the "openai_base" field.
  11123. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  11124. m.openai_base = &s
  11125. }
  11126. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  11127. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  11128. v := m.openai_base
  11129. if v == nil {
  11130. return
  11131. }
  11132. return *v, true
  11133. }
  11134. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  11135. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11137. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  11138. if !m.op.Is(OpUpdateOne) {
  11139. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  11140. }
  11141. if m.id == nil || m.oldValue == nil {
  11142. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  11143. }
  11144. oldValue, err := m.oldValue(ctx)
  11145. if err != nil {
  11146. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  11147. }
  11148. return oldValue.OpenaiBase, nil
  11149. }
  11150. // ResetOpenaiBase resets all changes to the "openai_base" field.
  11151. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  11152. m.openai_base = nil
  11153. }
  11154. // SetOpenaiKey sets the "openai_key" field.
  11155. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  11156. m.openai_key = &s
  11157. }
  11158. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  11159. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  11160. v := m.openai_key
  11161. if v == nil {
  11162. return
  11163. }
  11164. return *v, true
  11165. }
  11166. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  11167. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11169. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  11170. if !m.op.Is(OpUpdateOne) {
  11171. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  11172. }
  11173. if m.id == nil || m.oldValue == nil {
  11174. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  11175. }
  11176. oldValue, err := m.oldValue(ctx)
  11177. if err != nil {
  11178. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  11179. }
  11180. return oldValue.OpenaiKey, nil
  11181. }
  11182. // ResetOpenaiKey resets all changes to the "openai_key" field.
  11183. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  11184. m.openai_key = nil
  11185. }
  11186. // SetRequestRaw sets the "request_raw" field.
  11187. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  11188. m.request_raw = &s
  11189. }
  11190. // RequestRaw returns the value of the "request_raw" field in the mutation.
  11191. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  11192. v := m.request_raw
  11193. if v == nil {
  11194. return
  11195. }
  11196. return *v, true
  11197. }
  11198. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  11199. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11201. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  11202. if !m.op.Is(OpUpdateOne) {
  11203. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  11204. }
  11205. if m.id == nil || m.oldValue == nil {
  11206. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  11207. }
  11208. oldValue, err := m.oldValue(ctx)
  11209. if err != nil {
  11210. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  11211. }
  11212. return oldValue.RequestRaw, nil
  11213. }
  11214. // ResetRequestRaw resets all changes to the "request_raw" field.
  11215. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  11216. m.request_raw = nil
  11217. }
  11218. // SetResponseRaw sets the "response_raw" field.
  11219. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  11220. m.response_raw = &s
  11221. }
  11222. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  11223. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  11224. v := m.response_raw
  11225. if v == nil {
  11226. return
  11227. }
  11228. return *v, true
  11229. }
  11230. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  11231. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11233. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  11234. if !m.op.Is(OpUpdateOne) {
  11235. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  11236. }
  11237. if m.id == nil || m.oldValue == nil {
  11238. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  11239. }
  11240. oldValue, err := m.oldValue(ctx)
  11241. if err != nil {
  11242. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  11243. }
  11244. return oldValue.ResponseRaw, nil
  11245. }
  11246. // ClearResponseRaw clears the value of the "response_raw" field.
  11247. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  11248. m.response_raw = nil
  11249. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  11250. }
  11251. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  11252. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  11253. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  11254. return ok
  11255. }
  11256. // ResetResponseRaw resets all changes to the "response_raw" field.
  11257. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  11258. m.response_raw = nil
  11259. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  11260. }
  11261. // SetCallbackURL sets the "callback_url" field.
  11262. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  11263. m.callback_url = &s
  11264. }
  11265. // CallbackURL returns the value of the "callback_url" field in the mutation.
  11266. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  11267. v := m.callback_url
  11268. if v == nil {
  11269. return
  11270. }
  11271. return *v, true
  11272. }
  11273. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  11274. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11276. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  11277. if !m.op.Is(OpUpdateOne) {
  11278. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  11279. }
  11280. if m.id == nil || m.oldValue == nil {
  11281. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  11282. }
  11283. oldValue, err := m.oldValue(ctx)
  11284. if err != nil {
  11285. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  11286. }
  11287. return oldValue.CallbackURL, nil
  11288. }
  11289. // ResetCallbackURL resets all changes to the "callback_url" field.
  11290. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  11291. m.callback_url = nil
  11292. }
  11293. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  11294. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  11295. m.callback_response_raw = &s
  11296. }
  11297. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  11298. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  11299. v := m.callback_response_raw
  11300. if v == nil {
  11301. return
  11302. }
  11303. return *v, true
  11304. }
  11305. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  11306. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11308. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  11309. if !m.op.Is(OpUpdateOne) {
  11310. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  11311. }
  11312. if m.id == nil || m.oldValue == nil {
  11313. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  11314. }
  11315. oldValue, err := m.oldValue(ctx)
  11316. if err != nil {
  11317. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  11318. }
  11319. return oldValue.CallbackResponseRaw, nil
  11320. }
  11321. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  11322. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  11323. m.callback_response_raw = nil
  11324. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  11325. }
  11326. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  11327. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  11328. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  11329. return ok
  11330. }
  11331. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  11332. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  11333. m.callback_response_raw = nil
  11334. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  11335. }
  11336. // SetModel sets the "model" field.
  11337. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  11338. m.model = &s
  11339. }
  11340. // Model returns the value of the "model" field in the mutation.
  11341. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  11342. v := m.model
  11343. if v == nil {
  11344. return
  11345. }
  11346. return *v, true
  11347. }
  11348. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  11349. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11351. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  11352. if !m.op.Is(OpUpdateOne) {
  11353. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  11354. }
  11355. if m.id == nil || m.oldValue == nil {
  11356. return v, errors.New("OldModel requires an ID field in the mutation")
  11357. }
  11358. oldValue, err := m.oldValue(ctx)
  11359. if err != nil {
  11360. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  11361. }
  11362. return oldValue.Model, nil
  11363. }
  11364. // ClearModel clears the value of the "model" field.
  11365. func (m *CompapiAsynctaskMutation) ClearModel() {
  11366. m.model = nil
  11367. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  11368. }
  11369. // ModelCleared returns if the "model" field was cleared in this mutation.
  11370. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  11371. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  11372. return ok
  11373. }
  11374. // ResetModel resets all changes to the "model" field.
  11375. func (m *CompapiAsynctaskMutation) ResetModel() {
  11376. m.model = nil
  11377. delete(m.clearedFields, compapiasynctask.FieldModel)
  11378. }
  11379. // SetTaskStatus sets the "task_status" field.
  11380. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  11381. m.task_status = &i
  11382. m.addtask_status = nil
  11383. }
  11384. // TaskStatus returns the value of the "task_status" field in the mutation.
  11385. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  11386. v := m.task_status
  11387. if v == nil {
  11388. return
  11389. }
  11390. return *v, true
  11391. }
  11392. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  11393. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11395. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  11396. if !m.op.Is(OpUpdateOne) {
  11397. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  11398. }
  11399. if m.id == nil || m.oldValue == nil {
  11400. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  11401. }
  11402. oldValue, err := m.oldValue(ctx)
  11403. if err != nil {
  11404. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  11405. }
  11406. return oldValue.TaskStatus, nil
  11407. }
  11408. // AddTaskStatus adds i to the "task_status" field.
  11409. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  11410. if m.addtask_status != nil {
  11411. *m.addtask_status += i
  11412. } else {
  11413. m.addtask_status = &i
  11414. }
  11415. }
  11416. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  11417. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  11418. v := m.addtask_status
  11419. if v == nil {
  11420. return
  11421. }
  11422. return *v, true
  11423. }
  11424. // ClearTaskStatus clears the value of the "task_status" field.
  11425. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  11426. m.task_status = nil
  11427. m.addtask_status = nil
  11428. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  11429. }
  11430. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  11431. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  11432. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  11433. return ok
  11434. }
  11435. // ResetTaskStatus resets all changes to the "task_status" field.
  11436. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  11437. m.task_status = nil
  11438. m.addtask_status = nil
  11439. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  11440. }
  11441. // SetRetryCount sets the "retry_count" field.
  11442. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  11443. m.retry_count = &i
  11444. m.addretry_count = nil
  11445. }
  11446. // RetryCount returns the value of the "retry_count" field in the mutation.
  11447. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  11448. v := m.retry_count
  11449. if v == nil {
  11450. return
  11451. }
  11452. return *v, true
  11453. }
  11454. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  11455. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11457. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  11458. if !m.op.Is(OpUpdateOne) {
  11459. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  11460. }
  11461. if m.id == nil || m.oldValue == nil {
  11462. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  11463. }
  11464. oldValue, err := m.oldValue(ctx)
  11465. if err != nil {
  11466. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  11467. }
  11468. return oldValue.RetryCount, nil
  11469. }
  11470. // AddRetryCount adds i to the "retry_count" field.
  11471. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  11472. if m.addretry_count != nil {
  11473. *m.addretry_count += i
  11474. } else {
  11475. m.addretry_count = &i
  11476. }
  11477. }
  11478. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  11479. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  11480. v := m.addretry_count
  11481. if v == nil {
  11482. return
  11483. }
  11484. return *v, true
  11485. }
  11486. // ClearRetryCount clears the value of the "retry_count" field.
  11487. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  11488. m.retry_count = nil
  11489. m.addretry_count = nil
  11490. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  11491. }
  11492. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  11493. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  11494. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  11495. return ok
  11496. }
  11497. // ResetRetryCount resets all changes to the "retry_count" field.
  11498. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  11499. m.retry_count = nil
  11500. m.addretry_count = nil
  11501. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  11502. }
  11503. // SetLastError sets the "last_error" field.
  11504. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  11505. m.last_error = &s
  11506. }
  11507. // LastError returns the value of the "last_error" field in the mutation.
  11508. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  11509. v := m.last_error
  11510. if v == nil {
  11511. return
  11512. }
  11513. return *v, true
  11514. }
  11515. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  11516. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11518. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  11519. if !m.op.Is(OpUpdateOne) {
  11520. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  11521. }
  11522. if m.id == nil || m.oldValue == nil {
  11523. return v, errors.New("OldLastError requires an ID field in the mutation")
  11524. }
  11525. oldValue, err := m.oldValue(ctx)
  11526. if err != nil {
  11527. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  11528. }
  11529. return oldValue.LastError, nil
  11530. }
  11531. // ClearLastError clears the value of the "last_error" field.
  11532. func (m *CompapiAsynctaskMutation) ClearLastError() {
  11533. m.last_error = nil
  11534. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  11535. }
  11536. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  11537. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  11538. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  11539. return ok
  11540. }
  11541. // ResetLastError resets all changes to the "last_error" field.
  11542. func (m *CompapiAsynctaskMutation) ResetLastError() {
  11543. m.last_error = nil
  11544. delete(m.clearedFields, compapiasynctask.FieldLastError)
  11545. }
  11546. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  11547. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  11548. m.predicates = append(m.predicates, ps...)
  11549. }
  11550. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  11551. // users can use type-assertion to append predicates that do not depend on any generated package.
  11552. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  11553. p := make([]predicate.CompapiAsynctask, len(ps))
  11554. for i := range ps {
  11555. p[i] = ps[i]
  11556. }
  11557. m.Where(p...)
  11558. }
  11559. // Op returns the operation name.
  11560. func (m *CompapiAsynctaskMutation) Op() Op {
  11561. return m.op
  11562. }
  11563. // SetOp allows setting the mutation operation.
  11564. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  11565. m.op = op
  11566. }
  11567. // Type returns the node type of this mutation (CompapiAsynctask).
  11568. func (m *CompapiAsynctaskMutation) Type() string {
  11569. return m.typ
  11570. }
  11571. // Fields returns all fields that were changed during this mutation. Note that in
  11572. // order to get all numeric fields that were incremented/decremented, call
  11573. // AddedFields().
  11574. func (m *CompapiAsynctaskMutation) Fields() []string {
  11575. fields := make([]string, 0, 17)
  11576. if m.created_at != nil {
  11577. fields = append(fields, compapiasynctask.FieldCreatedAt)
  11578. }
  11579. if m.updated_at != nil {
  11580. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  11581. }
  11582. if m.auth_token != nil {
  11583. fields = append(fields, compapiasynctask.FieldAuthToken)
  11584. }
  11585. if m.event_type != nil {
  11586. fields = append(fields, compapiasynctask.FieldEventType)
  11587. }
  11588. if m.chat_id != nil {
  11589. fields = append(fields, compapiasynctask.FieldChatID)
  11590. }
  11591. if m.response_chat_item_id != nil {
  11592. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11593. }
  11594. if m.organization_id != nil {
  11595. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11596. }
  11597. if m.openai_base != nil {
  11598. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  11599. }
  11600. if m.openai_key != nil {
  11601. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  11602. }
  11603. if m.request_raw != nil {
  11604. fields = append(fields, compapiasynctask.FieldRequestRaw)
  11605. }
  11606. if m.response_raw != nil {
  11607. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11608. }
  11609. if m.callback_url != nil {
  11610. fields = append(fields, compapiasynctask.FieldCallbackURL)
  11611. }
  11612. if m.callback_response_raw != nil {
  11613. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11614. }
  11615. if m.model != nil {
  11616. fields = append(fields, compapiasynctask.FieldModel)
  11617. }
  11618. if m.task_status != nil {
  11619. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11620. }
  11621. if m.retry_count != nil {
  11622. fields = append(fields, compapiasynctask.FieldRetryCount)
  11623. }
  11624. if m.last_error != nil {
  11625. fields = append(fields, compapiasynctask.FieldLastError)
  11626. }
  11627. return fields
  11628. }
  11629. // Field returns the value of a field with the given name. The second boolean
  11630. // return value indicates that this field was not set, or was not defined in the
  11631. // schema.
  11632. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  11633. switch name {
  11634. case compapiasynctask.FieldCreatedAt:
  11635. return m.CreatedAt()
  11636. case compapiasynctask.FieldUpdatedAt:
  11637. return m.UpdatedAt()
  11638. case compapiasynctask.FieldAuthToken:
  11639. return m.AuthToken()
  11640. case compapiasynctask.FieldEventType:
  11641. return m.EventType()
  11642. case compapiasynctask.FieldChatID:
  11643. return m.ChatID()
  11644. case compapiasynctask.FieldResponseChatItemID:
  11645. return m.ResponseChatItemID()
  11646. case compapiasynctask.FieldOrganizationID:
  11647. return m.OrganizationID()
  11648. case compapiasynctask.FieldOpenaiBase:
  11649. return m.OpenaiBase()
  11650. case compapiasynctask.FieldOpenaiKey:
  11651. return m.OpenaiKey()
  11652. case compapiasynctask.FieldRequestRaw:
  11653. return m.RequestRaw()
  11654. case compapiasynctask.FieldResponseRaw:
  11655. return m.ResponseRaw()
  11656. case compapiasynctask.FieldCallbackURL:
  11657. return m.CallbackURL()
  11658. case compapiasynctask.FieldCallbackResponseRaw:
  11659. return m.CallbackResponseRaw()
  11660. case compapiasynctask.FieldModel:
  11661. return m.Model()
  11662. case compapiasynctask.FieldTaskStatus:
  11663. return m.TaskStatus()
  11664. case compapiasynctask.FieldRetryCount:
  11665. return m.RetryCount()
  11666. case compapiasynctask.FieldLastError:
  11667. return m.LastError()
  11668. }
  11669. return nil, false
  11670. }
  11671. // OldField returns the old value of the field from the database. An error is
  11672. // returned if the mutation operation is not UpdateOne, or the query to the
  11673. // database failed.
  11674. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11675. switch name {
  11676. case compapiasynctask.FieldCreatedAt:
  11677. return m.OldCreatedAt(ctx)
  11678. case compapiasynctask.FieldUpdatedAt:
  11679. return m.OldUpdatedAt(ctx)
  11680. case compapiasynctask.FieldAuthToken:
  11681. return m.OldAuthToken(ctx)
  11682. case compapiasynctask.FieldEventType:
  11683. return m.OldEventType(ctx)
  11684. case compapiasynctask.FieldChatID:
  11685. return m.OldChatID(ctx)
  11686. case compapiasynctask.FieldResponseChatItemID:
  11687. return m.OldResponseChatItemID(ctx)
  11688. case compapiasynctask.FieldOrganizationID:
  11689. return m.OldOrganizationID(ctx)
  11690. case compapiasynctask.FieldOpenaiBase:
  11691. return m.OldOpenaiBase(ctx)
  11692. case compapiasynctask.FieldOpenaiKey:
  11693. return m.OldOpenaiKey(ctx)
  11694. case compapiasynctask.FieldRequestRaw:
  11695. return m.OldRequestRaw(ctx)
  11696. case compapiasynctask.FieldResponseRaw:
  11697. return m.OldResponseRaw(ctx)
  11698. case compapiasynctask.FieldCallbackURL:
  11699. return m.OldCallbackURL(ctx)
  11700. case compapiasynctask.FieldCallbackResponseRaw:
  11701. return m.OldCallbackResponseRaw(ctx)
  11702. case compapiasynctask.FieldModel:
  11703. return m.OldModel(ctx)
  11704. case compapiasynctask.FieldTaskStatus:
  11705. return m.OldTaskStatus(ctx)
  11706. case compapiasynctask.FieldRetryCount:
  11707. return m.OldRetryCount(ctx)
  11708. case compapiasynctask.FieldLastError:
  11709. return m.OldLastError(ctx)
  11710. }
  11711. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11712. }
  11713. // SetField sets the value of a field with the given name. It returns an error if
  11714. // the field is not defined in the schema, or if the type mismatched the field
  11715. // type.
  11716. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  11717. switch name {
  11718. case compapiasynctask.FieldCreatedAt:
  11719. v, ok := value.(time.Time)
  11720. if !ok {
  11721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11722. }
  11723. m.SetCreatedAt(v)
  11724. return nil
  11725. case compapiasynctask.FieldUpdatedAt:
  11726. v, ok := value.(time.Time)
  11727. if !ok {
  11728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11729. }
  11730. m.SetUpdatedAt(v)
  11731. return nil
  11732. case compapiasynctask.FieldAuthToken:
  11733. v, ok := value.(string)
  11734. if !ok {
  11735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11736. }
  11737. m.SetAuthToken(v)
  11738. return nil
  11739. case compapiasynctask.FieldEventType:
  11740. v, ok := value.(string)
  11741. if !ok {
  11742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11743. }
  11744. m.SetEventType(v)
  11745. return nil
  11746. case compapiasynctask.FieldChatID:
  11747. v, ok := value.(string)
  11748. if !ok {
  11749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11750. }
  11751. m.SetChatID(v)
  11752. return nil
  11753. case compapiasynctask.FieldResponseChatItemID:
  11754. v, ok := value.(string)
  11755. if !ok {
  11756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11757. }
  11758. m.SetResponseChatItemID(v)
  11759. return nil
  11760. case compapiasynctask.FieldOrganizationID:
  11761. v, ok := value.(uint64)
  11762. if !ok {
  11763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11764. }
  11765. m.SetOrganizationID(v)
  11766. return nil
  11767. case compapiasynctask.FieldOpenaiBase:
  11768. v, ok := value.(string)
  11769. if !ok {
  11770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11771. }
  11772. m.SetOpenaiBase(v)
  11773. return nil
  11774. case compapiasynctask.FieldOpenaiKey:
  11775. v, ok := value.(string)
  11776. if !ok {
  11777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11778. }
  11779. m.SetOpenaiKey(v)
  11780. return nil
  11781. case compapiasynctask.FieldRequestRaw:
  11782. v, ok := value.(string)
  11783. if !ok {
  11784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11785. }
  11786. m.SetRequestRaw(v)
  11787. return nil
  11788. case compapiasynctask.FieldResponseRaw:
  11789. v, ok := value.(string)
  11790. if !ok {
  11791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11792. }
  11793. m.SetResponseRaw(v)
  11794. return nil
  11795. case compapiasynctask.FieldCallbackURL:
  11796. v, ok := value.(string)
  11797. if !ok {
  11798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11799. }
  11800. m.SetCallbackURL(v)
  11801. return nil
  11802. case compapiasynctask.FieldCallbackResponseRaw:
  11803. v, ok := value.(string)
  11804. if !ok {
  11805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11806. }
  11807. m.SetCallbackResponseRaw(v)
  11808. return nil
  11809. case compapiasynctask.FieldModel:
  11810. v, ok := value.(string)
  11811. if !ok {
  11812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11813. }
  11814. m.SetModel(v)
  11815. return nil
  11816. case compapiasynctask.FieldTaskStatus:
  11817. v, ok := value.(int8)
  11818. if !ok {
  11819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11820. }
  11821. m.SetTaskStatus(v)
  11822. return nil
  11823. case compapiasynctask.FieldRetryCount:
  11824. v, ok := value.(int8)
  11825. if !ok {
  11826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11827. }
  11828. m.SetRetryCount(v)
  11829. return nil
  11830. case compapiasynctask.FieldLastError:
  11831. v, ok := value.(string)
  11832. if !ok {
  11833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11834. }
  11835. m.SetLastError(v)
  11836. return nil
  11837. }
  11838. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11839. }
  11840. // AddedFields returns all numeric fields that were incremented/decremented during
  11841. // this mutation.
  11842. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  11843. var fields []string
  11844. if m.addorganization_id != nil {
  11845. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11846. }
  11847. if m.addtask_status != nil {
  11848. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11849. }
  11850. if m.addretry_count != nil {
  11851. fields = append(fields, compapiasynctask.FieldRetryCount)
  11852. }
  11853. return fields
  11854. }
  11855. // AddedField returns the numeric value that was incremented/decremented on a field
  11856. // with the given name. The second boolean return value indicates that this field
  11857. // was not set, or was not defined in the schema.
  11858. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  11859. switch name {
  11860. case compapiasynctask.FieldOrganizationID:
  11861. return m.AddedOrganizationID()
  11862. case compapiasynctask.FieldTaskStatus:
  11863. return m.AddedTaskStatus()
  11864. case compapiasynctask.FieldRetryCount:
  11865. return m.AddedRetryCount()
  11866. }
  11867. return nil, false
  11868. }
  11869. // AddField adds the value to the field with the given name. It returns an error if
  11870. // the field is not defined in the schema, or if the type mismatched the field
  11871. // type.
  11872. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  11873. switch name {
  11874. case compapiasynctask.FieldOrganizationID:
  11875. v, ok := value.(int64)
  11876. if !ok {
  11877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11878. }
  11879. m.AddOrganizationID(v)
  11880. return nil
  11881. case compapiasynctask.FieldTaskStatus:
  11882. v, ok := value.(int8)
  11883. if !ok {
  11884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11885. }
  11886. m.AddTaskStatus(v)
  11887. return nil
  11888. case compapiasynctask.FieldRetryCount:
  11889. v, ok := value.(int8)
  11890. if !ok {
  11891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11892. }
  11893. m.AddRetryCount(v)
  11894. return nil
  11895. }
  11896. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  11897. }
  11898. // ClearedFields returns all nullable fields that were cleared during this
  11899. // mutation.
  11900. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  11901. var fields []string
  11902. if m.FieldCleared(compapiasynctask.FieldChatID) {
  11903. fields = append(fields, compapiasynctask.FieldChatID)
  11904. }
  11905. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  11906. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11907. }
  11908. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  11909. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11910. }
  11911. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  11912. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11913. }
  11914. if m.FieldCleared(compapiasynctask.FieldModel) {
  11915. fields = append(fields, compapiasynctask.FieldModel)
  11916. }
  11917. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  11918. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11919. }
  11920. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  11921. fields = append(fields, compapiasynctask.FieldRetryCount)
  11922. }
  11923. if m.FieldCleared(compapiasynctask.FieldLastError) {
  11924. fields = append(fields, compapiasynctask.FieldLastError)
  11925. }
  11926. return fields
  11927. }
  11928. // FieldCleared returns a boolean indicating if a field with the given name was
  11929. // cleared in this mutation.
  11930. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  11931. _, ok := m.clearedFields[name]
  11932. return ok
  11933. }
  11934. // ClearField clears the value of the field with the given name. It returns an
  11935. // error if the field is not defined in the schema.
  11936. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  11937. switch name {
  11938. case compapiasynctask.FieldChatID:
  11939. m.ClearChatID()
  11940. return nil
  11941. case compapiasynctask.FieldResponseChatItemID:
  11942. m.ClearResponseChatItemID()
  11943. return nil
  11944. case compapiasynctask.FieldResponseRaw:
  11945. m.ClearResponseRaw()
  11946. return nil
  11947. case compapiasynctask.FieldCallbackResponseRaw:
  11948. m.ClearCallbackResponseRaw()
  11949. return nil
  11950. case compapiasynctask.FieldModel:
  11951. m.ClearModel()
  11952. return nil
  11953. case compapiasynctask.FieldTaskStatus:
  11954. m.ClearTaskStatus()
  11955. return nil
  11956. case compapiasynctask.FieldRetryCount:
  11957. m.ClearRetryCount()
  11958. return nil
  11959. case compapiasynctask.FieldLastError:
  11960. m.ClearLastError()
  11961. return nil
  11962. }
  11963. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  11964. }
  11965. // ResetField resets all changes in the mutation for the field with the given name.
  11966. // It returns an error if the field is not defined in the schema.
  11967. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  11968. switch name {
  11969. case compapiasynctask.FieldCreatedAt:
  11970. m.ResetCreatedAt()
  11971. return nil
  11972. case compapiasynctask.FieldUpdatedAt:
  11973. m.ResetUpdatedAt()
  11974. return nil
  11975. case compapiasynctask.FieldAuthToken:
  11976. m.ResetAuthToken()
  11977. return nil
  11978. case compapiasynctask.FieldEventType:
  11979. m.ResetEventType()
  11980. return nil
  11981. case compapiasynctask.FieldChatID:
  11982. m.ResetChatID()
  11983. return nil
  11984. case compapiasynctask.FieldResponseChatItemID:
  11985. m.ResetResponseChatItemID()
  11986. return nil
  11987. case compapiasynctask.FieldOrganizationID:
  11988. m.ResetOrganizationID()
  11989. return nil
  11990. case compapiasynctask.FieldOpenaiBase:
  11991. m.ResetOpenaiBase()
  11992. return nil
  11993. case compapiasynctask.FieldOpenaiKey:
  11994. m.ResetOpenaiKey()
  11995. return nil
  11996. case compapiasynctask.FieldRequestRaw:
  11997. m.ResetRequestRaw()
  11998. return nil
  11999. case compapiasynctask.FieldResponseRaw:
  12000. m.ResetResponseRaw()
  12001. return nil
  12002. case compapiasynctask.FieldCallbackURL:
  12003. m.ResetCallbackURL()
  12004. return nil
  12005. case compapiasynctask.FieldCallbackResponseRaw:
  12006. m.ResetCallbackResponseRaw()
  12007. return nil
  12008. case compapiasynctask.FieldModel:
  12009. m.ResetModel()
  12010. return nil
  12011. case compapiasynctask.FieldTaskStatus:
  12012. m.ResetTaskStatus()
  12013. return nil
  12014. case compapiasynctask.FieldRetryCount:
  12015. m.ResetRetryCount()
  12016. return nil
  12017. case compapiasynctask.FieldLastError:
  12018. m.ResetLastError()
  12019. return nil
  12020. }
  12021. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  12022. }
  12023. // AddedEdges returns all edge names that were set/added in this mutation.
  12024. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  12025. edges := make([]string, 0, 0)
  12026. return edges
  12027. }
  12028. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12029. // name in this mutation.
  12030. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  12031. return nil
  12032. }
  12033. // RemovedEdges returns all edge names that were removed in this mutation.
  12034. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  12035. edges := make([]string, 0, 0)
  12036. return edges
  12037. }
  12038. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12039. // the given name in this mutation.
  12040. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  12041. return nil
  12042. }
  12043. // ClearedEdges returns all edge names that were cleared in this mutation.
  12044. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  12045. edges := make([]string, 0, 0)
  12046. return edges
  12047. }
  12048. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12049. // was cleared in this mutation.
  12050. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  12051. return false
  12052. }
  12053. // ClearEdge clears the value of the edge with the given name. It returns an error
  12054. // if that edge is not defined in the schema.
  12055. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  12056. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  12057. }
  12058. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12059. // It returns an error if the edge is not defined in the schema.
  12060. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  12061. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  12062. }
  12063. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  12064. type ContactMutation struct {
  12065. config
  12066. op Op
  12067. typ string
  12068. id *uint64
  12069. created_at *time.Time
  12070. updated_at *time.Time
  12071. status *uint8
  12072. addstatus *int8
  12073. deleted_at *time.Time
  12074. wx_wxid *string
  12075. _type *int
  12076. add_type *int
  12077. wxid *string
  12078. account *string
  12079. nickname *string
  12080. markname *string
  12081. headimg *string
  12082. sex *int
  12083. addsex *int
  12084. starrole *string
  12085. dontseeit *int
  12086. adddontseeit *int
  12087. dontseeme *int
  12088. adddontseeme *int
  12089. lag *string
  12090. gid *string
  12091. gname *string
  12092. v3 *string
  12093. organization_id *uint64
  12094. addorganization_id *int64
  12095. ctype *uint64
  12096. addctype *int64
  12097. cage *int
  12098. addcage *int
  12099. cname *string
  12100. carea *string
  12101. cbirthday *string
  12102. cbirtharea *string
  12103. cidcard_no *string
  12104. ctitle *string
  12105. cc *string
  12106. phone *string
  12107. clearedFields map[string]struct{}
  12108. contact_relationships map[uint64]struct{}
  12109. removedcontact_relationships map[uint64]struct{}
  12110. clearedcontact_relationships bool
  12111. contact_fields map[uint64]struct{}
  12112. removedcontact_fields map[uint64]struct{}
  12113. clearedcontact_fields bool
  12114. contact_messages map[uint64]struct{}
  12115. removedcontact_messages map[uint64]struct{}
  12116. clearedcontact_messages bool
  12117. done bool
  12118. oldValue func(context.Context) (*Contact, error)
  12119. predicates []predicate.Contact
  12120. }
  12121. var _ ent.Mutation = (*ContactMutation)(nil)
  12122. // contactOption allows management of the mutation configuration using functional options.
  12123. type contactOption func(*ContactMutation)
  12124. // newContactMutation creates new mutation for the Contact entity.
  12125. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  12126. m := &ContactMutation{
  12127. config: c,
  12128. op: op,
  12129. typ: TypeContact,
  12130. clearedFields: make(map[string]struct{}),
  12131. }
  12132. for _, opt := range opts {
  12133. opt(m)
  12134. }
  12135. return m
  12136. }
  12137. // withContactID sets the ID field of the mutation.
  12138. func withContactID(id uint64) contactOption {
  12139. return func(m *ContactMutation) {
  12140. var (
  12141. err error
  12142. once sync.Once
  12143. value *Contact
  12144. )
  12145. m.oldValue = func(ctx context.Context) (*Contact, error) {
  12146. once.Do(func() {
  12147. if m.done {
  12148. err = errors.New("querying old values post mutation is not allowed")
  12149. } else {
  12150. value, err = m.Client().Contact.Get(ctx, id)
  12151. }
  12152. })
  12153. return value, err
  12154. }
  12155. m.id = &id
  12156. }
  12157. }
  12158. // withContact sets the old Contact of the mutation.
  12159. func withContact(node *Contact) contactOption {
  12160. return func(m *ContactMutation) {
  12161. m.oldValue = func(context.Context) (*Contact, error) {
  12162. return node, nil
  12163. }
  12164. m.id = &node.ID
  12165. }
  12166. }
  12167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12168. // executed in a transaction (ent.Tx), a transactional client is returned.
  12169. func (m ContactMutation) Client() *Client {
  12170. client := &Client{config: m.config}
  12171. client.init()
  12172. return client
  12173. }
  12174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12175. // it returns an error otherwise.
  12176. func (m ContactMutation) Tx() (*Tx, error) {
  12177. if _, ok := m.driver.(*txDriver); !ok {
  12178. return nil, errors.New("ent: mutation is not running in a transaction")
  12179. }
  12180. tx := &Tx{config: m.config}
  12181. tx.init()
  12182. return tx, nil
  12183. }
  12184. // SetID sets the value of the id field. Note that this
  12185. // operation is only accepted on creation of Contact entities.
  12186. func (m *ContactMutation) SetID(id uint64) {
  12187. m.id = &id
  12188. }
  12189. // ID returns the ID value in the mutation. Note that the ID is only available
  12190. // if it was provided to the builder or after it was returned from the database.
  12191. func (m *ContactMutation) ID() (id uint64, exists bool) {
  12192. if m.id == nil {
  12193. return
  12194. }
  12195. return *m.id, true
  12196. }
  12197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12198. // That means, if the mutation is applied within a transaction with an isolation level such
  12199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12200. // or updated by the mutation.
  12201. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  12202. switch {
  12203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12204. id, exists := m.ID()
  12205. if exists {
  12206. return []uint64{id}, nil
  12207. }
  12208. fallthrough
  12209. case m.op.Is(OpUpdate | OpDelete):
  12210. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  12211. default:
  12212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12213. }
  12214. }
  12215. // SetCreatedAt sets the "created_at" field.
  12216. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  12217. m.created_at = &t
  12218. }
  12219. // CreatedAt returns the value of the "created_at" field in the mutation.
  12220. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  12221. v := m.created_at
  12222. if v == nil {
  12223. return
  12224. }
  12225. return *v, true
  12226. }
  12227. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  12228. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12230. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12231. if !m.op.Is(OpUpdateOne) {
  12232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12233. }
  12234. if m.id == nil || m.oldValue == nil {
  12235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12236. }
  12237. oldValue, err := m.oldValue(ctx)
  12238. if err != nil {
  12239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12240. }
  12241. return oldValue.CreatedAt, nil
  12242. }
  12243. // ResetCreatedAt resets all changes to the "created_at" field.
  12244. func (m *ContactMutation) ResetCreatedAt() {
  12245. m.created_at = nil
  12246. }
  12247. // SetUpdatedAt sets the "updated_at" field.
  12248. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  12249. m.updated_at = &t
  12250. }
  12251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12252. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  12253. v := m.updated_at
  12254. if v == nil {
  12255. return
  12256. }
  12257. return *v, true
  12258. }
  12259. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  12260. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12262. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12263. if !m.op.Is(OpUpdateOne) {
  12264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12265. }
  12266. if m.id == nil || m.oldValue == nil {
  12267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12268. }
  12269. oldValue, err := m.oldValue(ctx)
  12270. if err != nil {
  12271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12272. }
  12273. return oldValue.UpdatedAt, nil
  12274. }
  12275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12276. func (m *ContactMutation) ResetUpdatedAt() {
  12277. m.updated_at = nil
  12278. }
  12279. // SetStatus sets the "status" field.
  12280. func (m *ContactMutation) SetStatus(u uint8) {
  12281. m.status = &u
  12282. m.addstatus = nil
  12283. }
  12284. // Status returns the value of the "status" field in the mutation.
  12285. func (m *ContactMutation) Status() (r uint8, exists bool) {
  12286. v := m.status
  12287. if v == nil {
  12288. return
  12289. }
  12290. return *v, true
  12291. }
  12292. // OldStatus returns the old "status" field's value of the Contact entity.
  12293. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12295. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12296. if !m.op.Is(OpUpdateOne) {
  12297. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12298. }
  12299. if m.id == nil || m.oldValue == nil {
  12300. return v, errors.New("OldStatus requires an ID field in the mutation")
  12301. }
  12302. oldValue, err := m.oldValue(ctx)
  12303. if err != nil {
  12304. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12305. }
  12306. return oldValue.Status, nil
  12307. }
  12308. // AddStatus adds u to the "status" field.
  12309. func (m *ContactMutation) AddStatus(u int8) {
  12310. if m.addstatus != nil {
  12311. *m.addstatus += u
  12312. } else {
  12313. m.addstatus = &u
  12314. }
  12315. }
  12316. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12317. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  12318. v := m.addstatus
  12319. if v == nil {
  12320. return
  12321. }
  12322. return *v, true
  12323. }
  12324. // ClearStatus clears the value of the "status" field.
  12325. func (m *ContactMutation) ClearStatus() {
  12326. m.status = nil
  12327. m.addstatus = nil
  12328. m.clearedFields[contact.FieldStatus] = struct{}{}
  12329. }
  12330. // StatusCleared returns if the "status" field was cleared in this mutation.
  12331. func (m *ContactMutation) StatusCleared() bool {
  12332. _, ok := m.clearedFields[contact.FieldStatus]
  12333. return ok
  12334. }
  12335. // ResetStatus resets all changes to the "status" field.
  12336. func (m *ContactMutation) ResetStatus() {
  12337. m.status = nil
  12338. m.addstatus = nil
  12339. delete(m.clearedFields, contact.FieldStatus)
  12340. }
  12341. // SetDeletedAt sets the "deleted_at" field.
  12342. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  12343. m.deleted_at = &t
  12344. }
  12345. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12346. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  12347. v := m.deleted_at
  12348. if v == nil {
  12349. return
  12350. }
  12351. return *v, true
  12352. }
  12353. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  12354. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12356. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12357. if !m.op.Is(OpUpdateOne) {
  12358. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12359. }
  12360. if m.id == nil || m.oldValue == nil {
  12361. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12362. }
  12363. oldValue, err := m.oldValue(ctx)
  12364. if err != nil {
  12365. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12366. }
  12367. return oldValue.DeletedAt, nil
  12368. }
  12369. // ClearDeletedAt clears the value of the "deleted_at" field.
  12370. func (m *ContactMutation) ClearDeletedAt() {
  12371. m.deleted_at = nil
  12372. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  12373. }
  12374. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12375. func (m *ContactMutation) DeletedAtCleared() bool {
  12376. _, ok := m.clearedFields[contact.FieldDeletedAt]
  12377. return ok
  12378. }
  12379. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12380. func (m *ContactMutation) ResetDeletedAt() {
  12381. m.deleted_at = nil
  12382. delete(m.clearedFields, contact.FieldDeletedAt)
  12383. }
  12384. // SetWxWxid sets the "wx_wxid" field.
  12385. func (m *ContactMutation) SetWxWxid(s string) {
  12386. m.wx_wxid = &s
  12387. }
  12388. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12389. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  12390. v := m.wx_wxid
  12391. if v == nil {
  12392. return
  12393. }
  12394. return *v, true
  12395. }
  12396. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  12397. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12399. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12400. if !m.op.Is(OpUpdateOne) {
  12401. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12402. }
  12403. if m.id == nil || m.oldValue == nil {
  12404. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12405. }
  12406. oldValue, err := m.oldValue(ctx)
  12407. if err != nil {
  12408. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12409. }
  12410. return oldValue.WxWxid, nil
  12411. }
  12412. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12413. func (m *ContactMutation) ResetWxWxid() {
  12414. m.wx_wxid = nil
  12415. }
  12416. // SetType sets the "type" field.
  12417. func (m *ContactMutation) SetType(i int) {
  12418. m._type = &i
  12419. m.add_type = nil
  12420. }
  12421. // GetType returns the value of the "type" field in the mutation.
  12422. func (m *ContactMutation) GetType() (r int, exists bool) {
  12423. v := m._type
  12424. if v == nil {
  12425. return
  12426. }
  12427. return *v, true
  12428. }
  12429. // OldType returns the old "type" field's value of the Contact entity.
  12430. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12432. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  12433. if !m.op.Is(OpUpdateOne) {
  12434. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12435. }
  12436. if m.id == nil || m.oldValue == nil {
  12437. return v, errors.New("OldType requires an ID field in the mutation")
  12438. }
  12439. oldValue, err := m.oldValue(ctx)
  12440. if err != nil {
  12441. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12442. }
  12443. return oldValue.Type, nil
  12444. }
  12445. // AddType adds i to the "type" field.
  12446. func (m *ContactMutation) AddType(i int) {
  12447. if m.add_type != nil {
  12448. *m.add_type += i
  12449. } else {
  12450. m.add_type = &i
  12451. }
  12452. }
  12453. // AddedType returns the value that was added to the "type" field in this mutation.
  12454. func (m *ContactMutation) AddedType() (r int, exists bool) {
  12455. v := m.add_type
  12456. if v == nil {
  12457. return
  12458. }
  12459. return *v, true
  12460. }
  12461. // ClearType clears the value of the "type" field.
  12462. func (m *ContactMutation) ClearType() {
  12463. m._type = nil
  12464. m.add_type = nil
  12465. m.clearedFields[contact.FieldType] = struct{}{}
  12466. }
  12467. // TypeCleared returns if the "type" field was cleared in this mutation.
  12468. func (m *ContactMutation) TypeCleared() bool {
  12469. _, ok := m.clearedFields[contact.FieldType]
  12470. return ok
  12471. }
  12472. // ResetType resets all changes to the "type" field.
  12473. func (m *ContactMutation) ResetType() {
  12474. m._type = nil
  12475. m.add_type = nil
  12476. delete(m.clearedFields, contact.FieldType)
  12477. }
  12478. // SetWxid sets the "wxid" field.
  12479. func (m *ContactMutation) SetWxid(s string) {
  12480. m.wxid = &s
  12481. }
  12482. // Wxid returns the value of the "wxid" field in the mutation.
  12483. func (m *ContactMutation) Wxid() (r string, exists bool) {
  12484. v := m.wxid
  12485. if v == nil {
  12486. return
  12487. }
  12488. return *v, true
  12489. }
  12490. // OldWxid returns the old "wxid" field's value of the Contact entity.
  12491. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12493. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  12494. if !m.op.Is(OpUpdateOne) {
  12495. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12496. }
  12497. if m.id == nil || m.oldValue == nil {
  12498. return v, errors.New("OldWxid requires an ID field in the mutation")
  12499. }
  12500. oldValue, err := m.oldValue(ctx)
  12501. if err != nil {
  12502. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12503. }
  12504. return oldValue.Wxid, nil
  12505. }
  12506. // ResetWxid resets all changes to the "wxid" field.
  12507. func (m *ContactMutation) ResetWxid() {
  12508. m.wxid = nil
  12509. }
  12510. // SetAccount sets the "account" field.
  12511. func (m *ContactMutation) SetAccount(s string) {
  12512. m.account = &s
  12513. }
  12514. // Account returns the value of the "account" field in the mutation.
  12515. func (m *ContactMutation) Account() (r string, exists bool) {
  12516. v := m.account
  12517. if v == nil {
  12518. return
  12519. }
  12520. return *v, true
  12521. }
  12522. // OldAccount returns the old "account" field's value of the Contact entity.
  12523. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12525. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  12526. if !m.op.Is(OpUpdateOne) {
  12527. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  12528. }
  12529. if m.id == nil || m.oldValue == nil {
  12530. return v, errors.New("OldAccount requires an ID field in the mutation")
  12531. }
  12532. oldValue, err := m.oldValue(ctx)
  12533. if err != nil {
  12534. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  12535. }
  12536. return oldValue.Account, nil
  12537. }
  12538. // ResetAccount resets all changes to the "account" field.
  12539. func (m *ContactMutation) ResetAccount() {
  12540. m.account = nil
  12541. }
  12542. // SetNickname sets the "nickname" field.
  12543. func (m *ContactMutation) SetNickname(s string) {
  12544. m.nickname = &s
  12545. }
  12546. // Nickname returns the value of the "nickname" field in the mutation.
  12547. func (m *ContactMutation) Nickname() (r string, exists bool) {
  12548. v := m.nickname
  12549. if v == nil {
  12550. return
  12551. }
  12552. return *v, true
  12553. }
  12554. // OldNickname returns the old "nickname" field's value of the Contact entity.
  12555. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12557. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  12558. if !m.op.Is(OpUpdateOne) {
  12559. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  12560. }
  12561. if m.id == nil || m.oldValue == nil {
  12562. return v, errors.New("OldNickname requires an ID field in the mutation")
  12563. }
  12564. oldValue, err := m.oldValue(ctx)
  12565. if err != nil {
  12566. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  12567. }
  12568. return oldValue.Nickname, nil
  12569. }
  12570. // ResetNickname resets all changes to the "nickname" field.
  12571. func (m *ContactMutation) ResetNickname() {
  12572. m.nickname = nil
  12573. }
  12574. // SetMarkname sets the "markname" field.
  12575. func (m *ContactMutation) SetMarkname(s string) {
  12576. m.markname = &s
  12577. }
  12578. // Markname returns the value of the "markname" field in the mutation.
  12579. func (m *ContactMutation) Markname() (r string, exists bool) {
  12580. v := m.markname
  12581. if v == nil {
  12582. return
  12583. }
  12584. return *v, true
  12585. }
  12586. // OldMarkname returns the old "markname" field's value of the Contact entity.
  12587. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12589. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  12590. if !m.op.Is(OpUpdateOne) {
  12591. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  12592. }
  12593. if m.id == nil || m.oldValue == nil {
  12594. return v, errors.New("OldMarkname requires an ID field in the mutation")
  12595. }
  12596. oldValue, err := m.oldValue(ctx)
  12597. if err != nil {
  12598. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  12599. }
  12600. return oldValue.Markname, nil
  12601. }
  12602. // ResetMarkname resets all changes to the "markname" field.
  12603. func (m *ContactMutation) ResetMarkname() {
  12604. m.markname = nil
  12605. }
  12606. // SetHeadimg sets the "headimg" field.
  12607. func (m *ContactMutation) SetHeadimg(s string) {
  12608. m.headimg = &s
  12609. }
  12610. // Headimg returns the value of the "headimg" field in the mutation.
  12611. func (m *ContactMutation) Headimg() (r string, exists bool) {
  12612. v := m.headimg
  12613. if v == nil {
  12614. return
  12615. }
  12616. return *v, true
  12617. }
  12618. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  12619. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12621. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  12622. if !m.op.Is(OpUpdateOne) {
  12623. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  12624. }
  12625. if m.id == nil || m.oldValue == nil {
  12626. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  12627. }
  12628. oldValue, err := m.oldValue(ctx)
  12629. if err != nil {
  12630. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  12631. }
  12632. return oldValue.Headimg, nil
  12633. }
  12634. // ResetHeadimg resets all changes to the "headimg" field.
  12635. func (m *ContactMutation) ResetHeadimg() {
  12636. m.headimg = nil
  12637. }
  12638. // SetSex sets the "sex" field.
  12639. func (m *ContactMutation) SetSex(i int) {
  12640. m.sex = &i
  12641. m.addsex = nil
  12642. }
  12643. // Sex returns the value of the "sex" field in the mutation.
  12644. func (m *ContactMutation) Sex() (r int, exists bool) {
  12645. v := m.sex
  12646. if v == nil {
  12647. return
  12648. }
  12649. return *v, true
  12650. }
  12651. // OldSex returns the old "sex" field's value of the Contact entity.
  12652. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12654. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  12655. if !m.op.Is(OpUpdateOne) {
  12656. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  12657. }
  12658. if m.id == nil || m.oldValue == nil {
  12659. return v, errors.New("OldSex requires an ID field in the mutation")
  12660. }
  12661. oldValue, err := m.oldValue(ctx)
  12662. if err != nil {
  12663. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  12664. }
  12665. return oldValue.Sex, nil
  12666. }
  12667. // AddSex adds i to the "sex" field.
  12668. func (m *ContactMutation) AddSex(i int) {
  12669. if m.addsex != nil {
  12670. *m.addsex += i
  12671. } else {
  12672. m.addsex = &i
  12673. }
  12674. }
  12675. // AddedSex returns the value that was added to the "sex" field in this mutation.
  12676. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  12677. v := m.addsex
  12678. if v == nil {
  12679. return
  12680. }
  12681. return *v, true
  12682. }
  12683. // ResetSex resets all changes to the "sex" field.
  12684. func (m *ContactMutation) ResetSex() {
  12685. m.sex = nil
  12686. m.addsex = nil
  12687. }
  12688. // SetStarrole sets the "starrole" field.
  12689. func (m *ContactMutation) SetStarrole(s string) {
  12690. m.starrole = &s
  12691. }
  12692. // Starrole returns the value of the "starrole" field in the mutation.
  12693. func (m *ContactMutation) Starrole() (r string, exists bool) {
  12694. v := m.starrole
  12695. if v == nil {
  12696. return
  12697. }
  12698. return *v, true
  12699. }
  12700. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  12701. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12703. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  12704. if !m.op.Is(OpUpdateOne) {
  12705. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  12706. }
  12707. if m.id == nil || m.oldValue == nil {
  12708. return v, errors.New("OldStarrole requires an ID field in the mutation")
  12709. }
  12710. oldValue, err := m.oldValue(ctx)
  12711. if err != nil {
  12712. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  12713. }
  12714. return oldValue.Starrole, nil
  12715. }
  12716. // ResetStarrole resets all changes to the "starrole" field.
  12717. func (m *ContactMutation) ResetStarrole() {
  12718. m.starrole = nil
  12719. }
  12720. // SetDontseeit sets the "dontseeit" field.
  12721. func (m *ContactMutation) SetDontseeit(i int) {
  12722. m.dontseeit = &i
  12723. m.adddontseeit = nil
  12724. }
  12725. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  12726. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  12727. v := m.dontseeit
  12728. if v == nil {
  12729. return
  12730. }
  12731. return *v, true
  12732. }
  12733. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  12734. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12736. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  12737. if !m.op.Is(OpUpdateOne) {
  12738. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  12739. }
  12740. if m.id == nil || m.oldValue == nil {
  12741. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  12742. }
  12743. oldValue, err := m.oldValue(ctx)
  12744. if err != nil {
  12745. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  12746. }
  12747. return oldValue.Dontseeit, nil
  12748. }
  12749. // AddDontseeit adds i to the "dontseeit" field.
  12750. func (m *ContactMutation) AddDontseeit(i int) {
  12751. if m.adddontseeit != nil {
  12752. *m.adddontseeit += i
  12753. } else {
  12754. m.adddontseeit = &i
  12755. }
  12756. }
  12757. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  12758. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  12759. v := m.adddontseeit
  12760. if v == nil {
  12761. return
  12762. }
  12763. return *v, true
  12764. }
  12765. // ResetDontseeit resets all changes to the "dontseeit" field.
  12766. func (m *ContactMutation) ResetDontseeit() {
  12767. m.dontseeit = nil
  12768. m.adddontseeit = nil
  12769. }
  12770. // SetDontseeme sets the "dontseeme" field.
  12771. func (m *ContactMutation) SetDontseeme(i int) {
  12772. m.dontseeme = &i
  12773. m.adddontseeme = nil
  12774. }
  12775. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  12776. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  12777. v := m.dontseeme
  12778. if v == nil {
  12779. return
  12780. }
  12781. return *v, true
  12782. }
  12783. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  12784. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12786. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  12787. if !m.op.Is(OpUpdateOne) {
  12788. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  12789. }
  12790. if m.id == nil || m.oldValue == nil {
  12791. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  12792. }
  12793. oldValue, err := m.oldValue(ctx)
  12794. if err != nil {
  12795. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  12796. }
  12797. return oldValue.Dontseeme, nil
  12798. }
  12799. // AddDontseeme adds i to the "dontseeme" field.
  12800. func (m *ContactMutation) AddDontseeme(i int) {
  12801. if m.adddontseeme != nil {
  12802. *m.adddontseeme += i
  12803. } else {
  12804. m.adddontseeme = &i
  12805. }
  12806. }
  12807. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  12808. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  12809. v := m.adddontseeme
  12810. if v == nil {
  12811. return
  12812. }
  12813. return *v, true
  12814. }
  12815. // ResetDontseeme resets all changes to the "dontseeme" field.
  12816. func (m *ContactMutation) ResetDontseeme() {
  12817. m.dontseeme = nil
  12818. m.adddontseeme = nil
  12819. }
  12820. // SetLag sets the "lag" field.
  12821. func (m *ContactMutation) SetLag(s string) {
  12822. m.lag = &s
  12823. }
  12824. // Lag returns the value of the "lag" field in the mutation.
  12825. func (m *ContactMutation) Lag() (r string, exists bool) {
  12826. v := m.lag
  12827. if v == nil {
  12828. return
  12829. }
  12830. return *v, true
  12831. }
  12832. // OldLag returns the old "lag" field's value of the Contact entity.
  12833. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12835. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  12836. if !m.op.Is(OpUpdateOne) {
  12837. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  12838. }
  12839. if m.id == nil || m.oldValue == nil {
  12840. return v, errors.New("OldLag requires an ID field in the mutation")
  12841. }
  12842. oldValue, err := m.oldValue(ctx)
  12843. if err != nil {
  12844. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  12845. }
  12846. return oldValue.Lag, nil
  12847. }
  12848. // ResetLag resets all changes to the "lag" field.
  12849. func (m *ContactMutation) ResetLag() {
  12850. m.lag = nil
  12851. }
  12852. // SetGid sets the "gid" field.
  12853. func (m *ContactMutation) SetGid(s string) {
  12854. m.gid = &s
  12855. }
  12856. // Gid returns the value of the "gid" field in the mutation.
  12857. func (m *ContactMutation) Gid() (r string, exists bool) {
  12858. v := m.gid
  12859. if v == nil {
  12860. return
  12861. }
  12862. return *v, true
  12863. }
  12864. // OldGid returns the old "gid" field's value of the Contact entity.
  12865. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12867. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  12868. if !m.op.Is(OpUpdateOne) {
  12869. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  12870. }
  12871. if m.id == nil || m.oldValue == nil {
  12872. return v, errors.New("OldGid requires an ID field in the mutation")
  12873. }
  12874. oldValue, err := m.oldValue(ctx)
  12875. if err != nil {
  12876. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  12877. }
  12878. return oldValue.Gid, nil
  12879. }
  12880. // ResetGid resets all changes to the "gid" field.
  12881. func (m *ContactMutation) ResetGid() {
  12882. m.gid = nil
  12883. }
  12884. // SetGname sets the "gname" field.
  12885. func (m *ContactMutation) SetGname(s string) {
  12886. m.gname = &s
  12887. }
  12888. // Gname returns the value of the "gname" field in the mutation.
  12889. func (m *ContactMutation) Gname() (r string, exists bool) {
  12890. v := m.gname
  12891. if v == nil {
  12892. return
  12893. }
  12894. return *v, true
  12895. }
  12896. // OldGname returns the old "gname" field's value of the Contact entity.
  12897. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12899. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  12900. if !m.op.Is(OpUpdateOne) {
  12901. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  12902. }
  12903. if m.id == nil || m.oldValue == nil {
  12904. return v, errors.New("OldGname requires an ID field in the mutation")
  12905. }
  12906. oldValue, err := m.oldValue(ctx)
  12907. if err != nil {
  12908. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  12909. }
  12910. return oldValue.Gname, nil
  12911. }
  12912. // ResetGname resets all changes to the "gname" field.
  12913. func (m *ContactMutation) ResetGname() {
  12914. m.gname = nil
  12915. }
  12916. // SetV3 sets the "v3" field.
  12917. func (m *ContactMutation) SetV3(s string) {
  12918. m.v3 = &s
  12919. }
  12920. // V3 returns the value of the "v3" field in the mutation.
  12921. func (m *ContactMutation) V3() (r string, exists bool) {
  12922. v := m.v3
  12923. if v == nil {
  12924. return
  12925. }
  12926. return *v, true
  12927. }
  12928. // OldV3 returns the old "v3" field's value of the Contact entity.
  12929. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12931. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  12932. if !m.op.Is(OpUpdateOne) {
  12933. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  12934. }
  12935. if m.id == nil || m.oldValue == nil {
  12936. return v, errors.New("OldV3 requires an ID field in the mutation")
  12937. }
  12938. oldValue, err := m.oldValue(ctx)
  12939. if err != nil {
  12940. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  12941. }
  12942. return oldValue.V3, nil
  12943. }
  12944. // ResetV3 resets all changes to the "v3" field.
  12945. func (m *ContactMutation) ResetV3() {
  12946. m.v3 = nil
  12947. }
  12948. // SetOrganizationID sets the "organization_id" field.
  12949. func (m *ContactMutation) SetOrganizationID(u uint64) {
  12950. m.organization_id = &u
  12951. m.addorganization_id = nil
  12952. }
  12953. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12954. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  12955. v := m.organization_id
  12956. if v == nil {
  12957. return
  12958. }
  12959. return *v, true
  12960. }
  12961. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  12962. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12964. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12965. if !m.op.Is(OpUpdateOne) {
  12966. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12967. }
  12968. if m.id == nil || m.oldValue == nil {
  12969. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12970. }
  12971. oldValue, err := m.oldValue(ctx)
  12972. if err != nil {
  12973. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12974. }
  12975. return oldValue.OrganizationID, nil
  12976. }
  12977. // AddOrganizationID adds u to the "organization_id" field.
  12978. func (m *ContactMutation) AddOrganizationID(u int64) {
  12979. if m.addorganization_id != nil {
  12980. *m.addorganization_id += u
  12981. } else {
  12982. m.addorganization_id = &u
  12983. }
  12984. }
  12985. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12986. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  12987. v := m.addorganization_id
  12988. if v == nil {
  12989. return
  12990. }
  12991. return *v, true
  12992. }
  12993. // ClearOrganizationID clears the value of the "organization_id" field.
  12994. func (m *ContactMutation) ClearOrganizationID() {
  12995. m.organization_id = nil
  12996. m.addorganization_id = nil
  12997. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  12998. }
  12999. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13000. func (m *ContactMutation) OrganizationIDCleared() bool {
  13001. _, ok := m.clearedFields[contact.FieldOrganizationID]
  13002. return ok
  13003. }
  13004. // ResetOrganizationID resets all changes to the "organization_id" field.
  13005. func (m *ContactMutation) ResetOrganizationID() {
  13006. m.organization_id = nil
  13007. m.addorganization_id = nil
  13008. delete(m.clearedFields, contact.FieldOrganizationID)
  13009. }
  13010. // SetCtype sets the "ctype" field.
  13011. func (m *ContactMutation) SetCtype(u uint64) {
  13012. m.ctype = &u
  13013. m.addctype = nil
  13014. }
  13015. // Ctype returns the value of the "ctype" field in the mutation.
  13016. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  13017. v := m.ctype
  13018. if v == nil {
  13019. return
  13020. }
  13021. return *v, true
  13022. }
  13023. // OldCtype returns the old "ctype" field's value of the Contact entity.
  13024. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13026. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  13027. if !m.op.Is(OpUpdateOne) {
  13028. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  13029. }
  13030. if m.id == nil || m.oldValue == nil {
  13031. return v, errors.New("OldCtype requires an ID field in the mutation")
  13032. }
  13033. oldValue, err := m.oldValue(ctx)
  13034. if err != nil {
  13035. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  13036. }
  13037. return oldValue.Ctype, nil
  13038. }
  13039. // AddCtype adds u to the "ctype" field.
  13040. func (m *ContactMutation) AddCtype(u int64) {
  13041. if m.addctype != nil {
  13042. *m.addctype += u
  13043. } else {
  13044. m.addctype = &u
  13045. }
  13046. }
  13047. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  13048. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  13049. v := m.addctype
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // ResetCtype resets all changes to the "ctype" field.
  13056. func (m *ContactMutation) ResetCtype() {
  13057. m.ctype = nil
  13058. m.addctype = nil
  13059. }
  13060. // SetCage sets the "cage" field.
  13061. func (m *ContactMutation) SetCage(i int) {
  13062. m.cage = &i
  13063. m.addcage = nil
  13064. }
  13065. // Cage returns the value of the "cage" field in the mutation.
  13066. func (m *ContactMutation) Cage() (r int, exists bool) {
  13067. v := m.cage
  13068. if v == nil {
  13069. return
  13070. }
  13071. return *v, true
  13072. }
  13073. // OldCage returns the old "cage" field's value of the Contact entity.
  13074. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13076. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  13077. if !m.op.Is(OpUpdateOne) {
  13078. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  13079. }
  13080. if m.id == nil || m.oldValue == nil {
  13081. return v, errors.New("OldCage requires an ID field in the mutation")
  13082. }
  13083. oldValue, err := m.oldValue(ctx)
  13084. if err != nil {
  13085. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  13086. }
  13087. return oldValue.Cage, nil
  13088. }
  13089. // AddCage adds i to the "cage" field.
  13090. func (m *ContactMutation) AddCage(i int) {
  13091. if m.addcage != nil {
  13092. *m.addcage += i
  13093. } else {
  13094. m.addcage = &i
  13095. }
  13096. }
  13097. // AddedCage returns the value that was added to the "cage" field in this mutation.
  13098. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  13099. v := m.addcage
  13100. if v == nil {
  13101. return
  13102. }
  13103. return *v, true
  13104. }
  13105. // ResetCage resets all changes to the "cage" field.
  13106. func (m *ContactMutation) ResetCage() {
  13107. m.cage = nil
  13108. m.addcage = nil
  13109. }
  13110. // SetCname sets the "cname" field.
  13111. func (m *ContactMutation) SetCname(s string) {
  13112. m.cname = &s
  13113. }
  13114. // Cname returns the value of the "cname" field in the mutation.
  13115. func (m *ContactMutation) Cname() (r string, exists bool) {
  13116. v := m.cname
  13117. if v == nil {
  13118. return
  13119. }
  13120. return *v, true
  13121. }
  13122. // OldCname returns the old "cname" field's value of the Contact entity.
  13123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13125. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  13126. if !m.op.Is(OpUpdateOne) {
  13127. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  13128. }
  13129. if m.id == nil || m.oldValue == nil {
  13130. return v, errors.New("OldCname requires an ID field in the mutation")
  13131. }
  13132. oldValue, err := m.oldValue(ctx)
  13133. if err != nil {
  13134. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  13135. }
  13136. return oldValue.Cname, nil
  13137. }
  13138. // ResetCname resets all changes to the "cname" field.
  13139. func (m *ContactMutation) ResetCname() {
  13140. m.cname = nil
  13141. }
  13142. // SetCarea sets the "carea" field.
  13143. func (m *ContactMutation) SetCarea(s string) {
  13144. m.carea = &s
  13145. }
  13146. // Carea returns the value of the "carea" field in the mutation.
  13147. func (m *ContactMutation) Carea() (r string, exists bool) {
  13148. v := m.carea
  13149. if v == nil {
  13150. return
  13151. }
  13152. return *v, true
  13153. }
  13154. // OldCarea returns the old "carea" field's value of the Contact entity.
  13155. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13157. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  13158. if !m.op.Is(OpUpdateOne) {
  13159. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  13160. }
  13161. if m.id == nil || m.oldValue == nil {
  13162. return v, errors.New("OldCarea requires an ID field in the mutation")
  13163. }
  13164. oldValue, err := m.oldValue(ctx)
  13165. if err != nil {
  13166. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  13167. }
  13168. return oldValue.Carea, nil
  13169. }
  13170. // ResetCarea resets all changes to the "carea" field.
  13171. func (m *ContactMutation) ResetCarea() {
  13172. m.carea = nil
  13173. }
  13174. // SetCbirthday sets the "cbirthday" field.
  13175. func (m *ContactMutation) SetCbirthday(s string) {
  13176. m.cbirthday = &s
  13177. }
  13178. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  13179. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  13180. v := m.cbirthday
  13181. if v == nil {
  13182. return
  13183. }
  13184. return *v, true
  13185. }
  13186. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  13187. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13189. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  13190. if !m.op.Is(OpUpdateOne) {
  13191. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  13192. }
  13193. if m.id == nil || m.oldValue == nil {
  13194. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  13195. }
  13196. oldValue, err := m.oldValue(ctx)
  13197. if err != nil {
  13198. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  13199. }
  13200. return oldValue.Cbirthday, nil
  13201. }
  13202. // ResetCbirthday resets all changes to the "cbirthday" field.
  13203. func (m *ContactMutation) ResetCbirthday() {
  13204. m.cbirthday = nil
  13205. }
  13206. // SetCbirtharea sets the "cbirtharea" field.
  13207. func (m *ContactMutation) SetCbirtharea(s string) {
  13208. m.cbirtharea = &s
  13209. }
  13210. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  13211. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  13212. v := m.cbirtharea
  13213. if v == nil {
  13214. return
  13215. }
  13216. return *v, true
  13217. }
  13218. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  13219. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13221. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  13222. if !m.op.Is(OpUpdateOne) {
  13223. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  13224. }
  13225. if m.id == nil || m.oldValue == nil {
  13226. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  13227. }
  13228. oldValue, err := m.oldValue(ctx)
  13229. if err != nil {
  13230. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  13231. }
  13232. return oldValue.Cbirtharea, nil
  13233. }
  13234. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  13235. func (m *ContactMutation) ResetCbirtharea() {
  13236. m.cbirtharea = nil
  13237. }
  13238. // SetCidcardNo sets the "cidcard_no" field.
  13239. func (m *ContactMutation) SetCidcardNo(s string) {
  13240. m.cidcard_no = &s
  13241. }
  13242. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  13243. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  13244. v := m.cidcard_no
  13245. if v == nil {
  13246. return
  13247. }
  13248. return *v, true
  13249. }
  13250. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  13251. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13253. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  13254. if !m.op.Is(OpUpdateOne) {
  13255. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  13256. }
  13257. if m.id == nil || m.oldValue == nil {
  13258. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  13259. }
  13260. oldValue, err := m.oldValue(ctx)
  13261. if err != nil {
  13262. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  13263. }
  13264. return oldValue.CidcardNo, nil
  13265. }
  13266. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  13267. func (m *ContactMutation) ResetCidcardNo() {
  13268. m.cidcard_no = nil
  13269. }
  13270. // SetCtitle sets the "ctitle" field.
  13271. func (m *ContactMutation) SetCtitle(s string) {
  13272. m.ctitle = &s
  13273. }
  13274. // Ctitle returns the value of the "ctitle" field in the mutation.
  13275. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  13276. v := m.ctitle
  13277. if v == nil {
  13278. return
  13279. }
  13280. return *v, true
  13281. }
  13282. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  13283. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13285. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  13286. if !m.op.Is(OpUpdateOne) {
  13287. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  13288. }
  13289. if m.id == nil || m.oldValue == nil {
  13290. return v, errors.New("OldCtitle requires an ID field in the mutation")
  13291. }
  13292. oldValue, err := m.oldValue(ctx)
  13293. if err != nil {
  13294. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  13295. }
  13296. return oldValue.Ctitle, nil
  13297. }
  13298. // ResetCtitle resets all changes to the "ctitle" field.
  13299. func (m *ContactMutation) ResetCtitle() {
  13300. m.ctitle = nil
  13301. }
  13302. // SetCc sets the "cc" field.
  13303. func (m *ContactMutation) SetCc(s string) {
  13304. m.cc = &s
  13305. }
  13306. // Cc returns the value of the "cc" field in the mutation.
  13307. func (m *ContactMutation) Cc() (r string, exists bool) {
  13308. v := m.cc
  13309. if v == nil {
  13310. return
  13311. }
  13312. return *v, true
  13313. }
  13314. // OldCc returns the old "cc" field's value of the Contact entity.
  13315. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13317. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  13318. if !m.op.Is(OpUpdateOne) {
  13319. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  13320. }
  13321. if m.id == nil || m.oldValue == nil {
  13322. return v, errors.New("OldCc requires an ID field in the mutation")
  13323. }
  13324. oldValue, err := m.oldValue(ctx)
  13325. if err != nil {
  13326. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  13327. }
  13328. return oldValue.Cc, nil
  13329. }
  13330. // ResetCc resets all changes to the "cc" field.
  13331. func (m *ContactMutation) ResetCc() {
  13332. m.cc = nil
  13333. }
  13334. // SetPhone sets the "phone" field.
  13335. func (m *ContactMutation) SetPhone(s string) {
  13336. m.phone = &s
  13337. }
  13338. // Phone returns the value of the "phone" field in the mutation.
  13339. func (m *ContactMutation) Phone() (r string, exists bool) {
  13340. v := m.phone
  13341. if v == nil {
  13342. return
  13343. }
  13344. return *v, true
  13345. }
  13346. // OldPhone returns the old "phone" field's value of the Contact entity.
  13347. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13349. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  13350. if !m.op.Is(OpUpdateOne) {
  13351. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  13352. }
  13353. if m.id == nil || m.oldValue == nil {
  13354. return v, errors.New("OldPhone requires an ID field in the mutation")
  13355. }
  13356. oldValue, err := m.oldValue(ctx)
  13357. if err != nil {
  13358. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  13359. }
  13360. return oldValue.Phone, nil
  13361. }
  13362. // ResetPhone resets all changes to the "phone" field.
  13363. func (m *ContactMutation) ResetPhone() {
  13364. m.phone = nil
  13365. }
  13366. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  13367. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  13368. if m.contact_relationships == nil {
  13369. m.contact_relationships = make(map[uint64]struct{})
  13370. }
  13371. for i := range ids {
  13372. m.contact_relationships[ids[i]] = struct{}{}
  13373. }
  13374. }
  13375. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  13376. func (m *ContactMutation) ClearContactRelationships() {
  13377. m.clearedcontact_relationships = true
  13378. }
  13379. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  13380. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  13381. return m.clearedcontact_relationships
  13382. }
  13383. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  13384. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  13385. if m.removedcontact_relationships == nil {
  13386. m.removedcontact_relationships = make(map[uint64]struct{})
  13387. }
  13388. for i := range ids {
  13389. delete(m.contact_relationships, ids[i])
  13390. m.removedcontact_relationships[ids[i]] = struct{}{}
  13391. }
  13392. }
  13393. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  13394. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  13395. for id := range m.removedcontact_relationships {
  13396. ids = append(ids, id)
  13397. }
  13398. return
  13399. }
  13400. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  13401. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  13402. for id := range m.contact_relationships {
  13403. ids = append(ids, id)
  13404. }
  13405. return
  13406. }
  13407. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  13408. func (m *ContactMutation) ResetContactRelationships() {
  13409. m.contact_relationships = nil
  13410. m.clearedcontact_relationships = false
  13411. m.removedcontact_relationships = nil
  13412. }
  13413. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  13414. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  13415. if m.contact_fields == nil {
  13416. m.contact_fields = make(map[uint64]struct{})
  13417. }
  13418. for i := range ids {
  13419. m.contact_fields[ids[i]] = struct{}{}
  13420. }
  13421. }
  13422. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  13423. func (m *ContactMutation) ClearContactFields() {
  13424. m.clearedcontact_fields = true
  13425. }
  13426. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  13427. func (m *ContactMutation) ContactFieldsCleared() bool {
  13428. return m.clearedcontact_fields
  13429. }
  13430. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  13431. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  13432. if m.removedcontact_fields == nil {
  13433. m.removedcontact_fields = make(map[uint64]struct{})
  13434. }
  13435. for i := range ids {
  13436. delete(m.contact_fields, ids[i])
  13437. m.removedcontact_fields[ids[i]] = struct{}{}
  13438. }
  13439. }
  13440. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  13441. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  13442. for id := range m.removedcontact_fields {
  13443. ids = append(ids, id)
  13444. }
  13445. return
  13446. }
  13447. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  13448. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  13449. for id := range m.contact_fields {
  13450. ids = append(ids, id)
  13451. }
  13452. return
  13453. }
  13454. // ResetContactFields resets all changes to the "contact_fields" edge.
  13455. func (m *ContactMutation) ResetContactFields() {
  13456. m.contact_fields = nil
  13457. m.clearedcontact_fields = false
  13458. m.removedcontact_fields = nil
  13459. }
  13460. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  13461. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  13462. if m.contact_messages == nil {
  13463. m.contact_messages = make(map[uint64]struct{})
  13464. }
  13465. for i := range ids {
  13466. m.contact_messages[ids[i]] = struct{}{}
  13467. }
  13468. }
  13469. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  13470. func (m *ContactMutation) ClearContactMessages() {
  13471. m.clearedcontact_messages = true
  13472. }
  13473. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  13474. func (m *ContactMutation) ContactMessagesCleared() bool {
  13475. return m.clearedcontact_messages
  13476. }
  13477. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  13478. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  13479. if m.removedcontact_messages == nil {
  13480. m.removedcontact_messages = make(map[uint64]struct{})
  13481. }
  13482. for i := range ids {
  13483. delete(m.contact_messages, ids[i])
  13484. m.removedcontact_messages[ids[i]] = struct{}{}
  13485. }
  13486. }
  13487. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  13488. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  13489. for id := range m.removedcontact_messages {
  13490. ids = append(ids, id)
  13491. }
  13492. return
  13493. }
  13494. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  13495. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  13496. for id := range m.contact_messages {
  13497. ids = append(ids, id)
  13498. }
  13499. return
  13500. }
  13501. // ResetContactMessages resets all changes to the "contact_messages" edge.
  13502. func (m *ContactMutation) ResetContactMessages() {
  13503. m.contact_messages = nil
  13504. m.clearedcontact_messages = false
  13505. m.removedcontact_messages = nil
  13506. }
  13507. // Where appends a list predicates to the ContactMutation builder.
  13508. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  13509. m.predicates = append(m.predicates, ps...)
  13510. }
  13511. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  13512. // users can use type-assertion to append predicates that do not depend on any generated package.
  13513. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  13514. p := make([]predicate.Contact, len(ps))
  13515. for i := range ps {
  13516. p[i] = ps[i]
  13517. }
  13518. m.Where(p...)
  13519. }
  13520. // Op returns the operation name.
  13521. func (m *ContactMutation) Op() Op {
  13522. return m.op
  13523. }
  13524. // SetOp allows setting the mutation operation.
  13525. func (m *ContactMutation) SetOp(op Op) {
  13526. m.op = op
  13527. }
  13528. // Type returns the node type of this mutation (Contact).
  13529. func (m *ContactMutation) Type() string {
  13530. return m.typ
  13531. }
  13532. // Fields returns all fields that were changed during this mutation. Note that in
  13533. // order to get all numeric fields that were incremented/decremented, call
  13534. // AddedFields().
  13535. func (m *ContactMutation) Fields() []string {
  13536. fields := make([]string, 0, 30)
  13537. if m.created_at != nil {
  13538. fields = append(fields, contact.FieldCreatedAt)
  13539. }
  13540. if m.updated_at != nil {
  13541. fields = append(fields, contact.FieldUpdatedAt)
  13542. }
  13543. if m.status != nil {
  13544. fields = append(fields, contact.FieldStatus)
  13545. }
  13546. if m.deleted_at != nil {
  13547. fields = append(fields, contact.FieldDeletedAt)
  13548. }
  13549. if m.wx_wxid != nil {
  13550. fields = append(fields, contact.FieldWxWxid)
  13551. }
  13552. if m._type != nil {
  13553. fields = append(fields, contact.FieldType)
  13554. }
  13555. if m.wxid != nil {
  13556. fields = append(fields, contact.FieldWxid)
  13557. }
  13558. if m.account != nil {
  13559. fields = append(fields, contact.FieldAccount)
  13560. }
  13561. if m.nickname != nil {
  13562. fields = append(fields, contact.FieldNickname)
  13563. }
  13564. if m.markname != nil {
  13565. fields = append(fields, contact.FieldMarkname)
  13566. }
  13567. if m.headimg != nil {
  13568. fields = append(fields, contact.FieldHeadimg)
  13569. }
  13570. if m.sex != nil {
  13571. fields = append(fields, contact.FieldSex)
  13572. }
  13573. if m.starrole != nil {
  13574. fields = append(fields, contact.FieldStarrole)
  13575. }
  13576. if m.dontseeit != nil {
  13577. fields = append(fields, contact.FieldDontseeit)
  13578. }
  13579. if m.dontseeme != nil {
  13580. fields = append(fields, contact.FieldDontseeme)
  13581. }
  13582. if m.lag != nil {
  13583. fields = append(fields, contact.FieldLag)
  13584. }
  13585. if m.gid != nil {
  13586. fields = append(fields, contact.FieldGid)
  13587. }
  13588. if m.gname != nil {
  13589. fields = append(fields, contact.FieldGname)
  13590. }
  13591. if m.v3 != nil {
  13592. fields = append(fields, contact.FieldV3)
  13593. }
  13594. if m.organization_id != nil {
  13595. fields = append(fields, contact.FieldOrganizationID)
  13596. }
  13597. if m.ctype != nil {
  13598. fields = append(fields, contact.FieldCtype)
  13599. }
  13600. if m.cage != nil {
  13601. fields = append(fields, contact.FieldCage)
  13602. }
  13603. if m.cname != nil {
  13604. fields = append(fields, contact.FieldCname)
  13605. }
  13606. if m.carea != nil {
  13607. fields = append(fields, contact.FieldCarea)
  13608. }
  13609. if m.cbirthday != nil {
  13610. fields = append(fields, contact.FieldCbirthday)
  13611. }
  13612. if m.cbirtharea != nil {
  13613. fields = append(fields, contact.FieldCbirtharea)
  13614. }
  13615. if m.cidcard_no != nil {
  13616. fields = append(fields, contact.FieldCidcardNo)
  13617. }
  13618. if m.ctitle != nil {
  13619. fields = append(fields, contact.FieldCtitle)
  13620. }
  13621. if m.cc != nil {
  13622. fields = append(fields, contact.FieldCc)
  13623. }
  13624. if m.phone != nil {
  13625. fields = append(fields, contact.FieldPhone)
  13626. }
  13627. return fields
  13628. }
  13629. // Field returns the value of a field with the given name. The second boolean
  13630. // return value indicates that this field was not set, or was not defined in the
  13631. // schema.
  13632. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  13633. switch name {
  13634. case contact.FieldCreatedAt:
  13635. return m.CreatedAt()
  13636. case contact.FieldUpdatedAt:
  13637. return m.UpdatedAt()
  13638. case contact.FieldStatus:
  13639. return m.Status()
  13640. case contact.FieldDeletedAt:
  13641. return m.DeletedAt()
  13642. case contact.FieldWxWxid:
  13643. return m.WxWxid()
  13644. case contact.FieldType:
  13645. return m.GetType()
  13646. case contact.FieldWxid:
  13647. return m.Wxid()
  13648. case contact.FieldAccount:
  13649. return m.Account()
  13650. case contact.FieldNickname:
  13651. return m.Nickname()
  13652. case contact.FieldMarkname:
  13653. return m.Markname()
  13654. case contact.FieldHeadimg:
  13655. return m.Headimg()
  13656. case contact.FieldSex:
  13657. return m.Sex()
  13658. case contact.FieldStarrole:
  13659. return m.Starrole()
  13660. case contact.FieldDontseeit:
  13661. return m.Dontseeit()
  13662. case contact.FieldDontseeme:
  13663. return m.Dontseeme()
  13664. case contact.FieldLag:
  13665. return m.Lag()
  13666. case contact.FieldGid:
  13667. return m.Gid()
  13668. case contact.FieldGname:
  13669. return m.Gname()
  13670. case contact.FieldV3:
  13671. return m.V3()
  13672. case contact.FieldOrganizationID:
  13673. return m.OrganizationID()
  13674. case contact.FieldCtype:
  13675. return m.Ctype()
  13676. case contact.FieldCage:
  13677. return m.Cage()
  13678. case contact.FieldCname:
  13679. return m.Cname()
  13680. case contact.FieldCarea:
  13681. return m.Carea()
  13682. case contact.FieldCbirthday:
  13683. return m.Cbirthday()
  13684. case contact.FieldCbirtharea:
  13685. return m.Cbirtharea()
  13686. case contact.FieldCidcardNo:
  13687. return m.CidcardNo()
  13688. case contact.FieldCtitle:
  13689. return m.Ctitle()
  13690. case contact.FieldCc:
  13691. return m.Cc()
  13692. case contact.FieldPhone:
  13693. return m.Phone()
  13694. }
  13695. return nil, false
  13696. }
  13697. // OldField returns the old value of the field from the database. An error is
  13698. // returned if the mutation operation is not UpdateOne, or the query to the
  13699. // database failed.
  13700. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13701. switch name {
  13702. case contact.FieldCreatedAt:
  13703. return m.OldCreatedAt(ctx)
  13704. case contact.FieldUpdatedAt:
  13705. return m.OldUpdatedAt(ctx)
  13706. case contact.FieldStatus:
  13707. return m.OldStatus(ctx)
  13708. case contact.FieldDeletedAt:
  13709. return m.OldDeletedAt(ctx)
  13710. case contact.FieldWxWxid:
  13711. return m.OldWxWxid(ctx)
  13712. case contact.FieldType:
  13713. return m.OldType(ctx)
  13714. case contact.FieldWxid:
  13715. return m.OldWxid(ctx)
  13716. case contact.FieldAccount:
  13717. return m.OldAccount(ctx)
  13718. case contact.FieldNickname:
  13719. return m.OldNickname(ctx)
  13720. case contact.FieldMarkname:
  13721. return m.OldMarkname(ctx)
  13722. case contact.FieldHeadimg:
  13723. return m.OldHeadimg(ctx)
  13724. case contact.FieldSex:
  13725. return m.OldSex(ctx)
  13726. case contact.FieldStarrole:
  13727. return m.OldStarrole(ctx)
  13728. case contact.FieldDontseeit:
  13729. return m.OldDontseeit(ctx)
  13730. case contact.FieldDontseeme:
  13731. return m.OldDontseeme(ctx)
  13732. case contact.FieldLag:
  13733. return m.OldLag(ctx)
  13734. case contact.FieldGid:
  13735. return m.OldGid(ctx)
  13736. case contact.FieldGname:
  13737. return m.OldGname(ctx)
  13738. case contact.FieldV3:
  13739. return m.OldV3(ctx)
  13740. case contact.FieldOrganizationID:
  13741. return m.OldOrganizationID(ctx)
  13742. case contact.FieldCtype:
  13743. return m.OldCtype(ctx)
  13744. case contact.FieldCage:
  13745. return m.OldCage(ctx)
  13746. case contact.FieldCname:
  13747. return m.OldCname(ctx)
  13748. case contact.FieldCarea:
  13749. return m.OldCarea(ctx)
  13750. case contact.FieldCbirthday:
  13751. return m.OldCbirthday(ctx)
  13752. case contact.FieldCbirtharea:
  13753. return m.OldCbirtharea(ctx)
  13754. case contact.FieldCidcardNo:
  13755. return m.OldCidcardNo(ctx)
  13756. case contact.FieldCtitle:
  13757. return m.OldCtitle(ctx)
  13758. case contact.FieldCc:
  13759. return m.OldCc(ctx)
  13760. case contact.FieldPhone:
  13761. return m.OldPhone(ctx)
  13762. }
  13763. return nil, fmt.Errorf("unknown Contact field %s", name)
  13764. }
  13765. // SetField sets the value of a field with the given name. It returns an error if
  13766. // the field is not defined in the schema, or if the type mismatched the field
  13767. // type.
  13768. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  13769. switch name {
  13770. case contact.FieldCreatedAt:
  13771. v, ok := value.(time.Time)
  13772. if !ok {
  13773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13774. }
  13775. m.SetCreatedAt(v)
  13776. return nil
  13777. case contact.FieldUpdatedAt:
  13778. v, ok := value.(time.Time)
  13779. if !ok {
  13780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13781. }
  13782. m.SetUpdatedAt(v)
  13783. return nil
  13784. case contact.FieldStatus:
  13785. v, ok := value.(uint8)
  13786. if !ok {
  13787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13788. }
  13789. m.SetStatus(v)
  13790. return nil
  13791. case contact.FieldDeletedAt:
  13792. v, ok := value.(time.Time)
  13793. if !ok {
  13794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13795. }
  13796. m.SetDeletedAt(v)
  13797. return nil
  13798. case contact.FieldWxWxid:
  13799. v, ok := value.(string)
  13800. if !ok {
  13801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13802. }
  13803. m.SetWxWxid(v)
  13804. return nil
  13805. case contact.FieldType:
  13806. v, ok := value.(int)
  13807. if !ok {
  13808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13809. }
  13810. m.SetType(v)
  13811. return nil
  13812. case contact.FieldWxid:
  13813. v, ok := value.(string)
  13814. if !ok {
  13815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13816. }
  13817. m.SetWxid(v)
  13818. return nil
  13819. case contact.FieldAccount:
  13820. v, ok := value.(string)
  13821. if !ok {
  13822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13823. }
  13824. m.SetAccount(v)
  13825. return nil
  13826. case contact.FieldNickname:
  13827. v, ok := value.(string)
  13828. if !ok {
  13829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13830. }
  13831. m.SetNickname(v)
  13832. return nil
  13833. case contact.FieldMarkname:
  13834. v, ok := value.(string)
  13835. if !ok {
  13836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13837. }
  13838. m.SetMarkname(v)
  13839. return nil
  13840. case contact.FieldHeadimg:
  13841. v, ok := value.(string)
  13842. if !ok {
  13843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13844. }
  13845. m.SetHeadimg(v)
  13846. return nil
  13847. case contact.FieldSex:
  13848. v, ok := value.(int)
  13849. if !ok {
  13850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13851. }
  13852. m.SetSex(v)
  13853. return nil
  13854. case contact.FieldStarrole:
  13855. v, ok := value.(string)
  13856. if !ok {
  13857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13858. }
  13859. m.SetStarrole(v)
  13860. return nil
  13861. case contact.FieldDontseeit:
  13862. v, ok := value.(int)
  13863. if !ok {
  13864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13865. }
  13866. m.SetDontseeit(v)
  13867. return nil
  13868. case contact.FieldDontseeme:
  13869. v, ok := value.(int)
  13870. if !ok {
  13871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13872. }
  13873. m.SetDontseeme(v)
  13874. return nil
  13875. case contact.FieldLag:
  13876. v, ok := value.(string)
  13877. if !ok {
  13878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13879. }
  13880. m.SetLag(v)
  13881. return nil
  13882. case contact.FieldGid:
  13883. v, ok := value.(string)
  13884. if !ok {
  13885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13886. }
  13887. m.SetGid(v)
  13888. return nil
  13889. case contact.FieldGname:
  13890. v, ok := value.(string)
  13891. if !ok {
  13892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13893. }
  13894. m.SetGname(v)
  13895. return nil
  13896. case contact.FieldV3:
  13897. v, ok := value.(string)
  13898. if !ok {
  13899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13900. }
  13901. m.SetV3(v)
  13902. return nil
  13903. case contact.FieldOrganizationID:
  13904. v, ok := value.(uint64)
  13905. if !ok {
  13906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13907. }
  13908. m.SetOrganizationID(v)
  13909. return nil
  13910. case contact.FieldCtype:
  13911. v, ok := value.(uint64)
  13912. if !ok {
  13913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13914. }
  13915. m.SetCtype(v)
  13916. return nil
  13917. case contact.FieldCage:
  13918. v, ok := value.(int)
  13919. if !ok {
  13920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13921. }
  13922. m.SetCage(v)
  13923. return nil
  13924. case contact.FieldCname:
  13925. v, ok := value.(string)
  13926. if !ok {
  13927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13928. }
  13929. m.SetCname(v)
  13930. return nil
  13931. case contact.FieldCarea:
  13932. v, ok := value.(string)
  13933. if !ok {
  13934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13935. }
  13936. m.SetCarea(v)
  13937. return nil
  13938. case contact.FieldCbirthday:
  13939. v, ok := value.(string)
  13940. if !ok {
  13941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13942. }
  13943. m.SetCbirthday(v)
  13944. return nil
  13945. case contact.FieldCbirtharea:
  13946. v, ok := value.(string)
  13947. if !ok {
  13948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13949. }
  13950. m.SetCbirtharea(v)
  13951. return nil
  13952. case contact.FieldCidcardNo:
  13953. v, ok := value.(string)
  13954. if !ok {
  13955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13956. }
  13957. m.SetCidcardNo(v)
  13958. return nil
  13959. case contact.FieldCtitle:
  13960. v, ok := value.(string)
  13961. if !ok {
  13962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13963. }
  13964. m.SetCtitle(v)
  13965. return nil
  13966. case contact.FieldCc:
  13967. v, ok := value.(string)
  13968. if !ok {
  13969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13970. }
  13971. m.SetCc(v)
  13972. return nil
  13973. case contact.FieldPhone:
  13974. v, ok := value.(string)
  13975. if !ok {
  13976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13977. }
  13978. m.SetPhone(v)
  13979. return nil
  13980. }
  13981. return fmt.Errorf("unknown Contact field %s", name)
  13982. }
  13983. // AddedFields returns all numeric fields that were incremented/decremented during
  13984. // this mutation.
  13985. func (m *ContactMutation) AddedFields() []string {
  13986. var fields []string
  13987. if m.addstatus != nil {
  13988. fields = append(fields, contact.FieldStatus)
  13989. }
  13990. if m.add_type != nil {
  13991. fields = append(fields, contact.FieldType)
  13992. }
  13993. if m.addsex != nil {
  13994. fields = append(fields, contact.FieldSex)
  13995. }
  13996. if m.adddontseeit != nil {
  13997. fields = append(fields, contact.FieldDontseeit)
  13998. }
  13999. if m.adddontseeme != nil {
  14000. fields = append(fields, contact.FieldDontseeme)
  14001. }
  14002. if m.addorganization_id != nil {
  14003. fields = append(fields, contact.FieldOrganizationID)
  14004. }
  14005. if m.addctype != nil {
  14006. fields = append(fields, contact.FieldCtype)
  14007. }
  14008. if m.addcage != nil {
  14009. fields = append(fields, contact.FieldCage)
  14010. }
  14011. return fields
  14012. }
  14013. // AddedField returns the numeric value that was incremented/decremented on a field
  14014. // with the given name. The second boolean return value indicates that this field
  14015. // was not set, or was not defined in the schema.
  14016. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  14017. switch name {
  14018. case contact.FieldStatus:
  14019. return m.AddedStatus()
  14020. case contact.FieldType:
  14021. return m.AddedType()
  14022. case contact.FieldSex:
  14023. return m.AddedSex()
  14024. case contact.FieldDontseeit:
  14025. return m.AddedDontseeit()
  14026. case contact.FieldDontseeme:
  14027. return m.AddedDontseeme()
  14028. case contact.FieldOrganizationID:
  14029. return m.AddedOrganizationID()
  14030. case contact.FieldCtype:
  14031. return m.AddedCtype()
  14032. case contact.FieldCage:
  14033. return m.AddedCage()
  14034. }
  14035. return nil, false
  14036. }
  14037. // AddField adds the value to the field with the given name. It returns an error if
  14038. // the field is not defined in the schema, or if the type mismatched the field
  14039. // type.
  14040. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  14041. switch name {
  14042. case contact.FieldStatus:
  14043. v, ok := value.(int8)
  14044. if !ok {
  14045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14046. }
  14047. m.AddStatus(v)
  14048. return nil
  14049. case contact.FieldType:
  14050. v, ok := value.(int)
  14051. if !ok {
  14052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14053. }
  14054. m.AddType(v)
  14055. return nil
  14056. case contact.FieldSex:
  14057. v, ok := value.(int)
  14058. if !ok {
  14059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14060. }
  14061. m.AddSex(v)
  14062. return nil
  14063. case contact.FieldDontseeit:
  14064. v, ok := value.(int)
  14065. if !ok {
  14066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14067. }
  14068. m.AddDontseeit(v)
  14069. return nil
  14070. case contact.FieldDontseeme:
  14071. v, ok := value.(int)
  14072. if !ok {
  14073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14074. }
  14075. m.AddDontseeme(v)
  14076. return nil
  14077. case contact.FieldOrganizationID:
  14078. v, ok := value.(int64)
  14079. if !ok {
  14080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14081. }
  14082. m.AddOrganizationID(v)
  14083. return nil
  14084. case contact.FieldCtype:
  14085. v, ok := value.(int64)
  14086. if !ok {
  14087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14088. }
  14089. m.AddCtype(v)
  14090. return nil
  14091. case contact.FieldCage:
  14092. v, ok := value.(int)
  14093. if !ok {
  14094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14095. }
  14096. m.AddCage(v)
  14097. return nil
  14098. }
  14099. return fmt.Errorf("unknown Contact numeric field %s", name)
  14100. }
  14101. // ClearedFields returns all nullable fields that were cleared during this
  14102. // mutation.
  14103. func (m *ContactMutation) ClearedFields() []string {
  14104. var fields []string
  14105. if m.FieldCleared(contact.FieldStatus) {
  14106. fields = append(fields, contact.FieldStatus)
  14107. }
  14108. if m.FieldCleared(contact.FieldDeletedAt) {
  14109. fields = append(fields, contact.FieldDeletedAt)
  14110. }
  14111. if m.FieldCleared(contact.FieldType) {
  14112. fields = append(fields, contact.FieldType)
  14113. }
  14114. if m.FieldCleared(contact.FieldOrganizationID) {
  14115. fields = append(fields, contact.FieldOrganizationID)
  14116. }
  14117. return fields
  14118. }
  14119. // FieldCleared returns a boolean indicating if a field with the given name was
  14120. // cleared in this mutation.
  14121. func (m *ContactMutation) FieldCleared(name string) bool {
  14122. _, ok := m.clearedFields[name]
  14123. return ok
  14124. }
  14125. // ClearField clears the value of the field with the given name. It returns an
  14126. // error if the field is not defined in the schema.
  14127. func (m *ContactMutation) ClearField(name string) error {
  14128. switch name {
  14129. case contact.FieldStatus:
  14130. m.ClearStatus()
  14131. return nil
  14132. case contact.FieldDeletedAt:
  14133. m.ClearDeletedAt()
  14134. return nil
  14135. case contact.FieldType:
  14136. m.ClearType()
  14137. return nil
  14138. case contact.FieldOrganizationID:
  14139. m.ClearOrganizationID()
  14140. return nil
  14141. }
  14142. return fmt.Errorf("unknown Contact nullable field %s", name)
  14143. }
  14144. // ResetField resets all changes in the mutation for the field with the given name.
  14145. // It returns an error if the field is not defined in the schema.
  14146. func (m *ContactMutation) ResetField(name string) error {
  14147. switch name {
  14148. case contact.FieldCreatedAt:
  14149. m.ResetCreatedAt()
  14150. return nil
  14151. case contact.FieldUpdatedAt:
  14152. m.ResetUpdatedAt()
  14153. return nil
  14154. case contact.FieldStatus:
  14155. m.ResetStatus()
  14156. return nil
  14157. case contact.FieldDeletedAt:
  14158. m.ResetDeletedAt()
  14159. return nil
  14160. case contact.FieldWxWxid:
  14161. m.ResetWxWxid()
  14162. return nil
  14163. case contact.FieldType:
  14164. m.ResetType()
  14165. return nil
  14166. case contact.FieldWxid:
  14167. m.ResetWxid()
  14168. return nil
  14169. case contact.FieldAccount:
  14170. m.ResetAccount()
  14171. return nil
  14172. case contact.FieldNickname:
  14173. m.ResetNickname()
  14174. return nil
  14175. case contact.FieldMarkname:
  14176. m.ResetMarkname()
  14177. return nil
  14178. case contact.FieldHeadimg:
  14179. m.ResetHeadimg()
  14180. return nil
  14181. case contact.FieldSex:
  14182. m.ResetSex()
  14183. return nil
  14184. case contact.FieldStarrole:
  14185. m.ResetStarrole()
  14186. return nil
  14187. case contact.FieldDontseeit:
  14188. m.ResetDontseeit()
  14189. return nil
  14190. case contact.FieldDontseeme:
  14191. m.ResetDontseeme()
  14192. return nil
  14193. case contact.FieldLag:
  14194. m.ResetLag()
  14195. return nil
  14196. case contact.FieldGid:
  14197. m.ResetGid()
  14198. return nil
  14199. case contact.FieldGname:
  14200. m.ResetGname()
  14201. return nil
  14202. case contact.FieldV3:
  14203. m.ResetV3()
  14204. return nil
  14205. case contact.FieldOrganizationID:
  14206. m.ResetOrganizationID()
  14207. return nil
  14208. case contact.FieldCtype:
  14209. m.ResetCtype()
  14210. return nil
  14211. case contact.FieldCage:
  14212. m.ResetCage()
  14213. return nil
  14214. case contact.FieldCname:
  14215. m.ResetCname()
  14216. return nil
  14217. case contact.FieldCarea:
  14218. m.ResetCarea()
  14219. return nil
  14220. case contact.FieldCbirthday:
  14221. m.ResetCbirthday()
  14222. return nil
  14223. case contact.FieldCbirtharea:
  14224. m.ResetCbirtharea()
  14225. return nil
  14226. case contact.FieldCidcardNo:
  14227. m.ResetCidcardNo()
  14228. return nil
  14229. case contact.FieldCtitle:
  14230. m.ResetCtitle()
  14231. return nil
  14232. case contact.FieldCc:
  14233. m.ResetCc()
  14234. return nil
  14235. case contact.FieldPhone:
  14236. m.ResetPhone()
  14237. return nil
  14238. }
  14239. return fmt.Errorf("unknown Contact field %s", name)
  14240. }
  14241. // AddedEdges returns all edge names that were set/added in this mutation.
  14242. func (m *ContactMutation) AddedEdges() []string {
  14243. edges := make([]string, 0, 3)
  14244. if m.contact_relationships != nil {
  14245. edges = append(edges, contact.EdgeContactRelationships)
  14246. }
  14247. if m.contact_fields != nil {
  14248. edges = append(edges, contact.EdgeContactFields)
  14249. }
  14250. if m.contact_messages != nil {
  14251. edges = append(edges, contact.EdgeContactMessages)
  14252. }
  14253. return edges
  14254. }
  14255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14256. // name in this mutation.
  14257. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  14258. switch name {
  14259. case contact.EdgeContactRelationships:
  14260. ids := make([]ent.Value, 0, len(m.contact_relationships))
  14261. for id := range m.contact_relationships {
  14262. ids = append(ids, id)
  14263. }
  14264. return ids
  14265. case contact.EdgeContactFields:
  14266. ids := make([]ent.Value, 0, len(m.contact_fields))
  14267. for id := range m.contact_fields {
  14268. ids = append(ids, id)
  14269. }
  14270. return ids
  14271. case contact.EdgeContactMessages:
  14272. ids := make([]ent.Value, 0, len(m.contact_messages))
  14273. for id := range m.contact_messages {
  14274. ids = append(ids, id)
  14275. }
  14276. return ids
  14277. }
  14278. return nil
  14279. }
  14280. // RemovedEdges returns all edge names that were removed in this mutation.
  14281. func (m *ContactMutation) RemovedEdges() []string {
  14282. edges := make([]string, 0, 3)
  14283. if m.removedcontact_relationships != nil {
  14284. edges = append(edges, contact.EdgeContactRelationships)
  14285. }
  14286. if m.removedcontact_fields != nil {
  14287. edges = append(edges, contact.EdgeContactFields)
  14288. }
  14289. if m.removedcontact_messages != nil {
  14290. edges = append(edges, contact.EdgeContactMessages)
  14291. }
  14292. return edges
  14293. }
  14294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14295. // the given name in this mutation.
  14296. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  14297. switch name {
  14298. case contact.EdgeContactRelationships:
  14299. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  14300. for id := range m.removedcontact_relationships {
  14301. ids = append(ids, id)
  14302. }
  14303. return ids
  14304. case contact.EdgeContactFields:
  14305. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  14306. for id := range m.removedcontact_fields {
  14307. ids = append(ids, id)
  14308. }
  14309. return ids
  14310. case contact.EdgeContactMessages:
  14311. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  14312. for id := range m.removedcontact_messages {
  14313. ids = append(ids, id)
  14314. }
  14315. return ids
  14316. }
  14317. return nil
  14318. }
  14319. // ClearedEdges returns all edge names that were cleared in this mutation.
  14320. func (m *ContactMutation) ClearedEdges() []string {
  14321. edges := make([]string, 0, 3)
  14322. if m.clearedcontact_relationships {
  14323. edges = append(edges, contact.EdgeContactRelationships)
  14324. }
  14325. if m.clearedcontact_fields {
  14326. edges = append(edges, contact.EdgeContactFields)
  14327. }
  14328. if m.clearedcontact_messages {
  14329. edges = append(edges, contact.EdgeContactMessages)
  14330. }
  14331. return edges
  14332. }
  14333. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14334. // was cleared in this mutation.
  14335. func (m *ContactMutation) EdgeCleared(name string) bool {
  14336. switch name {
  14337. case contact.EdgeContactRelationships:
  14338. return m.clearedcontact_relationships
  14339. case contact.EdgeContactFields:
  14340. return m.clearedcontact_fields
  14341. case contact.EdgeContactMessages:
  14342. return m.clearedcontact_messages
  14343. }
  14344. return false
  14345. }
  14346. // ClearEdge clears the value of the edge with the given name. It returns an error
  14347. // if that edge is not defined in the schema.
  14348. func (m *ContactMutation) ClearEdge(name string) error {
  14349. switch name {
  14350. }
  14351. return fmt.Errorf("unknown Contact unique edge %s", name)
  14352. }
  14353. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14354. // It returns an error if the edge is not defined in the schema.
  14355. func (m *ContactMutation) ResetEdge(name string) error {
  14356. switch name {
  14357. case contact.EdgeContactRelationships:
  14358. m.ResetContactRelationships()
  14359. return nil
  14360. case contact.EdgeContactFields:
  14361. m.ResetContactFields()
  14362. return nil
  14363. case contact.EdgeContactMessages:
  14364. m.ResetContactMessages()
  14365. return nil
  14366. }
  14367. return fmt.Errorf("unknown Contact edge %s", name)
  14368. }
  14369. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  14370. type ContactFieldMutation struct {
  14371. config
  14372. op Op
  14373. typ string
  14374. id *uint64
  14375. created_at *time.Time
  14376. updated_at *time.Time
  14377. status *uint8
  14378. addstatus *int8
  14379. deleted_at *time.Time
  14380. form_id *string
  14381. value *[]string
  14382. appendvalue []string
  14383. clearedFields map[string]struct{}
  14384. field_contact *uint64
  14385. clearedfield_contact bool
  14386. done bool
  14387. oldValue func(context.Context) (*ContactField, error)
  14388. predicates []predicate.ContactField
  14389. }
  14390. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  14391. // contactfieldOption allows management of the mutation configuration using functional options.
  14392. type contactfieldOption func(*ContactFieldMutation)
  14393. // newContactFieldMutation creates new mutation for the ContactField entity.
  14394. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  14395. m := &ContactFieldMutation{
  14396. config: c,
  14397. op: op,
  14398. typ: TypeContactField,
  14399. clearedFields: make(map[string]struct{}),
  14400. }
  14401. for _, opt := range opts {
  14402. opt(m)
  14403. }
  14404. return m
  14405. }
  14406. // withContactFieldID sets the ID field of the mutation.
  14407. func withContactFieldID(id uint64) contactfieldOption {
  14408. return func(m *ContactFieldMutation) {
  14409. var (
  14410. err error
  14411. once sync.Once
  14412. value *ContactField
  14413. )
  14414. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  14415. once.Do(func() {
  14416. if m.done {
  14417. err = errors.New("querying old values post mutation is not allowed")
  14418. } else {
  14419. value, err = m.Client().ContactField.Get(ctx, id)
  14420. }
  14421. })
  14422. return value, err
  14423. }
  14424. m.id = &id
  14425. }
  14426. }
  14427. // withContactField sets the old ContactField of the mutation.
  14428. func withContactField(node *ContactField) contactfieldOption {
  14429. return func(m *ContactFieldMutation) {
  14430. m.oldValue = func(context.Context) (*ContactField, error) {
  14431. return node, nil
  14432. }
  14433. m.id = &node.ID
  14434. }
  14435. }
  14436. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14437. // executed in a transaction (ent.Tx), a transactional client is returned.
  14438. func (m ContactFieldMutation) Client() *Client {
  14439. client := &Client{config: m.config}
  14440. client.init()
  14441. return client
  14442. }
  14443. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14444. // it returns an error otherwise.
  14445. func (m ContactFieldMutation) Tx() (*Tx, error) {
  14446. if _, ok := m.driver.(*txDriver); !ok {
  14447. return nil, errors.New("ent: mutation is not running in a transaction")
  14448. }
  14449. tx := &Tx{config: m.config}
  14450. tx.init()
  14451. return tx, nil
  14452. }
  14453. // SetID sets the value of the id field. Note that this
  14454. // operation is only accepted on creation of ContactField entities.
  14455. func (m *ContactFieldMutation) SetID(id uint64) {
  14456. m.id = &id
  14457. }
  14458. // ID returns the ID value in the mutation. Note that the ID is only available
  14459. // if it was provided to the builder or after it was returned from the database.
  14460. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  14461. if m.id == nil {
  14462. return
  14463. }
  14464. return *m.id, true
  14465. }
  14466. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14467. // That means, if the mutation is applied within a transaction with an isolation level such
  14468. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14469. // or updated by the mutation.
  14470. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  14471. switch {
  14472. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14473. id, exists := m.ID()
  14474. if exists {
  14475. return []uint64{id}, nil
  14476. }
  14477. fallthrough
  14478. case m.op.Is(OpUpdate | OpDelete):
  14479. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  14480. default:
  14481. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14482. }
  14483. }
  14484. // SetCreatedAt sets the "created_at" field.
  14485. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  14486. m.created_at = &t
  14487. }
  14488. // CreatedAt returns the value of the "created_at" field in the mutation.
  14489. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  14490. v := m.created_at
  14491. if v == nil {
  14492. return
  14493. }
  14494. return *v, true
  14495. }
  14496. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  14497. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14499. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14500. if !m.op.Is(OpUpdateOne) {
  14501. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14502. }
  14503. if m.id == nil || m.oldValue == nil {
  14504. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14505. }
  14506. oldValue, err := m.oldValue(ctx)
  14507. if err != nil {
  14508. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14509. }
  14510. return oldValue.CreatedAt, nil
  14511. }
  14512. // ResetCreatedAt resets all changes to the "created_at" field.
  14513. func (m *ContactFieldMutation) ResetCreatedAt() {
  14514. m.created_at = nil
  14515. }
  14516. // SetUpdatedAt sets the "updated_at" field.
  14517. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  14518. m.updated_at = &t
  14519. }
  14520. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14521. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  14522. v := m.updated_at
  14523. if v == nil {
  14524. return
  14525. }
  14526. return *v, true
  14527. }
  14528. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  14529. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14531. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14532. if !m.op.Is(OpUpdateOne) {
  14533. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14534. }
  14535. if m.id == nil || m.oldValue == nil {
  14536. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14537. }
  14538. oldValue, err := m.oldValue(ctx)
  14539. if err != nil {
  14540. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14541. }
  14542. return oldValue.UpdatedAt, nil
  14543. }
  14544. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14545. func (m *ContactFieldMutation) ResetUpdatedAt() {
  14546. m.updated_at = nil
  14547. }
  14548. // SetStatus sets the "status" field.
  14549. func (m *ContactFieldMutation) SetStatus(u uint8) {
  14550. m.status = &u
  14551. m.addstatus = nil
  14552. }
  14553. // Status returns the value of the "status" field in the mutation.
  14554. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  14555. v := m.status
  14556. if v == nil {
  14557. return
  14558. }
  14559. return *v, true
  14560. }
  14561. // OldStatus returns the old "status" field's value of the ContactField entity.
  14562. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14564. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14565. if !m.op.Is(OpUpdateOne) {
  14566. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14567. }
  14568. if m.id == nil || m.oldValue == nil {
  14569. return v, errors.New("OldStatus requires an ID field in the mutation")
  14570. }
  14571. oldValue, err := m.oldValue(ctx)
  14572. if err != nil {
  14573. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14574. }
  14575. return oldValue.Status, nil
  14576. }
  14577. // AddStatus adds u to the "status" field.
  14578. func (m *ContactFieldMutation) AddStatus(u int8) {
  14579. if m.addstatus != nil {
  14580. *m.addstatus += u
  14581. } else {
  14582. m.addstatus = &u
  14583. }
  14584. }
  14585. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14586. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  14587. v := m.addstatus
  14588. if v == nil {
  14589. return
  14590. }
  14591. return *v, true
  14592. }
  14593. // ClearStatus clears the value of the "status" field.
  14594. func (m *ContactFieldMutation) ClearStatus() {
  14595. m.status = nil
  14596. m.addstatus = nil
  14597. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  14598. }
  14599. // StatusCleared returns if the "status" field was cleared in this mutation.
  14600. func (m *ContactFieldMutation) StatusCleared() bool {
  14601. _, ok := m.clearedFields[contactfield.FieldStatus]
  14602. return ok
  14603. }
  14604. // ResetStatus resets all changes to the "status" field.
  14605. func (m *ContactFieldMutation) ResetStatus() {
  14606. m.status = nil
  14607. m.addstatus = nil
  14608. delete(m.clearedFields, contactfield.FieldStatus)
  14609. }
  14610. // SetDeletedAt sets the "deleted_at" field.
  14611. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  14612. m.deleted_at = &t
  14613. }
  14614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14615. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  14616. v := m.deleted_at
  14617. if v == nil {
  14618. return
  14619. }
  14620. return *v, true
  14621. }
  14622. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  14623. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14625. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14626. if !m.op.Is(OpUpdateOne) {
  14627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14628. }
  14629. if m.id == nil || m.oldValue == nil {
  14630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14631. }
  14632. oldValue, err := m.oldValue(ctx)
  14633. if err != nil {
  14634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14635. }
  14636. return oldValue.DeletedAt, nil
  14637. }
  14638. // ClearDeletedAt clears the value of the "deleted_at" field.
  14639. func (m *ContactFieldMutation) ClearDeletedAt() {
  14640. m.deleted_at = nil
  14641. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  14642. }
  14643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14644. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  14645. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  14646. return ok
  14647. }
  14648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14649. func (m *ContactFieldMutation) ResetDeletedAt() {
  14650. m.deleted_at = nil
  14651. delete(m.clearedFields, contactfield.FieldDeletedAt)
  14652. }
  14653. // SetContactID sets the "contact_id" field.
  14654. func (m *ContactFieldMutation) SetContactID(u uint64) {
  14655. m.field_contact = &u
  14656. }
  14657. // ContactID returns the value of the "contact_id" field in the mutation.
  14658. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  14659. v := m.field_contact
  14660. if v == nil {
  14661. return
  14662. }
  14663. return *v, true
  14664. }
  14665. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  14666. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14668. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14669. if !m.op.Is(OpUpdateOne) {
  14670. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14671. }
  14672. if m.id == nil || m.oldValue == nil {
  14673. return v, errors.New("OldContactID requires an ID field in the mutation")
  14674. }
  14675. oldValue, err := m.oldValue(ctx)
  14676. if err != nil {
  14677. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14678. }
  14679. return oldValue.ContactID, nil
  14680. }
  14681. // ResetContactID resets all changes to the "contact_id" field.
  14682. func (m *ContactFieldMutation) ResetContactID() {
  14683. m.field_contact = nil
  14684. }
  14685. // SetFormID sets the "form_id" field.
  14686. func (m *ContactFieldMutation) SetFormID(s string) {
  14687. m.form_id = &s
  14688. }
  14689. // FormID returns the value of the "form_id" field in the mutation.
  14690. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  14691. v := m.form_id
  14692. if v == nil {
  14693. return
  14694. }
  14695. return *v, true
  14696. }
  14697. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  14698. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14700. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  14701. if !m.op.Is(OpUpdateOne) {
  14702. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  14703. }
  14704. if m.id == nil || m.oldValue == nil {
  14705. return v, errors.New("OldFormID requires an ID field in the mutation")
  14706. }
  14707. oldValue, err := m.oldValue(ctx)
  14708. if err != nil {
  14709. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  14710. }
  14711. return oldValue.FormID, nil
  14712. }
  14713. // ResetFormID resets all changes to the "form_id" field.
  14714. func (m *ContactFieldMutation) ResetFormID() {
  14715. m.form_id = nil
  14716. }
  14717. // SetValue sets the "value" field.
  14718. func (m *ContactFieldMutation) SetValue(s []string) {
  14719. m.value = &s
  14720. m.appendvalue = nil
  14721. }
  14722. // Value returns the value of the "value" field in the mutation.
  14723. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  14724. v := m.value
  14725. if v == nil {
  14726. return
  14727. }
  14728. return *v, true
  14729. }
  14730. // OldValue returns the old "value" field's value of the ContactField entity.
  14731. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14733. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  14734. if !m.op.Is(OpUpdateOne) {
  14735. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  14736. }
  14737. if m.id == nil || m.oldValue == nil {
  14738. return v, errors.New("OldValue requires an ID field in the mutation")
  14739. }
  14740. oldValue, err := m.oldValue(ctx)
  14741. if err != nil {
  14742. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  14743. }
  14744. return oldValue.Value, nil
  14745. }
  14746. // AppendValue adds s to the "value" field.
  14747. func (m *ContactFieldMutation) AppendValue(s []string) {
  14748. m.appendvalue = append(m.appendvalue, s...)
  14749. }
  14750. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  14751. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  14752. if len(m.appendvalue) == 0 {
  14753. return nil, false
  14754. }
  14755. return m.appendvalue, true
  14756. }
  14757. // ResetValue resets all changes to the "value" field.
  14758. func (m *ContactFieldMutation) ResetValue() {
  14759. m.value = nil
  14760. m.appendvalue = nil
  14761. }
  14762. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  14763. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  14764. m.field_contact = &id
  14765. }
  14766. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  14767. func (m *ContactFieldMutation) ClearFieldContact() {
  14768. m.clearedfield_contact = true
  14769. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  14770. }
  14771. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  14772. func (m *ContactFieldMutation) FieldContactCleared() bool {
  14773. return m.clearedfield_contact
  14774. }
  14775. // FieldContactID returns the "field_contact" edge ID in the mutation.
  14776. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  14777. if m.field_contact != nil {
  14778. return *m.field_contact, true
  14779. }
  14780. return
  14781. }
  14782. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  14783. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14784. // FieldContactID instead. It exists only for internal usage by the builders.
  14785. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  14786. if id := m.field_contact; id != nil {
  14787. ids = append(ids, *id)
  14788. }
  14789. return
  14790. }
  14791. // ResetFieldContact resets all changes to the "field_contact" edge.
  14792. func (m *ContactFieldMutation) ResetFieldContact() {
  14793. m.field_contact = nil
  14794. m.clearedfield_contact = false
  14795. }
  14796. // Where appends a list predicates to the ContactFieldMutation builder.
  14797. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  14798. m.predicates = append(m.predicates, ps...)
  14799. }
  14800. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  14801. // users can use type-assertion to append predicates that do not depend on any generated package.
  14802. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  14803. p := make([]predicate.ContactField, len(ps))
  14804. for i := range ps {
  14805. p[i] = ps[i]
  14806. }
  14807. m.Where(p...)
  14808. }
  14809. // Op returns the operation name.
  14810. func (m *ContactFieldMutation) Op() Op {
  14811. return m.op
  14812. }
  14813. // SetOp allows setting the mutation operation.
  14814. func (m *ContactFieldMutation) SetOp(op Op) {
  14815. m.op = op
  14816. }
  14817. // Type returns the node type of this mutation (ContactField).
  14818. func (m *ContactFieldMutation) Type() string {
  14819. return m.typ
  14820. }
  14821. // Fields returns all fields that were changed during this mutation. Note that in
  14822. // order to get all numeric fields that were incremented/decremented, call
  14823. // AddedFields().
  14824. func (m *ContactFieldMutation) Fields() []string {
  14825. fields := make([]string, 0, 7)
  14826. if m.created_at != nil {
  14827. fields = append(fields, contactfield.FieldCreatedAt)
  14828. }
  14829. if m.updated_at != nil {
  14830. fields = append(fields, contactfield.FieldUpdatedAt)
  14831. }
  14832. if m.status != nil {
  14833. fields = append(fields, contactfield.FieldStatus)
  14834. }
  14835. if m.deleted_at != nil {
  14836. fields = append(fields, contactfield.FieldDeletedAt)
  14837. }
  14838. if m.field_contact != nil {
  14839. fields = append(fields, contactfield.FieldContactID)
  14840. }
  14841. if m.form_id != nil {
  14842. fields = append(fields, contactfield.FieldFormID)
  14843. }
  14844. if m.value != nil {
  14845. fields = append(fields, contactfield.FieldValue)
  14846. }
  14847. return fields
  14848. }
  14849. // Field returns the value of a field with the given name. The second boolean
  14850. // return value indicates that this field was not set, or was not defined in the
  14851. // schema.
  14852. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  14853. switch name {
  14854. case contactfield.FieldCreatedAt:
  14855. return m.CreatedAt()
  14856. case contactfield.FieldUpdatedAt:
  14857. return m.UpdatedAt()
  14858. case contactfield.FieldStatus:
  14859. return m.Status()
  14860. case contactfield.FieldDeletedAt:
  14861. return m.DeletedAt()
  14862. case contactfield.FieldContactID:
  14863. return m.ContactID()
  14864. case contactfield.FieldFormID:
  14865. return m.FormID()
  14866. case contactfield.FieldValue:
  14867. return m.Value()
  14868. }
  14869. return nil, false
  14870. }
  14871. // OldField returns the old value of the field from the database. An error is
  14872. // returned if the mutation operation is not UpdateOne, or the query to the
  14873. // database failed.
  14874. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14875. switch name {
  14876. case contactfield.FieldCreatedAt:
  14877. return m.OldCreatedAt(ctx)
  14878. case contactfield.FieldUpdatedAt:
  14879. return m.OldUpdatedAt(ctx)
  14880. case contactfield.FieldStatus:
  14881. return m.OldStatus(ctx)
  14882. case contactfield.FieldDeletedAt:
  14883. return m.OldDeletedAt(ctx)
  14884. case contactfield.FieldContactID:
  14885. return m.OldContactID(ctx)
  14886. case contactfield.FieldFormID:
  14887. return m.OldFormID(ctx)
  14888. case contactfield.FieldValue:
  14889. return m.OldValue(ctx)
  14890. }
  14891. return nil, fmt.Errorf("unknown ContactField field %s", name)
  14892. }
  14893. // SetField sets the value of a field with the given name. It returns an error if
  14894. // the field is not defined in the schema, or if the type mismatched the field
  14895. // type.
  14896. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  14897. switch name {
  14898. case contactfield.FieldCreatedAt:
  14899. v, ok := value.(time.Time)
  14900. if !ok {
  14901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14902. }
  14903. m.SetCreatedAt(v)
  14904. return nil
  14905. case contactfield.FieldUpdatedAt:
  14906. v, ok := value.(time.Time)
  14907. if !ok {
  14908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14909. }
  14910. m.SetUpdatedAt(v)
  14911. return nil
  14912. case contactfield.FieldStatus:
  14913. v, ok := value.(uint8)
  14914. if !ok {
  14915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14916. }
  14917. m.SetStatus(v)
  14918. return nil
  14919. case contactfield.FieldDeletedAt:
  14920. v, ok := value.(time.Time)
  14921. if !ok {
  14922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14923. }
  14924. m.SetDeletedAt(v)
  14925. return nil
  14926. case contactfield.FieldContactID:
  14927. v, ok := value.(uint64)
  14928. if !ok {
  14929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14930. }
  14931. m.SetContactID(v)
  14932. return nil
  14933. case contactfield.FieldFormID:
  14934. v, ok := value.(string)
  14935. if !ok {
  14936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14937. }
  14938. m.SetFormID(v)
  14939. return nil
  14940. case contactfield.FieldValue:
  14941. v, ok := value.([]string)
  14942. if !ok {
  14943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14944. }
  14945. m.SetValue(v)
  14946. return nil
  14947. }
  14948. return fmt.Errorf("unknown ContactField field %s", name)
  14949. }
  14950. // AddedFields returns all numeric fields that were incremented/decremented during
  14951. // this mutation.
  14952. func (m *ContactFieldMutation) AddedFields() []string {
  14953. var fields []string
  14954. if m.addstatus != nil {
  14955. fields = append(fields, contactfield.FieldStatus)
  14956. }
  14957. return fields
  14958. }
  14959. // AddedField returns the numeric value that was incremented/decremented on a field
  14960. // with the given name. The second boolean return value indicates that this field
  14961. // was not set, or was not defined in the schema.
  14962. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  14963. switch name {
  14964. case contactfield.FieldStatus:
  14965. return m.AddedStatus()
  14966. }
  14967. return nil, false
  14968. }
  14969. // AddField adds the value to the field with the given name. It returns an error if
  14970. // the field is not defined in the schema, or if the type mismatched the field
  14971. // type.
  14972. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  14973. switch name {
  14974. case contactfield.FieldStatus:
  14975. v, ok := value.(int8)
  14976. if !ok {
  14977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14978. }
  14979. m.AddStatus(v)
  14980. return nil
  14981. }
  14982. return fmt.Errorf("unknown ContactField numeric field %s", name)
  14983. }
  14984. // ClearedFields returns all nullable fields that were cleared during this
  14985. // mutation.
  14986. func (m *ContactFieldMutation) ClearedFields() []string {
  14987. var fields []string
  14988. if m.FieldCleared(contactfield.FieldStatus) {
  14989. fields = append(fields, contactfield.FieldStatus)
  14990. }
  14991. if m.FieldCleared(contactfield.FieldDeletedAt) {
  14992. fields = append(fields, contactfield.FieldDeletedAt)
  14993. }
  14994. return fields
  14995. }
  14996. // FieldCleared returns a boolean indicating if a field with the given name was
  14997. // cleared in this mutation.
  14998. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  14999. _, ok := m.clearedFields[name]
  15000. return ok
  15001. }
  15002. // ClearField clears the value of the field with the given name. It returns an
  15003. // error if the field is not defined in the schema.
  15004. func (m *ContactFieldMutation) ClearField(name string) error {
  15005. switch name {
  15006. case contactfield.FieldStatus:
  15007. m.ClearStatus()
  15008. return nil
  15009. case contactfield.FieldDeletedAt:
  15010. m.ClearDeletedAt()
  15011. return nil
  15012. }
  15013. return fmt.Errorf("unknown ContactField nullable field %s", name)
  15014. }
  15015. // ResetField resets all changes in the mutation for the field with the given name.
  15016. // It returns an error if the field is not defined in the schema.
  15017. func (m *ContactFieldMutation) ResetField(name string) error {
  15018. switch name {
  15019. case contactfield.FieldCreatedAt:
  15020. m.ResetCreatedAt()
  15021. return nil
  15022. case contactfield.FieldUpdatedAt:
  15023. m.ResetUpdatedAt()
  15024. return nil
  15025. case contactfield.FieldStatus:
  15026. m.ResetStatus()
  15027. return nil
  15028. case contactfield.FieldDeletedAt:
  15029. m.ResetDeletedAt()
  15030. return nil
  15031. case contactfield.FieldContactID:
  15032. m.ResetContactID()
  15033. return nil
  15034. case contactfield.FieldFormID:
  15035. m.ResetFormID()
  15036. return nil
  15037. case contactfield.FieldValue:
  15038. m.ResetValue()
  15039. return nil
  15040. }
  15041. return fmt.Errorf("unknown ContactField field %s", name)
  15042. }
  15043. // AddedEdges returns all edge names that were set/added in this mutation.
  15044. func (m *ContactFieldMutation) AddedEdges() []string {
  15045. edges := make([]string, 0, 1)
  15046. if m.field_contact != nil {
  15047. edges = append(edges, contactfield.EdgeFieldContact)
  15048. }
  15049. return edges
  15050. }
  15051. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15052. // name in this mutation.
  15053. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  15054. switch name {
  15055. case contactfield.EdgeFieldContact:
  15056. if id := m.field_contact; id != nil {
  15057. return []ent.Value{*id}
  15058. }
  15059. }
  15060. return nil
  15061. }
  15062. // RemovedEdges returns all edge names that were removed in this mutation.
  15063. func (m *ContactFieldMutation) RemovedEdges() []string {
  15064. edges := make([]string, 0, 1)
  15065. return edges
  15066. }
  15067. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15068. // the given name in this mutation.
  15069. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  15070. return nil
  15071. }
  15072. // ClearedEdges returns all edge names that were cleared in this mutation.
  15073. func (m *ContactFieldMutation) ClearedEdges() []string {
  15074. edges := make([]string, 0, 1)
  15075. if m.clearedfield_contact {
  15076. edges = append(edges, contactfield.EdgeFieldContact)
  15077. }
  15078. return edges
  15079. }
  15080. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15081. // was cleared in this mutation.
  15082. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  15083. switch name {
  15084. case contactfield.EdgeFieldContact:
  15085. return m.clearedfield_contact
  15086. }
  15087. return false
  15088. }
  15089. // ClearEdge clears the value of the edge with the given name. It returns an error
  15090. // if that edge is not defined in the schema.
  15091. func (m *ContactFieldMutation) ClearEdge(name string) error {
  15092. switch name {
  15093. case contactfield.EdgeFieldContact:
  15094. m.ClearFieldContact()
  15095. return nil
  15096. }
  15097. return fmt.Errorf("unknown ContactField unique edge %s", name)
  15098. }
  15099. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15100. // It returns an error if the edge is not defined in the schema.
  15101. func (m *ContactFieldMutation) ResetEdge(name string) error {
  15102. switch name {
  15103. case contactfield.EdgeFieldContact:
  15104. m.ResetFieldContact()
  15105. return nil
  15106. }
  15107. return fmt.Errorf("unknown ContactField edge %s", name)
  15108. }
  15109. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  15110. type ContactFieldTemplateMutation struct {
  15111. config
  15112. op Op
  15113. typ string
  15114. id *uint64
  15115. created_at *time.Time
  15116. updated_at *time.Time
  15117. status *uint8
  15118. addstatus *int8
  15119. deleted_at *time.Time
  15120. organization_id *uint64
  15121. addorganization_id *int64
  15122. template *[]custom_types.ContactFieldTemplate
  15123. appendtemplate []custom_types.ContactFieldTemplate
  15124. clearedFields map[string]struct{}
  15125. done bool
  15126. oldValue func(context.Context) (*ContactFieldTemplate, error)
  15127. predicates []predicate.ContactFieldTemplate
  15128. }
  15129. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  15130. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  15131. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  15132. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  15133. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  15134. m := &ContactFieldTemplateMutation{
  15135. config: c,
  15136. op: op,
  15137. typ: TypeContactFieldTemplate,
  15138. clearedFields: make(map[string]struct{}),
  15139. }
  15140. for _, opt := range opts {
  15141. opt(m)
  15142. }
  15143. return m
  15144. }
  15145. // withContactFieldTemplateID sets the ID field of the mutation.
  15146. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  15147. return func(m *ContactFieldTemplateMutation) {
  15148. var (
  15149. err error
  15150. once sync.Once
  15151. value *ContactFieldTemplate
  15152. )
  15153. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  15154. once.Do(func() {
  15155. if m.done {
  15156. err = errors.New("querying old values post mutation is not allowed")
  15157. } else {
  15158. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  15159. }
  15160. })
  15161. return value, err
  15162. }
  15163. m.id = &id
  15164. }
  15165. }
  15166. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  15167. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  15168. return func(m *ContactFieldTemplateMutation) {
  15169. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  15170. return node, nil
  15171. }
  15172. m.id = &node.ID
  15173. }
  15174. }
  15175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15176. // executed in a transaction (ent.Tx), a transactional client is returned.
  15177. func (m ContactFieldTemplateMutation) Client() *Client {
  15178. client := &Client{config: m.config}
  15179. client.init()
  15180. return client
  15181. }
  15182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15183. // it returns an error otherwise.
  15184. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  15185. if _, ok := m.driver.(*txDriver); !ok {
  15186. return nil, errors.New("ent: mutation is not running in a transaction")
  15187. }
  15188. tx := &Tx{config: m.config}
  15189. tx.init()
  15190. return tx, nil
  15191. }
  15192. // SetID sets the value of the id field. Note that this
  15193. // operation is only accepted on creation of ContactFieldTemplate entities.
  15194. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  15195. m.id = &id
  15196. }
  15197. // ID returns the ID value in the mutation. Note that the ID is only available
  15198. // if it was provided to the builder or after it was returned from the database.
  15199. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  15200. if m.id == nil {
  15201. return
  15202. }
  15203. return *m.id, true
  15204. }
  15205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15206. // That means, if the mutation is applied within a transaction with an isolation level such
  15207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15208. // or updated by the mutation.
  15209. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  15210. switch {
  15211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15212. id, exists := m.ID()
  15213. if exists {
  15214. return []uint64{id}, nil
  15215. }
  15216. fallthrough
  15217. case m.op.Is(OpUpdate | OpDelete):
  15218. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  15219. default:
  15220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15221. }
  15222. }
  15223. // SetCreatedAt sets the "created_at" field.
  15224. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  15225. m.created_at = &t
  15226. }
  15227. // CreatedAt returns the value of the "created_at" field in the mutation.
  15228. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  15229. v := m.created_at
  15230. if v == nil {
  15231. return
  15232. }
  15233. return *v, true
  15234. }
  15235. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  15236. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15238. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15239. if !m.op.Is(OpUpdateOne) {
  15240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15241. }
  15242. if m.id == nil || m.oldValue == nil {
  15243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15244. }
  15245. oldValue, err := m.oldValue(ctx)
  15246. if err != nil {
  15247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15248. }
  15249. return oldValue.CreatedAt, nil
  15250. }
  15251. // ResetCreatedAt resets all changes to the "created_at" field.
  15252. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  15253. m.created_at = nil
  15254. }
  15255. // SetUpdatedAt sets the "updated_at" field.
  15256. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  15257. m.updated_at = &t
  15258. }
  15259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15260. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  15261. v := m.updated_at
  15262. if v == nil {
  15263. return
  15264. }
  15265. return *v, true
  15266. }
  15267. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  15268. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15270. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15271. if !m.op.Is(OpUpdateOne) {
  15272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15273. }
  15274. if m.id == nil || m.oldValue == nil {
  15275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15276. }
  15277. oldValue, err := m.oldValue(ctx)
  15278. if err != nil {
  15279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15280. }
  15281. return oldValue.UpdatedAt, nil
  15282. }
  15283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15284. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  15285. m.updated_at = nil
  15286. }
  15287. // SetStatus sets the "status" field.
  15288. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  15289. m.status = &u
  15290. m.addstatus = nil
  15291. }
  15292. // Status returns the value of the "status" field in the mutation.
  15293. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  15294. v := m.status
  15295. if v == nil {
  15296. return
  15297. }
  15298. return *v, true
  15299. }
  15300. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  15301. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15303. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15304. if !m.op.Is(OpUpdateOne) {
  15305. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15306. }
  15307. if m.id == nil || m.oldValue == nil {
  15308. return v, errors.New("OldStatus requires an ID field in the mutation")
  15309. }
  15310. oldValue, err := m.oldValue(ctx)
  15311. if err != nil {
  15312. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15313. }
  15314. return oldValue.Status, nil
  15315. }
  15316. // AddStatus adds u to the "status" field.
  15317. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  15318. if m.addstatus != nil {
  15319. *m.addstatus += u
  15320. } else {
  15321. m.addstatus = &u
  15322. }
  15323. }
  15324. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15325. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  15326. v := m.addstatus
  15327. if v == nil {
  15328. return
  15329. }
  15330. return *v, true
  15331. }
  15332. // ClearStatus clears the value of the "status" field.
  15333. func (m *ContactFieldTemplateMutation) ClearStatus() {
  15334. m.status = nil
  15335. m.addstatus = nil
  15336. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  15337. }
  15338. // StatusCleared returns if the "status" field was cleared in this mutation.
  15339. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  15340. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  15341. return ok
  15342. }
  15343. // ResetStatus resets all changes to the "status" field.
  15344. func (m *ContactFieldTemplateMutation) ResetStatus() {
  15345. m.status = nil
  15346. m.addstatus = nil
  15347. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  15348. }
  15349. // SetDeletedAt sets the "deleted_at" field.
  15350. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  15351. m.deleted_at = &t
  15352. }
  15353. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15354. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  15355. v := m.deleted_at
  15356. if v == nil {
  15357. return
  15358. }
  15359. return *v, true
  15360. }
  15361. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  15362. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15364. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15365. if !m.op.Is(OpUpdateOne) {
  15366. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15367. }
  15368. if m.id == nil || m.oldValue == nil {
  15369. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15370. }
  15371. oldValue, err := m.oldValue(ctx)
  15372. if err != nil {
  15373. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15374. }
  15375. return oldValue.DeletedAt, nil
  15376. }
  15377. // ClearDeletedAt clears the value of the "deleted_at" field.
  15378. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  15379. m.deleted_at = nil
  15380. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  15381. }
  15382. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15383. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  15384. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  15385. return ok
  15386. }
  15387. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15388. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  15389. m.deleted_at = nil
  15390. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  15391. }
  15392. // SetOrganizationID sets the "organization_id" field.
  15393. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  15394. m.organization_id = &u
  15395. m.addorganization_id = nil
  15396. }
  15397. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15398. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  15399. v := m.organization_id
  15400. if v == nil {
  15401. return
  15402. }
  15403. return *v, true
  15404. }
  15405. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  15406. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15408. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15409. if !m.op.Is(OpUpdateOne) {
  15410. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15411. }
  15412. if m.id == nil || m.oldValue == nil {
  15413. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15414. }
  15415. oldValue, err := m.oldValue(ctx)
  15416. if err != nil {
  15417. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15418. }
  15419. return oldValue.OrganizationID, nil
  15420. }
  15421. // AddOrganizationID adds u to the "organization_id" field.
  15422. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  15423. if m.addorganization_id != nil {
  15424. *m.addorganization_id += u
  15425. } else {
  15426. m.addorganization_id = &u
  15427. }
  15428. }
  15429. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15430. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  15431. v := m.addorganization_id
  15432. if v == nil {
  15433. return
  15434. }
  15435. return *v, true
  15436. }
  15437. // ResetOrganizationID resets all changes to the "organization_id" field.
  15438. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  15439. m.organization_id = nil
  15440. m.addorganization_id = nil
  15441. }
  15442. // SetTemplate sets the "template" field.
  15443. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  15444. m.template = &ctft
  15445. m.appendtemplate = nil
  15446. }
  15447. // Template returns the value of the "template" field in the mutation.
  15448. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  15449. v := m.template
  15450. if v == nil {
  15451. return
  15452. }
  15453. return *v, true
  15454. }
  15455. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  15456. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15458. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  15459. if !m.op.Is(OpUpdateOne) {
  15460. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  15461. }
  15462. if m.id == nil || m.oldValue == nil {
  15463. return v, errors.New("OldTemplate requires an ID field in the mutation")
  15464. }
  15465. oldValue, err := m.oldValue(ctx)
  15466. if err != nil {
  15467. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  15468. }
  15469. return oldValue.Template, nil
  15470. }
  15471. // AppendTemplate adds ctft to the "template" field.
  15472. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  15473. m.appendtemplate = append(m.appendtemplate, ctft...)
  15474. }
  15475. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  15476. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  15477. if len(m.appendtemplate) == 0 {
  15478. return nil, false
  15479. }
  15480. return m.appendtemplate, true
  15481. }
  15482. // ResetTemplate resets all changes to the "template" field.
  15483. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  15484. m.template = nil
  15485. m.appendtemplate = nil
  15486. }
  15487. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  15488. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  15489. m.predicates = append(m.predicates, ps...)
  15490. }
  15491. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  15492. // users can use type-assertion to append predicates that do not depend on any generated package.
  15493. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  15494. p := make([]predicate.ContactFieldTemplate, len(ps))
  15495. for i := range ps {
  15496. p[i] = ps[i]
  15497. }
  15498. m.Where(p...)
  15499. }
  15500. // Op returns the operation name.
  15501. func (m *ContactFieldTemplateMutation) Op() Op {
  15502. return m.op
  15503. }
  15504. // SetOp allows setting the mutation operation.
  15505. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  15506. m.op = op
  15507. }
  15508. // Type returns the node type of this mutation (ContactFieldTemplate).
  15509. func (m *ContactFieldTemplateMutation) Type() string {
  15510. return m.typ
  15511. }
  15512. // Fields returns all fields that were changed during this mutation. Note that in
  15513. // order to get all numeric fields that were incremented/decremented, call
  15514. // AddedFields().
  15515. func (m *ContactFieldTemplateMutation) Fields() []string {
  15516. fields := make([]string, 0, 6)
  15517. if m.created_at != nil {
  15518. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  15519. }
  15520. if m.updated_at != nil {
  15521. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  15522. }
  15523. if m.status != nil {
  15524. fields = append(fields, contactfieldtemplate.FieldStatus)
  15525. }
  15526. if m.deleted_at != nil {
  15527. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15528. }
  15529. if m.organization_id != nil {
  15530. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15531. }
  15532. if m.template != nil {
  15533. fields = append(fields, contactfieldtemplate.FieldTemplate)
  15534. }
  15535. return fields
  15536. }
  15537. // Field returns the value of a field with the given name. The second boolean
  15538. // return value indicates that this field was not set, or was not defined in the
  15539. // schema.
  15540. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  15541. switch name {
  15542. case contactfieldtemplate.FieldCreatedAt:
  15543. return m.CreatedAt()
  15544. case contactfieldtemplate.FieldUpdatedAt:
  15545. return m.UpdatedAt()
  15546. case contactfieldtemplate.FieldStatus:
  15547. return m.Status()
  15548. case contactfieldtemplate.FieldDeletedAt:
  15549. return m.DeletedAt()
  15550. case contactfieldtemplate.FieldOrganizationID:
  15551. return m.OrganizationID()
  15552. case contactfieldtemplate.FieldTemplate:
  15553. return m.Template()
  15554. }
  15555. return nil, false
  15556. }
  15557. // OldField returns the old value of the field from the database. An error is
  15558. // returned if the mutation operation is not UpdateOne, or the query to the
  15559. // database failed.
  15560. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15561. switch name {
  15562. case contactfieldtemplate.FieldCreatedAt:
  15563. return m.OldCreatedAt(ctx)
  15564. case contactfieldtemplate.FieldUpdatedAt:
  15565. return m.OldUpdatedAt(ctx)
  15566. case contactfieldtemplate.FieldStatus:
  15567. return m.OldStatus(ctx)
  15568. case contactfieldtemplate.FieldDeletedAt:
  15569. return m.OldDeletedAt(ctx)
  15570. case contactfieldtemplate.FieldOrganizationID:
  15571. return m.OldOrganizationID(ctx)
  15572. case contactfieldtemplate.FieldTemplate:
  15573. return m.OldTemplate(ctx)
  15574. }
  15575. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15576. }
  15577. // SetField sets the value of a field with the given name. It returns an error if
  15578. // the field is not defined in the schema, or if the type mismatched the field
  15579. // type.
  15580. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  15581. switch name {
  15582. case contactfieldtemplate.FieldCreatedAt:
  15583. v, ok := value.(time.Time)
  15584. if !ok {
  15585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15586. }
  15587. m.SetCreatedAt(v)
  15588. return nil
  15589. case contactfieldtemplate.FieldUpdatedAt:
  15590. v, ok := value.(time.Time)
  15591. if !ok {
  15592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15593. }
  15594. m.SetUpdatedAt(v)
  15595. return nil
  15596. case contactfieldtemplate.FieldStatus:
  15597. v, ok := value.(uint8)
  15598. if !ok {
  15599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15600. }
  15601. m.SetStatus(v)
  15602. return nil
  15603. case contactfieldtemplate.FieldDeletedAt:
  15604. v, ok := value.(time.Time)
  15605. if !ok {
  15606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15607. }
  15608. m.SetDeletedAt(v)
  15609. return nil
  15610. case contactfieldtemplate.FieldOrganizationID:
  15611. v, ok := value.(uint64)
  15612. if !ok {
  15613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15614. }
  15615. m.SetOrganizationID(v)
  15616. return nil
  15617. case contactfieldtemplate.FieldTemplate:
  15618. v, ok := value.([]custom_types.ContactFieldTemplate)
  15619. if !ok {
  15620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15621. }
  15622. m.SetTemplate(v)
  15623. return nil
  15624. }
  15625. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15626. }
  15627. // AddedFields returns all numeric fields that were incremented/decremented during
  15628. // this mutation.
  15629. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  15630. var fields []string
  15631. if m.addstatus != nil {
  15632. fields = append(fields, contactfieldtemplate.FieldStatus)
  15633. }
  15634. if m.addorganization_id != nil {
  15635. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15636. }
  15637. return fields
  15638. }
  15639. // AddedField returns the numeric value that was incremented/decremented on a field
  15640. // with the given name. The second boolean return value indicates that this field
  15641. // was not set, or was not defined in the schema.
  15642. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  15643. switch name {
  15644. case contactfieldtemplate.FieldStatus:
  15645. return m.AddedStatus()
  15646. case contactfieldtemplate.FieldOrganizationID:
  15647. return m.AddedOrganizationID()
  15648. }
  15649. return nil, false
  15650. }
  15651. // AddField adds the value to the field with the given name. It returns an error if
  15652. // the field is not defined in the schema, or if the type mismatched the field
  15653. // type.
  15654. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  15655. switch name {
  15656. case contactfieldtemplate.FieldStatus:
  15657. v, ok := value.(int8)
  15658. if !ok {
  15659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15660. }
  15661. m.AddStatus(v)
  15662. return nil
  15663. case contactfieldtemplate.FieldOrganizationID:
  15664. v, ok := value.(int64)
  15665. if !ok {
  15666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15667. }
  15668. m.AddOrganizationID(v)
  15669. return nil
  15670. }
  15671. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  15672. }
  15673. // ClearedFields returns all nullable fields that were cleared during this
  15674. // mutation.
  15675. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  15676. var fields []string
  15677. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  15678. fields = append(fields, contactfieldtemplate.FieldStatus)
  15679. }
  15680. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  15681. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15682. }
  15683. return fields
  15684. }
  15685. // FieldCleared returns a boolean indicating if a field with the given name was
  15686. // cleared in this mutation.
  15687. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  15688. _, ok := m.clearedFields[name]
  15689. return ok
  15690. }
  15691. // ClearField clears the value of the field with the given name. It returns an
  15692. // error if the field is not defined in the schema.
  15693. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  15694. switch name {
  15695. case contactfieldtemplate.FieldStatus:
  15696. m.ClearStatus()
  15697. return nil
  15698. case contactfieldtemplate.FieldDeletedAt:
  15699. m.ClearDeletedAt()
  15700. return nil
  15701. }
  15702. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  15703. }
  15704. // ResetField resets all changes in the mutation for the field with the given name.
  15705. // It returns an error if the field is not defined in the schema.
  15706. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  15707. switch name {
  15708. case contactfieldtemplate.FieldCreatedAt:
  15709. m.ResetCreatedAt()
  15710. return nil
  15711. case contactfieldtemplate.FieldUpdatedAt:
  15712. m.ResetUpdatedAt()
  15713. return nil
  15714. case contactfieldtemplate.FieldStatus:
  15715. m.ResetStatus()
  15716. return nil
  15717. case contactfieldtemplate.FieldDeletedAt:
  15718. m.ResetDeletedAt()
  15719. return nil
  15720. case contactfieldtemplate.FieldOrganizationID:
  15721. m.ResetOrganizationID()
  15722. return nil
  15723. case contactfieldtemplate.FieldTemplate:
  15724. m.ResetTemplate()
  15725. return nil
  15726. }
  15727. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15728. }
  15729. // AddedEdges returns all edge names that were set/added in this mutation.
  15730. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  15731. edges := make([]string, 0, 0)
  15732. return edges
  15733. }
  15734. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15735. // name in this mutation.
  15736. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  15737. return nil
  15738. }
  15739. // RemovedEdges returns all edge names that were removed in this mutation.
  15740. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  15741. edges := make([]string, 0, 0)
  15742. return edges
  15743. }
  15744. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15745. // the given name in this mutation.
  15746. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  15747. return nil
  15748. }
  15749. // ClearedEdges returns all edge names that were cleared in this mutation.
  15750. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  15751. edges := make([]string, 0, 0)
  15752. return edges
  15753. }
  15754. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15755. // was cleared in this mutation.
  15756. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  15757. return false
  15758. }
  15759. // ClearEdge clears the value of the edge with the given name. It returns an error
  15760. // if that edge is not defined in the schema.
  15761. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  15762. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  15763. }
  15764. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15765. // It returns an error if the edge is not defined in the schema.
  15766. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  15767. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  15768. }
  15769. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  15770. type CreditBalanceMutation struct {
  15771. config
  15772. op Op
  15773. typ string
  15774. id *uint64
  15775. created_at *time.Time
  15776. updated_at *time.Time
  15777. deleted_at *time.Time
  15778. user_id *string
  15779. balance *float64
  15780. addbalance *float64
  15781. status *int
  15782. addstatus *int
  15783. organization_id *uint64
  15784. addorganization_id *int64
  15785. clearedFields map[string]struct{}
  15786. done bool
  15787. oldValue func(context.Context) (*CreditBalance, error)
  15788. predicates []predicate.CreditBalance
  15789. }
  15790. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  15791. // creditbalanceOption allows management of the mutation configuration using functional options.
  15792. type creditbalanceOption func(*CreditBalanceMutation)
  15793. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  15794. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  15795. m := &CreditBalanceMutation{
  15796. config: c,
  15797. op: op,
  15798. typ: TypeCreditBalance,
  15799. clearedFields: make(map[string]struct{}),
  15800. }
  15801. for _, opt := range opts {
  15802. opt(m)
  15803. }
  15804. return m
  15805. }
  15806. // withCreditBalanceID sets the ID field of the mutation.
  15807. func withCreditBalanceID(id uint64) creditbalanceOption {
  15808. return func(m *CreditBalanceMutation) {
  15809. var (
  15810. err error
  15811. once sync.Once
  15812. value *CreditBalance
  15813. )
  15814. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  15815. once.Do(func() {
  15816. if m.done {
  15817. err = errors.New("querying old values post mutation is not allowed")
  15818. } else {
  15819. value, err = m.Client().CreditBalance.Get(ctx, id)
  15820. }
  15821. })
  15822. return value, err
  15823. }
  15824. m.id = &id
  15825. }
  15826. }
  15827. // withCreditBalance sets the old CreditBalance of the mutation.
  15828. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  15829. return func(m *CreditBalanceMutation) {
  15830. m.oldValue = func(context.Context) (*CreditBalance, error) {
  15831. return node, nil
  15832. }
  15833. m.id = &node.ID
  15834. }
  15835. }
  15836. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15837. // executed in a transaction (ent.Tx), a transactional client is returned.
  15838. func (m CreditBalanceMutation) Client() *Client {
  15839. client := &Client{config: m.config}
  15840. client.init()
  15841. return client
  15842. }
  15843. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15844. // it returns an error otherwise.
  15845. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  15846. if _, ok := m.driver.(*txDriver); !ok {
  15847. return nil, errors.New("ent: mutation is not running in a transaction")
  15848. }
  15849. tx := &Tx{config: m.config}
  15850. tx.init()
  15851. return tx, nil
  15852. }
  15853. // SetID sets the value of the id field. Note that this
  15854. // operation is only accepted on creation of CreditBalance entities.
  15855. func (m *CreditBalanceMutation) SetID(id uint64) {
  15856. m.id = &id
  15857. }
  15858. // ID returns the ID value in the mutation. Note that the ID is only available
  15859. // if it was provided to the builder or after it was returned from the database.
  15860. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  15861. if m.id == nil {
  15862. return
  15863. }
  15864. return *m.id, true
  15865. }
  15866. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15867. // That means, if the mutation is applied within a transaction with an isolation level such
  15868. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15869. // or updated by the mutation.
  15870. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  15871. switch {
  15872. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15873. id, exists := m.ID()
  15874. if exists {
  15875. return []uint64{id}, nil
  15876. }
  15877. fallthrough
  15878. case m.op.Is(OpUpdate | OpDelete):
  15879. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  15880. default:
  15881. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15882. }
  15883. }
  15884. // SetCreatedAt sets the "created_at" field.
  15885. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  15886. m.created_at = &t
  15887. }
  15888. // CreatedAt returns the value of the "created_at" field in the mutation.
  15889. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  15890. v := m.created_at
  15891. if v == nil {
  15892. return
  15893. }
  15894. return *v, true
  15895. }
  15896. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  15897. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15899. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15900. if !m.op.Is(OpUpdateOne) {
  15901. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15902. }
  15903. if m.id == nil || m.oldValue == nil {
  15904. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15905. }
  15906. oldValue, err := m.oldValue(ctx)
  15907. if err != nil {
  15908. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15909. }
  15910. return oldValue.CreatedAt, nil
  15911. }
  15912. // ResetCreatedAt resets all changes to the "created_at" field.
  15913. func (m *CreditBalanceMutation) ResetCreatedAt() {
  15914. m.created_at = nil
  15915. }
  15916. // SetUpdatedAt sets the "updated_at" field.
  15917. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  15918. m.updated_at = &t
  15919. }
  15920. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15921. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  15922. v := m.updated_at
  15923. if v == nil {
  15924. return
  15925. }
  15926. return *v, true
  15927. }
  15928. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  15929. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15931. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15932. if !m.op.Is(OpUpdateOne) {
  15933. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15934. }
  15935. if m.id == nil || m.oldValue == nil {
  15936. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15937. }
  15938. oldValue, err := m.oldValue(ctx)
  15939. if err != nil {
  15940. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15941. }
  15942. return oldValue.UpdatedAt, nil
  15943. }
  15944. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15945. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  15946. m.updated_at = nil
  15947. }
  15948. // SetDeletedAt sets the "deleted_at" field.
  15949. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  15950. m.deleted_at = &t
  15951. }
  15952. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15953. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  15954. v := m.deleted_at
  15955. if v == nil {
  15956. return
  15957. }
  15958. return *v, true
  15959. }
  15960. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  15961. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15963. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15964. if !m.op.Is(OpUpdateOne) {
  15965. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15966. }
  15967. if m.id == nil || m.oldValue == nil {
  15968. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15969. }
  15970. oldValue, err := m.oldValue(ctx)
  15971. if err != nil {
  15972. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15973. }
  15974. return oldValue.DeletedAt, nil
  15975. }
  15976. // ClearDeletedAt clears the value of the "deleted_at" field.
  15977. func (m *CreditBalanceMutation) ClearDeletedAt() {
  15978. m.deleted_at = nil
  15979. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  15980. }
  15981. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15982. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  15983. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  15984. return ok
  15985. }
  15986. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15987. func (m *CreditBalanceMutation) ResetDeletedAt() {
  15988. m.deleted_at = nil
  15989. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  15990. }
  15991. // SetUserID sets the "user_id" field.
  15992. func (m *CreditBalanceMutation) SetUserID(s string) {
  15993. m.user_id = &s
  15994. }
  15995. // UserID returns the value of the "user_id" field in the mutation.
  15996. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  15997. v := m.user_id
  15998. if v == nil {
  15999. return
  16000. }
  16001. return *v, true
  16002. }
  16003. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  16004. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16006. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  16007. if !m.op.Is(OpUpdateOne) {
  16008. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16009. }
  16010. if m.id == nil || m.oldValue == nil {
  16011. return v, errors.New("OldUserID requires an ID field in the mutation")
  16012. }
  16013. oldValue, err := m.oldValue(ctx)
  16014. if err != nil {
  16015. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16016. }
  16017. return oldValue.UserID, nil
  16018. }
  16019. // ClearUserID clears the value of the "user_id" field.
  16020. func (m *CreditBalanceMutation) ClearUserID() {
  16021. m.user_id = nil
  16022. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  16023. }
  16024. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16025. func (m *CreditBalanceMutation) UserIDCleared() bool {
  16026. _, ok := m.clearedFields[creditbalance.FieldUserID]
  16027. return ok
  16028. }
  16029. // ResetUserID resets all changes to the "user_id" field.
  16030. func (m *CreditBalanceMutation) ResetUserID() {
  16031. m.user_id = nil
  16032. delete(m.clearedFields, creditbalance.FieldUserID)
  16033. }
  16034. // SetBalance sets the "balance" field.
  16035. func (m *CreditBalanceMutation) SetBalance(f float64) {
  16036. m.balance = &f
  16037. m.addbalance = nil
  16038. }
  16039. // Balance returns the value of the "balance" field in the mutation.
  16040. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  16041. v := m.balance
  16042. if v == nil {
  16043. return
  16044. }
  16045. return *v, true
  16046. }
  16047. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  16048. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16050. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  16051. if !m.op.Is(OpUpdateOne) {
  16052. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  16053. }
  16054. if m.id == nil || m.oldValue == nil {
  16055. return v, errors.New("OldBalance requires an ID field in the mutation")
  16056. }
  16057. oldValue, err := m.oldValue(ctx)
  16058. if err != nil {
  16059. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  16060. }
  16061. return oldValue.Balance, nil
  16062. }
  16063. // AddBalance adds f to the "balance" field.
  16064. func (m *CreditBalanceMutation) AddBalance(f float64) {
  16065. if m.addbalance != nil {
  16066. *m.addbalance += f
  16067. } else {
  16068. m.addbalance = &f
  16069. }
  16070. }
  16071. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  16072. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  16073. v := m.addbalance
  16074. if v == nil {
  16075. return
  16076. }
  16077. return *v, true
  16078. }
  16079. // ResetBalance resets all changes to the "balance" field.
  16080. func (m *CreditBalanceMutation) ResetBalance() {
  16081. m.balance = nil
  16082. m.addbalance = nil
  16083. }
  16084. // SetStatus sets the "status" field.
  16085. func (m *CreditBalanceMutation) SetStatus(i int) {
  16086. m.status = &i
  16087. m.addstatus = nil
  16088. }
  16089. // Status returns the value of the "status" field in the mutation.
  16090. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  16091. v := m.status
  16092. if v == nil {
  16093. return
  16094. }
  16095. return *v, true
  16096. }
  16097. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  16098. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16100. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  16101. if !m.op.Is(OpUpdateOne) {
  16102. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16103. }
  16104. if m.id == nil || m.oldValue == nil {
  16105. return v, errors.New("OldStatus requires an ID field in the mutation")
  16106. }
  16107. oldValue, err := m.oldValue(ctx)
  16108. if err != nil {
  16109. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16110. }
  16111. return oldValue.Status, nil
  16112. }
  16113. // AddStatus adds i to the "status" field.
  16114. func (m *CreditBalanceMutation) AddStatus(i int) {
  16115. if m.addstatus != nil {
  16116. *m.addstatus += i
  16117. } else {
  16118. m.addstatus = &i
  16119. }
  16120. }
  16121. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16122. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  16123. v := m.addstatus
  16124. if v == nil {
  16125. return
  16126. }
  16127. return *v, true
  16128. }
  16129. // ClearStatus clears the value of the "status" field.
  16130. func (m *CreditBalanceMutation) ClearStatus() {
  16131. m.status = nil
  16132. m.addstatus = nil
  16133. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  16134. }
  16135. // StatusCleared returns if the "status" field was cleared in this mutation.
  16136. func (m *CreditBalanceMutation) StatusCleared() bool {
  16137. _, ok := m.clearedFields[creditbalance.FieldStatus]
  16138. return ok
  16139. }
  16140. // ResetStatus resets all changes to the "status" field.
  16141. func (m *CreditBalanceMutation) ResetStatus() {
  16142. m.status = nil
  16143. m.addstatus = nil
  16144. delete(m.clearedFields, creditbalance.FieldStatus)
  16145. }
  16146. // SetOrganizationID sets the "organization_id" field.
  16147. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  16148. m.organization_id = &u
  16149. m.addorganization_id = nil
  16150. }
  16151. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16152. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  16153. v := m.organization_id
  16154. if v == nil {
  16155. return
  16156. }
  16157. return *v, true
  16158. }
  16159. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  16160. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16162. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16163. if !m.op.Is(OpUpdateOne) {
  16164. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16165. }
  16166. if m.id == nil || m.oldValue == nil {
  16167. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16168. }
  16169. oldValue, err := m.oldValue(ctx)
  16170. if err != nil {
  16171. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16172. }
  16173. return oldValue.OrganizationID, nil
  16174. }
  16175. // AddOrganizationID adds u to the "organization_id" field.
  16176. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  16177. if m.addorganization_id != nil {
  16178. *m.addorganization_id += u
  16179. } else {
  16180. m.addorganization_id = &u
  16181. }
  16182. }
  16183. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16184. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  16185. v := m.addorganization_id
  16186. if v == nil {
  16187. return
  16188. }
  16189. return *v, true
  16190. }
  16191. // ClearOrganizationID clears the value of the "organization_id" field.
  16192. func (m *CreditBalanceMutation) ClearOrganizationID() {
  16193. m.organization_id = nil
  16194. m.addorganization_id = nil
  16195. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  16196. }
  16197. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16198. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  16199. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  16200. return ok
  16201. }
  16202. // ResetOrganizationID resets all changes to the "organization_id" field.
  16203. func (m *CreditBalanceMutation) ResetOrganizationID() {
  16204. m.organization_id = nil
  16205. m.addorganization_id = nil
  16206. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  16207. }
  16208. // Where appends a list predicates to the CreditBalanceMutation builder.
  16209. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  16210. m.predicates = append(m.predicates, ps...)
  16211. }
  16212. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  16213. // users can use type-assertion to append predicates that do not depend on any generated package.
  16214. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  16215. p := make([]predicate.CreditBalance, len(ps))
  16216. for i := range ps {
  16217. p[i] = ps[i]
  16218. }
  16219. m.Where(p...)
  16220. }
  16221. // Op returns the operation name.
  16222. func (m *CreditBalanceMutation) Op() Op {
  16223. return m.op
  16224. }
  16225. // SetOp allows setting the mutation operation.
  16226. func (m *CreditBalanceMutation) SetOp(op Op) {
  16227. m.op = op
  16228. }
  16229. // Type returns the node type of this mutation (CreditBalance).
  16230. func (m *CreditBalanceMutation) Type() string {
  16231. return m.typ
  16232. }
  16233. // Fields returns all fields that were changed during this mutation. Note that in
  16234. // order to get all numeric fields that were incremented/decremented, call
  16235. // AddedFields().
  16236. func (m *CreditBalanceMutation) Fields() []string {
  16237. fields := make([]string, 0, 7)
  16238. if m.created_at != nil {
  16239. fields = append(fields, creditbalance.FieldCreatedAt)
  16240. }
  16241. if m.updated_at != nil {
  16242. fields = append(fields, creditbalance.FieldUpdatedAt)
  16243. }
  16244. if m.deleted_at != nil {
  16245. fields = append(fields, creditbalance.FieldDeletedAt)
  16246. }
  16247. if m.user_id != nil {
  16248. fields = append(fields, creditbalance.FieldUserID)
  16249. }
  16250. if m.balance != nil {
  16251. fields = append(fields, creditbalance.FieldBalance)
  16252. }
  16253. if m.status != nil {
  16254. fields = append(fields, creditbalance.FieldStatus)
  16255. }
  16256. if m.organization_id != nil {
  16257. fields = append(fields, creditbalance.FieldOrganizationID)
  16258. }
  16259. return fields
  16260. }
  16261. // Field returns the value of a field with the given name. The second boolean
  16262. // return value indicates that this field was not set, or was not defined in the
  16263. // schema.
  16264. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  16265. switch name {
  16266. case creditbalance.FieldCreatedAt:
  16267. return m.CreatedAt()
  16268. case creditbalance.FieldUpdatedAt:
  16269. return m.UpdatedAt()
  16270. case creditbalance.FieldDeletedAt:
  16271. return m.DeletedAt()
  16272. case creditbalance.FieldUserID:
  16273. return m.UserID()
  16274. case creditbalance.FieldBalance:
  16275. return m.Balance()
  16276. case creditbalance.FieldStatus:
  16277. return m.Status()
  16278. case creditbalance.FieldOrganizationID:
  16279. return m.OrganizationID()
  16280. }
  16281. return nil, false
  16282. }
  16283. // OldField returns the old value of the field from the database. An error is
  16284. // returned if the mutation operation is not UpdateOne, or the query to the
  16285. // database failed.
  16286. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16287. switch name {
  16288. case creditbalance.FieldCreatedAt:
  16289. return m.OldCreatedAt(ctx)
  16290. case creditbalance.FieldUpdatedAt:
  16291. return m.OldUpdatedAt(ctx)
  16292. case creditbalance.FieldDeletedAt:
  16293. return m.OldDeletedAt(ctx)
  16294. case creditbalance.FieldUserID:
  16295. return m.OldUserID(ctx)
  16296. case creditbalance.FieldBalance:
  16297. return m.OldBalance(ctx)
  16298. case creditbalance.FieldStatus:
  16299. return m.OldStatus(ctx)
  16300. case creditbalance.FieldOrganizationID:
  16301. return m.OldOrganizationID(ctx)
  16302. }
  16303. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  16304. }
  16305. // SetField sets the value of a field with the given name. It returns an error if
  16306. // the field is not defined in the schema, or if the type mismatched the field
  16307. // type.
  16308. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  16309. switch name {
  16310. case creditbalance.FieldCreatedAt:
  16311. v, ok := value.(time.Time)
  16312. if !ok {
  16313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16314. }
  16315. m.SetCreatedAt(v)
  16316. return nil
  16317. case creditbalance.FieldUpdatedAt:
  16318. v, ok := value.(time.Time)
  16319. if !ok {
  16320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16321. }
  16322. m.SetUpdatedAt(v)
  16323. return nil
  16324. case creditbalance.FieldDeletedAt:
  16325. v, ok := value.(time.Time)
  16326. if !ok {
  16327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16328. }
  16329. m.SetDeletedAt(v)
  16330. return nil
  16331. case creditbalance.FieldUserID:
  16332. v, ok := value.(string)
  16333. if !ok {
  16334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16335. }
  16336. m.SetUserID(v)
  16337. return nil
  16338. case creditbalance.FieldBalance:
  16339. v, ok := value.(float64)
  16340. if !ok {
  16341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16342. }
  16343. m.SetBalance(v)
  16344. return nil
  16345. case creditbalance.FieldStatus:
  16346. v, ok := value.(int)
  16347. if !ok {
  16348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16349. }
  16350. m.SetStatus(v)
  16351. return nil
  16352. case creditbalance.FieldOrganizationID:
  16353. v, ok := value.(uint64)
  16354. if !ok {
  16355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16356. }
  16357. m.SetOrganizationID(v)
  16358. return nil
  16359. }
  16360. return fmt.Errorf("unknown CreditBalance field %s", name)
  16361. }
  16362. // AddedFields returns all numeric fields that were incremented/decremented during
  16363. // this mutation.
  16364. func (m *CreditBalanceMutation) AddedFields() []string {
  16365. var fields []string
  16366. if m.addbalance != nil {
  16367. fields = append(fields, creditbalance.FieldBalance)
  16368. }
  16369. if m.addstatus != nil {
  16370. fields = append(fields, creditbalance.FieldStatus)
  16371. }
  16372. if m.addorganization_id != nil {
  16373. fields = append(fields, creditbalance.FieldOrganizationID)
  16374. }
  16375. return fields
  16376. }
  16377. // AddedField returns the numeric value that was incremented/decremented on a field
  16378. // with the given name. The second boolean return value indicates that this field
  16379. // was not set, or was not defined in the schema.
  16380. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  16381. switch name {
  16382. case creditbalance.FieldBalance:
  16383. return m.AddedBalance()
  16384. case creditbalance.FieldStatus:
  16385. return m.AddedStatus()
  16386. case creditbalance.FieldOrganizationID:
  16387. return m.AddedOrganizationID()
  16388. }
  16389. return nil, false
  16390. }
  16391. // AddField adds the value to the field with the given name. It returns an error if
  16392. // the field is not defined in the schema, or if the type mismatched the field
  16393. // type.
  16394. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  16395. switch name {
  16396. case creditbalance.FieldBalance:
  16397. v, ok := value.(float64)
  16398. if !ok {
  16399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16400. }
  16401. m.AddBalance(v)
  16402. return nil
  16403. case creditbalance.FieldStatus:
  16404. v, ok := value.(int)
  16405. if !ok {
  16406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16407. }
  16408. m.AddStatus(v)
  16409. return nil
  16410. case creditbalance.FieldOrganizationID:
  16411. v, ok := value.(int64)
  16412. if !ok {
  16413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16414. }
  16415. m.AddOrganizationID(v)
  16416. return nil
  16417. }
  16418. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  16419. }
  16420. // ClearedFields returns all nullable fields that were cleared during this
  16421. // mutation.
  16422. func (m *CreditBalanceMutation) ClearedFields() []string {
  16423. var fields []string
  16424. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  16425. fields = append(fields, creditbalance.FieldDeletedAt)
  16426. }
  16427. if m.FieldCleared(creditbalance.FieldUserID) {
  16428. fields = append(fields, creditbalance.FieldUserID)
  16429. }
  16430. if m.FieldCleared(creditbalance.FieldStatus) {
  16431. fields = append(fields, creditbalance.FieldStatus)
  16432. }
  16433. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  16434. fields = append(fields, creditbalance.FieldOrganizationID)
  16435. }
  16436. return fields
  16437. }
  16438. // FieldCleared returns a boolean indicating if a field with the given name was
  16439. // cleared in this mutation.
  16440. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  16441. _, ok := m.clearedFields[name]
  16442. return ok
  16443. }
  16444. // ClearField clears the value of the field with the given name. It returns an
  16445. // error if the field is not defined in the schema.
  16446. func (m *CreditBalanceMutation) ClearField(name string) error {
  16447. switch name {
  16448. case creditbalance.FieldDeletedAt:
  16449. m.ClearDeletedAt()
  16450. return nil
  16451. case creditbalance.FieldUserID:
  16452. m.ClearUserID()
  16453. return nil
  16454. case creditbalance.FieldStatus:
  16455. m.ClearStatus()
  16456. return nil
  16457. case creditbalance.FieldOrganizationID:
  16458. m.ClearOrganizationID()
  16459. return nil
  16460. }
  16461. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  16462. }
  16463. // ResetField resets all changes in the mutation for the field with the given name.
  16464. // It returns an error if the field is not defined in the schema.
  16465. func (m *CreditBalanceMutation) ResetField(name string) error {
  16466. switch name {
  16467. case creditbalance.FieldCreatedAt:
  16468. m.ResetCreatedAt()
  16469. return nil
  16470. case creditbalance.FieldUpdatedAt:
  16471. m.ResetUpdatedAt()
  16472. return nil
  16473. case creditbalance.FieldDeletedAt:
  16474. m.ResetDeletedAt()
  16475. return nil
  16476. case creditbalance.FieldUserID:
  16477. m.ResetUserID()
  16478. return nil
  16479. case creditbalance.FieldBalance:
  16480. m.ResetBalance()
  16481. return nil
  16482. case creditbalance.FieldStatus:
  16483. m.ResetStatus()
  16484. return nil
  16485. case creditbalance.FieldOrganizationID:
  16486. m.ResetOrganizationID()
  16487. return nil
  16488. }
  16489. return fmt.Errorf("unknown CreditBalance field %s", name)
  16490. }
  16491. // AddedEdges returns all edge names that were set/added in this mutation.
  16492. func (m *CreditBalanceMutation) AddedEdges() []string {
  16493. edges := make([]string, 0, 0)
  16494. return edges
  16495. }
  16496. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16497. // name in this mutation.
  16498. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  16499. return nil
  16500. }
  16501. // RemovedEdges returns all edge names that were removed in this mutation.
  16502. func (m *CreditBalanceMutation) RemovedEdges() []string {
  16503. edges := make([]string, 0, 0)
  16504. return edges
  16505. }
  16506. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16507. // the given name in this mutation.
  16508. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  16509. return nil
  16510. }
  16511. // ClearedEdges returns all edge names that were cleared in this mutation.
  16512. func (m *CreditBalanceMutation) ClearedEdges() []string {
  16513. edges := make([]string, 0, 0)
  16514. return edges
  16515. }
  16516. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16517. // was cleared in this mutation.
  16518. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  16519. return false
  16520. }
  16521. // ClearEdge clears the value of the edge with the given name. It returns an error
  16522. // if that edge is not defined in the schema.
  16523. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  16524. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  16525. }
  16526. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16527. // It returns an error if the edge is not defined in the schema.
  16528. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  16529. return fmt.Errorf("unknown CreditBalance edge %s", name)
  16530. }
  16531. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  16532. type CreditUsageMutation struct {
  16533. config
  16534. op Op
  16535. typ string
  16536. id *uint64
  16537. created_at *time.Time
  16538. updated_at *time.Time
  16539. deleted_at *time.Time
  16540. user_id *string
  16541. number *float64
  16542. addnumber *float64
  16543. pay_number *float64
  16544. addpay_number *float64
  16545. before_number *float64
  16546. addbefore_number *float64
  16547. after_number *float64
  16548. addafter_number *float64
  16549. pay_method *int
  16550. addpay_method *int
  16551. status *int
  16552. addstatus *int
  16553. ntype *int
  16554. addntype *int
  16555. table *string
  16556. organization_id *uint64
  16557. addorganization_id *int64
  16558. nid *uint64
  16559. addnid *int64
  16560. reason *string
  16561. operator *string
  16562. clearedFields map[string]struct{}
  16563. done bool
  16564. oldValue func(context.Context) (*CreditUsage, error)
  16565. predicates []predicate.CreditUsage
  16566. }
  16567. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  16568. // creditusageOption allows management of the mutation configuration using functional options.
  16569. type creditusageOption func(*CreditUsageMutation)
  16570. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  16571. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  16572. m := &CreditUsageMutation{
  16573. config: c,
  16574. op: op,
  16575. typ: TypeCreditUsage,
  16576. clearedFields: make(map[string]struct{}),
  16577. }
  16578. for _, opt := range opts {
  16579. opt(m)
  16580. }
  16581. return m
  16582. }
  16583. // withCreditUsageID sets the ID field of the mutation.
  16584. func withCreditUsageID(id uint64) creditusageOption {
  16585. return func(m *CreditUsageMutation) {
  16586. var (
  16587. err error
  16588. once sync.Once
  16589. value *CreditUsage
  16590. )
  16591. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  16592. once.Do(func() {
  16593. if m.done {
  16594. err = errors.New("querying old values post mutation is not allowed")
  16595. } else {
  16596. value, err = m.Client().CreditUsage.Get(ctx, id)
  16597. }
  16598. })
  16599. return value, err
  16600. }
  16601. m.id = &id
  16602. }
  16603. }
  16604. // withCreditUsage sets the old CreditUsage of the mutation.
  16605. func withCreditUsage(node *CreditUsage) creditusageOption {
  16606. return func(m *CreditUsageMutation) {
  16607. m.oldValue = func(context.Context) (*CreditUsage, error) {
  16608. return node, nil
  16609. }
  16610. m.id = &node.ID
  16611. }
  16612. }
  16613. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16614. // executed in a transaction (ent.Tx), a transactional client is returned.
  16615. func (m CreditUsageMutation) Client() *Client {
  16616. client := &Client{config: m.config}
  16617. client.init()
  16618. return client
  16619. }
  16620. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16621. // it returns an error otherwise.
  16622. func (m CreditUsageMutation) Tx() (*Tx, error) {
  16623. if _, ok := m.driver.(*txDriver); !ok {
  16624. return nil, errors.New("ent: mutation is not running in a transaction")
  16625. }
  16626. tx := &Tx{config: m.config}
  16627. tx.init()
  16628. return tx, nil
  16629. }
  16630. // SetID sets the value of the id field. Note that this
  16631. // operation is only accepted on creation of CreditUsage entities.
  16632. func (m *CreditUsageMutation) SetID(id uint64) {
  16633. m.id = &id
  16634. }
  16635. // ID returns the ID value in the mutation. Note that the ID is only available
  16636. // if it was provided to the builder or after it was returned from the database.
  16637. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  16638. if m.id == nil {
  16639. return
  16640. }
  16641. return *m.id, true
  16642. }
  16643. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16644. // That means, if the mutation is applied within a transaction with an isolation level such
  16645. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16646. // or updated by the mutation.
  16647. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16648. switch {
  16649. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16650. id, exists := m.ID()
  16651. if exists {
  16652. return []uint64{id}, nil
  16653. }
  16654. fallthrough
  16655. case m.op.Is(OpUpdate | OpDelete):
  16656. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  16657. default:
  16658. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16659. }
  16660. }
  16661. // SetCreatedAt sets the "created_at" field.
  16662. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  16663. m.created_at = &t
  16664. }
  16665. // CreatedAt returns the value of the "created_at" field in the mutation.
  16666. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  16667. v := m.created_at
  16668. if v == nil {
  16669. return
  16670. }
  16671. return *v, true
  16672. }
  16673. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  16674. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16676. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16677. if !m.op.Is(OpUpdateOne) {
  16678. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16679. }
  16680. if m.id == nil || m.oldValue == nil {
  16681. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16682. }
  16683. oldValue, err := m.oldValue(ctx)
  16684. if err != nil {
  16685. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16686. }
  16687. return oldValue.CreatedAt, nil
  16688. }
  16689. // ResetCreatedAt resets all changes to the "created_at" field.
  16690. func (m *CreditUsageMutation) ResetCreatedAt() {
  16691. m.created_at = nil
  16692. }
  16693. // SetUpdatedAt sets the "updated_at" field.
  16694. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  16695. m.updated_at = &t
  16696. }
  16697. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16698. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  16699. v := m.updated_at
  16700. if v == nil {
  16701. return
  16702. }
  16703. return *v, true
  16704. }
  16705. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  16706. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16708. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16709. if !m.op.Is(OpUpdateOne) {
  16710. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16711. }
  16712. if m.id == nil || m.oldValue == nil {
  16713. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16714. }
  16715. oldValue, err := m.oldValue(ctx)
  16716. if err != nil {
  16717. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16718. }
  16719. return oldValue.UpdatedAt, nil
  16720. }
  16721. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16722. func (m *CreditUsageMutation) ResetUpdatedAt() {
  16723. m.updated_at = nil
  16724. }
  16725. // SetDeletedAt sets the "deleted_at" field.
  16726. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  16727. m.deleted_at = &t
  16728. }
  16729. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16730. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  16731. v := m.deleted_at
  16732. if v == nil {
  16733. return
  16734. }
  16735. return *v, true
  16736. }
  16737. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  16738. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16740. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16741. if !m.op.Is(OpUpdateOne) {
  16742. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16743. }
  16744. if m.id == nil || m.oldValue == nil {
  16745. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16746. }
  16747. oldValue, err := m.oldValue(ctx)
  16748. if err != nil {
  16749. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16750. }
  16751. return oldValue.DeletedAt, nil
  16752. }
  16753. // ClearDeletedAt clears the value of the "deleted_at" field.
  16754. func (m *CreditUsageMutation) ClearDeletedAt() {
  16755. m.deleted_at = nil
  16756. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  16757. }
  16758. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16759. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  16760. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  16761. return ok
  16762. }
  16763. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16764. func (m *CreditUsageMutation) ResetDeletedAt() {
  16765. m.deleted_at = nil
  16766. delete(m.clearedFields, creditusage.FieldDeletedAt)
  16767. }
  16768. // SetUserID sets the "user_id" field.
  16769. func (m *CreditUsageMutation) SetUserID(s string) {
  16770. m.user_id = &s
  16771. }
  16772. // UserID returns the value of the "user_id" field in the mutation.
  16773. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  16774. v := m.user_id
  16775. if v == nil {
  16776. return
  16777. }
  16778. return *v, true
  16779. }
  16780. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  16781. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16783. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  16784. if !m.op.Is(OpUpdateOne) {
  16785. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16786. }
  16787. if m.id == nil || m.oldValue == nil {
  16788. return v, errors.New("OldUserID requires an ID field in the mutation")
  16789. }
  16790. oldValue, err := m.oldValue(ctx)
  16791. if err != nil {
  16792. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16793. }
  16794. return oldValue.UserID, nil
  16795. }
  16796. // ClearUserID clears the value of the "user_id" field.
  16797. func (m *CreditUsageMutation) ClearUserID() {
  16798. m.user_id = nil
  16799. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  16800. }
  16801. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16802. func (m *CreditUsageMutation) UserIDCleared() bool {
  16803. _, ok := m.clearedFields[creditusage.FieldUserID]
  16804. return ok
  16805. }
  16806. // ResetUserID resets all changes to the "user_id" field.
  16807. func (m *CreditUsageMutation) ResetUserID() {
  16808. m.user_id = nil
  16809. delete(m.clearedFields, creditusage.FieldUserID)
  16810. }
  16811. // SetNumber sets the "number" field.
  16812. func (m *CreditUsageMutation) SetNumber(f float64) {
  16813. m.number = &f
  16814. m.addnumber = nil
  16815. }
  16816. // Number returns the value of the "number" field in the mutation.
  16817. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  16818. v := m.number
  16819. if v == nil {
  16820. return
  16821. }
  16822. return *v, true
  16823. }
  16824. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  16825. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16827. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  16828. if !m.op.Is(OpUpdateOne) {
  16829. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  16830. }
  16831. if m.id == nil || m.oldValue == nil {
  16832. return v, errors.New("OldNumber requires an ID field in the mutation")
  16833. }
  16834. oldValue, err := m.oldValue(ctx)
  16835. if err != nil {
  16836. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  16837. }
  16838. return oldValue.Number, nil
  16839. }
  16840. // AddNumber adds f to the "number" field.
  16841. func (m *CreditUsageMutation) AddNumber(f float64) {
  16842. if m.addnumber != nil {
  16843. *m.addnumber += f
  16844. } else {
  16845. m.addnumber = &f
  16846. }
  16847. }
  16848. // AddedNumber returns the value that was added to the "number" field in this mutation.
  16849. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  16850. v := m.addnumber
  16851. if v == nil {
  16852. return
  16853. }
  16854. return *v, true
  16855. }
  16856. // ResetNumber resets all changes to the "number" field.
  16857. func (m *CreditUsageMutation) ResetNumber() {
  16858. m.number = nil
  16859. m.addnumber = nil
  16860. }
  16861. // SetPayNumber sets the "pay_number" field.
  16862. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  16863. m.pay_number = &f
  16864. m.addpay_number = nil
  16865. }
  16866. // PayNumber returns the value of the "pay_number" field in the mutation.
  16867. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  16868. v := m.pay_number
  16869. if v == nil {
  16870. return
  16871. }
  16872. return *v, true
  16873. }
  16874. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  16875. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16877. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  16878. if !m.op.Is(OpUpdateOne) {
  16879. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  16880. }
  16881. if m.id == nil || m.oldValue == nil {
  16882. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  16883. }
  16884. oldValue, err := m.oldValue(ctx)
  16885. if err != nil {
  16886. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  16887. }
  16888. return oldValue.PayNumber, nil
  16889. }
  16890. // AddPayNumber adds f to the "pay_number" field.
  16891. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  16892. if m.addpay_number != nil {
  16893. *m.addpay_number += f
  16894. } else {
  16895. m.addpay_number = &f
  16896. }
  16897. }
  16898. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  16899. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  16900. v := m.addpay_number
  16901. if v == nil {
  16902. return
  16903. }
  16904. return *v, true
  16905. }
  16906. // ClearPayNumber clears the value of the "pay_number" field.
  16907. func (m *CreditUsageMutation) ClearPayNumber() {
  16908. m.pay_number = nil
  16909. m.addpay_number = nil
  16910. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  16911. }
  16912. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  16913. func (m *CreditUsageMutation) PayNumberCleared() bool {
  16914. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  16915. return ok
  16916. }
  16917. // ResetPayNumber resets all changes to the "pay_number" field.
  16918. func (m *CreditUsageMutation) ResetPayNumber() {
  16919. m.pay_number = nil
  16920. m.addpay_number = nil
  16921. delete(m.clearedFields, creditusage.FieldPayNumber)
  16922. }
  16923. // SetBeforeNumber sets the "before_number" field.
  16924. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  16925. m.before_number = &f
  16926. m.addbefore_number = nil
  16927. }
  16928. // BeforeNumber returns the value of the "before_number" field in the mutation.
  16929. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  16930. v := m.before_number
  16931. if v == nil {
  16932. return
  16933. }
  16934. return *v, true
  16935. }
  16936. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  16937. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16939. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  16940. if !m.op.Is(OpUpdateOne) {
  16941. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  16942. }
  16943. if m.id == nil || m.oldValue == nil {
  16944. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  16945. }
  16946. oldValue, err := m.oldValue(ctx)
  16947. if err != nil {
  16948. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  16949. }
  16950. return oldValue.BeforeNumber, nil
  16951. }
  16952. // AddBeforeNumber adds f to the "before_number" field.
  16953. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  16954. if m.addbefore_number != nil {
  16955. *m.addbefore_number += f
  16956. } else {
  16957. m.addbefore_number = &f
  16958. }
  16959. }
  16960. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  16961. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  16962. v := m.addbefore_number
  16963. if v == nil {
  16964. return
  16965. }
  16966. return *v, true
  16967. }
  16968. // ClearBeforeNumber clears the value of the "before_number" field.
  16969. func (m *CreditUsageMutation) ClearBeforeNumber() {
  16970. m.before_number = nil
  16971. m.addbefore_number = nil
  16972. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  16973. }
  16974. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  16975. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  16976. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  16977. return ok
  16978. }
  16979. // ResetBeforeNumber resets all changes to the "before_number" field.
  16980. func (m *CreditUsageMutation) ResetBeforeNumber() {
  16981. m.before_number = nil
  16982. m.addbefore_number = nil
  16983. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  16984. }
  16985. // SetAfterNumber sets the "after_number" field.
  16986. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  16987. m.after_number = &f
  16988. m.addafter_number = nil
  16989. }
  16990. // AfterNumber returns the value of the "after_number" field in the mutation.
  16991. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  16992. v := m.after_number
  16993. if v == nil {
  16994. return
  16995. }
  16996. return *v, true
  16997. }
  16998. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  16999. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17001. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  17002. if !m.op.Is(OpUpdateOne) {
  17003. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  17004. }
  17005. if m.id == nil || m.oldValue == nil {
  17006. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  17007. }
  17008. oldValue, err := m.oldValue(ctx)
  17009. if err != nil {
  17010. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  17011. }
  17012. return oldValue.AfterNumber, nil
  17013. }
  17014. // AddAfterNumber adds f to the "after_number" field.
  17015. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  17016. if m.addafter_number != nil {
  17017. *m.addafter_number += f
  17018. } else {
  17019. m.addafter_number = &f
  17020. }
  17021. }
  17022. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  17023. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  17024. v := m.addafter_number
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // ClearAfterNumber clears the value of the "after_number" field.
  17031. func (m *CreditUsageMutation) ClearAfterNumber() {
  17032. m.after_number = nil
  17033. m.addafter_number = nil
  17034. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  17035. }
  17036. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  17037. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  17038. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  17039. return ok
  17040. }
  17041. // ResetAfterNumber resets all changes to the "after_number" field.
  17042. func (m *CreditUsageMutation) ResetAfterNumber() {
  17043. m.after_number = nil
  17044. m.addafter_number = nil
  17045. delete(m.clearedFields, creditusage.FieldAfterNumber)
  17046. }
  17047. // SetPayMethod sets the "pay_method" field.
  17048. func (m *CreditUsageMutation) SetPayMethod(i int) {
  17049. m.pay_method = &i
  17050. m.addpay_method = nil
  17051. }
  17052. // PayMethod returns the value of the "pay_method" field in the mutation.
  17053. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  17054. v := m.pay_method
  17055. if v == nil {
  17056. return
  17057. }
  17058. return *v, true
  17059. }
  17060. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  17061. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17063. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  17064. if !m.op.Is(OpUpdateOne) {
  17065. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  17066. }
  17067. if m.id == nil || m.oldValue == nil {
  17068. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  17069. }
  17070. oldValue, err := m.oldValue(ctx)
  17071. if err != nil {
  17072. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  17073. }
  17074. return oldValue.PayMethod, nil
  17075. }
  17076. // AddPayMethod adds i to the "pay_method" field.
  17077. func (m *CreditUsageMutation) AddPayMethod(i int) {
  17078. if m.addpay_method != nil {
  17079. *m.addpay_method += i
  17080. } else {
  17081. m.addpay_method = &i
  17082. }
  17083. }
  17084. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  17085. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  17086. v := m.addpay_method
  17087. if v == nil {
  17088. return
  17089. }
  17090. return *v, true
  17091. }
  17092. // ClearPayMethod clears the value of the "pay_method" field.
  17093. func (m *CreditUsageMutation) ClearPayMethod() {
  17094. m.pay_method = nil
  17095. m.addpay_method = nil
  17096. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  17097. }
  17098. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  17099. func (m *CreditUsageMutation) PayMethodCleared() bool {
  17100. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  17101. return ok
  17102. }
  17103. // ResetPayMethod resets all changes to the "pay_method" field.
  17104. func (m *CreditUsageMutation) ResetPayMethod() {
  17105. m.pay_method = nil
  17106. m.addpay_method = nil
  17107. delete(m.clearedFields, creditusage.FieldPayMethod)
  17108. }
  17109. // SetStatus sets the "status" field.
  17110. func (m *CreditUsageMutation) SetStatus(i int) {
  17111. m.status = &i
  17112. m.addstatus = nil
  17113. }
  17114. // Status returns the value of the "status" field in the mutation.
  17115. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  17116. v := m.status
  17117. if v == nil {
  17118. return
  17119. }
  17120. return *v, true
  17121. }
  17122. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  17123. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17125. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  17126. if !m.op.Is(OpUpdateOne) {
  17127. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17128. }
  17129. if m.id == nil || m.oldValue == nil {
  17130. return v, errors.New("OldStatus requires an ID field in the mutation")
  17131. }
  17132. oldValue, err := m.oldValue(ctx)
  17133. if err != nil {
  17134. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17135. }
  17136. return oldValue.Status, nil
  17137. }
  17138. // AddStatus adds i to the "status" field.
  17139. func (m *CreditUsageMutation) AddStatus(i int) {
  17140. if m.addstatus != nil {
  17141. *m.addstatus += i
  17142. } else {
  17143. m.addstatus = &i
  17144. }
  17145. }
  17146. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17147. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  17148. v := m.addstatus
  17149. if v == nil {
  17150. return
  17151. }
  17152. return *v, true
  17153. }
  17154. // ClearStatus clears the value of the "status" field.
  17155. func (m *CreditUsageMutation) ClearStatus() {
  17156. m.status = nil
  17157. m.addstatus = nil
  17158. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  17159. }
  17160. // StatusCleared returns if the "status" field was cleared in this mutation.
  17161. func (m *CreditUsageMutation) StatusCleared() bool {
  17162. _, ok := m.clearedFields[creditusage.FieldStatus]
  17163. return ok
  17164. }
  17165. // ResetStatus resets all changes to the "status" field.
  17166. func (m *CreditUsageMutation) ResetStatus() {
  17167. m.status = nil
  17168. m.addstatus = nil
  17169. delete(m.clearedFields, creditusage.FieldStatus)
  17170. }
  17171. // SetNtype sets the "ntype" field.
  17172. func (m *CreditUsageMutation) SetNtype(i int) {
  17173. m.ntype = &i
  17174. m.addntype = nil
  17175. }
  17176. // Ntype returns the value of the "ntype" field in the mutation.
  17177. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  17178. v := m.ntype
  17179. if v == nil {
  17180. return
  17181. }
  17182. return *v, true
  17183. }
  17184. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  17185. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17187. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  17188. if !m.op.Is(OpUpdateOne) {
  17189. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  17190. }
  17191. if m.id == nil || m.oldValue == nil {
  17192. return v, errors.New("OldNtype requires an ID field in the mutation")
  17193. }
  17194. oldValue, err := m.oldValue(ctx)
  17195. if err != nil {
  17196. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  17197. }
  17198. return oldValue.Ntype, nil
  17199. }
  17200. // AddNtype adds i to the "ntype" field.
  17201. func (m *CreditUsageMutation) AddNtype(i int) {
  17202. if m.addntype != nil {
  17203. *m.addntype += i
  17204. } else {
  17205. m.addntype = &i
  17206. }
  17207. }
  17208. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  17209. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  17210. v := m.addntype
  17211. if v == nil {
  17212. return
  17213. }
  17214. return *v, true
  17215. }
  17216. // ResetNtype resets all changes to the "ntype" field.
  17217. func (m *CreditUsageMutation) ResetNtype() {
  17218. m.ntype = nil
  17219. m.addntype = nil
  17220. }
  17221. // SetTable sets the "table" field.
  17222. func (m *CreditUsageMutation) SetTable(s string) {
  17223. m.table = &s
  17224. }
  17225. // Table returns the value of the "table" field in the mutation.
  17226. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  17227. v := m.table
  17228. if v == nil {
  17229. return
  17230. }
  17231. return *v, true
  17232. }
  17233. // OldTable returns the old "table" field's value of the CreditUsage entity.
  17234. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17236. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  17237. if !m.op.Is(OpUpdateOne) {
  17238. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  17239. }
  17240. if m.id == nil || m.oldValue == nil {
  17241. return v, errors.New("OldTable requires an ID field in the mutation")
  17242. }
  17243. oldValue, err := m.oldValue(ctx)
  17244. if err != nil {
  17245. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  17246. }
  17247. return oldValue.Table, nil
  17248. }
  17249. // ResetTable resets all changes to the "table" field.
  17250. func (m *CreditUsageMutation) ResetTable() {
  17251. m.table = nil
  17252. }
  17253. // SetOrganizationID sets the "organization_id" field.
  17254. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  17255. m.organization_id = &u
  17256. m.addorganization_id = nil
  17257. }
  17258. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17259. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  17260. v := m.organization_id
  17261. if v == nil {
  17262. return
  17263. }
  17264. return *v, true
  17265. }
  17266. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  17267. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17269. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17270. if !m.op.Is(OpUpdateOne) {
  17271. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17272. }
  17273. if m.id == nil || m.oldValue == nil {
  17274. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17275. }
  17276. oldValue, err := m.oldValue(ctx)
  17277. if err != nil {
  17278. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17279. }
  17280. return oldValue.OrganizationID, nil
  17281. }
  17282. // AddOrganizationID adds u to the "organization_id" field.
  17283. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  17284. if m.addorganization_id != nil {
  17285. *m.addorganization_id += u
  17286. } else {
  17287. m.addorganization_id = &u
  17288. }
  17289. }
  17290. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17291. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  17292. v := m.addorganization_id
  17293. if v == nil {
  17294. return
  17295. }
  17296. return *v, true
  17297. }
  17298. // ClearOrganizationID clears the value of the "organization_id" field.
  17299. func (m *CreditUsageMutation) ClearOrganizationID() {
  17300. m.organization_id = nil
  17301. m.addorganization_id = nil
  17302. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  17303. }
  17304. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17305. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  17306. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  17307. return ok
  17308. }
  17309. // ResetOrganizationID resets all changes to the "organization_id" field.
  17310. func (m *CreditUsageMutation) ResetOrganizationID() {
  17311. m.organization_id = nil
  17312. m.addorganization_id = nil
  17313. delete(m.clearedFields, creditusage.FieldOrganizationID)
  17314. }
  17315. // SetNid sets the "nid" field.
  17316. func (m *CreditUsageMutation) SetNid(u uint64) {
  17317. m.nid = &u
  17318. m.addnid = nil
  17319. }
  17320. // Nid returns the value of the "nid" field in the mutation.
  17321. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  17322. v := m.nid
  17323. if v == nil {
  17324. return
  17325. }
  17326. return *v, true
  17327. }
  17328. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  17329. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17331. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  17332. if !m.op.Is(OpUpdateOne) {
  17333. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  17334. }
  17335. if m.id == nil || m.oldValue == nil {
  17336. return v, errors.New("OldNid requires an ID field in the mutation")
  17337. }
  17338. oldValue, err := m.oldValue(ctx)
  17339. if err != nil {
  17340. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  17341. }
  17342. return oldValue.Nid, nil
  17343. }
  17344. // AddNid adds u to the "nid" field.
  17345. func (m *CreditUsageMutation) AddNid(u int64) {
  17346. if m.addnid != nil {
  17347. *m.addnid += u
  17348. } else {
  17349. m.addnid = &u
  17350. }
  17351. }
  17352. // AddedNid returns the value that was added to the "nid" field in this mutation.
  17353. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  17354. v := m.addnid
  17355. if v == nil {
  17356. return
  17357. }
  17358. return *v, true
  17359. }
  17360. // ResetNid resets all changes to the "nid" field.
  17361. func (m *CreditUsageMutation) ResetNid() {
  17362. m.nid = nil
  17363. m.addnid = nil
  17364. }
  17365. // SetReason sets the "reason" field.
  17366. func (m *CreditUsageMutation) SetReason(s string) {
  17367. m.reason = &s
  17368. }
  17369. // Reason returns the value of the "reason" field in the mutation.
  17370. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  17371. v := m.reason
  17372. if v == nil {
  17373. return
  17374. }
  17375. return *v, true
  17376. }
  17377. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  17378. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17380. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  17381. if !m.op.Is(OpUpdateOne) {
  17382. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  17383. }
  17384. if m.id == nil || m.oldValue == nil {
  17385. return v, errors.New("OldReason requires an ID field in the mutation")
  17386. }
  17387. oldValue, err := m.oldValue(ctx)
  17388. if err != nil {
  17389. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  17390. }
  17391. return oldValue.Reason, nil
  17392. }
  17393. // ResetReason resets all changes to the "reason" field.
  17394. func (m *CreditUsageMutation) ResetReason() {
  17395. m.reason = nil
  17396. }
  17397. // SetOperator sets the "operator" field.
  17398. func (m *CreditUsageMutation) SetOperator(s string) {
  17399. m.operator = &s
  17400. }
  17401. // Operator returns the value of the "operator" field in the mutation.
  17402. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  17403. v := m.operator
  17404. if v == nil {
  17405. return
  17406. }
  17407. return *v, true
  17408. }
  17409. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  17410. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17412. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  17413. if !m.op.Is(OpUpdateOne) {
  17414. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  17415. }
  17416. if m.id == nil || m.oldValue == nil {
  17417. return v, errors.New("OldOperator requires an ID field in the mutation")
  17418. }
  17419. oldValue, err := m.oldValue(ctx)
  17420. if err != nil {
  17421. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  17422. }
  17423. return oldValue.Operator, nil
  17424. }
  17425. // ResetOperator resets all changes to the "operator" field.
  17426. func (m *CreditUsageMutation) ResetOperator() {
  17427. m.operator = nil
  17428. }
  17429. // Where appends a list predicates to the CreditUsageMutation builder.
  17430. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  17431. m.predicates = append(m.predicates, ps...)
  17432. }
  17433. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  17434. // users can use type-assertion to append predicates that do not depend on any generated package.
  17435. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  17436. p := make([]predicate.CreditUsage, len(ps))
  17437. for i := range ps {
  17438. p[i] = ps[i]
  17439. }
  17440. m.Where(p...)
  17441. }
  17442. // Op returns the operation name.
  17443. func (m *CreditUsageMutation) Op() Op {
  17444. return m.op
  17445. }
  17446. // SetOp allows setting the mutation operation.
  17447. func (m *CreditUsageMutation) SetOp(op Op) {
  17448. m.op = op
  17449. }
  17450. // Type returns the node type of this mutation (CreditUsage).
  17451. func (m *CreditUsageMutation) Type() string {
  17452. return m.typ
  17453. }
  17454. // Fields returns all fields that were changed during this mutation. Note that in
  17455. // order to get all numeric fields that were incremented/decremented, call
  17456. // AddedFields().
  17457. func (m *CreditUsageMutation) Fields() []string {
  17458. fields := make([]string, 0, 16)
  17459. if m.created_at != nil {
  17460. fields = append(fields, creditusage.FieldCreatedAt)
  17461. }
  17462. if m.updated_at != nil {
  17463. fields = append(fields, creditusage.FieldUpdatedAt)
  17464. }
  17465. if m.deleted_at != nil {
  17466. fields = append(fields, creditusage.FieldDeletedAt)
  17467. }
  17468. if m.user_id != nil {
  17469. fields = append(fields, creditusage.FieldUserID)
  17470. }
  17471. if m.number != nil {
  17472. fields = append(fields, creditusage.FieldNumber)
  17473. }
  17474. if m.pay_number != nil {
  17475. fields = append(fields, creditusage.FieldPayNumber)
  17476. }
  17477. if m.before_number != nil {
  17478. fields = append(fields, creditusage.FieldBeforeNumber)
  17479. }
  17480. if m.after_number != nil {
  17481. fields = append(fields, creditusage.FieldAfterNumber)
  17482. }
  17483. if m.pay_method != nil {
  17484. fields = append(fields, creditusage.FieldPayMethod)
  17485. }
  17486. if m.status != nil {
  17487. fields = append(fields, creditusage.FieldStatus)
  17488. }
  17489. if m.ntype != nil {
  17490. fields = append(fields, creditusage.FieldNtype)
  17491. }
  17492. if m.table != nil {
  17493. fields = append(fields, creditusage.FieldTable)
  17494. }
  17495. if m.organization_id != nil {
  17496. fields = append(fields, creditusage.FieldOrganizationID)
  17497. }
  17498. if m.nid != nil {
  17499. fields = append(fields, creditusage.FieldNid)
  17500. }
  17501. if m.reason != nil {
  17502. fields = append(fields, creditusage.FieldReason)
  17503. }
  17504. if m.operator != nil {
  17505. fields = append(fields, creditusage.FieldOperator)
  17506. }
  17507. return fields
  17508. }
  17509. // Field returns the value of a field with the given name. The second boolean
  17510. // return value indicates that this field was not set, or was not defined in the
  17511. // schema.
  17512. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  17513. switch name {
  17514. case creditusage.FieldCreatedAt:
  17515. return m.CreatedAt()
  17516. case creditusage.FieldUpdatedAt:
  17517. return m.UpdatedAt()
  17518. case creditusage.FieldDeletedAt:
  17519. return m.DeletedAt()
  17520. case creditusage.FieldUserID:
  17521. return m.UserID()
  17522. case creditusage.FieldNumber:
  17523. return m.Number()
  17524. case creditusage.FieldPayNumber:
  17525. return m.PayNumber()
  17526. case creditusage.FieldBeforeNumber:
  17527. return m.BeforeNumber()
  17528. case creditusage.FieldAfterNumber:
  17529. return m.AfterNumber()
  17530. case creditusage.FieldPayMethod:
  17531. return m.PayMethod()
  17532. case creditusage.FieldStatus:
  17533. return m.Status()
  17534. case creditusage.FieldNtype:
  17535. return m.Ntype()
  17536. case creditusage.FieldTable:
  17537. return m.Table()
  17538. case creditusage.FieldOrganizationID:
  17539. return m.OrganizationID()
  17540. case creditusage.FieldNid:
  17541. return m.Nid()
  17542. case creditusage.FieldReason:
  17543. return m.Reason()
  17544. case creditusage.FieldOperator:
  17545. return m.Operator()
  17546. }
  17547. return nil, false
  17548. }
  17549. // OldField returns the old value of the field from the database. An error is
  17550. // returned if the mutation operation is not UpdateOne, or the query to the
  17551. // database failed.
  17552. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17553. switch name {
  17554. case creditusage.FieldCreatedAt:
  17555. return m.OldCreatedAt(ctx)
  17556. case creditusage.FieldUpdatedAt:
  17557. return m.OldUpdatedAt(ctx)
  17558. case creditusage.FieldDeletedAt:
  17559. return m.OldDeletedAt(ctx)
  17560. case creditusage.FieldUserID:
  17561. return m.OldUserID(ctx)
  17562. case creditusage.FieldNumber:
  17563. return m.OldNumber(ctx)
  17564. case creditusage.FieldPayNumber:
  17565. return m.OldPayNumber(ctx)
  17566. case creditusage.FieldBeforeNumber:
  17567. return m.OldBeforeNumber(ctx)
  17568. case creditusage.FieldAfterNumber:
  17569. return m.OldAfterNumber(ctx)
  17570. case creditusage.FieldPayMethod:
  17571. return m.OldPayMethod(ctx)
  17572. case creditusage.FieldStatus:
  17573. return m.OldStatus(ctx)
  17574. case creditusage.FieldNtype:
  17575. return m.OldNtype(ctx)
  17576. case creditusage.FieldTable:
  17577. return m.OldTable(ctx)
  17578. case creditusage.FieldOrganizationID:
  17579. return m.OldOrganizationID(ctx)
  17580. case creditusage.FieldNid:
  17581. return m.OldNid(ctx)
  17582. case creditusage.FieldReason:
  17583. return m.OldReason(ctx)
  17584. case creditusage.FieldOperator:
  17585. return m.OldOperator(ctx)
  17586. }
  17587. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  17588. }
  17589. // SetField sets the value of a field with the given name. It returns an error if
  17590. // the field is not defined in the schema, or if the type mismatched the field
  17591. // type.
  17592. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  17593. switch name {
  17594. case creditusage.FieldCreatedAt:
  17595. v, ok := value.(time.Time)
  17596. if !ok {
  17597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17598. }
  17599. m.SetCreatedAt(v)
  17600. return nil
  17601. case creditusage.FieldUpdatedAt:
  17602. v, ok := value.(time.Time)
  17603. if !ok {
  17604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17605. }
  17606. m.SetUpdatedAt(v)
  17607. return nil
  17608. case creditusage.FieldDeletedAt:
  17609. v, ok := value.(time.Time)
  17610. if !ok {
  17611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17612. }
  17613. m.SetDeletedAt(v)
  17614. return nil
  17615. case creditusage.FieldUserID:
  17616. v, ok := value.(string)
  17617. if !ok {
  17618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17619. }
  17620. m.SetUserID(v)
  17621. return nil
  17622. case creditusage.FieldNumber:
  17623. v, ok := value.(float64)
  17624. if !ok {
  17625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17626. }
  17627. m.SetNumber(v)
  17628. return nil
  17629. case creditusage.FieldPayNumber:
  17630. v, ok := value.(float64)
  17631. if !ok {
  17632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17633. }
  17634. m.SetPayNumber(v)
  17635. return nil
  17636. case creditusage.FieldBeforeNumber:
  17637. v, ok := value.(float64)
  17638. if !ok {
  17639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17640. }
  17641. m.SetBeforeNumber(v)
  17642. return nil
  17643. case creditusage.FieldAfterNumber:
  17644. v, ok := value.(float64)
  17645. if !ok {
  17646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17647. }
  17648. m.SetAfterNumber(v)
  17649. return nil
  17650. case creditusage.FieldPayMethod:
  17651. v, ok := value.(int)
  17652. if !ok {
  17653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17654. }
  17655. m.SetPayMethod(v)
  17656. return nil
  17657. case creditusage.FieldStatus:
  17658. v, ok := value.(int)
  17659. if !ok {
  17660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17661. }
  17662. m.SetStatus(v)
  17663. return nil
  17664. case creditusage.FieldNtype:
  17665. v, ok := value.(int)
  17666. if !ok {
  17667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17668. }
  17669. m.SetNtype(v)
  17670. return nil
  17671. case creditusage.FieldTable:
  17672. v, ok := value.(string)
  17673. if !ok {
  17674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17675. }
  17676. m.SetTable(v)
  17677. return nil
  17678. case creditusage.FieldOrganizationID:
  17679. v, ok := value.(uint64)
  17680. if !ok {
  17681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17682. }
  17683. m.SetOrganizationID(v)
  17684. return nil
  17685. case creditusage.FieldNid:
  17686. v, ok := value.(uint64)
  17687. if !ok {
  17688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17689. }
  17690. m.SetNid(v)
  17691. return nil
  17692. case creditusage.FieldReason:
  17693. v, ok := value.(string)
  17694. if !ok {
  17695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17696. }
  17697. m.SetReason(v)
  17698. return nil
  17699. case creditusage.FieldOperator:
  17700. v, ok := value.(string)
  17701. if !ok {
  17702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17703. }
  17704. m.SetOperator(v)
  17705. return nil
  17706. }
  17707. return fmt.Errorf("unknown CreditUsage field %s", name)
  17708. }
  17709. // AddedFields returns all numeric fields that were incremented/decremented during
  17710. // this mutation.
  17711. func (m *CreditUsageMutation) AddedFields() []string {
  17712. var fields []string
  17713. if m.addnumber != nil {
  17714. fields = append(fields, creditusage.FieldNumber)
  17715. }
  17716. if m.addpay_number != nil {
  17717. fields = append(fields, creditusage.FieldPayNumber)
  17718. }
  17719. if m.addbefore_number != nil {
  17720. fields = append(fields, creditusage.FieldBeforeNumber)
  17721. }
  17722. if m.addafter_number != nil {
  17723. fields = append(fields, creditusage.FieldAfterNumber)
  17724. }
  17725. if m.addpay_method != nil {
  17726. fields = append(fields, creditusage.FieldPayMethod)
  17727. }
  17728. if m.addstatus != nil {
  17729. fields = append(fields, creditusage.FieldStatus)
  17730. }
  17731. if m.addntype != nil {
  17732. fields = append(fields, creditusage.FieldNtype)
  17733. }
  17734. if m.addorganization_id != nil {
  17735. fields = append(fields, creditusage.FieldOrganizationID)
  17736. }
  17737. if m.addnid != nil {
  17738. fields = append(fields, creditusage.FieldNid)
  17739. }
  17740. return fields
  17741. }
  17742. // AddedField returns the numeric value that was incremented/decremented on a field
  17743. // with the given name. The second boolean return value indicates that this field
  17744. // was not set, or was not defined in the schema.
  17745. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  17746. switch name {
  17747. case creditusage.FieldNumber:
  17748. return m.AddedNumber()
  17749. case creditusage.FieldPayNumber:
  17750. return m.AddedPayNumber()
  17751. case creditusage.FieldBeforeNumber:
  17752. return m.AddedBeforeNumber()
  17753. case creditusage.FieldAfterNumber:
  17754. return m.AddedAfterNumber()
  17755. case creditusage.FieldPayMethod:
  17756. return m.AddedPayMethod()
  17757. case creditusage.FieldStatus:
  17758. return m.AddedStatus()
  17759. case creditusage.FieldNtype:
  17760. return m.AddedNtype()
  17761. case creditusage.FieldOrganizationID:
  17762. return m.AddedOrganizationID()
  17763. case creditusage.FieldNid:
  17764. return m.AddedNid()
  17765. }
  17766. return nil, false
  17767. }
  17768. // AddField adds the value to the field with the given name. It returns an error if
  17769. // the field is not defined in the schema, or if the type mismatched the field
  17770. // type.
  17771. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  17772. switch name {
  17773. case creditusage.FieldNumber:
  17774. v, ok := value.(float64)
  17775. if !ok {
  17776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17777. }
  17778. m.AddNumber(v)
  17779. return nil
  17780. case creditusage.FieldPayNumber:
  17781. v, ok := value.(float64)
  17782. if !ok {
  17783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17784. }
  17785. m.AddPayNumber(v)
  17786. return nil
  17787. case creditusage.FieldBeforeNumber:
  17788. v, ok := value.(float64)
  17789. if !ok {
  17790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17791. }
  17792. m.AddBeforeNumber(v)
  17793. return nil
  17794. case creditusage.FieldAfterNumber:
  17795. v, ok := value.(float64)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.AddAfterNumber(v)
  17800. return nil
  17801. case creditusage.FieldPayMethod:
  17802. v, ok := value.(int)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.AddPayMethod(v)
  17807. return nil
  17808. case creditusage.FieldStatus:
  17809. v, ok := value.(int)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.AddStatus(v)
  17814. return nil
  17815. case creditusage.FieldNtype:
  17816. v, ok := value.(int)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.AddNtype(v)
  17821. return nil
  17822. case creditusage.FieldOrganizationID:
  17823. v, ok := value.(int64)
  17824. if !ok {
  17825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17826. }
  17827. m.AddOrganizationID(v)
  17828. return nil
  17829. case creditusage.FieldNid:
  17830. v, ok := value.(int64)
  17831. if !ok {
  17832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17833. }
  17834. m.AddNid(v)
  17835. return nil
  17836. }
  17837. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  17838. }
  17839. // ClearedFields returns all nullable fields that were cleared during this
  17840. // mutation.
  17841. func (m *CreditUsageMutation) ClearedFields() []string {
  17842. var fields []string
  17843. if m.FieldCleared(creditusage.FieldDeletedAt) {
  17844. fields = append(fields, creditusage.FieldDeletedAt)
  17845. }
  17846. if m.FieldCleared(creditusage.FieldUserID) {
  17847. fields = append(fields, creditusage.FieldUserID)
  17848. }
  17849. if m.FieldCleared(creditusage.FieldPayNumber) {
  17850. fields = append(fields, creditusage.FieldPayNumber)
  17851. }
  17852. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  17853. fields = append(fields, creditusage.FieldBeforeNumber)
  17854. }
  17855. if m.FieldCleared(creditusage.FieldAfterNumber) {
  17856. fields = append(fields, creditusage.FieldAfterNumber)
  17857. }
  17858. if m.FieldCleared(creditusage.FieldPayMethod) {
  17859. fields = append(fields, creditusage.FieldPayMethod)
  17860. }
  17861. if m.FieldCleared(creditusage.FieldStatus) {
  17862. fields = append(fields, creditusage.FieldStatus)
  17863. }
  17864. if m.FieldCleared(creditusage.FieldOrganizationID) {
  17865. fields = append(fields, creditusage.FieldOrganizationID)
  17866. }
  17867. return fields
  17868. }
  17869. // FieldCleared returns a boolean indicating if a field with the given name was
  17870. // cleared in this mutation.
  17871. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  17872. _, ok := m.clearedFields[name]
  17873. return ok
  17874. }
  17875. // ClearField clears the value of the field with the given name. It returns an
  17876. // error if the field is not defined in the schema.
  17877. func (m *CreditUsageMutation) ClearField(name string) error {
  17878. switch name {
  17879. case creditusage.FieldDeletedAt:
  17880. m.ClearDeletedAt()
  17881. return nil
  17882. case creditusage.FieldUserID:
  17883. m.ClearUserID()
  17884. return nil
  17885. case creditusage.FieldPayNumber:
  17886. m.ClearPayNumber()
  17887. return nil
  17888. case creditusage.FieldBeforeNumber:
  17889. m.ClearBeforeNumber()
  17890. return nil
  17891. case creditusage.FieldAfterNumber:
  17892. m.ClearAfterNumber()
  17893. return nil
  17894. case creditusage.FieldPayMethod:
  17895. m.ClearPayMethod()
  17896. return nil
  17897. case creditusage.FieldStatus:
  17898. m.ClearStatus()
  17899. return nil
  17900. case creditusage.FieldOrganizationID:
  17901. m.ClearOrganizationID()
  17902. return nil
  17903. }
  17904. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  17905. }
  17906. // ResetField resets all changes in the mutation for the field with the given name.
  17907. // It returns an error if the field is not defined in the schema.
  17908. func (m *CreditUsageMutation) ResetField(name string) error {
  17909. switch name {
  17910. case creditusage.FieldCreatedAt:
  17911. m.ResetCreatedAt()
  17912. return nil
  17913. case creditusage.FieldUpdatedAt:
  17914. m.ResetUpdatedAt()
  17915. return nil
  17916. case creditusage.FieldDeletedAt:
  17917. m.ResetDeletedAt()
  17918. return nil
  17919. case creditusage.FieldUserID:
  17920. m.ResetUserID()
  17921. return nil
  17922. case creditusage.FieldNumber:
  17923. m.ResetNumber()
  17924. return nil
  17925. case creditusage.FieldPayNumber:
  17926. m.ResetPayNumber()
  17927. return nil
  17928. case creditusage.FieldBeforeNumber:
  17929. m.ResetBeforeNumber()
  17930. return nil
  17931. case creditusage.FieldAfterNumber:
  17932. m.ResetAfterNumber()
  17933. return nil
  17934. case creditusage.FieldPayMethod:
  17935. m.ResetPayMethod()
  17936. return nil
  17937. case creditusage.FieldStatus:
  17938. m.ResetStatus()
  17939. return nil
  17940. case creditusage.FieldNtype:
  17941. m.ResetNtype()
  17942. return nil
  17943. case creditusage.FieldTable:
  17944. m.ResetTable()
  17945. return nil
  17946. case creditusage.FieldOrganizationID:
  17947. m.ResetOrganizationID()
  17948. return nil
  17949. case creditusage.FieldNid:
  17950. m.ResetNid()
  17951. return nil
  17952. case creditusage.FieldReason:
  17953. m.ResetReason()
  17954. return nil
  17955. case creditusage.FieldOperator:
  17956. m.ResetOperator()
  17957. return nil
  17958. }
  17959. return fmt.Errorf("unknown CreditUsage field %s", name)
  17960. }
  17961. // AddedEdges returns all edge names that were set/added in this mutation.
  17962. func (m *CreditUsageMutation) AddedEdges() []string {
  17963. edges := make([]string, 0, 0)
  17964. return edges
  17965. }
  17966. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17967. // name in this mutation.
  17968. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  17969. return nil
  17970. }
  17971. // RemovedEdges returns all edge names that were removed in this mutation.
  17972. func (m *CreditUsageMutation) RemovedEdges() []string {
  17973. edges := make([]string, 0, 0)
  17974. return edges
  17975. }
  17976. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17977. // the given name in this mutation.
  17978. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  17979. return nil
  17980. }
  17981. // ClearedEdges returns all edge names that were cleared in this mutation.
  17982. func (m *CreditUsageMutation) ClearedEdges() []string {
  17983. edges := make([]string, 0, 0)
  17984. return edges
  17985. }
  17986. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17987. // was cleared in this mutation.
  17988. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  17989. return false
  17990. }
  17991. // ClearEdge clears the value of the edge with the given name. It returns an error
  17992. // if that edge is not defined in the schema.
  17993. func (m *CreditUsageMutation) ClearEdge(name string) error {
  17994. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  17995. }
  17996. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17997. // It returns an error if the edge is not defined in the schema.
  17998. func (m *CreditUsageMutation) ResetEdge(name string) error {
  17999. return fmt.Errorf("unknown CreditUsage edge %s", name)
  18000. }
  18001. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  18002. type EmployeeMutation struct {
  18003. config
  18004. op Op
  18005. typ string
  18006. id *uint64
  18007. created_at *time.Time
  18008. updated_at *time.Time
  18009. deleted_at *time.Time
  18010. title *string
  18011. avatar *string
  18012. tags *string
  18013. hire_count *int
  18014. addhire_count *int
  18015. service_count *int
  18016. addservice_count *int
  18017. achievement_count *int
  18018. addachievement_count *int
  18019. intro *string
  18020. estimate *string
  18021. skill *string
  18022. ability_type *string
  18023. scene *string
  18024. switch_in *string
  18025. video_url *string
  18026. organization_id *uint64
  18027. addorganization_id *int64
  18028. category_id *uint64
  18029. addcategory_id *int64
  18030. api_base *string
  18031. api_key *string
  18032. ai_info *string
  18033. is_vip *int
  18034. addis_vip *int
  18035. chat_url *string
  18036. clearedFields map[string]struct{}
  18037. em_work_experiences map[uint64]struct{}
  18038. removedem_work_experiences map[uint64]struct{}
  18039. clearedem_work_experiences bool
  18040. em_tutorial map[uint64]struct{}
  18041. removedem_tutorial map[uint64]struct{}
  18042. clearedem_tutorial bool
  18043. done bool
  18044. oldValue func(context.Context) (*Employee, error)
  18045. predicates []predicate.Employee
  18046. }
  18047. var _ ent.Mutation = (*EmployeeMutation)(nil)
  18048. // employeeOption allows management of the mutation configuration using functional options.
  18049. type employeeOption func(*EmployeeMutation)
  18050. // newEmployeeMutation creates new mutation for the Employee entity.
  18051. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  18052. m := &EmployeeMutation{
  18053. config: c,
  18054. op: op,
  18055. typ: TypeEmployee,
  18056. clearedFields: make(map[string]struct{}),
  18057. }
  18058. for _, opt := range opts {
  18059. opt(m)
  18060. }
  18061. return m
  18062. }
  18063. // withEmployeeID sets the ID field of the mutation.
  18064. func withEmployeeID(id uint64) employeeOption {
  18065. return func(m *EmployeeMutation) {
  18066. var (
  18067. err error
  18068. once sync.Once
  18069. value *Employee
  18070. )
  18071. m.oldValue = func(ctx context.Context) (*Employee, error) {
  18072. once.Do(func() {
  18073. if m.done {
  18074. err = errors.New("querying old values post mutation is not allowed")
  18075. } else {
  18076. value, err = m.Client().Employee.Get(ctx, id)
  18077. }
  18078. })
  18079. return value, err
  18080. }
  18081. m.id = &id
  18082. }
  18083. }
  18084. // withEmployee sets the old Employee of the mutation.
  18085. func withEmployee(node *Employee) employeeOption {
  18086. return func(m *EmployeeMutation) {
  18087. m.oldValue = func(context.Context) (*Employee, error) {
  18088. return node, nil
  18089. }
  18090. m.id = &node.ID
  18091. }
  18092. }
  18093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18094. // executed in a transaction (ent.Tx), a transactional client is returned.
  18095. func (m EmployeeMutation) Client() *Client {
  18096. client := &Client{config: m.config}
  18097. client.init()
  18098. return client
  18099. }
  18100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18101. // it returns an error otherwise.
  18102. func (m EmployeeMutation) Tx() (*Tx, error) {
  18103. if _, ok := m.driver.(*txDriver); !ok {
  18104. return nil, errors.New("ent: mutation is not running in a transaction")
  18105. }
  18106. tx := &Tx{config: m.config}
  18107. tx.init()
  18108. return tx, nil
  18109. }
  18110. // SetID sets the value of the id field. Note that this
  18111. // operation is only accepted on creation of Employee entities.
  18112. func (m *EmployeeMutation) SetID(id uint64) {
  18113. m.id = &id
  18114. }
  18115. // ID returns the ID value in the mutation. Note that the ID is only available
  18116. // if it was provided to the builder or after it was returned from the database.
  18117. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  18118. if m.id == nil {
  18119. return
  18120. }
  18121. return *m.id, true
  18122. }
  18123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18124. // That means, if the mutation is applied within a transaction with an isolation level such
  18125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18126. // or updated by the mutation.
  18127. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  18128. switch {
  18129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18130. id, exists := m.ID()
  18131. if exists {
  18132. return []uint64{id}, nil
  18133. }
  18134. fallthrough
  18135. case m.op.Is(OpUpdate | OpDelete):
  18136. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  18137. default:
  18138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18139. }
  18140. }
  18141. // SetCreatedAt sets the "created_at" field.
  18142. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  18143. m.created_at = &t
  18144. }
  18145. // CreatedAt returns the value of the "created_at" field in the mutation.
  18146. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  18147. v := m.created_at
  18148. if v == nil {
  18149. return
  18150. }
  18151. return *v, true
  18152. }
  18153. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  18154. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18156. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18157. if !m.op.Is(OpUpdateOne) {
  18158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18159. }
  18160. if m.id == nil || m.oldValue == nil {
  18161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18162. }
  18163. oldValue, err := m.oldValue(ctx)
  18164. if err != nil {
  18165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18166. }
  18167. return oldValue.CreatedAt, nil
  18168. }
  18169. // ResetCreatedAt resets all changes to the "created_at" field.
  18170. func (m *EmployeeMutation) ResetCreatedAt() {
  18171. m.created_at = nil
  18172. }
  18173. // SetUpdatedAt sets the "updated_at" field.
  18174. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  18175. m.updated_at = &t
  18176. }
  18177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18178. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  18179. v := m.updated_at
  18180. if v == nil {
  18181. return
  18182. }
  18183. return *v, true
  18184. }
  18185. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  18186. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18188. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18189. if !m.op.Is(OpUpdateOne) {
  18190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18191. }
  18192. if m.id == nil || m.oldValue == nil {
  18193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18194. }
  18195. oldValue, err := m.oldValue(ctx)
  18196. if err != nil {
  18197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18198. }
  18199. return oldValue.UpdatedAt, nil
  18200. }
  18201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18202. func (m *EmployeeMutation) ResetUpdatedAt() {
  18203. m.updated_at = nil
  18204. }
  18205. // SetDeletedAt sets the "deleted_at" field.
  18206. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  18207. m.deleted_at = &t
  18208. }
  18209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18210. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  18211. v := m.deleted_at
  18212. if v == nil {
  18213. return
  18214. }
  18215. return *v, true
  18216. }
  18217. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  18218. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18220. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18221. if !m.op.Is(OpUpdateOne) {
  18222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18223. }
  18224. if m.id == nil || m.oldValue == nil {
  18225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18226. }
  18227. oldValue, err := m.oldValue(ctx)
  18228. if err != nil {
  18229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18230. }
  18231. return oldValue.DeletedAt, nil
  18232. }
  18233. // ClearDeletedAt clears the value of the "deleted_at" field.
  18234. func (m *EmployeeMutation) ClearDeletedAt() {
  18235. m.deleted_at = nil
  18236. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  18237. }
  18238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18239. func (m *EmployeeMutation) DeletedAtCleared() bool {
  18240. _, ok := m.clearedFields[employee.FieldDeletedAt]
  18241. return ok
  18242. }
  18243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18244. func (m *EmployeeMutation) ResetDeletedAt() {
  18245. m.deleted_at = nil
  18246. delete(m.clearedFields, employee.FieldDeletedAt)
  18247. }
  18248. // SetTitle sets the "title" field.
  18249. func (m *EmployeeMutation) SetTitle(s string) {
  18250. m.title = &s
  18251. }
  18252. // Title returns the value of the "title" field in the mutation.
  18253. func (m *EmployeeMutation) Title() (r string, exists bool) {
  18254. v := m.title
  18255. if v == nil {
  18256. return
  18257. }
  18258. return *v, true
  18259. }
  18260. // OldTitle returns the old "title" field's value of the Employee entity.
  18261. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18263. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  18264. if !m.op.Is(OpUpdateOne) {
  18265. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18266. }
  18267. if m.id == nil || m.oldValue == nil {
  18268. return v, errors.New("OldTitle requires an ID field in the mutation")
  18269. }
  18270. oldValue, err := m.oldValue(ctx)
  18271. if err != nil {
  18272. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18273. }
  18274. return oldValue.Title, nil
  18275. }
  18276. // ResetTitle resets all changes to the "title" field.
  18277. func (m *EmployeeMutation) ResetTitle() {
  18278. m.title = nil
  18279. }
  18280. // SetAvatar sets the "avatar" field.
  18281. func (m *EmployeeMutation) SetAvatar(s string) {
  18282. m.avatar = &s
  18283. }
  18284. // Avatar returns the value of the "avatar" field in the mutation.
  18285. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  18286. v := m.avatar
  18287. if v == nil {
  18288. return
  18289. }
  18290. return *v, true
  18291. }
  18292. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  18293. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18295. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  18296. if !m.op.Is(OpUpdateOne) {
  18297. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  18298. }
  18299. if m.id == nil || m.oldValue == nil {
  18300. return v, errors.New("OldAvatar requires an ID field in the mutation")
  18301. }
  18302. oldValue, err := m.oldValue(ctx)
  18303. if err != nil {
  18304. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  18305. }
  18306. return oldValue.Avatar, nil
  18307. }
  18308. // ResetAvatar resets all changes to the "avatar" field.
  18309. func (m *EmployeeMutation) ResetAvatar() {
  18310. m.avatar = nil
  18311. }
  18312. // SetTags sets the "tags" field.
  18313. func (m *EmployeeMutation) SetTags(s string) {
  18314. m.tags = &s
  18315. }
  18316. // Tags returns the value of the "tags" field in the mutation.
  18317. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  18318. v := m.tags
  18319. if v == nil {
  18320. return
  18321. }
  18322. return *v, true
  18323. }
  18324. // OldTags returns the old "tags" field's value of the Employee entity.
  18325. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18327. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  18328. if !m.op.Is(OpUpdateOne) {
  18329. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  18330. }
  18331. if m.id == nil || m.oldValue == nil {
  18332. return v, errors.New("OldTags requires an ID field in the mutation")
  18333. }
  18334. oldValue, err := m.oldValue(ctx)
  18335. if err != nil {
  18336. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  18337. }
  18338. return oldValue.Tags, nil
  18339. }
  18340. // ResetTags resets all changes to the "tags" field.
  18341. func (m *EmployeeMutation) ResetTags() {
  18342. m.tags = nil
  18343. }
  18344. // SetHireCount sets the "hire_count" field.
  18345. func (m *EmployeeMutation) SetHireCount(i int) {
  18346. m.hire_count = &i
  18347. m.addhire_count = nil
  18348. }
  18349. // HireCount returns the value of the "hire_count" field in the mutation.
  18350. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  18351. v := m.hire_count
  18352. if v == nil {
  18353. return
  18354. }
  18355. return *v, true
  18356. }
  18357. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  18358. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18360. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  18361. if !m.op.Is(OpUpdateOne) {
  18362. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  18363. }
  18364. if m.id == nil || m.oldValue == nil {
  18365. return v, errors.New("OldHireCount requires an ID field in the mutation")
  18366. }
  18367. oldValue, err := m.oldValue(ctx)
  18368. if err != nil {
  18369. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  18370. }
  18371. return oldValue.HireCount, nil
  18372. }
  18373. // AddHireCount adds i to the "hire_count" field.
  18374. func (m *EmployeeMutation) AddHireCount(i int) {
  18375. if m.addhire_count != nil {
  18376. *m.addhire_count += i
  18377. } else {
  18378. m.addhire_count = &i
  18379. }
  18380. }
  18381. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  18382. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  18383. v := m.addhire_count
  18384. if v == nil {
  18385. return
  18386. }
  18387. return *v, true
  18388. }
  18389. // ResetHireCount resets all changes to the "hire_count" field.
  18390. func (m *EmployeeMutation) ResetHireCount() {
  18391. m.hire_count = nil
  18392. m.addhire_count = nil
  18393. }
  18394. // SetServiceCount sets the "service_count" field.
  18395. func (m *EmployeeMutation) SetServiceCount(i int) {
  18396. m.service_count = &i
  18397. m.addservice_count = nil
  18398. }
  18399. // ServiceCount returns the value of the "service_count" field in the mutation.
  18400. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  18401. v := m.service_count
  18402. if v == nil {
  18403. return
  18404. }
  18405. return *v, true
  18406. }
  18407. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  18408. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18410. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  18411. if !m.op.Is(OpUpdateOne) {
  18412. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  18413. }
  18414. if m.id == nil || m.oldValue == nil {
  18415. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  18416. }
  18417. oldValue, err := m.oldValue(ctx)
  18418. if err != nil {
  18419. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  18420. }
  18421. return oldValue.ServiceCount, nil
  18422. }
  18423. // AddServiceCount adds i to the "service_count" field.
  18424. func (m *EmployeeMutation) AddServiceCount(i int) {
  18425. if m.addservice_count != nil {
  18426. *m.addservice_count += i
  18427. } else {
  18428. m.addservice_count = &i
  18429. }
  18430. }
  18431. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  18432. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  18433. v := m.addservice_count
  18434. if v == nil {
  18435. return
  18436. }
  18437. return *v, true
  18438. }
  18439. // ResetServiceCount resets all changes to the "service_count" field.
  18440. func (m *EmployeeMutation) ResetServiceCount() {
  18441. m.service_count = nil
  18442. m.addservice_count = nil
  18443. }
  18444. // SetAchievementCount sets the "achievement_count" field.
  18445. func (m *EmployeeMutation) SetAchievementCount(i int) {
  18446. m.achievement_count = &i
  18447. m.addachievement_count = nil
  18448. }
  18449. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  18450. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  18451. v := m.achievement_count
  18452. if v == nil {
  18453. return
  18454. }
  18455. return *v, true
  18456. }
  18457. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  18458. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18460. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  18461. if !m.op.Is(OpUpdateOne) {
  18462. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  18463. }
  18464. if m.id == nil || m.oldValue == nil {
  18465. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  18466. }
  18467. oldValue, err := m.oldValue(ctx)
  18468. if err != nil {
  18469. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  18470. }
  18471. return oldValue.AchievementCount, nil
  18472. }
  18473. // AddAchievementCount adds i to the "achievement_count" field.
  18474. func (m *EmployeeMutation) AddAchievementCount(i int) {
  18475. if m.addachievement_count != nil {
  18476. *m.addachievement_count += i
  18477. } else {
  18478. m.addachievement_count = &i
  18479. }
  18480. }
  18481. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  18482. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  18483. v := m.addachievement_count
  18484. if v == nil {
  18485. return
  18486. }
  18487. return *v, true
  18488. }
  18489. // ResetAchievementCount resets all changes to the "achievement_count" field.
  18490. func (m *EmployeeMutation) ResetAchievementCount() {
  18491. m.achievement_count = nil
  18492. m.addachievement_count = nil
  18493. }
  18494. // SetIntro sets the "intro" field.
  18495. func (m *EmployeeMutation) SetIntro(s string) {
  18496. m.intro = &s
  18497. }
  18498. // Intro returns the value of the "intro" field in the mutation.
  18499. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  18500. v := m.intro
  18501. if v == nil {
  18502. return
  18503. }
  18504. return *v, true
  18505. }
  18506. // OldIntro returns the old "intro" field's value of the Employee entity.
  18507. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18509. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  18510. if !m.op.Is(OpUpdateOne) {
  18511. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  18512. }
  18513. if m.id == nil || m.oldValue == nil {
  18514. return v, errors.New("OldIntro requires an ID field in the mutation")
  18515. }
  18516. oldValue, err := m.oldValue(ctx)
  18517. if err != nil {
  18518. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  18519. }
  18520. return oldValue.Intro, nil
  18521. }
  18522. // ResetIntro resets all changes to the "intro" field.
  18523. func (m *EmployeeMutation) ResetIntro() {
  18524. m.intro = nil
  18525. }
  18526. // SetEstimate sets the "estimate" field.
  18527. func (m *EmployeeMutation) SetEstimate(s string) {
  18528. m.estimate = &s
  18529. }
  18530. // Estimate returns the value of the "estimate" field in the mutation.
  18531. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  18532. v := m.estimate
  18533. if v == nil {
  18534. return
  18535. }
  18536. return *v, true
  18537. }
  18538. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  18539. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18541. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  18542. if !m.op.Is(OpUpdateOne) {
  18543. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  18544. }
  18545. if m.id == nil || m.oldValue == nil {
  18546. return v, errors.New("OldEstimate requires an ID field in the mutation")
  18547. }
  18548. oldValue, err := m.oldValue(ctx)
  18549. if err != nil {
  18550. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  18551. }
  18552. return oldValue.Estimate, nil
  18553. }
  18554. // ResetEstimate resets all changes to the "estimate" field.
  18555. func (m *EmployeeMutation) ResetEstimate() {
  18556. m.estimate = nil
  18557. }
  18558. // SetSkill sets the "skill" field.
  18559. func (m *EmployeeMutation) SetSkill(s string) {
  18560. m.skill = &s
  18561. }
  18562. // Skill returns the value of the "skill" field in the mutation.
  18563. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  18564. v := m.skill
  18565. if v == nil {
  18566. return
  18567. }
  18568. return *v, true
  18569. }
  18570. // OldSkill returns the old "skill" field's value of the Employee entity.
  18571. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18573. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  18574. if !m.op.Is(OpUpdateOne) {
  18575. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  18576. }
  18577. if m.id == nil || m.oldValue == nil {
  18578. return v, errors.New("OldSkill requires an ID field in the mutation")
  18579. }
  18580. oldValue, err := m.oldValue(ctx)
  18581. if err != nil {
  18582. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  18583. }
  18584. return oldValue.Skill, nil
  18585. }
  18586. // ResetSkill resets all changes to the "skill" field.
  18587. func (m *EmployeeMutation) ResetSkill() {
  18588. m.skill = nil
  18589. }
  18590. // SetAbilityType sets the "ability_type" field.
  18591. func (m *EmployeeMutation) SetAbilityType(s string) {
  18592. m.ability_type = &s
  18593. }
  18594. // AbilityType returns the value of the "ability_type" field in the mutation.
  18595. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  18596. v := m.ability_type
  18597. if v == nil {
  18598. return
  18599. }
  18600. return *v, true
  18601. }
  18602. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  18603. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18605. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  18606. if !m.op.Is(OpUpdateOne) {
  18607. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  18608. }
  18609. if m.id == nil || m.oldValue == nil {
  18610. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  18611. }
  18612. oldValue, err := m.oldValue(ctx)
  18613. if err != nil {
  18614. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  18615. }
  18616. return oldValue.AbilityType, nil
  18617. }
  18618. // ResetAbilityType resets all changes to the "ability_type" field.
  18619. func (m *EmployeeMutation) ResetAbilityType() {
  18620. m.ability_type = nil
  18621. }
  18622. // SetScene sets the "scene" field.
  18623. func (m *EmployeeMutation) SetScene(s string) {
  18624. m.scene = &s
  18625. }
  18626. // Scene returns the value of the "scene" field in the mutation.
  18627. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  18628. v := m.scene
  18629. if v == nil {
  18630. return
  18631. }
  18632. return *v, true
  18633. }
  18634. // OldScene returns the old "scene" field's value of the Employee entity.
  18635. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18637. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  18638. if !m.op.Is(OpUpdateOne) {
  18639. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  18640. }
  18641. if m.id == nil || m.oldValue == nil {
  18642. return v, errors.New("OldScene requires an ID field in the mutation")
  18643. }
  18644. oldValue, err := m.oldValue(ctx)
  18645. if err != nil {
  18646. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  18647. }
  18648. return oldValue.Scene, nil
  18649. }
  18650. // ResetScene resets all changes to the "scene" field.
  18651. func (m *EmployeeMutation) ResetScene() {
  18652. m.scene = nil
  18653. }
  18654. // SetSwitchIn sets the "switch_in" field.
  18655. func (m *EmployeeMutation) SetSwitchIn(s string) {
  18656. m.switch_in = &s
  18657. }
  18658. // SwitchIn returns the value of the "switch_in" field in the mutation.
  18659. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  18660. v := m.switch_in
  18661. if v == nil {
  18662. return
  18663. }
  18664. return *v, true
  18665. }
  18666. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  18667. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18669. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  18670. if !m.op.Is(OpUpdateOne) {
  18671. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  18672. }
  18673. if m.id == nil || m.oldValue == nil {
  18674. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  18675. }
  18676. oldValue, err := m.oldValue(ctx)
  18677. if err != nil {
  18678. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  18679. }
  18680. return oldValue.SwitchIn, nil
  18681. }
  18682. // ResetSwitchIn resets all changes to the "switch_in" field.
  18683. func (m *EmployeeMutation) ResetSwitchIn() {
  18684. m.switch_in = nil
  18685. }
  18686. // SetVideoURL sets the "video_url" field.
  18687. func (m *EmployeeMutation) SetVideoURL(s string) {
  18688. m.video_url = &s
  18689. }
  18690. // VideoURL returns the value of the "video_url" field in the mutation.
  18691. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  18692. v := m.video_url
  18693. if v == nil {
  18694. return
  18695. }
  18696. return *v, true
  18697. }
  18698. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  18699. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18701. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  18702. if !m.op.Is(OpUpdateOne) {
  18703. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  18704. }
  18705. if m.id == nil || m.oldValue == nil {
  18706. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  18707. }
  18708. oldValue, err := m.oldValue(ctx)
  18709. if err != nil {
  18710. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  18711. }
  18712. return oldValue.VideoURL, nil
  18713. }
  18714. // ResetVideoURL resets all changes to the "video_url" field.
  18715. func (m *EmployeeMutation) ResetVideoURL() {
  18716. m.video_url = nil
  18717. }
  18718. // SetOrganizationID sets the "organization_id" field.
  18719. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  18720. m.organization_id = &u
  18721. m.addorganization_id = nil
  18722. }
  18723. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18724. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  18725. v := m.organization_id
  18726. if v == nil {
  18727. return
  18728. }
  18729. return *v, true
  18730. }
  18731. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  18732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18734. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18735. if !m.op.Is(OpUpdateOne) {
  18736. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18737. }
  18738. if m.id == nil || m.oldValue == nil {
  18739. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18740. }
  18741. oldValue, err := m.oldValue(ctx)
  18742. if err != nil {
  18743. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18744. }
  18745. return oldValue.OrganizationID, nil
  18746. }
  18747. // AddOrganizationID adds u to the "organization_id" field.
  18748. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  18749. if m.addorganization_id != nil {
  18750. *m.addorganization_id += u
  18751. } else {
  18752. m.addorganization_id = &u
  18753. }
  18754. }
  18755. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18756. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  18757. v := m.addorganization_id
  18758. if v == nil {
  18759. return
  18760. }
  18761. return *v, true
  18762. }
  18763. // ResetOrganizationID resets all changes to the "organization_id" field.
  18764. func (m *EmployeeMutation) ResetOrganizationID() {
  18765. m.organization_id = nil
  18766. m.addorganization_id = nil
  18767. }
  18768. // SetCategoryID sets the "category_id" field.
  18769. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  18770. m.category_id = &u
  18771. m.addcategory_id = nil
  18772. }
  18773. // CategoryID returns the value of the "category_id" field in the mutation.
  18774. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  18775. v := m.category_id
  18776. if v == nil {
  18777. return
  18778. }
  18779. return *v, true
  18780. }
  18781. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  18782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18784. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  18785. if !m.op.Is(OpUpdateOne) {
  18786. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  18787. }
  18788. if m.id == nil || m.oldValue == nil {
  18789. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  18790. }
  18791. oldValue, err := m.oldValue(ctx)
  18792. if err != nil {
  18793. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  18794. }
  18795. return oldValue.CategoryID, nil
  18796. }
  18797. // AddCategoryID adds u to the "category_id" field.
  18798. func (m *EmployeeMutation) AddCategoryID(u int64) {
  18799. if m.addcategory_id != nil {
  18800. *m.addcategory_id += u
  18801. } else {
  18802. m.addcategory_id = &u
  18803. }
  18804. }
  18805. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  18806. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  18807. v := m.addcategory_id
  18808. if v == nil {
  18809. return
  18810. }
  18811. return *v, true
  18812. }
  18813. // ResetCategoryID resets all changes to the "category_id" field.
  18814. func (m *EmployeeMutation) ResetCategoryID() {
  18815. m.category_id = nil
  18816. m.addcategory_id = nil
  18817. }
  18818. // SetAPIBase sets the "api_base" field.
  18819. func (m *EmployeeMutation) SetAPIBase(s string) {
  18820. m.api_base = &s
  18821. }
  18822. // APIBase returns the value of the "api_base" field in the mutation.
  18823. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  18824. v := m.api_base
  18825. if v == nil {
  18826. return
  18827. }
  18828. return *v, true
  18829. }
  18830. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  18831. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18833. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18834. if !m.op.Is(OpUpdateOne) {
  18835. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18836. }
  18837. if m.id == nil || m.oldValue == nil {
  18838. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18839. }
  18840. oldValue, err := m.oldValue(ctx)
  18841. if err != nil {
  18842. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18843. }
  18844. return oldValue.APIBase, nil
  18845. }
  18846. // ResetAPIBase resets all changes to the "api_base" field.
  18847. func (m *EmployeeMutation) ResetAPIBase() {
  18848. m.api_base = nil
  18849. }
  18850. // SetAPIKey sets the "api_key" field.
  18851. func (m *EmployeeMutation) SetAPIKey(s string) {
  18852. m.api_key = &s
  18853. }
  18854. // APIKey returns the value of the "api_key" field in the mutation.
  18855. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  18856. v := m.api_key
  18857. if v == nil {
  18858. return
  18859. }
  18860. return *v, true
  18861. }
  18862. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  18863. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18865. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18866. if !m.op.Is(OpUpdateOne) {
  18867. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18868. }
  18869. if m.id == nil || m.oldValue == nil {
  18870. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18871. }
  18872. oldValue, err := m.oldValue(ctx)
  18873. if err != nil {
  18874. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  18875. }
  18876. return oldValue.APIKey, nil
  18877. }
  18878. // ResetAPIKey resets all changes to the "api_key" field.
  18879. func (m *EmployeeMutation) ResetAPIKey() {
  18880. m.api_key = nil
  18881. }
  18882. // SetAiInfo sets the "ai_info" field.
  18883. func (m *EmployeeMutation) SetAiInfo(s string) {
  18884. m.ai_info = &s
  18885. }
  18886. // AiInfo returns the value of the "ai_info" field in the mutation.
  18887. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  18888. v := m.ai_info
  18889. if v == nil {
  18890. return
  18891. }
  18892. return *v, true
  18893. }
  18894. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  18895. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18897. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  18898. if !m.op.Is(OpUpdateOne) {
  18899. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  18900. }
  18901. if m.id == nil || m.oldValue == nil {
  18902. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  18903. }
  18904. oldValue, err := m.oldValue(ctx)
  18905. if err != nil {
  18906. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  18907. }
  18908. return oldValue.AiInfo, nil
  18909. }
  18910. // ClearAiInfo clears the value of the "ai_info" field.
  18911. func (m *EmployeeMutation) ClearAiInfo() {
  18912. m.ai_info = nil
  18913. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  18914. }
  18915. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  18916. func (m *EmployeeMutation) AiInfoCleared() bool {
  18917. _, ok := m.clearedFields[employee.FieldAiInfo]
  18918. return ok
  18919. }
  18920. // ResetAiInfo resets all changes to the "ai_info" field.
  18921. func (m *EmployeeMutation) ResetAiInfo() {
  18922. m.ai_info = nil
  18923. delete(m.clearedFields, employee.FieldAiInfo)
  18924. }
  18925. // SetIsVip sets the "is_vip" field.
  18926. func (m *EmployeeMutation) SetIsVip(i int) {
  18927. m.is_vip = &i
  18928. m.addis_vip = nil
  18929. }
  18930. // IsVip returns the value of the "is_vip" field in the mutation.
  18931. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  18932. v := m.is_vip
  18933. if v == nil {
  18934. return
  18935. }
  18936. return *v, true
  18937. }
  18938. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  18939. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18941. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  18942. if !m.op.Is(OpUpdateOne) {
  18943. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  18944. }
  18945. if m.id == nil || m.oldValue == nil {
  18946. return v, errors.New("OldIsVip requires an ID field in the mutation")
  18947. }
  18948. oldValue, err := m.oldValue(ctx)
  18949. if err != nil {
  18950. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  18951. }
  18952. return oldValue.IsVip, nil
  18953. }
  18954. // AddIsVip adds i to the "is_vip" field.
  18955. func (m *EmployeeMutation) AddIsVip(i int) {
  18956. if m.addis_vip != nil {
  18957. *m.addis_vip += i
  18958. } else {
  18959. m.addis_vip = &i
  18960. }
  18961. }
  18962. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  18963. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  18964. v := m.addis_vip
  18965. if v == nil {
  18966. return
  18967. }
  18968. return *v, true
  18969. }
  18970. // ResetIsVip resets all changes to the "is_vip" field.
  18971. func (m *EmployeeMutation) ResetIsVip() {
  18972. m.is_vip = nil
  18973. m.addis_vip = nil
  18974. }
  18975. // SetChatURL sets the "chat_url" field.
  18976. func (m *EmployeeMutation) SetChatURL(s string) {
  18977. m.chat_url = &s
  18978. }
  18979. // ChatURL returns the value of the "chat_url" field in the mutation.
  18980. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  18981. v := m.chat_url
  18982. if v == nil {
  18983. return
  18984. }
  18985. return *v, true
  18986. }
  18987. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  18988. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18990. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  18991. if !m.op.Is(OpUpdateOne) {
  18992. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  18993. }
  18994. if m.id == nil || m.oldValue == nil {
  18995. return v, errors.New("OldChatURL requires an ID field in the mutation")
  18996. }
  18997. oldValue, err := m.oldValue(ctx)
  18998. if err != nil {
  18999. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  19000. }
  19001. return oldValue.ChatURL, nil
  19002. }
  19003. // ResetChatURL resets all changes to the "chat_url" field.
  19004. func (m *EmployeeMutation) ResetChatURL() {
  19005. m.chat_url = nil
  19006. }
  19007. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  19008. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  19009. if m.em_work_experiences == nil {
  19010. m.em_work_experiences = make(map[uint64]struct{})
  19011. }
  19012. for i := range ids {
  19013. m.em_work_experiences[ids[i]] = struct{}{}
  19014. }
  19015. }
  19016. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  19017. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  19018. m.clearedem_work_experiences = true
  19019. }
  19020. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  19021. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  19022. return m.clearedem_work_experiences
  19023. }
  19024. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  19025. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  19026. if m.removedem_work_experiences == nil {
  19027. m.removedem_work_experiences = make(map[uint64]struct{})
  19028. }
  19029. for i := range ids {
  19030. delete(m.em_work_experiences, ids[i])
  19031. m.removedem_work_experiences[ids[i]] = struct{}{}
  19032. }
  19033. }
  19034. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  19035. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  19036. for id := range m.removedem_work_experiences {
  19037. ids = append(ids, id)
  19038. }
  19039. return
  19040. }
  19041. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  19042. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  19043. for id := range m.em_work_experiences {
  19044. ids = append(ids, id)
  19045. }
  19046. return
  19047. }
  19048. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  19049. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  19050. m.em_work_experiences = nil
  19051. m.clearedem_work_experiences = false
  19052. m.removedem_work_experiences = nil
  19053. }
  19054. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  19055. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  19056. if m.em_tutorial == nil {
  19057. m.em_tutorial = make(map[uint64]struct{})
  19058. }
  19059. for i := range ids {
  19060. m.em_tutorial[ids[i]] = struct{}{}
  19061. }
  19062. }
  19063. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  19064. func (m *EmployeeMutation) ClearEmTutorial() {
  19065. m.clearedem_tutorial = true
  19066. }
  19067. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  19068. func (m *EmployeeMutation) EmTutorialCleared() bool {
  19069. return m.clearedem_tutorial
  19070. }
  19071. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  19072. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  19073. if m.removedem_tutorial == nil {
  19074. m.removedem_tutorial = make(map[uint64]struct{})
  19075. }
  19076. for i := range ids {
  19077. delete(m.em_tutorial, ids[i])
  19078. m.removedem_tutorial[ids[i]] = struct{}{}
  19079. }
  19080. }
  19081. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  19082. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  19083. for id := range m.removedem_tutorial {
  19084. ids = append(ids, id)
  19085. }
  19086. return
  19087. }
  19088. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  19089. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  19090. for id := range m.em_tutorial {
  19091. ids = append(ids, id)
  19092. }
  19093. return
  19094. }
  19095. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  19096. func (m *EmployeeMutation) ResetEmTutorial() {
  19097. m.em_tutorial = nil
  19098. m.clearedem_tutorial = false
  19099. m.removedem_tutorial = nil
  19100. }
  19101. // Where appends a list predicates to the EmployeeMutation builder.
  19102. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  19103. m.predicates = append(m.predicates, ps...)
  19104. }
  19105. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  19106. // users can use type-assertion to append predicates that do not depend on any generated package.
  19107. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  19108. p := make([]predicate.Employee, len(ps))
  19109. for i := range ps {
  19110. p[i] = ps[i]
  19111. }
  19112. m.Where(p...)
  19113. }
  19114. // Op returns the operation name.
  19115. func (m *EmployeeMutation) Op() Op {
  19116. return m.op
  19117. }
  19118. // SetOp allows setting the mutation operation.
  19119. func (m *EmployeeMutation) SetOp(op Op) {
  19120. m.op = op
  19121. }
  19122. // Type returns the node type of this mutation (Employee).
  19123. func (m *EmployeeMutation) Type() string {
  19124. return m.typ
  19125. }
  19126. // Fields returns all fields that were changed during this mutation. Note that in
  19127. // order to get all numeric fields that were incremented/decremented, call
  19128. // AddedFields().
  19129. func (m *EmployeeMutation) Fields() []string {
  19130. fields := make([]string, 0, 23)
  19131. if m.created_at != nil {
  19132. fields = append(fields, employee.FieldCreatedAt)
  19133. }
  19134. if m.updated_at != nil {
  19135. fields = append(fields, employee.FieldUpdatedAt)
  19136. }
  19137. if m.deleted_at != nil {
  19138. fields = append(fields, employee.FieldDeletedAt)
  19139. }
  19140. if m.title != nil {
  19141. fields = append(fields, employee.FieldTitle)
  19142. }
  19143. if m.avatar != nil {
  19144. fields = append(fields, employee.FieldAvatar)
  19145. }
  19146. if m.tags != nil {
  19147. fields = append(fields, employee.FieldTags)
  19148. }
  19149. if m.hire_count != nil {
  19150. fields = append(fields, employee.FieldHireCount)
  19151. }
  19152. if m.service_count != nil {
  19153. fields = append(fields, employee.FieldServiceCount)
  19154. }
  19155. if m.achievement_count != nil {
  19156. fields = append(fields, employee.FieldAchievementCount)
  19157. }
  19158. if m.intro != nil {
  19159. fields = append(fields, employee.FieldIntro)
  19160. }
  19161. if m.estimate != nil {
  19162. fields = append(fields, employee.FieldEstimate)
  19163. }
  19164. if m.skill != nil {
  19165. fields = append(fields, employee.FieldSkill)
  19166. }
  19167. if m.ability_type != nil {
  19168. fields = append(fields, employee.FieldAbilityType)
  19169. }
  19170. if m.scene != nil {
  19171. fields = append(fields, employee.FieldScene)
  19172. }
  19173. if m.switch_in != nil {
  19174. fields = append(fields, employee.FieldSwitchIn)
  19175. }
  19176. if m.video_url != nil {
  19177. fields = append(fields, employee.FieldVideoURL)
  19178. }
  19179. if m.organization_id != nil {
  19180. fields = append(fields, employee.FieldOrganizationID)
  19181. }
  19182. if m.category_id != nil {
  19183. fields = append(fields, employee.FieldCategoryID)
  19184. }
  19185. if m.api_base != nil {
  19186. fields = append(fields, employee.FieldAPIBase)
  19187. }
  19188. if m.api_key != nil {
  19189. fields = append(fields, employee.FieldAPIKey)
  19190. }
  19191. if m.ai_info != nil {
  19192. fields = append(fields, employee.FieldAiInfo)
  19193. }
  19194. if m.is_vip != nil {
  19195. fields = append(fields, employee.FieldIsVip)
  19196. }
  19197. if m.chat_url != nil {
  19198. fields = append(fields, employee.FieldChatURL)
  19199. }
  19200. return fields
  19201. }
  19202. // Field returns the value of a field with the given name. The second boolean
  19203. // return value indicates that this field was not set, or was not defined in the
  19204. // schema.
  19205. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  19206. switch name {
  19207. case employee.FieldCreatedAt:
  19208. return m.CreatedAt()
  19209. case employee.FieldUpdatedAt:
  19210. return m.UpdatedAt()
  19211. case employee.FieldDeletedAt:
  19212. return m.DeletedAt()
  19213. case employee.FieldTitle:
  19214. return m.Title()
  19215. case employee.FieldAvatar:
  19216. return m.Avatar()
  19217. case employee.FieldTags:
  19218. return m.Tags()
  19219. case employee.FieldHireCount:
  19220. return m.HireCount()
  19221. case employee.FieldServiceCount:
  19222. return m.ServiceCount()
  19223. case employee.FieldAchievementCount:
  19224. return m.AchievementCount()
  19225. case employee.FieldIntro:
  19226. return m.Intro()
  19227. case employee.FieldEstimate:
  19228. return m.Estimate()
  19229. case employee.FieldSkill:
  19230. return m.Skill()
  19231. case employee.FieldAbilityType:
  19232. return m.AbilityType()
  19233. case employee.FieldScene:
  19234. return m.Scene()
  19235. case employee.FieldSwitchIn:
  19236. return m.SwitchIn()
  19237. case employee.FieldVideoURL:
  19238. return m.VideoURL()
  19239. case employee.FieldOrganizationID:
  19240. return m.OrganizationID()
  19241. case employee.FieldCategoryID:
  19242. return m.CategoryID()
  19243. case employee.FieldAPIBase:
  19244. return m.APIBase()
  19245. case employee.FieldAPIKey:
  19246. return m.APIKey()
  19247. case employee.FieldAiInfo:
  19248. return m.AiInfo()
  19249. case employee.FieldIsVip:
  19250. return m.IsVip()
  19251. case employee.FieldChatURL:
  19252. return m.ChatURL()
  19253. }
  19254. return nil, false
  19255. }
  19256. // OldField returns the old value of the field from the database. An error is
  19257. // returned if the mutation operation is not UpdateOne, or the query to the
  19258. // database failed.
  19259. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19260. switch name {
  19261. case employee.FieldCreatedAt:
  19262. return m.OldCreatedAt(ctx)
  19263. case employee.FieldUpdatedAt:
  19264. return m.OldUpdatedAt(ctx)
  19265. case employee.FieldDeletedAt:
  19266. return m.OldDeletedAt(ctx)
  19267. case employee.FieldTitle:
  19268. return m.OldTitle(ctx)
  19269. case employee.FieldAvatar:
  19270. return m.OldAvatar(ctx)
  19271. case employee.FieldTags:
  19272. return m.OldTags(ctx)
  19273. case employee.FieldHireCount:
  19274. return m.OldHireCount(ctx)
  19275. case employee.FieldServiceCount:
  19276. return m.OldServiceCount(ctx)
  19277. case employee.FieldAchievementCount:
  19278. return m.OldAchievementCount(ctx)
  19279. case employee.FieldIntro:
  19280. return m.OldIntro(ctx)
  19281. case employee.FieldEstimate:
  19282. return m.OldEstimate(ctx)
  19283. case employee.FieldSkill:
  19284. return m.OldSkill(ctx)
  19285. case employee.FieldAbilityType:
  19286. return m.OldAbilityType(ctx)
  19287. case employee.FieldScene:
  19288. return m.OldScene(ctx)
  19289. case employee.FieldSwitchIn:
  19290. return m.OldSwitchIn(ctx)
  19291. case employee.FieldVideoURL:
  19292. return m.OldVideoURL(ctx)
  19293. case employee.FieldOrganizationID:
  19294. return m.OldOrganizationID(ctx)
  19295. case employee.FieldCategoryID:
  19296. return m.OldCategoryID(ctx)
  19297. case employee.FieldAPIBase:
  19298. return m.OldAPIBase(ctx)
  19299. case employee.FieldAPIKey:
  19300. return m.OldAPIKey(ctx)
  19301. case employee.FieldAiInfo:
  19302. return m.OldAiInfo(ctx)
  19303. case employee.FieldIsVip:
  19304. return m.OldIsVip(ctx)
  19305. case employee.FieldChatURL:
  19306. return m.OldChatURL(ctx)
  19307. }
  19308. return nil, fmt.Errorf("unknown Employee field %s", name)
  19309. }
  19310. // SetField sets the value of a field with the given name. It returns an error if
  19311. // the field is not defined in the schema, or if the type mismatched the field
  19312. // type.
  19313. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  19314. switch name {
  19315. case employee.FieldCreatedAt:
  19316. v, ok := value.(time.Time)
  19317. if !ok {
  19318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19319. }
  19320. m.SetCreatedAt(v)
  19321. return nil
  19322. case employee.FieldUpdatedAt:
  19323. v, ok := value.(time.Time)
  19324. if !ok {
  19325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19326. }
  19327. m.SetUpdatedAt(v)
  19328. return nil
  19329. case employee.FieldDeletedAt:
  19330. v, ok := value.(time.Time)
  19331. if !ok {
  19332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19333. }
  19334. m.SetDeletedAt(v)
  19335. return nil
  19336. case employee.FieldTitle:
  19337. v, ok := value.(string)
  19338. if !ok {
  19339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19340. }
  19341. m.SetTitle(v)
  19342. return nil
  19343. case employee.FieldAvatar:
  19344. v, ok := value.(string)
  19345. if !ok {
  19346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19347. }
  19348. m.SetAvatar(v)
  19349. return nil
  19350. case employee.FieldTags:
  19351. v, ok := value.(string)
  19352. if !ok {
  19353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19354. }
  19355. m.SetTags(v)
  19356. return nil
  19357. case employee.FieldHireCount:
  19358. v, ok := value.(int)
  19359. if !ok {
  19360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19361. }
  19362. m.SetHireCount(v)
  19363. return nil
  19364. case employee.FieldServiceCount:
  19365. v, ok := value.(int)
  19366. if !ok {
  19367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19368. }
  19369. m.SetServiceCount(v)
  19370. return nil
  19371. case employee.FieldAchievementCount:
  19372. v, ok := value.(int)
  19373. if !ok {
  19374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19375. }
  19376. m.SetAchievementCount(v)
  19377. return nil
  19378. case employee.FieldIntro:
  19379. v, ok := value.(string)
  19380. if !ok {
  19381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19382. }
  19383. m.SetIntro(v)
  19384. return nil
  19385. case employee.FieldEstimate:
  19386. v, ok := value.(string)
  19387. if !ok {
  19388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19389. }
  19390. m.SetEstimate(v)
  19391. return nil
  19392. case employee.FieldSkill:
  19393. v, ok := value.(string)
  19394. if !ok {
  19395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19396. }
  19397. m.SetSkill(v)
  19398. return nil
  19399. case employee.FieldAbilityType:
  19400. v, ok := value.(string)
  19401. if !ok {
  19402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19403. }
  19404. m.SetAbilityType(v)
  19405. return nil
  19406. case employee.FieldScene:
  19407. v, ok := value.(string)
  19408. if !ok {
  19409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19410. }
  19411. m.SetScene(v)
  19412. return nil
  19413. case employee.FieldSwitchIn:
  19414. v, ok := value.(string)
  19415. if !ok {
  19416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19417. }
  19418. m.SetSwitchIn(v)
  19419. return nil
  19420. case employee.FieldVideoURL:
  19421. v, ok := value.(string)
  19422. if !ok {
  19423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19424. }
  19425. m.SetVideoURL(v)
  19426. return nil
  19427. case employee.FieldOrganizationID:
  19428. v, ok := value.(uint64)
  19429. if !ok {
  19430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19431. }
  19432. m.SetOrganizationID(v)
  19433. return nil
  19434. case employee.FieldCategoryID:
  19435. v, ok := value.(uint64)
  19436. if !ok {
  19437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19438. }
  19439. m.SetCategoryID(v)
  19440. return nil
  19441. case employee.FieldAPIBase:
  19442. v, ok := value.(string)
  19443. if !ok {
  19444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19445. }
  19446. m.SetAPIBase(v)
  19447. return nil
  19448. case employee.FieldAPIKey:
  19449. v, ok := value.(string)
  19450. if !ok {
  19451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19452. }
  19453. m.SetAPIKey(v)
  19454. return nil
  19455. case employee.FieldAiInfo:
  19456. v, ok := value.(string)
  19457. if !ok {
  19458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19459. }
  19460. m.SetAiInfo(v)
  19461. return nil
  19462. case employee.FieldIsVip:
  19463. v, ok := value.(int)
  19464. if !ok {
  19465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19466. }
  19467. m.SetIsVip(v)
  19468. return nil
  19469. case employee.FieldChatURL:
  19470. v, ok := value.(string)
  19471. if !ok {
  19472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19473. }
  19474. m.SetChatURL(v)
  19475. return nil
  19476. }
  19477. return fmt.Errorf("unknown Employee field %s", name)
  19478. }
  19479. // AddedFields returns all numeric fields that were incremented/decremented during
  19480. // this mutation.
  19481. func (m *EmployeeMutation) AddedFields() []string {
  19482. var fields []string
  19483. if m.addhire_count != nil {
  19484. fields = append(fields, employee.FieldHireCount)
  19485. }
  19486. if m.addservice_count != nil {
  19487. fields = append(fields, employee.FieldServiceCount)
  19488. }
  19489. if m.addachievement_count != nil {
  19490. fields = append(fields, employee.FieldAchievementCount)
  19491. }
  19492. if m.addorganization_id != nil {
  19493. fields = append(fields, employee.FieldOrganizationID)
  19494. }
  19495. if m.addcategory_id != nil {
  19496. fields = append(fields, employee.FieldCategoryID)
  19497. }
  19498. if m.addis_vip != nil {
  19499. fields = append(fields, employee.FieldIsVip)
  19500. }
  19501. return fields
  19502. }
  19503. // AddedField returns the numeric value that was incremented/decremented on a field
  19504. // with the given name. The second boolean return value indicates that this field
  19505. // was not set, or was not defined in the schema.
  19506. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  19507. switch name {
  19508. case employee.FieldHireCount:
  19509. return m.AddedHireCount()
  19510. case employee.FieldServiceCount:
  19511. return m.AddedServiceCount()
  19512. case employee.FieldAchievementCount:
  19513. return m.AddedAchievementCount()
  19514. case employee.FieldOrganizationID:
  19515. return m.AddedOrganizationID()
  19516. case employee.FieldCategoryID:
  19517. return m.AddedCategoryID()
  19518. case employee.FieldIsVip:
  19519. return m.AddedIsVip()
  19520. }
  19521. return nil, false
  19522. }
  19523. // AddField adds the value to the field with the given name. It returns an error if
  19524. // the field is not defined in the schema, or if the type mismatched the field
  19525. // type.
  19526. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  19527. switch name {
  19528. case employee.FieldHireCount:
  19529. v, ok := value.(int)
  19530. if !ok {
  19531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19532. }
  19533. m.AddHireCount(v)
  19534. return nil
  19535. case employee.FieldServiceCount:
  19536. v, ok := value.(int)
  19537. if !ok {
  19538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19539. }
  19540. m.AddServiceCount(v)
  19541. return nil
  19542. case employee.FieldAchievementCount:
  19543. v, ok := value.(int)
  19544. if !ok {
  19545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19546. }
  19547. m.AddAchievementCount(v)
  19548. return nil
  19549. case employee.FieldOrganizationID:
  19550. v, ok := value.(int64)
  19551. if !ok {
  19552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19553. }
  19554. m.AddOrganizationID(v)
  19555. return nil
  19556. case employee.FieldCategoryID:
  19557. v, ok := value.(int64)
  19558. if !ok {
  19559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19560. }
  19561. m.AddCategoryID(v)
  19562. return nil
  19563. case employee.FieldIsVip:
  19564. v, ok := value.(int)
  19565. if !ok {
  19566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19567. }
  19568. m.AddIsVip(v)
  19569. return nil
  19570. }
  19571. return fmt.Errorf("unknown Employee numeric field %s", name)
  19572. }
  19573. // ClearedFields returns all nullable fields that were cleared during this
  19574. // mutation.
  19575. func (m *EmployeeMutation) ClearedFields() []string {
  19576. var fields []string
  19577. if m.FieldCleared(employee.FieldDeletedAt) {
  19578. fields = append(fields, employee.FieldDeletedAt)
  19579. }
  19580. if m.FieldCleared(employee.FieldAiInfo) {
  19581. fields = append(fields, employee.FieldAiInfo)
  19582. }
  19583. return fields
  19584. }
  19585. // FieldCleared returns a boolean indicating if a field with the given name was
  19586. // cleared in this mutation.
  19587. func (m *EmployeeMutation) FieldCleared(name string) bool {
  19588. _, ok := m.clearedFields[name]
  19589. return ok
  19590. }
  19591. // ClearField clears the value of the field with the given name. It returns an
  19592. // error if the field is not defined in the schema.
  19593. func (m *EmployeeMutation) ClearField(name string) error {
  19594. switch name {
  19595. case employee.FieldDeletedAt:
  19596. m.ClearDeletedAt()
  19597. return nil
  19598. case employee.FieldAiInfo:
  19599. m.ClearAiInfo()
  19600. return nil
  19601. }
  19602. return fmt.Errorf("unknown Employee nullable field %s", name)
  19603. }
  19604. // ResetField resets all changes in the mutation for the field with the given name.
  19605. // It returns an error if the field is not defined in the schema.
  19606. func (m *EmployeeMutation) ResetField(name string) error {
  19607. switch name {
  19608. case employee.FieldCreatedAt:
  19609. m.ResetCreatedAt()
  19610. return nil
  19611. case employee.FieldUpdatedAt:
  19612. m.ResetUpdatedAt()
  19613. return nil
  19614. case employee.FieldDeletedAt:
  19615. m.ResetDeletedAt()
  19616. return nil
  19617. case employee.FieldTitle:
  19618. m.ResetTitle()
  19619. return nil
  19620. case employee.FieldAvatar:
  19621. m.ResetAvatar()
  19622. return nil
  19623. case employee.FieldTags:
  19624. m.ResetTags()
  19625. return nil
  19626. case employee.FieldHireCount:
  19627. m.ResetHireCount()
  19628. return nil
  19629. case employee.FieldServiceCount:
  19630. m.ResetServiceCount()
  19631. return nil
  19632. case employee.FieldAchievementCount:
  19633. m.ResetAchievementCount()
  19634. return nil
  19635. case employee.FieldIntro:
  19636. m.ResetIntro()
  19637. return nil
  19638. case employee.FieldEstimate:
  19639. m.ResetEstimate()
  19640. return nil
  19641. case employee.FieldSkill:
  19642. m.ResetSkill()
  19643. return nil
  19644. case employee.FieldAbilityType:
  19645. m.ResetAbilityType()
  19646. return nil
  19647. case employee.FieldScene:
  19648. m.ResetScene()
  19649. return nil
  19650. case employee.FieldSwitchIn:
  19651. m.ResetSwitchIn()
  19652. return nil
  19653. case employee.FieldVideoURL:
  19654. m.ResetVideoURL()
  19655. return nil
  19656. case employee.FieldOrganizationID:
  19657. m.ResetOrganizationID()
  19658. return nil
  19659. case employee.FieldCategoryID:
  19660. m.ResetCategoryID()
  19661. return nil
  19662. case employee.FieldAPIBase:
  19663. m.ResetAPIBase()
  19664. return nil
  19665. case employee.FieldAPIKey:
  19666. m.ResetAPIKey()
  19667. return nil
  19668. case employee.FieldAiInfo:
  19669. m.ResetAiInfo()
  19670. return nil
  19671. case employee.FieldIsVip:
  19672. m.ResetIsVip()
  19673. return nil
  19674. case employee.FieldChatURL:
  19675. m.ResetChatURL()
  19676. return nil
  19677. }
  19678. return fmt.Errorf("unknown Employee field %s", name)
  19679. }
  19680. // AddedEdges returns all edge names that were set/added in this mutation.
  19681. func (m *EmployeeMutation) AddedEdges() []string {
  19682. edges := make([]string, 0, 2)
  19683. if m.em_work_experiences != nil {
  19684. edges = append(edges, employee.EdgeEmWorkExperiences)
  19685. }
  19686. if m.em_tutorial != nil {
  19687. edges = append(edges, employee.EdgeEmTutorial)
  19688. }
  19689. return edges
  19690. }
  19691. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19692. // name in this mutation.
  19693. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  19694. switch name {
  19695. case employee.EdgeEmWorkExperiences:
  19696. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  19697. for id := range m.em_work_experiences {
  19698. ids = append(ids, id)
  19699. }
  19700. return ids
  19701. case employee.EdgeEmTutorial:
  19702. ids := make([]ent.Value, 0, len(m.em_tutorial))
  19703. for id := range m.em_tutorial {
  19704. ids = append(ids, id)
  19705. }
  19706. return ids
  19707. }
  19708. return nil
  19709. }
  19710. // RemovedEdges returns all edge names that were removed in this mutation.
  19711. func (m *EmployeeMutation) RemovedEdges() []string {
  19712. edges := make([]string, 0, 2)
  19713. if m.removedem_work_experiences != nil {
  19714. edges = append(edges, employee.EdgeEmWorkExperiences)
  19715. }
  19716. if m.removedem_tutorial != nil {
  19717. edges = append(edges, employee.EdgeEmTutorial)
  19718. }
  19719. return edges
  19720. }
  19721. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19722. // the given name in this mutation.
  19723. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  19724. switch name {
  19725. case employee.EdgeEmWorkExperiences:
  19726. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  19727. for id := range m.removedem_work_experiences {
  19728. ids = append(ids, id)
  19729. }
  19730. return ids
  19731. case employee.EdgeEmTutorial:
  19732. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  19733. for id := range m.removedem_tutorial {
  19734. ids = append(ids, id)
  19735. }
  19736. return ids
  19737. }
  19738. return nil
  19739. }
  19740. // ClearedEdges returns all edge names that were cleared in this mutation.
  19741. func (m *EmployeeMutation) ClearedEdges() []string {
  19742. edges := make([]string, 0, 2)
  19743. if m.clearedem_work_experiences {
  19744. edges = append(edges, employee.EdgeEmWorkExperiences)
  19745. }
  19746. if m.clearedem_tutorial {
  19747. edges = append(edges, employee.EdgeEmTutorial)
  19748. }
  19749. return edges
  19750. }
  19751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19752. // was cleared in this mutation.
  19753. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  19754. switch name {
  19755. case employee.EdgeEmWorkExperiences:
  19756. return m.clearedem_work_experiences
  19757. case employee.EdgeEmTutorial:
  19758. return m.clearedem_tutorial
  19759. }
  19760. return false
  19761. }
  19762. // ClearEdge clears the value of the edge with the given name. It returns an error
  19763. // if that edge is not defined in the schema.
  19764. func (m *EmployeeMutation) ClearEdge(name string) error {
  19765. switch name {
  19766. }
  19767. return fmt.Errorf("unknown Employee unique edge %s", name)
  19768. }
  19769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19770. // It returns an error if the edge is not defined in the schema.
  19771. func (m *EmployeeMutation) ResetEdge(name string) error {
  19772. switch name {
  19773. case employee.EdgeEmWorkExperiences:
  19774. m.ResetEmWorkExperiences()
  19775. return nil
  19776. case employee.EdgeEmTutorial:
  19777. m.ResetEmTutorial()
  19778. return nil
  19779. }
  19780. return fmt.Errorf("unknown Employee edge %s", name)
  19781. }
  19782. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  19783. type EmployeeConfigMutation struct {
  19784. config
  19785. op Op
  19786. typ string
  19787. id *uint64
  19788. created_at *time.Time
  19789. updated_at *time.Time
  19790. deleted_at *time.Time
  19791. stype *string
  19792. title *string
  19793. photo *string
  19794. organization_id *uint64
  19795. addorganization_id *int64
  19796. clearedFields map[string]struct{}
  19797. done bool
  19798. oldValue func(context.Context) (*EmployeeConfig, error)
  19799. predicates []predicate.EmployeeConfig
  19800. }
  19801. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  19802. // employeeconfigOption allows management of the mutation configuration using functional options.
  19803. type employeeconfigOption func(*EmployeeConfigMutation)
  19804. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  19805. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  19806. m := &EmployeeConfigMutation{
  19807. config: c,
  19808. op: op,
  19809. typ: TypeEmployeeConfig,
  19810. clearedFields: make(map[string]struct{}),
  19811. }
  19812. for _, opt := range opts {
  19813. opt(m)
  19814. }
  19815. return m
  19816. }
  19817. // withEmployeeConfigID sets the ID field of the mutation.
  19818. func withEmployeeConfigID(id uint64) employeeconfigOption {
  19819. return func(m *EmployeeConfigMutation) {
  19820. var (
  19821. err error
  19822. once sync.Once
  19823. value *EmployeeConfig
  19824. )
  19825. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  19826. once.Do(func() {
  19827. if m.done {
  19828. err = errors.New("querying old values post mutation is not allowed")
  19829. } else {
  19830. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  19831. }
  19832. })
  19833. return value, err
  19834. }
  19835. m.id = &id
  19836. }
  19837. }
  19838. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  19839. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  19840. return func(m *EmployeeConfigMutation) {
  19841. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  19842. return node, nil
  19843. }
  19844. m.id = &node.ID
  19845. }
  19846. }
  19847. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19848. // executed in a transaction (ent.Tx), a transactional client is returned.
  19849. func (m EmployeeConfigMutation) Client() *Client {
  19850. client := &Client{config: m.config}
  19851. client.init()
  19852. return client
  19853. }
  19854. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19855. // it returns an error otherwise.
  19856. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  19857. if _, ok := m.driver.(*txDriver); !ok {
  19858. return nil, errors.New("ent: mutation is not running in a transaction")
  19859. }
  19860. tx := &Tx{config: m.config}
  19861. tx.init()
  19862. return tx, nil
  19863. }
  19864. // SetID sets the value of the id field. Note that this
  19865. // operation is only accepted on creation of EmployeeConfig entities.
  19866. func (m *EmployeeConfigMutation) SetID(id uint64) {
  19867. m.id = &id
  19868. }
  19869. // ID returns the ID value in the mutation. Note that the ID is only available
  19870. // if it was provided to the builder or after it was returned from the database.
  19871. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  19872. if m.id == nil {
  19873. return
  19874. }
  19875. return *m.id, true
  19876. }
  19877. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19878. // That means, if the mutation is applied within a transaction with an isolation level such
  19879. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19880. // or updated by the mutation.
  19881. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  19882. switch {
  19883. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19884. id, exists := m.ID()
  19885. if exists {
  19886. return []uint64{id}, nil
  19887. }
  19888. fallthrough
  19889. case m.op.Is(OpUpdate | OpDelete):
  19890. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  19891. default:
  19892. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19893. }
  19894. }
  19895. // SetCreatedAt sets the "created_at" field.
  19896. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  19897. m.created_at = &t
  19898. }
  19899. // CreatedAt returns the value of the "created_at" field in the mutation.
  19900. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  19901. v := m.created_at
  19902. if v == nil {
  19903. return
  19904. }
  19905. return *v, true
  19906. }
  19907. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  19908. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19910. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19911. if !m.op.Is(OpUpdateOne) {
  19912. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19913. }
  19914. if m.id == nil || m.oldValue == nil {
  19915. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19916. }
  19917. oldValue, err := m.oldValue(ctx)
  19918. if err != nil {
  19919. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19920. }
  19921. return oldValue.CreatedAt, nil
  19922. }
  19923. // ResetCreatedAt resets all changes to the "created_at" field.
  19924. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  19925. m.created_at = nil
  19926. }
  19927. // SetUpdatedAt sets the "updated_at" field.
  19928. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  19929. m.updated_at = &t
  19930. }
  19931. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19932. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  19933. v := m.updated_at
  19934. if v == nil {
  19935. return
  19936. }
  19937. return *v, true
  19938. }
  19939. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  19940. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19942. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19943. if !m.op.Is(OpUpdateOne) {
  19944. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19945. }
  19946. if m.id == nil || m.oldValue == nil {
  19947. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19948. }
  19949. oldValue, err := m.oldValue(ctx)
  19950. if err != nil {
  19951. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19952. }
  19953. return oldValue.UpdatedAt, nil
  19954. }
  19955. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19956. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  19957. m.updated_at = nil
  19958. }
  19959. // SetDeletedAt sets the "deleted_at" field.
  19960. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  19961. m.deleted_at = &t
  19962. }
  19963. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19964. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  19965. v := m.deleted_at
  19966. if v == nil {
  19967. return
  19968. }
  19969. return *v, true
  19970. }
  19971. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  19972. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19974. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19975. if !m.op.Is(OpUpdateOne) {
  19976. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19977. }
  19978. if m.id == nil || m.oldValue == nil {
  19979. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19980. }
  19981. oldValue, err := m.oldValue(ctx)
  19982. if err != nil {
  19983. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19984. }
  19985. return oldValue.DeletedAt, nil
  19986. }
  19987. // ClearDeletedAt clears the value of the "deleted_at" field.
  19988. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  19989. m.deleted_at = nil
  19990. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  19991. }
  19992. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19993. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  19994. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  19995. return ok
  19996. }
  19997. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19998. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  19999. m.deleted_at = nil
  20000. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  20001. }
  20002. // SetStype sets the "stype" field.
  20003. func (m *EmployeeConfigMutation) SetStype(s string) {
  20004. m.stype = &s
  20005. }
  20006. // Stype returns the value of the "stype" field in the mutation.
  20007. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  20008. v := m.stype
  20009. if v == nil {
  20010. return
  20011. }
  20012. return *v, true
  20013. }
  20014. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  20015. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20017. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  20018. if !m.op.Is(OpUpdateOne) {
  20019. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  20020. }
  20021. if m.id == nil || m.oldValue == nil {
  20022. return v, errors.New("OldStype requires an ID field in the mutation")
  20023. }
  20024. oldValue, err := m.oldValue(ctx)
  20025. if err != nil {
  20026. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  20027. }
  20028. return oldValue.Stype, nil
  20029. }
  20030. // ResetStype resets all changes to the "stype" field.
  20031. func (m *EmployeeConfigMutation) ResetStype() {
  20032. m.stype = nil
  20033. }
  20034. // SetTitle sets the "title" field.
  20035. func (m *EmployeeConfigMutation) SetTitle(s string) {
  20036. m.title = &s
  20037. }
  20038. // Title returns the value of the "title" field in the mutation.
  20039. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  20040. v := m.title
  20041. if v == nil {
  20042. return
  20043. }
  20044. return *v, true
  20045. }
  20046. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  20047. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20049. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  20050. if !m.op.Is(OpUpdateOne) {
  20051. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  20052. }
  20053. if m.id == nil || m.oldValue == nil {
  20054. return v, errors.New("OldTitle requires an ID field in the mutation")
  20055. }
  20056. oldValue, err := m.oldValue(ctx)
  20057. if err != nil {
  20058. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  20059. }
  20060. return oldValue.Title, nil
  20061. }
  20062. // ResetTitle resets all changes to the "title" field.
  20063. func (m *EmployeeConfigMutation) ResetTitle() {
  20064. m.title = nil
  20065. }
  20066. // SetPhoto sets the "photo" field.
  20067. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  20068. m.photo = &s
  20069. }
  20070. // Photo returns the value of the "photo" field in the mutation.
  20071. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  20072. v := m.photo
  20073. if v == nil {
  20074. return
  20075. }
  20076. return *v, true
  20077. }
  20078. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  20079. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20081. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  20082. if !m.op.Is(OpUpdateOne) {
  20083. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  20084. }
  20085. if m.id == nil || m.oldValue == nil {
  20086. return v, errors.New("OldPhoto requires an ID field in the mutation")
  20087. }
  20088. oldValue, err := m.oldValue(ctx)
  20089. if err != nil {
  20090. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  20091. }
  20092. return oldValue.Photo, nil
  20093. }
  20094. // ResetPhoto resets all changes to the "photo" field.
  20095. func (m *EmployeeConfigMutation) ResetPhoto() {
  20096. m.photo = nil
  20097. }
  20098. // SetOrganizationID sets the "organization_id" field.
  20099. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  20100. m.organization_id = &u
  20101. m.addorganization_id = nil
  20102. }
  20103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20104. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  20105. v := m.organization_id
  20106. if v == nil {
  20107. return
  20108. }
  20109. return *v, true
  20110. }
  20111. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  20112. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20114. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20115. if !m.op.Is(OpUpdateOne) {
  20116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20117. }
  20118. if m.id == nil || m.oldValue == nil {
  20119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20120. }
  20121. oldValue, err := m.oldValue(ctx)
  20122. if err != nil {
  20123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20124. }
  20125. return oldValue.OrganizationID, nil
  20126. }
  20127. // AddOrganizationID adds u to the "organization_id" field.
  20128. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  20129. if m.addorganization_id != nil {
  20130. *m.addorganization_id += u
  20131. } else {
  20132. m.addorganization_id = &u
  20133. }
  20134. }
  20135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20136. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  20137. v := m.addorganization_id
  20138. if v == nil {
  20139. return
  20140. }
  20141. return *v, true
  20142. }
  20143. // ClearOrganizationID clears the value of the "organization_id" field.
  20144. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  20145. m.organization_id = nil
  20146. m.addorganization_id = nil
  20147. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  20148. }
  20149. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20150. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  20151. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  20152. return ok
  20153. }
  20154. // ResetOrganizationID resets all changes to the "organization_id" field.
  20155. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  20156. m.organization_id = nil
  20157. m.addorganization_id = nil
  20158. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  20159. }
  20160. // Where appends a list predicates to the EmployeeConfigMutation builder.
  20161. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  20162. m.predicates = append(m.predicates, ps...)
  20163. }
  20164. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  20165. // users can use type-assertion to append predicates that do not depend on any generated package.
  20166. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  20167. p := make([]predicate.EmployeeConfig, len(ps))
  20168. for i := range ps {
  20169. p[i] = ps[i]
  20170. }
  20171. m.Where(p...)
  20172. }
  20173. // Op returns the operation name.
  20174. func (m *EmployeeConfigMutation) Op() Op {
  20175. return m.op
  20176. }
  20177. // SetOp allows setting the mutation operation.
  20178. func (m *EmployeeConfigMutation) SetOp(op Op) {
  20179. m.op = op
  20180. }
  20181. // Type returns the node type of this mutation (EmployeeConfig).
  20182. func (m *EmployeeConfigMutation) Type() string {
  20183. return m.typ
  20184. }
  20185. // Fields returns all fields that were changed during this mutation. Note that in
  20186. // order to get all numeric fields that were incremented/decremented, call
  20187. // AddedFields().
  20188. func (m *EmployeeConfigMutation) Fields() []string {
  20189. fields := make([]string, 0, 7)
  20190. if m.created_at != nil {
  20191. fields = append(fields, employeeconfig.FieldCreatedAt)
  20192. }
  20193. if m.updated_at != nil {
  20194. fields = append(fields, employeeconfig.FieldUpdatedAt)
  20195. }
  20196. if m.deleted_at != nil {
  20197. fields = append(fields, employeeconfig.FieldDeletedAt)
  20198. }
  20199. if m.stype != nil {
  20200. fields = append(fields, employeeconfig.FieldStype)
  20201. }
  20202. if m.title != nil {
  20203. fields = append(fields, employeeconfig.FieldTitle)
  20204. }
  20205. if m.photo != nil {
  20206. fields = append(fields, employeeconfig.FieldPhoto)
  20207. }
  20208. if m.organization_id != nil {
  20209. fields = append(fields, employeeconfig.FieldOrganizationID)
  20210. }
  20211. return fields
  20212. }
  20213. // Field returns the value of a field with the given name. The second boolean
  20214. // return value indicates that this field was not set, or was not defined in the
  20215. // schema.
  20216. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  20217. switch name {
  20218. case employeeconfig.FieldCreatedAt:
  20219. return m.CreatedAt()
  20220. case employeeconfig.FieldUpdatedAt:
  20221. return m.UpdatedAt()
  20222. case employeeconfig.FieldDeletedAt:
  20223. return m.DeletedAt()
  20224. case employeeconfig.FieldStype:
  20225. return m.Stype()
  20226. case employeeconfig.FieldTitle:
  20227. return m.Title()
  20228. case employeeconfig.FieldPhoto:
  20229. return m.Photo()
  20230. case employeeconfig.FieldOrganizationID:
  20231. return m.OrganizationID()
  20232. }
  20233. return nil, false
  20234. }
  20235. // OldField returns the old value of the field from the database. An error is
  20236. // returned if the mutation operation is not UpdateOne, or the query to the
  20237. // database failed.
  20238. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20239. switch name {
  20240. case employeeconfig.FieldCreatedAt:
  20241. return m.OldCreatedAt(ctx)
  20242. case employeeconfig.FieldUpdatedAt:
  20243. return m.OldUpdatedAt(ctx)
  20244. case employeeconfig.FieldDeletedAt:
  20245. return m.OldDeletedAt(ctx)
  20246. case employeeconfig.FieldStype:
  20247. return m.OldStype(ctx)
  20248. case employeeconfig.FieldTitle:
  20249. return m.OldTitle(ctx)
  20250. case employeeconfig.FieldPhoto:
  20251. return m.OldPhoto(ctx)
  20252. case employeeconfig.FieldOrganizationID:
  20253. return m.OldOrganizationID(ctx)
  20254. }
  20255. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  20256. }
  20257. // SetField sets the value of a field with the given name. It returns an error if
  20258. // the field is not defined in the schema, or if the type mismatched the field
  20259. // type.
  20260. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  20261. switch name {
  20262. case employeeconfig.FieldCreatedAt:
  20263. v, ok := value.(time.Time)
  20264. if !ok {
  20265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20266. }
  20267. m.SetCreatedAt(v)
  20268. return nil
  20269. case employeeconfig.FieldUpdatedAt:
  20270. v, ok := value.(time.Time)
  20271. if !ok {
  20272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20273. }
  20274. m.SetUpdatedAt(v)
  20275. return nil
  20276. case employeeconfig.FieldDeletedAt:
  20277. v, ok := value.(time.Time)
  20278. if !ok {
  20279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20280. }
  20281. m.SetDeletedAt(v)
  20282. return nil
  20283. case employeeconfig.FieldStype:
  20284. v, ok := value.(string)
  20285. if !ok {
  20286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20287. }
  20288. m.SetStype(v)
  20289. return nil
  20290. case employeeconfig.FieldTitle:
  20291. v, ok := value.(string)
  20292. if !ok {
  20293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20294. }
  20295. m.SetTitle(v)
  20296. return nil
  20297. case employeeconfig.FieldPhoto:
  20298. v, ok := value.(string)
  20299. if !ok {
  20300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20301. }
  20302. m.SetPhoto(v)
  20303. return nil
  20304. case employeeconfig.FieldOrganizationID:
  20305. v, ok := value.(uint64)
  20306. if !ok {
  20307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20308. }
  20309. m.SetOrganizationID(v)
  20310. return nil
  20311. }
  20312. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20313. }
  20314. // AddedFields returns all numeric fields that were incremented/decremented during
  20315. // this mutation.
  20316. func (m *EmployeeConfigMutation) AddedFields() []string {
  20317. var fields []string
  20318. if m.addorganization_id != nil {
  20319. fields = append(fields, employeeconfig.FieldOrganizationID)
  20320. }
  20321. return fields
  20322. }
  20323. // AddedField returns the numeric value that was incremented/decremented on a field
  20324. // with the given name. The second boolean return value indicates that this field
  20325. // was not set, or was not defined in the schema.
  20326. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  20327. switch name {
  20328. case employeeconfig.FieldOrganizationID:
  20329. return m.AddedOrganizationID()
  20330. }
  20331. return nil, false
  20332. }
  20333. // AddField adds the value to the field with the given name. It returns an error if
  20334. // the field is not defined in the schema, or if the type mismatched the field
  20335. // type.
  20336. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  20337. switch name {
  20338. case employeeconfig.FieldOrganizationID:
  20339. v, ok := value.(int64)
  20340. if !ok {
  20341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20342. }
  20343. m.AddOrganizationID(v)
  20344. return nil
  20345. }
  20346. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  20347. }
  20348. // ClearedFields returns all nullable fields that were cleared during this
  20349. // mutation.
  20350. func (m *EmployeeConfigMutation) ClearedFields() []string {
  20351. var fields []string
  20352. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  20353. fields = append(fields, employeeconfig.FieldDeletedAt)
  20354. }
  20355. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  20356. fields = append(fields, employeeconfig.FieldOrganizationID)
  20357. }
  20358. return fields
  20359. }
  20360. // FieldCleared returns a boolean indicating if a field with the given name was
  20361. // cleared in this mutation.
  20362. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  20363. _, ok := m.clearedFields[name]
  20364. return ok
  20365. }
  20366. // ClearField clears the value of the field with the given name. It returns an
  20367. // error if the field is not defined in the schema.
  20368. func (m *EmployeeConfigMutation) ClearField(name string) error {
  20369. switch name {
  20370. case employeeconfig.FieldDeletedAt:
  20371. m.ClearDeletedAt()
  20372. return nil
  20373. case employeeconfig.FieldOrganizationID:
  20374. m.ClearOrganizationID()
  20375. return nil
  20376. }
  20377. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  20378. }
  20379. // ResetField resets all changes in the mutation for the field with the given name.
  20380. // It returns an error if the field is not defined in the schema.
  20381. func (m *EmployeeConfigMutation) ResetField(name string) error {
  20382. switch name {
  20383. case employeeconfig.FieldCreatedAt:
  20384. m.ResetCreatedAt()
  20385. return nil
  20386. case employeeconfig.FieldUpdatedAt:
  20387. m.ResetUpdatedAt()
  20388. return nil
  20389. case employeeconfig.FieldDeletedAt:
  20390. m.ResetDeletedAt()
  20391. return nil
  20392. case employeeconfig.FieldStype:
  20393. m.ResetStype()
  20394. return nil
  20395. case employeeconfig.FieldTitle:
  20396. m.ResetTitle()
  20397. return nil
  20398. case employeeconfig.FieldPhoto:
  20399. m.ResetPhoto()
  20400. return nil
  20401. case employeeconfig.FieldOrganizationID:
  20402. m.ResetOrganizationID()
  20403. return nil
  20404. }
  20405. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20406. }
  20407. // AddedEdges returns all edge names that were set/added in this mutation.
  20408. func (m *EmployeeConfigMutation) AddedEdges() []string {
  20409. edges := make([]string, 0, 0)
  20410. return edges
  20411. }
  20412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20413. // name in this mutation.
  20414. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  20415. return nil
  20416. }
  20417. // RemovedEdges returns all edge names that were removed in this mutation.
  20418. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  20419. edges := make([]string, 0, 0)
  20420. return edges
  20421. }
  20422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20423. // the given name in this mutation.
  20424. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  20425. return nil
  20426. }
  20427. // ClearedEdges returns all edge names that were cleared in this mutation.
  20428. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  20429. edges := make([]string, 0, 0)
  20430. return edges
  20431. }
  20432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20433. // was cleared in this mutation.
  20434. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  20435. return false
  20436. }
  20437. // ClearEdge clears the value of the edge with the given name. It returns an error
  20438. // if that edge is not defined in the schema.
  20439. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  20440. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  20441. }
  20442. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20443. // It returns an error if the edge is not defined in the schema.
  20444. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  20445. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  20446. }
  20447. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  20448. type LabelMutation struct {
  20449. config
  20450. op Op
  20451. typ string
  20452. id *uint64
  20453. created_at *time.Time
  20454. updated_at *time.Time
  20455. status *uint8
  20456. addstatus *int8
  20457. deleted_at *time.Time
  20458. _type *int
  20459. add_type *int
  20460. name *string
  20461. from *int
  20462. addfrom *int
  20463. mode *int
  20464. addmode *int
  20465. conditions *string
  20466. organization_id *uint64
  20467. addorganization_id *int64
  20468. clearedFields map[string]struct{}
  20469. label_relationships map[uint64]struct{}
  20470. removedlabel_relationships map[uint64]struct{}
  20471. clearedlabel_relationships bool
  20472. done bool
  20473. oldValue func(context.Context) (*Label, error)
  20474. predicates []predicate.Label
  20475. }
  20476. var _ ent.Mutation = (*LabelMutation)(nil)
  20477. // labelOption allows management of the mutation configuration using functional options.
  20478. type labelOption func(*LabelMutation)
  20479. // newLabelMutation creates new mutation for the Label entity.
  20480. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  20481. m := &LabelMutation{
  20482. config: c,
  20483. op: op,
  20484. typ: TypeLabel,
  20485. clearedFields: make(map[string]struct{}),
  20486. }
  20487. for _, opt := range opts {
  20488. opt(m)
  20489. }
  20490. return m
  20491. }
  20492. // withLabelID sets the ID field of the mutation.
  20493. func withLabelID(id uint64) labelOption {
  20494. return func(m *LabelMutation) {
  20495. var (
  20496. err error
  20497. once sync.Once
  20498. value *Label
  20499. )
  20500. m.oldValue = func(ctx context.Context) (*Label, error) {
  20501. once.Do(func() {
  20502. if m.done {
  20503. err = errors.New("querying old values post mutation is not allowed")
  20504. } else {
  20505. value, err = m.Client().Label.Get(ctx, id)
  20506. }
  20507. })
  20508. return value, err
  20509. }
  20510. m.id = &id
  20511. }
  20512. }
  20513. // withLabel sets the old Label of the mutation.
  20514. func withLabel(node *Label) labelOption {
  20515. return func(m *LabelMutation) {
  20516. m.oldValue = func(context.Context) (*Label, error) {
  20517. return node, nil
  20518. }
  20519. m.id = &node.ID
  20520. }
  20521. }
  20522. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20523. // executed in a transaction (ent.Tx), a transactional client is returned.
  20524. func (m LabelMutation) Client() *Client {
  20525. client := &Client{config: m.config}
  20526. client.init()
  20527. return client
  20528. }
  20529. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20530. // it returns an error otherwise.
  20531. func (m LabelMutation) Tx() (*Tx, error) {
  20532. if _, ok := m.driver.(*txDriver); !ok {
  20533. return nil, errors.New("ent: mutation is not running in a transaction")
  20534. }
  20535. tx := &Tx{config: m.config}
  20536. tx.init()
  20537. return tx, nil
  20538. }
  20539. // SetID sets the value of the id field. Note that this
  20540. // operation is only accepted on creation of Label entities.
  20541. func (m *LabelMutation) SetID(id uint64) {
  20542. m.id = &id
  20543. }
  20544. // ID returns the ID value in the mutation. Note that the ID is only available
  20545. // if it was provided to the builder or after it was returned from the database.
  20546. func (m *LabelMutation) ID() (id uint64, exists bool) {
  20547. if m.id == nil {
  20548. return
  20549. }
  20550. return *m.id, true
  20551. }
  20552. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20553. // That means, if the mutation is applied within a transaction with an isolation level such
  20554. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20555. // or updated by the mutation.
  20556. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  20557. switch {
  20558. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20559. id, exists := m.ID()
  20560. if exists {
  20561. return []uint64{id}, nil
  20562. }
  20563. fallthrough
  20564. case m.op.Is(OpUpdate | OpDelete):
  20565. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  20566. default:
  20567. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20568. }
  20569. }
  20570. // SetCreatedAt sets the "created_at" field.
  20571. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  20572. m.created_at = &t
  20573. }
  20574. // CreatedAt returns the value of the "created_at" field in the mutation.
  20575. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  20576. v := m.created_at
  20577. if v == nil {
  20578. return
  20579. }
  20580. return *v, true
  20581. }
  20582. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  20583. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20585. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20586. if !m.op.Is(OpUpdateOne) {
  20587. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20588. }
  20589. if m.id == nil || m.oldValue == nil {
  20590. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20591. }
  20592. oldValue, err := m.oldValue(ctx)
  20593. if err != nil {
  20594. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20595. }
  20596. return oldValue.CreatedAt, nil
  20597. }
  20598. // ResetCreatedAt resets all changes to the "created_at" field.
  20599. func (m *LabelMutation) ResetCreatedAt() {
  20600. m.created_at = nil
  20601. }
  20602. // SetUpdatedAt sets the "updated_at" field.
  20603. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  20604. m.updated_at = &t
  20605. }
  20606. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20607. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  20608. v := m.updated_at
  20609. if v == nil {
  20610. return
  20611. }
  20612. return *v, true
  20613. }
  20614. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  20615. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20617. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20618. if !m.op.Is(OpUpdateOne) {
  20619. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20620. }
  20621. if m.id == nil || m.oldValue == nil {
  20622. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20623. }
  20624. oldValue, err := m.oldValue(ctx)
  20625. if err != nil {
  20626. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20627. }
  20628. return oldValue.UpdatedAt, nil
  20629. }
  20630. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20631. func (m *LabelMutation) ResetUpdatedAt() {
  20632. m.updated_at = nil
  20633. }
  20634. // SetStatus sets the "status" field.
  20635. func (m *LabelMutation) SetStatus(u uint8) {
  20636. m.status = &u
  20637. m.addstatus = nil
  20638. }
  20639. // Status returns the value of the "status" field in the mutation.
  20640. func (m *LabelMutation) Status() (r uint8, exists bool) {
  20641. v := m.status
  20642. if v == nil {
  20643. return
  20644. }
  20645. return *v, true
  20646. }
  20647. // OldStatus returns the old "status" field's value of the Label entity.
  20648. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20650. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20651. if !m.op.Is(OpUpdateOne) {
  20652. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20653. }
  20654. if m.id == nil || m.oldValue == nil {
  20655. return v, errors.New("OldStatus requires an ID field in the mutation")
  20656. }
  20657. oldValue, err := m.oldValue(ctx)
  20658. if err != nil {
  20659. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20660. }
  20661. return oldValue.Status, nil
  20662. }
  20663. // AddStatus adds u to the "status" field.
  20664. func (m *LabelMutation) AddStatus(u int8) {
  20665. if m.addstatus != nil {
  20666. *m.addstatus += u
  20667. } else {
  20668. m.addstatus = &u
  20669. }
  20670. }
  20671. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20672. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  20673. v := m.addstatus
  20674. if v == nil {
  20675. return
  20676. }
  20677. return *v, true
  20678. }
  20679. // ClearStatus clears the value of the "status" field.
  20680. func (m *LabelMutation) ClearStatus() {
  20681. m.status = nil
  20682. m.addstatus = nil
  20683. m.clearedFields[label.FieldStatus] = struct{}{}
  20684. }
  20685. // StatusCleared returns if the "status" field was cleared in this mutation.
  20686. func (m *LabelMutation) StatusCleared() bool {
  20687. _, ok := m.clearedFields[label.FieldStatus]
  20688. return ok
  20689. }
  20690. // ResetStatus resets all changes to the "status" field.
  20691. func (m *LabelMutation) ResetStatus() {
  20692. m.status = nil
  20693. m.addstatus = nil
  20694. delete(m.clearedFields, label.FieldStatus)
  20695. }
  20696. // SetDeletedAt sets the "deleted_at" field.
  20697. func (m *LabelMutation) SetDeletedAt(t time.Time) {
  20698. m.deleted_at = &t
  20699. }
  20700. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20701. func (m *LabelMutation) DeletedAt() (r time.Time, exists bool) {
  20702. v := m.deleted_at
  20703. if v == nil {
  20704. return
  20705. }
  20706. return *v, true
  20707. }
  20708. // OldDeletedAt returns the old "deleted_at" field's value of the Label entity.
  20709. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20711. func (m *LabelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20712. if !m.op.Is(OpUpdateOne) {
  20713. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20714. }
  20715. if m.id == nil || m.oldValue == nil {
  20716. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20717. }
  20718. oldValue, err := m.oldValue(ctx)
  20719. if err != nil {
  20720. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20721. }
  20722. return oldValue.DeletedAt, nil
  20723. }
  20724. // ClearDeletedAt clears the value of the "deleted_at" field.
  20725. func (m *LabelMutation) ClearDeletedAt() {
  20726. m.deleted_at = nil
  20727. m.clearedFields[label.FieldDeletedAt] = struct{}{}
  20728. }
  20729. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20730. func (m *LabelMutation) DeletedAtCleared() bool {
  20731. _, ok := m.clearedFields[label.FieldDeletedAt]
  20732. return ok
  20733. }
  20734. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20735. func (m *LabelMutation) ResetDeletedAt() {
  20736. m.deleted_at = nil
  20737. delete(m.clearedFields, label.FieldDeletedAt)
  20738. }
  20739. // SetType sets the "type" field.
  20740. func (m *LabelMutation) SetType(i int) {
  20741. m._type = &i
  20742. m.add_type = nil
  20743. }
  20744. // GetType returns the value of the "type" field in the mutation.
  20745. func (m *LabelMutation) GetType() (r int, exists bool) {
  20746. v := m._type
  20747. if v == nil {
  20748. return
  20749. }
  20750. return *v, true
  20751. }
  20752. // OldType returns the old "type" field's value of the Label entity.
  20753. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20755. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  20756. if !m.op.Is(OpUpdateOne) {
  20757. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20758. }
  20759. if m.id == nil || m.oldValue == nil {
  20760. return v, errors.New("OldType requires an ID field in the mutation")
  20761. }
  20762. oldValue, err := m.oldValue(ctx)
  20763. if err != nil {
  20764. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20765. }
  20766. return oldValue.Type, nil
  20767. }
  20768. // AddType adds i to the "type" field.
  20769. func (m *LabelMutation) AddType(i int) {
  20770. if m.add_type != nil {
  20771. *m.add_type += i
  20772. } else {
  20773. m.add_type = &i
  20774. }
  20775. }
  20776. // AddedType returns the value that was added to the "type" field in this mutation.
  20777. func (m *LabelMutation) AddedType() (r int, exists bool) {
  20778. v := m.add_type
  20779. if v == nil {
  20780. return
  20781. }
  20782. return *v, true
  20783. }
  20784. // ResetType resets all changes to the "type" field.
  20785. func (m *LabelMutation) ResetType() {
  20786. m._type = nil
  20787. m.add_type = nil
  20788. }
  20789. // SetName sets the "name" field.
  20790. func (m *LabelMutation) SetName(s string) {
  20791. m.name = &s
  20792. }
  20793. // Name returns the value of the "name" field in the mutation.
  20794. func (m *LabelMutation) Name() (r string, exists bool) {
  20795. v := m.name
  20796. if v == nil {
  20797. return
  20798. }
  20799. return *v, true
  20800. }
  20801. // OldName returns the old "name" field's value of the Label entity.
  20802. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20804. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  20805. if !m.op.Is(OpUpdateOne) {
  20806. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20807. }
  20808. if m.id == nil || m.oldValue == nil {
  20809. return v, errors.New("OldName requires an ID field in the mutation")
  20810. }
  20811. oldValue, err := m.oldValue(ctx)
  20812. if err != nil {
  20813. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20814. }
  20815. return oldValue.Name, nil
  20816. }
  20817. // ResetName resets all changes to the "name" field.
  20818. func (m *LabelMutation) ResetName() {
  20819. m.name = nil
  20820. }
  20821. // SetFrom sets the "from" field.
  20822. func (m *LabelMutation) SetFrom(i int) {
  20823. m.from = &i
  20824. m.addfrom = nil
  20825. }
  20826. // From returns the value of the "from" field in the mutation.
  20827. func (m *LabelMutation) From() (r int, exists bool) {
  20828. v := m.from
  20829. if v == nil {
  20830. return
  20831. }
  20832. return *v, true
  20833. }
  20834. // OldFrom returns the old "from" field's value of the Label entity.
  20835. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20837. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  20838. if !m.op.Is(OpUpdateOne) {
  20839. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  20840. }
  20841. if m.id == nil || m.oldValue == nil {
  20842. return v, errors.New("OldFrom requires an ID field in the mutation")
  20843. }
  20844. oldValue, err := m.oldValue(ctx)
  20845. if err != nil {
  20846. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  20847. }
  20848. return oldValue.From, nil
  20849. }
  20850. // AddFrom adds i to the "from" field.
  20851. func (m *LabelMutation) AddFrom(i int) {
  20852. if m.addfrom != nil {
  20853. *m.addfrom += i
  20854. } else {
  20855. m.addfrom = &i
  20856. }
  20857. }
  20858. // AddedFrom returns the value that was added to the "from" field in this mutation.
  20859. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  20860. v := m.addfrom
  20861. if v == nil {
  20862. return
  20863. }
  20864. return *v, true
  20865. }
  20866. // ResetFrom resets all changes to the "from" field.
  20867. func (m *LabelMutation) ResetFrom() {
  20868. m.from = nil
  20869. m.addfrom = nil
  20870. }
  20871. // SetMode sets the "mode" field.
  20872. func (m *LabelMutation) SetMode(i int) {
  20873. m.mode = &i
  20874. m.addmode = nil
  20875. }
  20876. // Mode returns the value of the "mode" field in the mutation.
  20877. func (m *LabelMutation) Mode() (r int, exists bool) {
  20878. v := m.mode
  20879. if v == nil {
  20880. return
  20881. }
  20882. return *v, true
  20883. }
  20884. // OldMode returns the old "mode" field's value of the Label entity.
  20885. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20887. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  20888. if !m.op.Is(OpUpdateOne) {
  20889. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  20890. }
  20891. if m.id == nil || m.oldValue == nil {
  20892. return v, errors.New("OldMode requires an ID field in the mutation")
  20893. }
  20894. oldValue, err := m.oldValue(ctx)
  20895. if err != nil {
  20896. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  20897. }
  20898. return oldValue.Mode, nil
  20899. }
  20900. // AddMode adds i to the "mode" field.
  20901. func (m *LabelMutation) AddMode(i int) {
  20902. if m.addmode != nil {
  20903. *m.addmode += i
  20904. } else {
  20905. m.addmode = &i
  20906. }
  20907. }
  20908. // AddedMode returns the value that was added to the "mode" field in this mutation.
  20909. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  20910. v := m.addmode
  20911. if v == nil {
  20912. return
  20913. }
  20914. return *v, true
  20915. }
  20916. // ResetMode resets all changes to the "mode" field.
  20917. func (m *LabelMutation) ResetMode() {
  20918. m.mode = nil
  20919. m.addmode = nil
  20920. }
  20921. // SetConditions sets the "conditions" field.
  20922. func (m *LabelMutation) SetConditions(s string) {
  20923. m.conditions = &s
  20924. }
  20925. // Conditions returns the value of the "conditions" field in the mutation.
  20926. func (m *LabelMutation) Conditions() (r string, exists bool) {
  20927. v := m.conditions
  20928. if v == nil {
  20929. return
  20930. }
  20931. return *v, true
  20932. }
  20933. // OldConditions returns the old "conditions" field's value of the Label entity.
  20934. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20936. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  20937. if !m.op.Is(OpUpdateOne) {
  20938. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20939. }
  20940. if m.id == nil || m.oldValue == nil {
  20941. return v, errors.New("OldConditions requires an ID field in the mutation")
  20942. }
  20943. oldValue, err := m.oldValue(ctx)
  20944. if err != nil {
  20945. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20946. }
  20947. return oldValue.Conditions, nil
  20948. }
  20949. // ClearConditions clears the value of the "conditions" field.
  20950. func (m *LabelMutation) ClearConditions() {
  20951. m.conditions = nil
  20952. m.clearedFields[label.FieldConditions] = struct{}{}
  20953. }
  20954. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  20955. func (m *LabelMutation) ConditionsCleared() bool {
  20956. _, ok := m.clearedFields[label.FieldConditions]
  20957. return ok
  20958. }
  20959. // ResetConditions resets all changes to the "conditions" field.
  20960. func (m *LabelMutation) ResetConditions() {
  20961. m.conditions = nil
  20962. delete(m.clearedFields, label.FieldConditions)
  20963. }
  20964. // SetOrganizationID sets the "organization_id" field.
  20965. func (m *LabelMutation) SetOrganizationID(u uint64) {
  20966. m.organization_id = &u
  20967. m.addorganization_id = nil
  20968. }
  20969. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20970. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  20971. v := m.organization_id
  20972. if v == nil {
  20973. return
  20974. }
  20975. return *v, true
  20976. }
  20977. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  20978. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20980. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20981. if !m.op.Is(OpUpdateOne) {
  20982. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20983. }
  20984. if m.id == nil || m.oldValue == nil {
  20985. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20986. }
  20987. oldValue, err := m.oldValue(ctx)
  20988. if err != nil {
  20989. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20990. }
  20991. return oldValue.OrganizationID, nil
  20992. }
  20993. // AddOrganizationID adds u to the "organization_id" field.
  20994. func (m *LabelMutation) AddOrganizationID(u int64) {
  20995. if m.addorganization_id != nil {
  20996. *m.addorganization_id += u
  20997. } else {
  20998. m.addorganization_id = &u
  20999. }
  21000. }
  21001. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21002. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  21003. v := m.addorganization_id
  21004. if v == nil {
  21005. return
  21006. }
  21007. return *v, true
  21008. }
  21009. // ClearOrganizationID clears the value of the "organization_id" field.
  21010. func (m *LabelMutation) ClearOrganizationID() {
  21011. m.organization_id = nil
  21012. m.addorganization_id = nil
  21013. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  21014. }
  21015. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21016. func (m *LabelMutation) OrganizationIDCleared() bool {
  21017. _, ok := m.clearedFields[label.FieldOrganizationID]
  21018. return ok
  21019. }
  21020. // ResetOrganizationID resets all changes to the "organization_id" field.
  21021. func (m *LabelMutation) ResetOrganizationID() {
  21022. m.organization_id = nil
  21023. m.addorganization_id = nil
  21024. delete(m.clearedFields, label.FieldOrganizationID)
  21025. }
  21026. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  21027. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  21028. if m.label_relationships == nil {
  21029. m.label_relationships = make(map[uint64]struct{})
  21030. }
  21031. for i := range ids {
  21032. m.label_relationships[ids[i]] = struct{}{}
  21033. }
  21034. }
  21035. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  21036. func (m *LabelMutation) ClearLabelRelationships() {
  21037. m.clearedlabel_relationships = true
  21038. }
  21039. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  21040. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  21041. return m.clearedlabel_relationships
  21042. }
  21043. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  21044. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  21045. if m.removedlabel_relationships == nil {
  21046. m.removedlabel_relationships = make(map[uint64]struct{})
  21047. }
  21048. for i := range ids {
  21049. delete(m.label_relationships, ids[i])
  21050. m.removedlabel_relationships[ids[i]] = struct{}{}
  21051. }
  21052. }
  21053. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  21054. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  21055. for id := range m.removedlabel_relationships {
  21056. ids = append(ids, id)
  21057. }
  21058. return
  21059. }
  21060. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  21061. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  21062. for id := range m.label_relationships {
  21063. ids = append(ids, id)
  21064. }
  21065. return
  21066. }
  21067. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  21068. func (m *LabelMutation) ResetLabelRelationships() {
  21069. m.label_relationships = nil
  21070. m.clearedlabel_relationships = false
  21071. m.removedlabel_relationships = nil
  21072. }
  21073. // Where appends a list predicates to the LabelMutation builder.
  21074. func (m *LabelMutation) Where(ps ...predicate.Label) {
  21075. m.predicates = append(m.predicates, ps...)
  21076. }
  21077. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  21078. // users can use type-assertion to append predicates that do not depend on any generated package.
  21079. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  21080. p := make([]predicate.Label, len(ps))
  21081. for i := range ps {
  21082. p[i] = ps[i]
  21083. }
  21084. m.Where(p...)
  21085. }
  21086. // Op returns the operation name.
  21087. func (m *LabelMutation) Op() Op {
  21088. return m.op
  21089. }
  21090. // SetOp allows setting the mutation operation.
  21091. func (m *LabelMutation) SetOp(op Op) {
  21092. m.op = op
  21093. }
  21094. // Type returns the node type of this mutation (Label).
  21095. func (m *LabelMutation) Type() string {
  21096. return m.typ
  21097. }
  21098. // Fields returns all fields that were changed during this mutation. Note that in
  21099. // order to get all numeric fields that were incremented/decremented, call
  21100. // AddedFields().
  21101. func (m *LabelMutation) Fields() []string {
  21102. fields := make([]string, 0, 10)
  21103. if m.created_at != nil {
  21104. fields = append(fields, label.FieldCreatedAt)
  21105. }
  21106. if m.updated_at != nil {
  21107. fields = append(fields, label.FieldUpdatedAt)
  21108. }
  21109. if m.status != nil {
  21110. fields = append(fields, label.FieldStatus)
  21111. }
  21112. if m.deleted_at != nil {
  21113. fields = append(fields, label.FieldDeletedAt)
  21114. }
  21115. if m._type != nil {
  21116. fields = append(fields, label.FieldType)
  21117. }
  21118. if m.name != nil {
  21119. fields = append(fields, label.FieldName)
  21120. }
  21121. if m.from != nil {
  21122. fields = append(fields, label.FieldFrom)
  21123. }
  21124. if m.mode != nil {
  21125. fields = append(fields, label.FieldMode)
  21126. }
  21127. if m.conditions != nil {
  21128. fields = append(fields, label.FieldConditions)
  21129. }
  21130. if m.organization_id != nil {
  21131. fields = append(fields, label.FieldOrganizationID)
  21132. }
  21133. return fields
  21134. }
  21135. // Field returns the value of a field with the given name. The second boolean
  21136. // return value indicates that this field was not set, or was not defined in the
  21137. // schema.
  21138. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  21139. switch name {
  21140. case label.FieldCreatedAt:
  21141. return m.CreatedAt()
  21142. case label.FieldUpdatedAt:
  21143. return m.UpdatedAt()
  21144. case label.FieldStatus:
  21145. return m.Status()
  21146. case label.FieldDeletedAt:
  21147. return m.DeletedAt()
  21148. case label.FieldType:
  21149. return m.GetType()
  21150. case label.FieldName:
  21151. return m.Name()
  21152. case label.FieldFrom:
  21153. return m.From()
  21154. case label.FieldMode:
  21155. return m.Mode()
  21156. case label.FieldConditions:
  21157. return m.Conditions()
  21158. case label.FieldOrganizationID:
  21159. return m.OrganizationID()
  21160. }
  21161. return nil, false
  21162. }
  21163. // OldField returns the old value of the field from the database. An error is
  21164. // returned if the mutation operation is not UpdateOne, or the query to the
  21165. // database failed.
  21166. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21167. switch name {
  21168. case label.FieldCreatedAt:
  21169. return m.OldCreatedAt(ctx)
  21170. case label.FieldUpdatedAt:
  21171. return m.OldUpdatedAt(ctx)
  21172. case label.FieldStatus:
  21173. return m.OldStatus(ctx)
  21174. case label.FieldDeletedAt:
  21175. return m.OldDeletedAt(ctx)
  21176. case label.FieldType:
  21177. return m.OldType(ctx)
  21178. case label.FieldName:
  21179. return m.OldName(ctx)
  21180. case label.FieldFrom:
  21181. return m.OldFrom(ctx)
  21182. case label.FieldMode:
  21183. return m.OldMode(ctx)
  21184. case label.FieldConditions:
  21185. return m.OldConditions(ctx)
  21186. case label.FieldOrganizationID:
  21187. return m.OldOrganizationID(ctx)
  21188. }
  21189. return nil, fmt.Errorf("unknown Label field %s", name)
  21190. }
  21191. // SetField sets the value of a field with the given name. It returns an error if
  21192. // the field is not defined in the schema, or if the type mismatched the field
  21193. // type.
  21194. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  21195. switch name {
  21196. case label.FieldCreatedAt:
  21197. v, ok := value.(time.Time)
  21198. if !ok {
  21199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21200. }
  21201. m.SetCreatedAt(v)
  21202. return nil
  21203. case label.FieldUpdatedAt:
  21204. v, ok := value.(time.Time)
  21205. if !ok {
  21206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21207. }
  21208. m.SetUpdatedAt(v)
  21209. return nil
  21210. case label.FieldStatus:
  21211. v, ok := value.(uint8)
  21212. if !ok {
  21213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21214. }
  21215. m.SetStatus(v)
  21216. return nil
  21217. case label.FieldDeletedAt:
  21218. v, ok := value.(time.Time)
  21219. if !ok {
  21220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21221. }
  21222. m.SetDeletedAt(v)
  21223. return nil
  21224. case label.FieldType:
  21225. v, ok := value.(int)
  21226. if !ok {
  21227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21228. }
  21229. m.SetType(v)
  21230. return nil
  21231. case label.FieldName:
  21232. v, ok := value.(string)
  21233. if !ok {
  21234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21235. }
  21236. m.SetName(v)
  21237. return nil
  21238. case label.FieldFrom:
  21239. v, ok := value.(int)
  21240. if !ok {
  21241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21242. }
  21243. m.SetFrom(v)
  21244. return nil
  21245. case label.FieldMode:
  21246. v, ok := value.(int)
  21247. if !ok {
  21248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21249. }
  21250. m.SetMode(v)
  21251. return nil
  21252. case label.FieldConditions:
  21253. v, ok := value.(string)
  21254. if !ok {
  21255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21256. }
  21257. m.SetConditions(v)
  21258. return nil
  21259. case label.FieldOrganizationID:
  21260. v, ok := value.(uint64)
  21261. if !ok {
  21262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21263. }
  21264. m.SetOrganizationID(v)
  21265. return nil
  21266. }
  21267. return fmt.Errorf("unknown Label field %s", name)
  21268. }
  21269. // AddedFields returns all numeric fields that were incremented/decremented during
  21270. // this mutation.
  21271. func (m *LabelMutation) AddedFields() []string {
  21272. var fields []string
  21273. if m.addstatus != nil {
  21274. fields = append(fields, label.FieldStatus)
  21275. }
  21276. if m.add_type != nil {
  21277. fields = append(fields, label.FieldType)
  21278. }
  21279. if m.addfrom != nil {
  21280. fields = append(fields, label.FieldFrom)
  21281. }
  21282. if m.addmode != nil {
  21283. fields = append(fields, label.FieldMode)
  21284. }
  21285. if m.addorganization_id != nil {
  21286. fields = append(fields, label.FieldOrganizationID)
  21287. }
  21288. return fields
  21289. }
  21290. // AddedField returns the numeric value that was incremented/decremented on a field
  21291. // with the given name. The second boolean return value indicates that this field
  21292. // was not set, or was not defined in the schema.
  21293. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  21294. switch name {
  21295. case label.FieldStatus:
  21296. return m.AddedStatus()
  21297. case label.FieldType:
  21298. return m.AddedType()
  21299. case label.FieldFrom:
  21300. return m.AddedFrom()
  21301. case label.FieldMode:
  21302. return m.AddedMode()
  21303. case label.FieldOrganizationID:
  21304. return m.AddedOrganizationID()
  21305. }
  21306. return nil, false
  21307. }
  21308. // AddField adds the value to the field with the given name. It returns an error if
  21309. // the field is not defined in the schema, or if the type mismatched the field
  21310. // type.
  21311. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  21312. switch name {
  21313. case label.FieldStatus:
  21314. v, ok := value.(int8)
  21315. if !ok {
  21316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21317. }
  21318. m.AddStatus(v)
  21319. return nil
  21320. case label.FieldType:
  21321. v, ok := value.(int)
  21322. if !ok {
  21323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21324. }
  21325. m.AddType(v)
  21326. return nil
  21327. case label.FieldFrom:
  21328. v, ok := value.(int)
  21329. if !ok {
  21330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21331. }
  21332. m.AddFrom(v)
  21333. return nil
  21334. case label.FieldMode:
  21335. v, ok := value.(int)
  21336. if !ok {
  21337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21338. }
  21339. m.AddMode(v)
  21340. return nil
  21341. case label.FieldOrganizationID:
  21342. v, ok := value.(int64)
  21343. if !ok {
  21344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21345. }
  21346. m.AddOrganizationID(v)
  21347. return nil
  21348. }
  21349. return fmt.Errorf("unknown Label numeric field %s", name)
  21350. }
  21351. // ClearedFields returns all nullable fields that were cleared during this
  21352. // mutation.
  21353. func (m *LabelMutation) ClearedFields() []string {
  21354. var fields []string
  21355. if m.FieldCleared(label.FieldStatus) {
  21356. fields = append(fields, label.FieldStatus)
  21357. }
  21358. if m.FieldCleared(label.FieldDeletedAt) {
  21359. fields = append(fields, label.FieldDeletedAt)
  21360. }
  21361. if m.FieldCleared(label.FieldConditions) {
  21362. fields = append(fields, label.FieldConditions)
  21363. }
  21364. if m.FieldCleared(label.FieldOrganizationID) {
  21365. fields = append(fields, label.FieldOrganizationID)
  21366. }
  21367. return fields
  21368. }
  21369. // FieldCleared returns a boolean indicating if a field with the given name was
  21370. // cleared in this mutation.
  21371. func (m *LabelMutation) FieldCleared(name string) bool {
  21372. _, ok := m.clearedFields[name]
  21373. return ok
  21374. }
  21375. // ClearField clears the value of the field with the given name. It returns an
  21376. // error if the field is not defined in the schema.
  21377. func (m *LabelMutation) ClearField(name string) error {
  21378. switch name {
  21379. case label.FieldStatus:
  21380. m.ClearStatus()
  21381. return nil
  21382. case label.FieldDeletedAt:
  21383. m.ClearDeletedAt()
  21384. return nil
  21385. case label.FieldConditions:
  21386. m.ClearConditions()
  21387. return nil
  21388. case label.FieldOrganizationID:
  21389. m.ClearOrganizationID()
  21390. return nil
  21391. }
  21392. return fmt.Errorf("unknown Label nullable field %s", name)
  21393. }
  21394. // ResetField resets all changes in the mutation for the field with the given name.
  21395. // It returns an error if the field is not defined in the schema.
  21396. func (m *LabelMutation) ResetField(name string) error {
  21397. switch name {
  21398. case label.FieldCreatedAt:
  21399. m.ResetCreatedAt()
  21400. return nil
  21401. case label.FieldUpdatedAt:
  21402. m.ResetUpdatedAt()
  21403. return nil
  21404. case label.FieldStatus:
  21405. m.ResetStatus()
  21406. return nil
  21407. case label.FieldDeletedAt:
  21408. m.ResetDeletedAt()
  21409. return nil
  21410. case label.FieldType:
  21411. m.ResetType()
  21412. return nil
  21413. case label.FieldName:
  21414. m.ResetName()
  21415. return nil
  21416. case label.FieldFrom:
  21417. m.ResetFrom()
  21418. return nil
  21419. case label.FieldMode:
  21420. m.ResetMode()
  21421. return nil
  21422. case label.FieldConditions:
  21423. m.ResetConditions()
  21424. return nil
  21425. case label.FieldOrganizationID:
  21426. m.ResetOrganizationID()
  21427. return nil
  21428. }
  21429. return fmt.Errorf("unknown Label field %s", name)
  21430. }
  21431. // AddedEdges returns all edge names that were set/added in this mutation.
  21432. func (m *LabelMutation) AddedEdges() []string {
  21433. edges := make([]string, 0, 1)
  21434. if m.label_relationships != nil {
  21435. edges = append(edges, label.EdgeLabelRelationships)
  21436. }
  21437. return edges
  21438. }
  21439. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21440. // name in this mutation.
  21441. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  21442. switch name {
  21443. case label.EdgeLabelRelationships:
  21444. ids := make([]ent.Value, 0, len(m.label_relationships))
  21445. for id := range m.label_relationships {
  21446. ids = append(ids, id)
  21447. }
  21448. return ids
  21449. }
  21450. return nil
  21451. }
  21452. // RemovedEdges returns all edge names that were removed in this mutation.
  21453. func (m *LabelMutation) RemovedEdges() []string {
  21454. edges := make([]string, 0, 1)
  21455. if m.removedlabel_relationships != nil {
  21456. edges = append(edges, label.EdgeLabelRelationships)
  21457. }
  21458. return edges
  21459. }
  21460. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21461. // the given name in this mutation.
  21462. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  21463. switch name {
  21464. case label.EdgeLabelRelationships:
  21465. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  21466. for id := range m.removedlabel_relationships {
  21467. ids = append(ids, id)
  21468. }
  21469. return ids
  21470. }
  21471. return nil
  21472. }
  21473. // ClearedEdges returns all edge names that were cleared in this mutation.
  21474. func (m *LabelMutation) ClearedEdges() []string {
  21475. edges := make([]string, 0, 1)
  21476. if m.clearedlabel_relationships {
  21477. edges = append(edges, label.EdgeLabelRelationships)
  21478. }
  21479. return edges
  21480. }
  21481. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21482. // was cleared in this mutation.
  21483. func (m *LabelMutation) EdgeCleared(name string) bool {
  21484. switch name {
  21485. case label.EdgeLabelRelationships:
  21486. return m.clearedlabel_relationships
  21487. }
  21488. return false
  21489. }
  21490. // ClearEdge clears the value of the edge with the given name. It returns an error
  21491. // if that edge is not defined in the schema.
  21492. func (m *LabelMutation) ClearEdge(name string) error {
  21493. switch name {
  21494. }
  21495. return fmt.Errorf("unknown Label unique edge %s", name)
  21496. }
  21497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21498. // It returns an error if the edge is not defined in the schema.
  21499. func (m *LabelMutation) ResetEdge(name string) error {
  21500. switch name {
  21501. case label.EdgeLabelRelationships:
  21502. m.ResetLabelRelationships()
  21503. return nil
  21504. }
  21505. return fmt.Errorf("unknown Label edge %s", name)
  21506. }
  21507. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  21508. type LabelLogMutation struct {
  21509. config
  21510. op Op
  21511. typ string
  21512. id *uint64
  21513. created_at *time.Time
  21514. updated_at *time.Time
  21515. label_name *string
  21516. label_id *int
  21517. addlabel_id *int
  21518. wx_id *string
  21519. organization_id *uint64
  21520. addorganization_id *int64
  21521. clearedFields map[string]struct{}
  21522. done bool
  21523. oldValue func(context.Context) (*LabelLog, error)
  21524. predicates []predicate.LabelLog
  21525. }
  21526. var _ ent.Mutation = (*LabelLogMutation)(nil)
  21527. // labellogOption allows management of the mutation configuration using functional options.
  21528. type labellogOption func(*LabelLogMutation)
  21529. // newLabelLogMutation creates new mutation for the LabelLog entity.
  21530. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  21531. m := &LabelLogMutation{
  21532. config: c,
  21533. op: op,
  21534. typ: TypeLabelLog,
  21535. clearedFields: make(map[string]struct{}),
  21536. }
  21537. for _, opt := range opts {
  21538. opt(m)
  21539. }
  21540. return m
  21541. }
  21542. // withLabelLogID sets the ID field of the mutation.
  21543. func withLabelLogID(id uint64) labellogOption {
  21544. return func(m *LabelLogMutation) {
  21545. var (
  21546. err error
  21547. once sync.Once
  21548. value *LabelLog
  21549. )
  21550. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  21551. once.Do(func() {
  21552. if m.done {
  21553. err = errors.New("querying old values post mutation is not allowed")
  21554. } else {
  21555. value, err = m.Client().LabelLog.Get(ctx, id)
  21556. }
  21557. })
  21558. return value, err
  21559. }
  21560. m.id = &id
  21561. }
  21562. }
  21563. // withLabelLog sets the old LabelLog of the mutation.
  21564. func withLabelLog(node *LabelLog) labellogOption {
  21565. return func(m *LabelLogMutation) {
  21566. m.oldValue = func(context.Context) (*LabelLog, error) {
  21567. return node, nil
  21568. }
  21569. m.id = &node.ID
  21570. }
  21571. }
  21572. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21573. // executed in a transaction (ent.Tx), a transactional client is returned.
  21574. func (m LabelLogMutation) Client() *Client {
  21575. client := &Client{config: m.config}
  21576. client.init()
  21577. return client
  21578. }
  21579. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21580. // it returns an error otherwise.
  21581. func (m LabelLogMutation) Tx() (*Tx, error) {
  21582. if _, ok := m.driver.(*txDriver); !ok {
  21583. return nil, errors.New("ent: mutation is not running in a transaction")
  21584. }
  21585. tx := &Tx{config: m.config}
  21586. tx.init()
  21587. return tx, nil
  21588. }
  21589. // SetID sets the value of the id field. Note that this
  21590. // operation is only accepted on creation of LabelLog entities.
  21591. func (m *LabelLogMutation) SetID(id uint64) {
  21592. m.id = &id
  21593. }
  21594. // ID returns the ID value in the mutation. Note that the ID is only available
  21595. // if it was provided to the builder or after it was returned from the database.
  21596. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  21597. if m.id == nil {
  21598. return
  21599. }
  21600. return *m.id, true
  21601. }
  21602. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21603. // That means, if the mutation is applied within a transaction with an isolation level such
  21604. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21605. // or updated by the mutation.
  21606. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  21607. switch {
  21608. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21609. id, exists := m.ID()
  21610. if exists {
  21611. return []uint64{id}, nil
  21612. }
  21613. fallthrough
  21614. case m.op.Is(OpUpdate | OpDelete):
  21615. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  21616. default:
  21617. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21618. }
  21619. }
  21620. // SetCreatedAt sets the "created_at" field.
  21621. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  21622. m.created_at = &t
  21623. }
  21624. // CreatedAt returns the value of the "created_at" field in the mutation.
  21625. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  21626. v := m.created_at
  21627. if v == nil {
  21628. return
  21629. }
  21630. return *v, true
  21631. }
  21632. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  21633. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21635. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21636. if !m.op.Is(OpUpdateOne) {
  21637. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21638. }
  21639. if m.id == nil || m.oldValue == nil {
  21640. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21641. }
  21642. oldValue, err := m.oldValue(ctx)
  21643. if err != nil {
  21644. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21645. }
  21646. return oldValue.CreatedAt, nil
  21647. }
  21648. // ResetCreatedAt resets all changes to the "created_at" field.
  21649. func (m *LabelLogMutation) ResetCreatedAt() {
  21650. m.created_at = nil
  21651. }
  21652. // SetUpdatedAt sets the "updated_at" field.
  21653. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  21654. m.updated_at = &t
  21655. }
  21656. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21657. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  21658. v := m.updated_at
  21659. if v == nil {
  21660. return
  21661. }
  21662. return *v, true
  21663. }
  21664. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  21665. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21667. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21668. if !m.op.Is(OpUpdateOne) {
  21669. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21670. }
  21671. if m.id == nil || m.oldValue == nil {
  21672. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21673. }
  21674. oldValue, err := m.oldValue(ctx)
  21675. if err != nil {
  21676. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21677. }
  21678. return oldValue.UpdatedAt, nil
  21679. }
  21680. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21681. func (m *LabelLogMutation) ResetUpdatedAt() {
  21682. m.updated_at = nil
  21683. }
  21684. // SetLabelName sets the "label_name" field.
  21685. func (m *LabelLogMutation) SetLabelName(s string) {
  21686. m.label_name = &s
  21687. }
  21688. // LabelName returns the value of the "label_name" field in the mutation.
  21689. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  21690. v := m.label_name
  21691. if v == nil {
  21692. return
  21693. }
  21694. return *v, true
  21695. }
  21696. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  21697. // If the LabelLog 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 *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  21700. if !m.op.Is(OpUpdateOne) {
  21701. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  21702. }
  21703. if m.id == nil || m.oldValue == nil {
  21704. return v, errors.New("OldLabelName 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 OldLabelName: %w", err)
  21709. }
  21710. return oldValue.LabelName, nil
  21711. }
  21712. // ResetLabelName resets all changes to the "label_name" field.
  21713. func (m *LabelLogMutation) ResetLabelName() {
  21714. m.label_name = nil
  21715. }
  21716. // SetLabelID sets the "label_id" field.
  21717. func (m *LabelLogMutation) SetLabelID(i int) {
  21718. m.label_id = &i
  21719. m.addlabel_id = nil
  21720. }
  21721. // LabelID returns the value of the "label_id" field in the mutation.
  21722. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  21723. v := m.label_id
  21724. if v == nil {
  21725. return
  21726. }
  21727. return *v, true
  21728. }
  21729. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  21730. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21732. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  21733. if !m.op.Is(OpUpdateOne) {
  21734. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  21735. }
  21736. if m.id == nil || m.oldValue == nil {
  21737. return v, errors.New("OldLabelID requires an ID field in the mutation")
  21738. }
  21739. oldValue, err := m.oldValue(ctx)
  21740. if err != nil {
  21741. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  21742. }
  21743. return oldValue.LabelID, nil
  21744. }
  21745. // AddLabelID adds i to the "label_id" field.
  21746. func (m *LabelLogMutation) AddLabelID(i int) {
  21747. if m.addlabel_id != nil {
  21748. *m.addlabel_id += i
  21749. } else {
  21750. m.addlabel_id = &i
  21751. }
  21752. }
  21753. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  21754. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  21755. v := m.addlabel_id
  21756. if v == nil {
  21757. return
  21758. }
  21759. return *v, true
  21760. }
  21761. // ResetLabelID resets all changes to the "label_id" field.
  21762. func (m *LabelLogMutation) ResetLabelID() {
  21763. m.label_id = nil
  21764. m.addlabel_id = nil
  21765. }
  21766. // SetWxID sets the "wx_id" field.
  21767. func (m *LabelLogMutation) SetWxID(s string) {
  21768. m.wx_id = &s
  21769. }
  21770. // WxID returns the value of the "wx_id" field in the mutation.
  21771. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  21772. v := m.wx_id
  21773. if v == nil {
  21774. return
  21775. }
  21776. return *v, true
  21777. }
  21778. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  21779. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21781. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  21782. if !m.op.Is(OpUpdateOne) {
  21783. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  21784. }
  21785. if m.id == nil || m.oldValue == nil {
  21786. return v, errors.New("OldWxID requires an ID field in the mutation")
  21787. }
  21788. oldValue, err := m.oldValue(ctx)
  21789. if err != nil {
  21790. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  21791. }
  21792. return oldValue.WxID, nil
  21793. }
  21794. // ResetWxID resets all changes to the "wx_id" field.
  21795. func (m *LabelLogMutation) ResetWxID() {
  21796. m.wx_id = nil
  21797. }
  21798. // SetOrganizationID sets the "organization_id" field.
  21799. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  21800. m.organization_id = &u
  21801. m.addorganization_id = nil
  21802. }
  21803. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21804. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  21805. v := m.organization_id
  21806. if v == nil {
  21807. return
  21808. }
  21809. return *v, true
  21810. }
  21811. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  21812. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21814. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21815. if !m.op.Is(OpUpdateOne) {
  21816. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21817. }
  21818. if m.id == nil || m.oldValue == nil {
  21819. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21820. }
  21821. oldValue, err := m.oldValue(ctx)
  21822. if err != nil {
  21823. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21824. }
  21825. return oldValue.OrganizationID, nil
  21826. }
  21827. // AddOrganizationID adds u to the "organization_id" field.
  21828. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  21829. if m.addorganization_id != nil {
  21830. *m.addorganization_id += u
  21831. } else {
  21832. m.addorganization_id = &u
  21833. }
  21834. }
  21835. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21836. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  21837. v := m.addorganization_id
  21838. if v == nil {
  21839. return
  21840. }
  21841. return *v, true
  21842. }
  21843. // ClearOrganizationID clears the value of the "organization_id" field.
  21844. func (m *LabelLogMutation) ClearOrganizationID() {
  21845. m.organization_id = nil
  21846. m.addorganization_id = nil
  21847. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  21848. }
  21849. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21850. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  21851. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  21852. return ok
  21853. }
  21854. // ResetOrganizationID resets all changes to the "organization_id" field.
  21855. func (m *LabelLogMutation) ResetOrganizationID() {
  21856. m.organization_id = nil
  21857. m.addorganization_id = nil
  21858. delete(m.clearedFields, labellog.FieldOrganizationID)
  21859. }
  21860. // Where appends a list predicates to the LabelLogMutation builder.
  21861. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  21862. m.predicates = append(m.predicates, ps...)
  21863. }
  21864. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  21865. // users can use type-assertion to append predicates that do not depend on any generated package.
  21866. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  21867. p := make([]predicate.LabelLog, len(ps))
  21868. for i := range ps {
  21869. p[i] = ps[i]
  21870. }
  21871. m.Where(p...)
  21872. }
  21873. // Op returns the operation name.
  21874. func (m *LabelLogMutation) Op() Op {
  21875. return m.op
  21876. }
  21877. // SetOp allows setting the mutation operation.
  21878. func (m *LabelLogMutation) SetOp(op Op) {
  21879. m.op = op
  21880. }
  21881. // Type returns the node type of this mutation (LabelLog).
  21882. func (m *LabelLogMutation) Type() string {
  21883. return m.typ
  21884. }
  21885. // Fields returns all fields that were changed during this mutation. Note that in
  21886. // order to get all numeric fields that were incremented/decremented, call
  21887. // AddedFields().
  21888. func (m *LabelLogMutation) Fields() []string {
  21889. fields := make([]string, 0, 6)
  21890. if m.created_at != nil {
  21891. fields = append(fields, labellog.FieldCreatedAt)
  21892. }
  21893. if m.updated_at != nil {
  21894. fields = append(fields, labellog.FieldUpdatedAt)
  21895. }
  21896. if m.label_name != nil {
  21897. fields = append(fields, labellog.FieldLabelName)
  21898. }
  21899. if m.label_id != nil {
  21900. fields = append(fields, labellog.FieldLabelID)
  21901. }
  21902. if m.wx_id != nil {
  21903. fields = append(fields, labellog.FieldWxID)
  21904. }
  21905. if m.organization_id != nil {
  21906. fields = append(fields, labellog.FieldOrganizationID)
  21907. }
  21908. return fields
  21909. }
  21910. // Field returns the value of a field with the given name. The second boolean
  21911. // return value indicates that this field was not set, or was not defined in the
  21912. // schema.
  21913. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  21914. switch name {
  21915. case labellog.FieldCreatedAt:
  21916. return m.CreatedAt()
  21917. case labellog.FieldUpdatedAt:
  21918. return m.UpdatedAt()
  21919. case labellog.FieldLabelName:
  21920. return m.LabelName()
  21921. case labellog.FieldLabelID:
  21922. return m.LabelID()
  21923. case labellog.FieldWxID:
  21924. return m.WxID()
  21925. case labellog.FieldOrganizationID:
  21926. return m.OrganizationID()
  21927. }
  21928. return nil, false
  21929. }
  21930. // OldField returns the old value of the field from the database. An error is
  21931. // returned if the mutation operation is not UpdateOne, or the query to the
  21932. // database failed.
  21933. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21934. switch name {
  21935. case labellog.FieldCreatedAt:
  21936. return m.OldCreatedAt(ctx)
  21937. case labellog.FieldUpdatedAt:
  21938. return m.OldUpdatedAt(ctx)
  21939. case labellog.FieldLabelName:
  21940. return m.OldLabelName(ctx)
  21941. case labellog.FieldLabelID:
  21942. return m.OldLabelID(ctx)
  21943. case labellog.FieldWxID:
  21944. return m.OldWxID(ctx)
  21945. case labellog.FieldOrganizationID:
  21946. return m.OldOrganizationID(ctx)
  21947. }
  21948. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  21949. }
  21950. // SetField sets the value of a field with the given name. It returns an error if
  21951. // the field is not defined in the schema, or if the type mismatched the field
  21952. // type.
  21953. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  21954. switch name {
  21955. case labellog.FieldCreatedAt:
  21956. v, ok := value.(time.Time)
  21957. if !ok {
  21958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21959. }
  21960. m.SetCreatedAt(v)
  21961. return nil
  21962. case labellog.FieldUpdatedAt:
  21963. v, ok := value.(time.Time)
  21964. if !ok {
  21965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21966. }
  21967. m.SetUpdatedAt(v)
  21968. return nil
  21969. case labellog.FieldLabelName:
  21970. v, ok := value.(string)
  21971. if !ok {
  21972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21973. }
  21974. m.SetLabelName(v)
  21975. return nil
  21976. case labellog.FieldLabelID:
  21977. v, ok := value.(int)
  21978. if !ok {
  21979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21980. }
  21981. m.SetLabelID(v)
  21982. return nil
  21983. case labellog.FieldWxID:
  21984. v, ok := value.(string)
  21985. if !ok {
  21986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21987. }
  21988. m.SetWxID(v)
  21989. return nil
  21990. case labellog.FieldOrganizationID:
  21991. v, ok := value.(uint64)
  21992. if !ok {
  21993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21994. }
  21995. m.SetOrganizationID(v)
  21996. return nil
  21997. }
  21998. return fmt.Errorf("unknown LabelLog field %s", name)
  21999. }
  22000. // AddedFields returns all numeric fields that were incremented/decremented during
  22001. // this mutation.
  22002. func (m *LabelLogMutation) AddedFields() []string {
  22003. var fields []string
  22004. if m.addlabel_id != nil {
  22005. fields = append(fields, labellog.FieldLabelID)
  22006. }
  22007. if m.addorganization_id != nil {
  22008. fields = append(fields, labellog.FieldOrganizationID)
  22009. }
  22010. return fields
  22011. }
  22012. // AddedField returns the numeric value that was incremented/decremented on a field
  22013. // with the given name. The second boolean return value indicates that this field
  22014. // was not set, or was not defined in the schema.
  22015. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  22016. switch name {
  22017. case labellog.FieldLabelID:
  22018. return m.AddedLabelID()
  22019. case labellog.FieldOrganizationID:
  22020. return m.AddedOrganizationID()
  22021. }
  22022. return nil, false
  22023. }
  22024. // AddField adds the value to the field with the given name. It returns an error if
  22025. // the field is not defined in the schema, or if the type mismatched the field
  22026. // type.
  22027. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  22028. switch name {
  22029. case labellog.FieldLabelID:
  22030. v, ok := value.(int)
  22031. if !ok {
  22032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22033. }
  22034. m.AddLabelID(v)
  22035. return nil
  22036. case labellog.FieldOrganizationID:
  22037. v, ok := value.(int64)
  22038. if !ok {
  22039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22040. }
  22041. m.AddOrganizationID(v)
  22042. return nil
  22043. }
  22044. return fmt.Errorf("unknown LabelLog numeric field %s", name)
  22045. }
  22046. // ClearedFields returns all nullable fields that were cleared during this
  22047. // mutation.
  22048. func (m *LabelLogMutation) ClearedFields() []string {
  22049. var fields []string
  22050. if m.FieldCleared(labellog.FieldOrganizationID) {
  22051. fields = append(fields, labellog.FieldOrganizationID)
  22052. }
  22053. return fields
  22054. }
  22055. // FieldCleared returns a boolean indicating if a field with the given name was
  22056. // cleared in this mutation.
  22057. func (m *LabelLogMutation) FieldCleared(name string) bool {
  22058. _, ok := m.clearedFields[name]
  22059. return ok
  22060. }
  22061. // ClearField clears the value of the field with the given name. It returns an
  22062. // error if the field is not defined in the schema.
  22063. func (m *LabelLogMutation) ClearField(name string) error {
  22064. switch name {
  22065. case labellog.FieldOrganizationID:
  22066. m.ClearOrganizationID()
  22067. return nil
  22068. }
  22069. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  22070. }
  22071. // ResetField resets all changes in the mutation for the field with the given name.
  22072. // It returns an error if the field is not defined in the schema.
  22073. func (m *LabelLogMutation) ResetField(name string) error {
  22074. switch name {
  22075. case labellog.FieldCreatedAt:
  22076. m.ResetCreatedAt()
  22077. return nil
  22078. case labellog.FieldUpdatedAt:
  22079. m.ResetUpdatedAt()
  22080. return nil
  22081. case labellog.FieldLabelName:
  22082. m.ResetLabelName()
  22083. return nil
  22084. case labellog.FieldLabelID:
  22085. m.ResetLabelID()
  22086. return nil
  22087. case labellog.FieldWxID:
  22088. m.ResetWxID()
  22089. return nil
  22090. case labellog.FieldOrganizationID:
  22091. m.ResetOrganizationID()
  22092. return nil
  22093. }
  22094. return fmt.Errorf("unknown LabelLog field %s", name)
  22095. }
  22096. // AddedEdges returns all edge names that were set/added in this mutation.
  22097. func (m *LabelLogMutation) AddedEdges() []string {
  22098. edges := make([]string, 0, 0)
  22099. return edges
  22100. }
  22101. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22102. // name in this mutation.
  22103. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  22104. return nil
  22105. }
  22106. // RemovedEdges returns all edge names that were removed in this mutation.
  22107. func (m *LabelLogMutation) RemovedEdges() []string {
  22108. edges := make([]string, 0, 0)
  22109. return edges
  22110. }
  22111. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22112. // the given name in this mutation.
  22113. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  22114. return nil
  22115. }
  22116. // ClearedEdges returns all edge names that were cleared in this mutation.
  22117. func (m *LabelLogMutation) ClearedEdges() []string {
  22118. edges := make([]string, 0, 0)
  22119. return edges
  22120. }
  22121. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22122. // was cleared in this mutation.
  22123. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  22124. return false
  22125. }
  22126. // ClearEdge clears the value of the edge with the given name. It returns an error
  22127. // if that edge is not defined in the schema.
  22128. func (m *LabelLogMutation) ClearEdge(name string) error {
  22129. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  22130. }
  22131. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22132. // It returns an error if the edge is not defined in the schema.
  22133. func (m *LabelLogMutation) ResetEdge(name string) error {
  22134. return fmt.Errorf("unknown LabelLog edge %s", name)
  22135. }
  22136. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  22137. type LabelRelationshipMutation struct {
  22138. config
  22139. op Op
  22140. typ string
  22141. id *uint64
  22142. created_at *time.Time
  22143. updated_at *time.Time
  22144. status *uint8
  22145. addstatus *int8
  22146. organization_id *uint64
  22147. addorganization_id *int64
  22148. clearedFields map[string]struct{}
  22149. contacts *uint64
  22150. clearedcontacts bool
  22151. labels *uint64
  22152. clearedlabels bool
  22153. done bool
  22154. oldValue func(context.Context) (*LabelRelationship, error)
  22155. predicates []predicate.LabelRelationship
  22156. }
  22157. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  22158. // labelrelationshipOption allows management of the mutation configuration using functional options.
  22159. type labelrelationshipOption func(*LabelRelationshipMutation)
  22160. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  22161. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  22162. m := &LabelRelationshipMutation{
  22163. config: c,
  22164. op: op,
  22165. typ: TypeLabelRelationship,
  22166. clearedFields: make(map[string]struct{}),
  22167. }
  22168. for _, opt := range opts {
  22169. opt(m)
  22170. }
  22171. return m
  22172. }
  22173. // withLabelRelationshipID sets the ID field of the mutation.
  22174. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  22175. return func(m *LabelRelationshipMutation) {
  22176. var (
  22177. err error
  22178. once sync.Once
  22179. value *LabelRelationship
  22180. )
  22181. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  22182. once.Do(func() {
  22183. if m.done {
  22184. err = errors.New("querying old values post mutation is not allowed")
  22185. } else {
  22186. value, err = m.Client().LabelRelationship.Get(ctx, id)
  22187. }
  22188. })
  22189. return value, err
  22190. }
  22191. m.id = &id
  22192. }
  22193. }
  22194. // withLabelRelationship sets the old LabelRelationship of the mutation.
  22195. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  22196. return func(m *LabelRelationshipMutation) {
  22197. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  22198. return node, nil
  22199. }
  22200. m.id = &node.ID
  22201. }
  22202. }
  22203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22204. // executed in a transaction (ent.Tx), a transactional client is returned.
  22205. func (m LabelRelationshipMutation) Client() *Client {
  22206. client := &Client{config: m.config}
  22207. client.init()
  22208. return client
  22209. }
  22210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22211. // it returns an error otherwise.
  22212. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  22213. if _, ok := m.driver.(*txDriver); !ok {
  22214. return nil, errors.New("ent: mutation is not running in a transaction")
  22215. }
  22216. tx := &Tx{config: m.config}
  22217. tx.init()
  22218. return tx, nil
  22219. }
  22220. // SetID sets the value of the id field. Note that this
  22221. // operation is only accepted on creation of LabelRelationship entities.
  22222. func (m *LabelRelationshipMutation) SetID(id uint64) {
  22223. m.id = &id
  22224. }
  22225. // ID returns the ID value in the mutation. Note that the ID is only available
  22226. // if it was provided to the builder or after it was returned from the database.
  22227. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  22228. if m.id == nil {
  22229. return
  22230. }
  22231. return *m.id, true
  22232. }
  22233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22234. // That means, if the mutation is applied within a transaction with an isolation level such
  22235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22236. // or updated by the mutation.
  22237. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  22238. switch {
  22239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22240. id, exists := m.ID()
  22241. if exists {
  22242. return []uint64{id}, nil
  22243. }
  22244. fallthrough
  22245. case m.op.Is(OpUpdate | OpDelete):
  22246. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  22247. default:
  22248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22249. }
  22250. }
  22251. // SetCreatedAt sets the "created_at" field.
  22252. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  22253. m.created_at = &t
  22254. }
  22255. // CreatedAt returns the value of the "created_at" field in the mutation.
  22256. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  22257. v := m.created_at
  22258. if v == nil {
  22259. return
  22260. }
  22261. return *v, true
  22262. }
  22263. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  22264. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22266. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22267. if !m.op.Is(OpUpdateOne) {
  22268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22269. }
  22270. if m.id == nil || m.oldValue == nil {
  22271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22272. }
  22273. oldValue, err := m.oldValue(ctx)
  22274. if err != nil {
  22275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22276. }
  22277. return oldValue.CreatedAt, nil
  22278. }
  22279. // ResetCreatedAt resets all changes to the "created_at" field.
  22280. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  22281. m.created_at = nil
  22282. }
  22283. // SetUpdatedAt sets the "updated_at" field.
  22284. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  22285. m.updated_at = &t
  22286. }
  22287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22288. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  22289. v := m.updated_at
  22290. if v == nil {
  22291. return
  22292. }
  22293. return *v, true
  22294. }
  22295. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  22296. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22298. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22299. if !m.op.Is(OpUpdateOne) {
  22300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22301. }
  22302. if m.id == nil || m.oldValue == nil {
  22303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22304. }
  22305. oldValue, err := m.oldValue(ctx)
  22306. if err != nil {
  22307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22308. }
  22309. return oldValue.UpdatedAt, nil
  22310. }
  22311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22312. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  22313. m.updated_at = nil
  22314. }
  22315. // SetStatus sets the "status" field.
  22316. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  22317. m.status = &u
  22318. m.addstatus = nil
  22319. }
  22320. // Status returns the value of the "status" field in the mutation.
  22321. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  22322. v := m.status
  22323. if v == nil {
  22324. return
  22325. }
  22326. return *v, true
  22327. }
  22328. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  22329. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22331. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22332. if !m.op.Is(OpUpdateOne) {
  22333. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22334. }
  22335. if m.id == nil || m.oldValue == nil {
  22336. return v, errors.New("OldStatus requires an ID field in the mutation")
  22337. }
  22338. oldValue, err := m.oldValue(ctx)
  22339. if err != nil {
  22340. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22341. }
  22342. return oldValue.Status, nil
  22343. }
  22344. // AddStatus adds u to the "status" field.
  22345. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  22346. if m.addstatus != nil {
  22347. *m.addstatus += u
  22348. } else {
  22349. m.addstatus = &u
  22350. }
  22351. }
  22352. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22353. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  22354. v := m.addstatus
  22355. if v == nil {
  22356. return
  22357. }
  22358. return *v, true
  22359. }
  22360. // ClearStatus clears the value of the "status" field.
  22361. func (m *LabelRelationshipMutation) ClearStatus() {
  22362. m.status = nil
  22363. m.addstatus = nil
  22364. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  22365. }
  22366. // StatusCleared returns if the "status" field was cleared in this mutation.
  22367. func (m *LabelRelationshipMutation) StatusCleared() bool {
  22368. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  22369. return ok
  22370. }
  22371. // ResetStatus resets all changes to the "status" field.
  22372. func (m *LabelRelationshipMutation) ResetStatus() {
  22373. m.status = nil
  22374. m.addstatus = nil
  22375. delete(m.clearedFields, labelrelationship.FieldStatus)
  22376. }
  22377. // SetLabelID sets the "label_id" field.
  22378. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  22379. m.labels = &u
  22380. }
  22381. // LabelID returns the value of the "label_id" field in the mutation.
  22382. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  22383. v := m.labels
  22384. if v == nil {
  22385. return
  22386. }
  22387. return *v, true
  22388. }
  22389. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  22390. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22392. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  22393. if !m.op.Is(OpUpdateOne) {
  22394. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  22395. }
  22396. if m.id == nil || m.oldValue == nil {
  22397. return v, errors.New("OldLabelID requires an ID field in the mutation")
  22398. }
  22399. oldValue, err := m.oldValue(ctx)
  22400. if err != nil {
  22401. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  22402. }
  22403. return oldValue.LabelID, nil
  22404. }
  22405. // ResetLabelID resets all changes to the "label_id" field.
  22406. func (m *LabelRelationshipMutation) ResetLabelID() {
  22407. m.labels = nil
  22408. }
  22409. // SetContactID sets the "contact_id" field.
  22410. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  22411. m.contacts = &u
  22412. }
  22413. // ContactID returns the value of the "contact_id" field in the mutation.
  22414. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  22415. v := m.contacts
  22416. if v == nil {
  22417. return
  22418. }
  22419. return *v, true
  22420. }
  22421. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  22422. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22424. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22425. if !m.op.Is(OpUpdateOne) {
  22426. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22427. }
  22428. if m.id == nil || m.oldValue == nil {
  22429. return v, errors.New("OldContactID requires an ID field in the mutation")
  22430. }
  22431. oldValue, err := m.oldValue(ctx)
  22432. if err != nil {
  22433. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22434. }
  22435. return oldValue.ContactID, nil
  22436. }
  22437. // ResetContactID resets all changes to the "contact_id" field.
  22438. func (m *LabelRelationshipMutation) ResetContactID() {
  22439. m.contacts = nil
  22440. }
  22441. // SetOrganizationID sets the "organization_id" field.
  22442. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  22443. m.organization_id = &u
  22444. m.addorganization_id = nil
  22445. }
  22446. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22447. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  22448. v := m.organization_id
  22449. if v == nil {
  22450. return
  22451. }
  22452. return *v, true
  22453. }
  22454. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  22455. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22457. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22458. if !m.op.Is(OpUpdateOne) {
  22459. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22460. }
  22461. if m.id == nil || m.oldValue == nil {
  22462. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22463. }
  22464. oldValue, err := m.oldValue(ctx)
  22465. if err != nil {
  22466. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22467. }
  22468. return oldValue.OrganizationID, nil
  22469. }
  22470. // AddOrganizationID adds u to the "organization_id" field.
  22471. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  22472. if m.addorganization_id != nil {
  22473. *m.addorganization_id += u
  22474. } else {
  22475. m.addorganization_id = &u
  22476. }
  22477. }
  22478. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22479. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  22480. v := m.addorganization_id
  22481. if v == nil {
  22482. return
  22483. }
  22484. return *v, true
  22485. }
  22486. // ClearOrganizationID clears the value of the "organization_id" field.
  22487. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  22488. m.organization_id = nil
  22489. m.addorganization_id = nil
  22490. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  22491. }
  22492. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22493. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  22494. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  22495. return ok
  22496. }
  22497. // ResetOrganizationID resets all changes to the "organization_id" field.
  22498. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  22499. m.organization_id = nil
  22500. m.addorganization_id = nil
  22501. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  22502. }
  22503. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  22504. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  22505. m.contacts = &id
  22506. }
  22507. // ClearContacts clears the "contacts" edge to the Contact entity.
  22508. func (m *LabelRelationshipMutation) ClearContacts() {
  22509. m.clearedcontacts = true
  22510. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  22511. }
  22512. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  22513. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  22514. return m.clearedcontacts
  22515. }
  22516. // ContactsID returns the "contacts" edge ID in the mutation.
  22517. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  22518. if m.contacts != nil {
  22519. return *m.contacts, true
  22520. }
  22521. return
  22522. }
  22523. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  22524. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22525. // ContactsID instead. It exists only for internal usage by the builders.
  22526. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  22527. if id := m.contacts; id != nil {
  22528. ids = append(ids, *id)
  22529. }
  22530. return
  22531. }
  22532. // ResetContacts resets all changes to the "contacts" edge.
  22533. func (m *LabelRelationshipMutation) ResetContacts() {
  22534. m.contacts = nil
  22535. m.clearedcontacts = false
  22536. }
  22537. // SetLabelsID sets the "labels" edge to the Label entity by id.
  22538. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  22539. m.labels = &id
  22540. }
  22541. // ClearLabels clears the "labels" edge to the Label entity.
  22542. func (m *LabelRelationshipMutation) ClearLabels() {
  22543. m.clearedlabels = true
  22544. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  22545. }
  22546. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  22547. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  22548. return m.clearedlabels
  22549. }
  22550. // LabelsID returns the "labels" edge ID in the mutation.
  22551. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  22552. if m.labels != nil {
  22553. return *m.labels, true
  22554. }
  22555. return
  22556. }
  22557. // LabelsIDs returns the "labels" edge IDs in the mutation.
  22558. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22559. // LabelsID instead. It exists only for internal usage by the builders.
  22560. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  22561. if id := m.labels; id != nil {
  22562. ids = append(ids, *id)
  22563. }
  22564. return
  22565. }
  22566. // ResetLabels resets all changes to the "labels" edge.
  22567. func (m *LabelRelationshipMutation) ResetLabels() {
  22568. m.labels = nil
  22569. m.clearedlabels = false
  22570. }
  22571. // Where appends a list predicates to the LabelRelationshipMutation builder.
  22572. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  22573. m.predicates = append(m.predicates, ps...)
  22574. }
  22575. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  22576. // users can use type-assertion to append predicates that do not depend on any generated package.
  22577. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  22578. p := make([]predicate.LabelRelationship, len(ps))
  22579. for i := range ps {
  22580. p[i] = ps[i]
  22581. }
  22582. m.Where(p...)
  22583. }
  22584. // Op returns the operation name.
  22585. func (m *LabelRelationshipMutation) Op() Op {
  22586. return m.op
  22587. }
  22588. // SetOp allows setting the mutation operation.
  22589. func (m *LabelRelationshipMutation) SetOp(op Op) {
  22590. m.op = op
  22591. }
  22592. // Type returns the node type of this mutation (LabelRelationship).
  22593. func (m *LabelRelationshipMutation) Type() string {
  22594. return m.typ
  22595. }
  22596. // Fields returns all fields that were changed during this mutation. Note that in
  22597. // order to get all numeric fields that were incremented/decremented, call
  22598. // AddedFields().
  22599. func (m *LabelRelationshipMutation) Fields() []string {
  22600. fields := make([]string, 0, 6)
  22601. if m.created_at != nil {
  22602. fields = append(fields, labelrelationship.FieldCreatedAt)
  22603. }
  22604. if m.updated_at != nil {
  22605. fields = append(fields, labelrelationship.FieldUpdatedAt)
  22606. }
  22607. if m.status != nil {
  22608. fields = append(fields, labelrelationship.FieldStatus)
  22609. }
  22610. if m.labels != nil {
  22611. fields = append(fields, labelrelationship.FieldLabelID)
  22612. }
  22613. if m.contacts != nil {
  22614. fields = append(fields, labelrelationship.FieldContactID)
  22615. }
  22616. if m.organization_id != nil {
  22617. fields = append(fields, labelrelationship.FieldOrganizationID)
  22618. }
  22619. return fields
  22620. }
  22621. // Field returns the value of a field with the given name. The second boolean
  22622. // return value indicates that this field was not set, or was not defined in the
  22623. // schema.
  22624. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  22625. switch name {
  22626. case labelrelationship.FieldCreatedAt:
  22627. return m.CreatedAt()
  22628. case labelrelationship.FieldUpdatedAt:
  22629. return m.UpdatedAt()
  22630. case labelrelationship.FieldStatus:
  22631. return m.Status()
  22632. case labelrelationship.FieldLabelID:
  22633. return m.LabelID()
  22634. case labelrelationship.FieldContactID:
  22635. return m.ContactID()
  22636. case labelrelationship.FieldOrganizationID:
  22637. return m.OrganizationID()
  22638. }
  22639. return nil, false
  22640. }
  22641. // OldField returns the old value of the field from the database. An error is
  22642. // returned if the mutation operation is not UpdateOne, or the query to the
  22643. // database failed.
  22644. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22645. switch name {
  22646. case labelrelationship.FieldCreatedAt:
  22647. return m.OldCreatedAt(ctx)
  22648. case labelrelationship.FieldUpdatedAt:
  22649. return m.OldUpdatedAt(ctx)
  22650. case labelrelationship.FieldStatus:
  22651. return m.OldStatus(ctx)
  22652. case labelrelationship.FieldLabelID:
  22653. return m.OldLabelID(ctx)
  22654. case labelrelationship.FieldContactID:
  22655. return m.OldContactID(ctx)
  22656. case labelrelationship.FieldOrganizationID:
  22657. return m.OldOrganizationID(ctx)
  22658. }
  22659. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  22660. }
  22661. // SetField sets the value of a field with the given name. It returns an error if
  22662. // the field is not defined in the schema, or if the type mismatched the field
  22663. // type.
  22664. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  22665. switch name {
  22666. case labelrelationship.FieldCreatedAt:
  22667. v, ok := value.(time.Time)
  22668. if !ok {
  22669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22670. }
  22671. m.SetCreatedAt(v)
  22672. return nil
  22673. case labelrelationship.FieldUpdatedAt:
  22674. v, ok := value.(time.Time)
  22675. if !ok {
  22676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22677. }
  22678. m.SetUpdatedAt(v)
  22679. return nil
  22680. case labelrelationship.FieldStatus:
  22681. v, ok := value.(uint8)
  22682. if !ok {
  22683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22684. }
  22685. m.SetStatus(v)
  22686. return nil
  22687. case labelrelationship.FieldLabelID:
  22688. v, ok := value.(uint64)
  22689. if !ok {
  22690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22691. }
  22692. m.SetLabelID(v)
  22693. return nil
  22694. case labelrelationship.FieldContactID:
  22695. v, ok := value.(uint64)
  22696. if !ok {
  22697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22698. }
  22699. m.SetContactID(v)
  22700. return nil
  22701. case labelrelationship.FieldOrganizationID:
  22702. v, ok := value.(uint64)
  22703. if !ok {
  22704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22705. }
  22706. m.SetOrganizationID(v)
  22707. return nil
  22708. }
  22709. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22710. }
  22711. // AddedFields returns all numeric fields that were incremented/decremented during
  22712. // this mutation.
  22713. func (m *LabelRelationshipMutation) AddedFields() []string {
  22714. var fields []string
  22715. if m.addstatus != nil {
  22716. fields = append(fields, labelrelationship.FieldStatus)
  22717. }
  22718. if m.addorganization_id != nil {
  22719. fields = append(fields, labelrelationship.FieldOrganizationID)
  22720. }
  22721. return fields
  22722. }
  22723. // AddedField returns the numeric value that was incremented/decremented on a field
  22724. // with the given name. The second boolean return value indicates that this field
  22725. // was not set, or was not defined in the schema.
  22726. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  22727. switch name {
  22728. case labelrelationship.FieldStatus:
  22729. return m.AddedStatus()
  22730. case labelrelationship.FieldOrganizationID:
  22731. return m.AddedOrganizationID()
  22732. }
  22733. return nil, false
  22734. }
  22735. // AddField adds the value to the field with the given name. It returns an error if
  22736. // the field is not defined in the schema, or if the type mismatched the field
  22737. // type.
  22738. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  22739. switch name {
  22740. case labelrelationship.FieldStatus:
  22741. v, ok := value.(int8)
  22742. if !ok {
  22743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22744. }
  22745. m.AddStatus(v)
  22746. return nil
  22747. case labelrelationship.FieldOrganizationID:
  22748. v, ok := value.(int64)
  22749. if !ok {
  22750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22751. }
  22752. m.AddOrganizationID(v)
  22753. return nil
  22754. }
  22755. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  22756. }
  22757. // ClearedFields returns all nullable fields that were cleared during this
  22758. // mutation.
  22759. func (m *LabelRelationshipMutation) ClearedFields() []string {
  22760. var fields []string
  22761. if m.FieldCleared(labelrelationship.FieldStatus) {
  22762. fields = append(fields, labelrelationship.FieldStatus)
  22763. }
  22764. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  22765. fields = append(fields, labelrelationship.FieldOrganizationID)
  22766. }
  22767. return fields
  22768. }
  22769. // FieldCleared returns a boolean indicating if a field with the given name was
  22770. // cleared in this mutation.
  22771. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  22772. _, ok := m.clearedFields[name]
  22773. return ok
  22774. }
  22775. // ClearField clears the value of the field with the given name. It returns an
  22776. // error if the field is not defined in the schema.
  22777. func (m *LabelRelationshipMutation) ClearField(name string) error {
  22778. switch name {
  22779. case labelrelationship.FieldStatus:
  22780. m.ClearStatus()
  22781. return nil
  22782. case labelrelationship.FieldOrganizationID:
  22783. m.ClearOrganizationID()
  22784. return nil
  22785. }
  22786. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  22787. }
  22788. // ResetField resets all changes in the mutation for the field with the given name.
  22789. // It returns an error if the field is not defined in the schema.
  22790. func (m *LabelRelationshipMutation) ResetField(name string) error {
  22791. switch name {
  22792. case labelrelationship.FieldCreatedAt:
  22793. m.ResetCreatedAt()
  22794. return nil
  22795. case labelrelationship.FieldUpdatedAt:
  22796. m.ResetUpdatedAt()
  22797. return nil
  22798. case labelrelationship.FieldStatus:
  22799. m.ResetStatus()
  22800. return nil
  22801. case labelrelationship.FieldLabelID:
  22802. m.ResetLabelID()
  22803. return nil
  22804. case labelrelationship.FieldContactID:
  22805. m.ResetContactID()
  22806. return nil
  22807. case labelrelationship.FieldOrganizationID:
  22808. m.ResetOrganizationID()
  22809. return nil
  22810. }
  22811. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22812. }
  22813. // AddedEdges returns all edge names that were set/added in this mutation.
  22814. func (m *LabelRelationshipMutation) AddedEdges() []string {
  22815. edges := make([]string, 0, 2)
  22816. if m.contacts != nil {
  22817. edges = append(edges, labelrelationship.EdgeContacts)
  22818. }
  22819. if m.labels != nil {
  22820. edges = append(edges, labelrelationship.EdgeLabels)
  22821. }
  22822. return edges
  22823. }
  22824. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22825. // name in this mutation.
  22826. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  22827. switch name {
  22828. case labelrelationship.EdgeContacts:
  22829. if id := m.contacts; id != nil {
  22830. return []ent.Value{*id}
  22831. }
  22832. case labelrelationship.EdgeLabels:
  22833. if id := m.labels; id != nil {
  22834. return []ent.Value{*id}
  22835. }
  22836. }
  22837. return nil
  22838. }
  22839. // RemovedEdges returns all edge names that were removed in this mutation.
  22840. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  22841. edges := make([]string, 0, 2)
  22842. return edges
  22843. }
  22844. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22845. // the given name in this mutation.
  22846. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  22847. return nil
  22848. }
  22849. // ClearedEdges returns all edge names that were cleared in this mutation.
  22850. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  22851. edges := make([]string, 0, 2)
  22852. if m.clearedcontacts {
  22853. edges = append(edges, labelrelationship.EdgeContacts)
  22854. }
  22855. if m.clearedlabels {
  22856. edges = append(edges, labelrelationship.EdgeLabels)
  22857. }
  22858. return edges
  22859. }
  22860. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22861. // was cleared in this mutation.
  22862. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  22863. switch name {
  22864. case labelrelationship.EdgeContacts:
  22865. return m.clearedcontacts
  22866. case labelrelationship.EdgeLabels:
  22867. return m.clearedlabels
  22868. }
  22869. return false
  22870. }
  22871. // ClearEdge clears the value of the edge with the given name. It returns an error
  22872. // if that edge is not defined in the schema.
  22873. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  22874. switch name {
  22875. case labelrelationship.EdgeContacts:
  22876. m.ClearContacts()
  22877. return nil
  22878. case labelrelationship.EdgeLabels:
  22879. m.ClearLabels()
  22880. return nil
  22881. }
  22882. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  22883. }
  22884. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22885. // It returns an error if the edge is not defined in the schema.
  22886. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  22887. switch name {
  22888. case labelrelationship.EdgeContacts:
  22889. m.ResetContacts()
  22890. return nil
  22891. case labelrelationship.EdgeLabels:
  22892. m.ResetLabels()
  22893. return nil
  22894. }
  22895. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  22896. }
  22897. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  22898. type LabelTaggingMutation struct {
  22899. config
  22900. op Op
  22901. typ string
  22902. id *uint64
  22903. created_at *time.Time
  22904. updated_at *time.Time
  22905. status *uint8
  22906. addstatus *int8
  22907. deleted_at *time.Time
  22908. organization_id *uint64
  22909. addorganization_id *int64
  22910. _type *int
  22911. add_type *int
  22912. conditions *string
  22913. action_label_add *[]uint64
  22914. appendaction_label_add []uint64
  22915. action_label_del *[]uint64
  22916. appendaction_label_del []uint64
  22917. clearedFields map[string]struct{}
  22918. done bool
  22919. oldValue func(context.Context) (*LabelTagging, error)
  22920. predicates []predicate.LabelTagging
  22921. }
  22922. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  22923. // labeltaggingOption allows management of the mutation configuration using functional options.
  22924. type labeltaggingOption func(*LabelTaggingMutation)
  22925. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  22926. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  22927. m := &LabelTaggingMutation{
  22928. config: c,
  22929. op: op,
  22930. typ: TypeLabelTagging,
  22931. clearedFields: make(map[string]struct{}),
  22932. }
  22933. for _, opt := range opts {
  22934. opt(m)
  22935. }
  22936. return m
  22937. }
  22938. // withLabelTaggingID sets the ID field of the mutation.
  22939. func withLabelTaggingID(id uint64) labeltaggingOption {
  22940. return func(m *LabelTaggingMutation) {
  22941. var (
  22942. err error
  22943. once sync.Once
  22944. value *LabelTagging
  22945. )
  22946. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  22947. once.Do(func() {
  22948. if m.done {
  22949. err = errors.New("querying old values post mutation is not allowed")
  22950. } else {
  22951. value, err = m.Client().LabelTagging.Get(ctx, id)
  22952. }
  22953. })
  22954. return value, err
  22955. }
  22956. m.id = &id
  22957. }
  22958. }
  22959. // withLabelTagging sets the old LabelTagging of the mutation.
  22960. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  22961. return func(m *LabelTaggingMutation) {
  22962. m.oldValue = func(context.Context) (*LabelTagging, error) {
  22963. return node, nil
  22964. }
  22965. m.id = &node.ID
  22966. }
  22967. }
  22968. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22969. // executed in a transaction (ent.Tx), a transactional client is returned.
  22970. func (m LabelTaggingMutation) Client() *Client {
  22971. client := &Client{config: m.config}
  22972. client.init()
  22973. return client
  22974. }
  22975. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22976. // it returns an error otherwise.
  22977. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  22978. if _, ok := m.driver.(*txDriver); !ok {
  22979. return nil, errors.New("ent: mutation is not running in a transaction")
  22980. }
  22981. tx := &Tx{config: m.config}
  22982. tx.init()
  22983. return tx, nil
  22984. }
  22985. // SetID sets the value of the id field. Note that this
  22986. // operation is only accepted on creation of LabelTagging entities.
  22987. func (m *LabelTaggingMutation) SetID(id uint64) {
  22988. m.id = &id
  22989. }
  22990. // ID returns the ID value in the mutation. Note that the ID is only available
  22991. // if it was provided to the builder or after it was returned from the database.
  22992. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  22993. if m.id == nil {
  22994. return
  22995. }
  22996. return *m.id, true
  22997. }
  22998. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22999. // That means, if the mutation is applied within a transaction with an isolation level such
  23000. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23001. // or updated by the mutation.
  23002. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  23003. switch {
  23004. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23005. id, exists := m.ID()
  23006. if exists {
  23007. return []uint64{id}, nil
  23008. }
  23009. fallthrough
  23010. case m.op.Is(OpUpdate | OpDelete):
  23011. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  23012. default:
  23013. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23014. }
  23015. }
  23016. // SetCreatedAt sets the "created_at" field.
  23017. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  23018. m.created_at = &t
  23019. }
  23020. // CreatedAt returns the value of the "created_at" field in the mutation.
  23021. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  23022. v := m.created_at
  23023. if v == nil {
  23024. return
  23025. }
  23026. return *v, true
  23027. }
  23028. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  23029. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23031. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23032. if !m.op.Is(OpUpdateOne) {
  23033. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23034. }
  23035. if m.id == nil || m.oldValue == nil {
  23036. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23037. }
  23038. oldValue, err := m.oldValue(ctx)
  23039. if err != nil {
  23040. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23041. }
  23042. return oldValue.CreatedAt, nil
  23043. }
  23044. // ResetCreatedAt resets all changes to the "created_at" field.
  23045. func (m *LabelTaggingMutation) ResetCreatedAt() {
  23046. m.created_at = nil
  23047. }
  23048. // SetUpdatedAt sets the "updated_at" field.
  23049. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  23050. m.updated_at = &t
  23051. }
  23052. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23053. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  23054. v := m.updated_at
  23055. if v == nil {
  23056. return
  23057. }
  23058. return *v, true
  23059. }
  23060. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  23061. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23063. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23064. if !m.op.Is(OpUpdateOne) {
  23065. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23066. }
  23067. if m.id == nil || m.oldValue == nil {
  23068. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23069. }
  23070. oldValue, err := m.oldValue(ctx)
  23071. if err != nil {
  23072. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23073. }
  23074. return oldValue.UpdatedAt, nil
  23075. }
  23076. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23077. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  23078. m.updated_at = nil
  23079. }
  23080. // SetStatus sets the "status" field.
  23081. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  23082. m.status = &u
  23083. m.addstatus = nil
  23084. }
  23085. // Status returns the value of the "status" field in the mutation.
  23086. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  23087. v := m.status
  23088. if v == nil {
  23089. return
  23090. }
  23091. return *v, true
  23092. }
  23093. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  23094. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23096. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23097. if !m.op.Is(OpUpdateOne) {
  23098. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23099. }
  23100. if m.id == nil || m.oldValue == nil {
  23101. return v, errors.New("OldStatus requires an ID field in the mutation")
  23102. }
  23103. oldValue, err := m.oldValue(ctx)
  23104. if err != nil {
  23105. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23106. }
  23107. return oldValue.Status, nil
  23108. }
  23109. // AddStatus adds u to the "status" field.
  23110. func (m *LabelTaggingMutation) AddStatus(u int8) {
  23111. if m.addstatus != nil {
  23112. *m.addstatus += u
  23113. } else {
  23114. m.addstatus = &u
  23115. }
  23116. }
  23117. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23118. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  23119. v := m.addstatus
  23120. if v == nil {
  23121. return
  23122. }
  23123. return *v, true
  23124. }
  23125. // ClearStatus clears the value of the "status" field.
  23126. func (m *LabelTaggingMutation) ClearStatus() {
  23127. m.status = nil
  23128. m.addstatus = nil
  23129. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  23130. }
  23131. // StatusCleared returns if the "status" field was cleared in this mutation.
  23132. func (m *LabelTaggingMutation) StatusCleared() bool {
  23133. _, ok := m.clearedFields[labeltagging.FieldStatus]
  23134. return ok
  23135. }
  23136. // ResetStatus resets all changes to the "status" field.
  23137. func (m *LabelTaggingMutation) ResetStatus() {
  23138. m.status = nil
  23139. m.addstatus = nil
  23140. delete(m.clearedFields, labeltagging.FieldStatus)
  23141. }
  23142. // SetDeletedAt sets the "deleted_at" field.
  23143. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  23144. m.deleted_at = &t
  23145. }
  23146. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23147. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  23148. v := m.deleted_at
  23149. if v == nil {
  23150. return
  23151. }
  23152. return *v, true
  23153. }
  23154. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  23155. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23157. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23158. if !m.op.Is(OpUpdateOne) {
  23159. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23160. }
  23161. if m.id == nil || m.oldValue == nil {
  23162. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23163. }
  23164. oldValue, err := m.oldValue(ctx)
  23165. if err != nil {
  23166. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23167. }
  23168. return oldValue.DeletedAt, nil
  23169. }
  23170. // ClearDeletedAt clears the value of the "deleted_at" field.
  23171. func (m *LabelTaggingMutation) ClearDeletedAt() {
  23172. m.deleted_at = nil
  23173. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  23174. }
  23175. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23176. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  23177. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  23178. return ok
  23179. }
  23180. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23181. func (m *LabelTaggingMutation) ResetDeletedAt() {
  23182. m.deleted_at = nil
  23183. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  23184. }
  23185. // SetOrganizationID sets the "organization_id" field.
  23186. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  23187. m.organization_id = &u
  23188. m.addorganization_id = nil
  23189. }
  23190. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23191. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  23192. v := m.organization_id
  23193. if v == nil {
  23194. return
  23195. }
  23196. return *v, true
  23197. }
  23198. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  23199. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23201. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23202. if !m.op.Is(OpUpdateOne) {
  23203. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23204. }
  23205. if m.id == nil || m.oldValue == nil {
  23206. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23207. }
  23208. oldValue, err := m.oldValue(ctx)
  23209. if err != nil {
  23210. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23211. }
  23212. return oldValue.OrganizationID, nil
  23213. }
  23214. // AddOrganizationID adds u to the "organization_id" field.
  23215. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  23216. if m.addorganization_id != nil {
  23217. *m.addorganization_id += u
  23218. } else {
  23219. m.addorganization_id = &u
  23220. }
  23221. }
  23222. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23223. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  23224. v := m.addorganization_id
  23225. if v == nil {
  23226. return
  23227. }
  23228. return *v, true
  23229. }
  23230. // ResetOrganizationID resets all changes to the "organization_id" field.
  23231. func (m *LabelTaggingMutation) ResetOrganizationID() {
  23232. m.organization_id = nil
  23233. m.addorganization_id = nil
  23234. }
  23235. // SetType sets the "type" field.
  23236. func (m *LabelTaggingMutation) SetType(i int) {
  23237. m._type = &i
  23238. m.add_type = nil
  23239. }
  23240. // GetType returns the value of the "type" field in the mutation.
  23241. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  23242. v := m._type
  23243. if v == nil {
  23244. return
  23245. }
  23246. return *v, true
  23247. }
  23248. // OldType returns the old "type" field's value of the LabelTagging entity.
  23249. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23251. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  23252. if !m.op.Is(OpUpdateOne) {
  23253. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23254. }
  23255. if m.id == nil || m.oldValue == nil {
  23256. return v, errors.New("OldType requires an ID field in the mutation")
  23257. }
  23258. oldValue, err := m.oldValue(ctx)
  23259. if err != nil {
  23260. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23261. }
  23262. return oldValue.Type, nil
  23263. }
  23264. // AddType adds i to the "type" field.
  23265. func (m *LabelTaggingMutation) AddType(i int) {
  23266. if m.add_type != nil {
  23267. *m.add_type += i
  23268. } else {
  23269. m.add_type = &i
  23270. }
  23271. }
  23272. // AddedType returns the value that was added to the "type" field in this mutation.
  23273. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  23274. v := m.add_type
  23275. if v == nil {
  23276. return
  23277. }
  23278. return *v, true
  23279. }
  23280. // ResetType resets all changes to the "type" field.
  23281. func (m *LabelTaggingMutation) ResetType() {
  23282. m._type = nil
  23283. m.add_type = nil
  23284. }
  23285. // SetConditions sets the "conditions" field.
  23286. func (m *LabelTaggingMutation) SetConditions(s string) {
  23287. m.conditions = &s
  23288. }
  23289. // Conditions returns the value of the "conditions" field in the mutation.
  23290. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  23291. v := m.conditions
  23292. if v == nil {
  23293. return
  23294. }
  23295. return *v, true
  23296. }
  23297. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  23298. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23300. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  23301. if !m.op.Is(OpUpdateOne) {
  23302. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  23303. }
  23304. if m.id == nil || m.oldValue == nil {
  23305. return v, errors.New("OldConditions requires an ID field in the mutation")
  23306. }
  23307. oldValue, err := m.oldValue(ctx)
  23308. if err != nil {
  23309. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  23310. }
  23311. return oldValue.Conditions, nil
  23312. }
  23313. // ResetConditions resets all changes to the "conditions" field.
  23314. func (m *LabelTaggingMutation) ResetConditions() {
  23315. m.conditions = nil
  23316. }
  23317. // SetActionLabelAdd sets the "action_label_add" field.
  23318. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  23319. m.action_label_add = &u
  23320. m.appendaction_label_add = nil
  23321. }
  23322. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23323. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23324. v := m.action_label_add
  23325. if v == nil {
  23326. return
  23327. }
  23328. return *v, true
  23329. }
  23330. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  23331. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23333. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23334. if !m.op.Is(OpUpdateOne) {
  23335. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23336. }
  23337. if m.id == nil || m.oldValue == nil {
  23338. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23339. }
  23340. oldValue, err := m.oldValue(ctx)
  23341. if err != nil {
  23342. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23343. }
  23344. return oldValue.ActionLabelAdd, nil
  23345. }
  23346. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23347. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  23348. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23349. }
  23350. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23351. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23352. if len(m.appendaction_label_add) == 0 {
  23353. return nil, false
  23354. }
  23355. return m.appendaction_label_add, true
  23356. }
  23357. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23358. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  23359. m.action_label_add = nil
  23360. m.appendaction_label_add = nil
  23361. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  23362. }
  23363. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23364. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  23365. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  23366. return ok
  23367. }
  23368. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23369. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  23370. m.action_label_add = nil
  23371. m.appendaction_label_add = nil
  23372. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  23373. }
  23374. // SetActionLabelDel sets the "action_label_del" field.
  23375. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  23376. m.action_label_del = &u
  23377. m.appendaction_label_del = nil
  23378. }
  23379. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23380. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  23381. v := m.action_label_del
  23382. if v == nil {
  23383. return
  23384. }
  23385. return *v, true
  23386. }
  23387. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  23388. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23390. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23391. if !m.op.Is(OpUpdateOne) {
  23392. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23393. }
  23394. if m.id == nil || m.oldValue == nil {
  23395. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23396. }
  23397. oldValue, err := m.oldValue(ctx)
  23398. if err != nil {
  23399. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23400. }
  23401. return oldValue.ActionLabelDel, nil
  23402. }
  23403. // AppendActionLabelDel adds u to the "action_label_del" field.
  23404. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  23405. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23406. }
  23407. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23408. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23409. if len(m.appendaction_label_del) == 0 {
  23410. return nil, false
  23411. }
  23412. return m.appendaction_label_del, true
  23413. }
  23414. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23415. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  23416. m.action_label_del = nil
  23417. m.appendaction_label_del = nil
  23418. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  23419. }
  23420. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23421. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  23422. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  23423. return ok
  23424. }
  23425. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23426. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  23427. m.action_label_del = nil
  23428. m.appendaction_label_del = nil
  23429. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  23430. }
  23431. // Where appends a list predicates to the LabelTaggingMutation builder.
  23432. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  23433. m.predicates = append(m.predicates, ps...)
  23434. }
  23435. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  23436. // users can use type-assertion to append predicates that do not depend on any generated package.
  23437. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  23438. p := make([]predicate.LabelTagging, len(ps))
  23439. for i := range ps {
  23440. p[i] = ps[i]
  23441. }
  23442. m.Where(p...)
  23443. }
  23444. // Op returns the operation name.
  23445. func (m *LabelTaggingMutation) Op() Op {
  23446. return m.op
  23447. }
  23448. // SetOp allows setting the mutation operation.
  23449. func (m *LabelTaggingMutation) SetOp(op Op) {
  23450. m.op = op
  23451. }
  23452. // Type returns the node type of this mutation (LabelTagging).
  23453. func (m *LabelTaggingMutation) Type() string {
  23454. return m.typ
  23455. }
  23456. // Fields returns all fields that were changed during this mutation. Note that in
  23457. // order to get all numeric fields that were incremented/decremented, call
  23458. // AddedFields().
  23459. func (m *LabelTaggingMutation) Fields() []string {
  23460. fields := make([]string, 0, 9)
  23461. if m.created_at != nil {
  23462. fields = append(fields, labeltagging.FieldCreatedAt)
  23463. }
  23464. if m.updated_at != nil {
  23465. fields = append(fields, labeltagging.FieldUpdatedAt)
  23466. }
  23467. if m.status != nil {
  23468. fields = append(fields, labeltagging.FieldStatus)
  23469. }
  23470. if m.deleted_at != nil {
  23471. fields = append(fields, labeltagging.FieldDeletedAt)
  23472. }
  23473. if m.organization_id != nil {
  23474. fields = append(fields, labeltagging.FieldOrganizationID)
  23475. }
  23476. if m._type != nil {
  23477. fields = append(fields, labeltagging.FieldType)
  23478. }
  23479. if m.conditions != nil {
  23480. fields = append(fields, labeltagging.FieldConditions)
  23481. }
  23482. if m.action_label_add != nil {
  23483. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23484. }
  23485. if m.action_label_del != nil {
  23486. fields = append(fields, labeltagging.FieldActionLabelDel)
  23487. }
  23488. return fields
  23489. }
  23490. // Field returns the value of a field with the given name. The second boolean
  23491. // return value indicates that this field was not set, or was not defined in the
  23492. // schema.
  23493. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  23494. switch name {
  23495. case labeltagging.FieldCreatedAt:
  23496. return m.CreatedAt()
  23497. case labeltagging.FieldUpdatedAt:
  23498. return m.UpdatedAt()
  23499. case labeltagging.FieldStatus:
  23500. return m.Status()
  23501. case labeltagging.FieldDeletedAt:
  23502. return m.DeletedAt()
  23503. case labeltagging.FieldOrganizationID:
  23504. return m.OrganizationID()
  23505. case labeltagging.FieldType:
  23506. return m.GetType()
  23507. case labeltagging.FieldConditions:
  23508. return m.Conditions()
  23509. case labeltagging.FieldActionLabelAdd:
  23510. return m.ActionLabelAdd()
  23511. case labeltagging.FieldActionLabelDel:
  23512. return m.ActionLabelDel()
  23513. }
  23514. return nil, false
  23515. }
  23516. // OldField returns the old value of the field from the database. An error is
  23517. // returned if the mutation operation is not UpdateOne, or the query to the
  23518. // database failed.
  23519. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23520. switch name {
  23521. case labeltagging.FieldCreatedAt:
  23522. return m.OldCreatedAt(ctx)
  23523. case labeltagging.FieldUpdatedAt:
  23524. return m.OldUpdatedAt(ctx)
  23525. case labeltagging.FieldStatus:
  23526. return m.OldStatus(ctx)
  23527. case labeltagging.FieldDeletedAt:
  23528. return m.OldDeletedAt(ctx)
  23529. case labeltagging.FieldOrganizationID:
  23530. return m.OldOrganizationID(ctx)
  23531. case labeltagging.FieldType:
  23532. return m.OldType(ctx)
  23533. case labeltagging.FieldConditions:
  23534. return m.OldConditions(ctx)
  23535. case labeltagging.FieldActionLabelAdd:
  23536. return m.OldActionLabelAdd(ctx)
  23537. case labeltagging.FieldActionLabelDel:
  23538. return m.OldActionLabelDel(ctx)
  23539. }
  23540. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  23541. }
  23542. // SetField sets the value of a field with the given name. It returns an error if
  23543. // the field is not defined in the schema, or if the type mismatched the field
  23544. // type.
  23545. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  23546. switch name {
  23547. case labeltagging.FieldCreatedAt:
  23548. v, ok := value.(time.Time)
  23549. if !ok {
  23550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23551. }
  23552. m.SetCreatedAt(v)
  23553. return nil
  23554. case labeltagging.FieldUpdatedAt:
  23555. v, ok := value.(time.Time)
  23556. if !ok {
  23557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23558. }
  23559. m.SetUpdatedAt(v)
  23560. return nil
  23561. case labeltagging.FieldStatus:
  23562. v, ok := value.(uint8)
  23563. if !ok {
  23564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23565. }
  23566. m.SetStatus(v)
  23567. return nil
  23568. case labeltagging.FieldDeletedAt:
  23569. v, ok := value.(time.Time)
  23570. if !ok {
  23571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23572. }
  23573. m.SetDeletedAt(v)
  23574. return nil
  23575. case labeltagging.FieldOrganizationID:
  23576. v, ok := value.(uint64)
  23577. if !ok {
  23578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23579. }
  23580. m.SetOrganizationID(v)
  23581. return nil
  23582. case labeltagging.FieldType:
  23583. v, ok := value.(int)
  23584. if !ok {
  23585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23586. }
  23587. m.SetType(v)
  23588. return nil
  23589. case labeltagging.FieldConditions:
  23590. v, ok := value.(string)
  23591. if !ok {
  23592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23593. }
  23594. m.SetConditions(v)
  23595. return nil
  23596. case labeltagging.FieldActionLabelAdd:
  23597. v, ok := value.([]uint64)
  23598. if !ok {
  23599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23600. }
  23601. m.SetActionLabelAdd(v)
  23602. return nil
  23603. case labeltagging.FieldActionLabelDel:
  23604. v, ok := value.([]uint64)
  23605. if !ok {
  23606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23607. }
  23608. m.SetActionLabelDel(v)
  23609. return nil
  23610. }
  23611. return fmt.Errorf("unknown LabelTagging field %s", name)
  23612. }
  23613. // AddedFields returns all numeric fields that were incremented/decremented during
  23614. // this mutation.
  23615. func (m *LabelTaggingMutation) AddedFields() []string {
  23616. var fields []string
  23617. if m.addstatus != nil {
  23618. fields = append(fields, labeltagging.FieldStatus)
  23619. }
  23620. if m.addorganization_id != nil {
  23621. fields = append(fields, labeltagging.FieldOrganizationID)
  23622. }
  23623. if m.add_type != nil {
  23624. fields = append(fields, labeltagging.FieldType)
  23625. }
  23626. return fields
  23627. }
  23628. // AddedField returns the numeric value that was incremented/decremented on a field
  23629. // with the given name. The second boolean return value indicates that this field
  23630. // was not set, or was not defined in the schema.
  23631. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  23632. switch name {
  23633. case labeltagging.FieldStatus:
  23634. return m.AddedStatus()
  23635. case labeltagging.FieldOrganizationID:
  23636. return m.AddedOrganizationID()
  23637. case labeltagging.FieldType:
  23638. return m.AddedType()
  23639. }
  23640. return nil, false
  23641. }
  23642. // AddField adds the value to the field with the given name. It returns an error if
  23643. // the field is not defined in the schema, or if the type mismatched the field
  23644. // type.
  23645. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  23646. switch name {
  23647. case labeltagging.FieldStatus:
  23648. v, ok := value.(int8)
  23649. if !ok {
  23650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23651. }
  23652. m.AddStatus(v)
  23653. return nil
  23654. case labeltagging.FieldOrganizationID:
  23655. v, ok := value.(int64)
  23656. if !ok {
  23657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23658. }
  23659. m.AddOrganizationID(v)
  23660. return nil
  23661. case labeltagging.FieldType:
  23662. v, ok := value.(int)
  23663. if !ok {
  23664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23665. }
  23666. m.AddType(v)
  23667. return nil
  23668. }
  23669. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  23670. }
  23671. // ClearedFields returns all nullable fields that were cleared during this
  23672. // mutation.
  23673. func (m *LabelTaggingMutation) ClearedFields() []string {
  23674. var fields []string
  23675. if m.FieldCleared(labeltagging.FieldStatus) {
  23676. fields = append(fields, labeltagging.FieldStatus)
  23677. }
  23678. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  23679. fields = append(fields, labeltagging.FieldDeletedAt)
  23680. }
  23681. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  23682. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23683. }
  23684. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  23685. fields = append(fields, labeltagging.FieldActionLabelDel)
  23686. }
  23687. return fields
  23688. }
  23689. // FieldCleared returns a boolean indicating if a field with the given name was
  23690. // cleared in this mutation.
  23691. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  23692. _, ok := m.clearedFields[name]
  23693. return ok
  23694. }
  23695. // ClearField clears the value of the field with the given name. It returns an
  23696. // error if the field is not defined in the schema.
  23697. func (m *LabelTaggingMutation) ClearField(name string) error {
  23698. switch name {
  23699. case labeltagging.FieldStatus:
  23700. m.ClearStatus()
  23701. return nil
  23702. case labeltagging.FieldDeletedAt:
  23703. m.ClearDeletedAt()
  23704. return nil
  23705. case labeltagging.FieldActionLabelAdd:
  23706. m.ClearActionLabelAdd()
  23707. return nil
  23708. case labeltagging.FieldActionLabelDel:
  23709. m.ClearActionLabelDel()
  23710. return nil
  23711. }
  23712. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  23713. }
  23714. // ResetField resets all changes in the mutation for the field with the given name.
  23715. // It returns an error if the field is not defined in the schema.
  23716. func (m *LabelTaggingMutation) ResetField(name string) error {
  23717. switch name {
  23718. case labeltagging.FieldCreatedAt:
  23719. m.ResetCreatedAt()
  23720. return nil
  23721. case labeltagging.FieldUpdatedAt:
  23722. m.ResetUpdatedAt()
  23723. return nil
  23724. case labeltagging.FieldStatus:
  23725. m.ResetStatus()
  23726. return nil
  23727. case labeltagging.FieldDeletedAt:
  23728. m.ResetDeletedAt()
  23729. return nil
  23730. case labeltagging.FieldOrganizationID:
  23731. m.ResetOrganizationID()
  23732. return nil
  23733. case labeltagging.FieldType:
  23734. m.ResetType()
  23735. return nil
  23736. case labeltagging.FieldConditions:
  23737. m.ResetConditions()
  23738. return nil
  23739. case labeltagging.FieldActionLabelAdd:
  23740. m.ResetActionLabelAdd()
  23741. return nil
  23742. case labeltagging.FieldActionLabelDel:
  23743. m.ResetActionLabelDel()
  23744. return nil
  23745. }
  23746. return fmt.Errorf("unknown LabelTagging field %s", name)
  23747. }
  23748. // AddedEdges returns all edge names that were set/added in this mutation.
  23749. func (m *LabelTaggingMutation) AddedEdges() []string {
  23750. edges := make([]string, 0, 0)
  23751. return edges
  23752. }
  23753. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23754. // name in this mutation.
  23755. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  23756. return nil
  23757. }
  23758. // RemovedEdges returns all edge names that were removed in this mutation.
  23759. func (m *LabelTaggingMutation) RemovedEdges() []string {
  23760. edges := make([]string, 0, 0)
  23761. return edges
  23762. }
  23763. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23764. // the given name in this mutation.
  23765. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  23766. return nil
  23767. }
  23768. // ClearedEdges returns all edge names that were cleared in this mutation.
  23769. func (m *LabelTaggingMutation) ClearedEdges() []string {
  23770. edges := make([]string, 0, 0)
  23771. return edges
  23772. }
  23773. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23774. // was cleared in this mutation.
  23775. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  23776. return false
  23777. }
  23778. // ClearEdge clears the value of the edge with the given name. It returns an error
  23779. // if that edge is not defined in the schema.
  23780. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  23781. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  23782. }
  23783. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23784. // It returns an error if the edge is not defined in the schema.
  23785. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  23786. return fmt.Errorf("unknown LabelTagging edge %s", name)
  23787. }
  23788. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  23789. type MessageMutation struct {
  23790. config
  23791. op Op
  23792. typ string
  23793. id *int
  23794. wx_wxid *string
  23795. wxid *string
  23796. content *string
  23797. clearedFields map[string]struct{}
  23798. done bool
  23799. oldValue func(context.Context) (*Message, error)
  23800. predicates []predicate.Message
  23801. }
  23802. var _ ent.Mutation = (*MessageMutation)(nil)
  23803. // messageOption allows management of the mutation configuration using functional options.
  23804. type messageOption func(*MessageMutation)
  23805. // newMessageMutation creates new mutation for the Message entity.
  23806. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  23807. m := &MessageMutation{
  23808. config: c,
  23809. op: op,
  23810. typ: TypeMessage,
  23811. clearedFields: make(map[string]struct{}),
  23812. }
  23813. for _, opt := range opts {
  23814. opt(m)
  23815. }
  23816. return m
  23817. }
  23818. // withMessageID sets the ID field of the mutation.
  23819. func withMessageID(id int) messageOption {
  23820. return func(m *MessageMutation) {
  23821. var (
  23822. err error
  23823. once sync.Once
  23824. value *Message
  23825. )
  23826. m.oldValue = func(ctx context.Context) (*Message, error) {
  23827. once.Do(func() {
  23828. if m.done {
  23829. err = errors.New("querying old values post mutation is not allowed")
  23830. } else {
  23831. value, err = m.Client().Message.Get(ctx, id)
  23832. }
  23833. })
  23834. return value, err
  23835. }
  23836. m.id = &id
  23837. }
  23838. }
  23839. // withMessage sets the old Message of the mutation.
  23840. func withMessage(node *Message) messageOption {
  23841. return func(m *MessageMutation) {
  23842. m.oldValue = func(context.Context) (*Message, error) {
  23843. return node, nil
  23844. }
  23845. m.id = &node.ID
  23846. }
  23847. }
  23848. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23849. // executed in a transaction (ent.Tx), a transactional client is returned.
  23850. func (m MessageMutation) Client() *Client {
  23851. client := &Client{config: m.config}
  23852. client.init()
  23853. return client
  23854. }
  23855. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23856. // it returns an error otherwise.
  23857. func (m MessageMutation) Tx() (*Tx, error) {
  23858. if _, ok := m.driver.(*txDriver); !ok {
  23859. return nil, errors.New("ent: mutation is not running in a transaction")
  23860. }
  23861. tx := &Tx{config: m.config}
  23862. tx.init()
  23863. return tx, nil
  23864. }
  23865. // ID returns the ID value in the mutation. Note that the ID is only available
  23866. // if it was provided to the builder or after it was returned from the database.
  23867. func (m *MessageMutation) ID() (id int, exists bool) {
  23868. if m.id == nil {
  23869. return
  23870. }
  23871. return *m.id, true
  23872. }
  23873. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23874. // That means, if the mutation is applied within a transaction with an isolation level such
  23875. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23876. // or updated by the mutation.
  23877. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  23878. switch {
  23879. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23880. id, exists := m.ID()
  23881. if exists {
  23882. return []int{id}, nil
  23883. }
  23884. fallthrough
  23885. case m.op.Is(OpUpdate | OpDelete):
  23886. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  23887. default:
  23888. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23889. }
  23890. }
  23891. // SetWxWxid sets the "wx_wxid" field.
  23892. func (m *MessageMutation) SetWxWxid(s string) {
  23893. m.wx_wxid = &s
  23894. }
  23895. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  23896. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  23897. v := m.wx_wxid
  23898. if v == nil {
  23899. return
  23900. }
  23901. return *v, true
  23902. }
  23903. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  23904. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23906. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  23907. if !m.op.Is(OpUpdateOne) {
  23908. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  23909. }
  23910. if m.id == nil || m.oldValue == nil {
  23911. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  23912. }
  23913. oldValue, err := m.oldValue(ctx)
  23914. if err != nil {
  23915. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  23916. }
  23917. return oldValue.WxWxid, nil
  23918. }
  23919. // ClearWxWxid clears the value of the "wx_wxid" field.
  23920. func (m *MessageMutation) ClearWxWxid() {
  23921. m.wx_wxid = nil
  23922. m.clearedFields[message.FieldWxWxid] = struct{}{}
  23923. }
  23924. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  23925. func (m *MessageMutation) WxWxidCleared() bool {
  23926. _, ok := m.clearedFields[message.FieldWxWxid]
  23927. return ok
  23928. }
  23929. // ResetWxWxid resets all changes to the "wx_wxid" field.
  23930. func (m *MessageMutation) ResetWxWxid() {
  23931. m.wx_wxid = nil
  23932. delete(m.clearedFields, message.FieldWxWxid)
  23933. }
  23934. // SetWxid sets the "wxid" field.
  23935. func (m *MessageMutation) SetWxid(s string) {
  23936. m.wxid = &s
  23937. }
  23938. // Wxid returns the value of the "wxid" field in the mutation.
  23939. func (m *MessageMutation) Wxid() (r string, exists bool) {
  23940. v := m.wxid
  23941. if v == nil {
  23942. return
  23943. }
  23944. return *v, true
  23945. }
  23946. // OldWxid returns the old "wxid" field's value of the Message entity.
  23947. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23949. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  23950. if !m.op.Is(OpUpdateOne) {
  23951. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  23952. }
  23953. if m.id == nil || m.oldValue == nil {
  23954. return v, errors.New("OldWxid requires an ID field in the mutation")
  23955. }
  23956. oldValue, err := m.oldValue(ctx)
  23957. if err != nil {
  23958. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  23959. }
  23960. return oldValue.Wxid, nil
  23961. }
  23962. // ResetWxid resets all changes to the "wxid" field.
  23963. func (m *MessageMutation) ResetWxid() {
  23964. m.wxid = nil
  23965. }
  23966. // SetContent sets the "content" field.
  23967. func (m *MessageMutation) SetContent(s string) {
  23968. m.content = &s
  23969. }
  23970. // Content returns the value of the "content" field in the mutation.
  23971. func (m *MessageMutation) Content() (r string, exists bool) {
  23972. v := m.content
  23973. if v == nil {
  23974. return
  23975. }
  23976. return *v, true
  23977. }
  23978. // OldContent returns the old "content" field's value of the Message entity.
  23979. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23981. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  23982. if !m.op.Is(OpUpdateOne) {
  23983. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23984. }
  23985. if m.id == nil || m.oldValue == nil {
  23986. return v, errors.New("OldContent requires an ID field in the mutation")
  23987. }
  23988. oldValue, err := m.oldValue(ctx)
  23989. if err != nil {
  23990. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23991. }
  23992. return oldValue.Content, nil
  23993. }
  23994. // ResetContent resets all changes to the "content" field.
  23995. func (m *MessageMutation) ResetContent() {
  23996. m.content = nil
  23997. }
  23998. // Where appends a list predicates to the MessageMutation builder.
  23999. func (m *MessageMutation) Where(ps ...predicate.Message) {
  24000. m.predicates = append(m.predicates, ps...)
  24001. }
  24002. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  24003. // users can use type-assertion to append predicates that do not depend on any generated package.
  24004. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  24005. p := make([]predicate.Message, len(ps))
  24006. for i := range ps {
  24007. p[i] = ps[i]
  24008. }
  24009. m.Where(p...)
  24010. }
  24011. // Op returns the operation name.
  24012. func (m *MessageMutation) Op() Op {
  24013. return m.op
  24014. }
  24015. // SetOp allows setting the mutation operation.
  24016. func (m *MessageMutation) SetOp(op Op) {
  24017. m.op = op
  24018. }
  24019. // Type returns the node type of this mutation (Message).
  24020. func (m *MessageMutation) Type() string {
  24021. return m.typ
  24022. }
  24023. // Fields returns all fields that were changed during this mutation. Note that in
  24024. // order to get all numeric fields that were incremented/decremented, call
  24025. // AddedFields().
  24026. func (m *MessageMutation) Fields() []string {
  24027. fields := make([]string, 0, 3)
  24028. if m.wx_wxid != nil {
  24029. fields = append(fields, message.FieldWxWxid)
  24030. }
  24031. if m.wxid != nil {
  24032. fields = append(fields, message.FieldWxid)
  24033. }
  24034. if m.content != nil {
  24035. fields = append(fields, message.FieldContent)
  24036. }
  24037. return fields
  24038. }
  24039. // Field returns the value of a field with the given name. The second boolean
  24040. // return value indicates that this field was not set, or was not defined in the
  24041. // schema.
  24042. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  24043. switch name {
  24044. case message.FieldWxWxid:
  24045. return m.WxWxid()
  24046. case message.FieldWxid:
  24047. return m.Wxid()
  24048. case message.FieldContent:
  24049. return m.Content()
  24050. }
  24051. return nil, false
  24052. }
  24053. // OldField returns the old value of the field from the database. An error is
  24054. // returned if the mutation operation is not UpdateOne, or the query to the
  24055. // database failed.
  24056. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24057. switch name {
  24058. case message.FieldWxWxid:
  24059. return m.OldWxWxid(ctx)
  24060. case message.FieldWxid:
  24061. return m.OldWxid(ctx)
  24062. case message.FieldContent:
  24063. return m.OldContent(ctx)
  24064. }
  24065. return nil, fmt.Errorf("unknown Message field %s", name)
  24066. }
  24067. // SetField sets the value of a field with the given name. It returns an error if
  24068. // the field is not defined in the schema, or if the type mismatched the field
  24069. // type.
  24070. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  24071. switch name {
  24072. case message.FieldWxWxid:
  24073. v, ok := value.(string)
  24074. if !ok {
  24075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24076. }
  24077. m.SetWxWxid(v)
  24078. return nil
  24079. case message.FieldWxid:
  24080. v, ok := value.(string)
  24081. if !ok {
  24082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24083. }
  24084. m.SetWxid(v)
  24085. return nil
  24086. case message.FieldContent:
  24087. v, ok := value.(string)
  24088. if !ok {
  24089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24090. }
  24091. m.SetContent(v)
  24092. return nil
  24093. }
  24094. return fmt.Errorf("unknown Message field %s", name)
  24095. }
  24096. // AddedFields returns all numeric fields that were incremented/decremented during
  24097. // this mutation.
  24098. func (m *MessageMutation) AddedFields() []string {
  24099. return nil
  24100. }
  24101. // AddedField returns the numeric value that was incremented/decremented on a field
  24102. // with the given name. The second boolean return value indicates that this field
  24103. // was not set, or was not defined in the schema.
  24104. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  24105. return nil, false
  24106. }
  24107. // AddField adds the value to the field with the given name. It returns an error if
  24108. // the field is not defined in the schema, or if the type mismatched the field
  24109. // type.
  24110. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  24111. switch name {
  24112. }
  24113. return fmt.Errorf("unknown Message numeric field %s", name)
  24114. }
  24115. // ClearedFields returns all nullable fields that were cleared during this
  24116. // mutation.
  24117. func (m *MessageMutation) ClearedFields() []string {
  24118. var fields []string
  24119. if m.FieldCleared(message.FieldWxWxid) {
  24120. fields = append(fields, message.FieldWxWxid)
  24121. }
  24122. return fields
  24123. }
  24124. // FieldCleared returns a boolean indicating if a field with the given name was
  24125. // cleared in this mutation.
  24126. func (m *MessageMutation) FieldCleared(name string) bool {
  24127. _, ok := m.clearedFields[name]
  24128. return ok
  24129. }
  24130. // ClearField clears the value of the field with the given name. It returns an
  24131. // error if the field is not defined in the schema.
  24132. func (m *MessageMutation) ClearField(name string) error {
  24133. switch name {
  24134. case message.FieldWxWxid:
  24135. m.ClearWxWxid()
  24136. return nil
  24137. }
  24138. return fmt.Errorf("unknown Message nullable field %s", name)
  24139. }
  24140. // ResetField resets all changes in the mutation for the field with the given name.
  24141. // It returns an error if the field is not defined in the schema.
  24142. func (m *MessageMutation) ResetField(name string) error {
  24143. switch name {
  24144. case message.FieldWxWxid:
  24145. m.ResetWxWxid()
  24146. return nil
  24147. case message.FieldWxid:
  24148. m.ResetWxid()
  24149. return nil
  24150. case message.FieldContent:
  24151. m.ResetContent()
  24152. return nil
  24153. }
  24154. return fmt.Errorf("unknown Message field %s", name)
  24155. }
  24156. // AddedEdges returns all edge names that were set/added in this mutation.
  24157. func (m *MessageMutation) AddedEdges() []string {
  24158. edges := make([]string, 0, 0)
  24159. return edges
  24160. }
  24161. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24162. // name in this mutation.
  24163. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  24164. return nil
  24165. }
  24166. // RemovedEdges returns all edge names that were removed in this mutation.
  24167. func (m *MessageMutation) RemovedEdges() []string {
  24168. edges := make([]string, 0, 0)
  24169. return edges
  24170. }
  24171. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24172. // the given name in this mutation.
  24173. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  24174. return nil
  24175. }
  24176. // ClearedEdges returns all edge names that were cleared in this mutation.
  24177. func (m *MessageMutation) ClearedEdges() []string {
  24178. edges := make([]string, 0, 0)
  24179. return edges
  24180. }
  24181. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24182. // was cleared in this mutation.
  24183. func (m *MessageMutation) EdgeCleared(name string) bool {
  24184. return false
  24185. }
  24186. // ClearEdge clears the value of the edge with the given name. It returns an error
  24187. // if that edge is not defined in the schema.
  24188. func (m *MessageMutation) ClearEdge(name string) error {
  24189. return fmt.Errorf("unknown Message unique edge %s", name)
  24190. }
  24191. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24192. // It returns an error if the edge is not defined in the schema.
  24193. func (m *MessageMutation) ResetEdge(name string) error {
  24194. return fmt.Errorf("unknown Message edge %s", name)
  24195. }
  24196. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  24197. type MessageRecordsMutation struct {
  24198. config
  24199. op Op
  24200. typ string
  24201. id *uint64
  24202. created_at *time.Time
  24203. updated_at *time.Time
  24204. status *uint8
  24205. addstatus *int8
  24206. bot_wxid *string
  24207. contact_type *int
  24208. addcontact_type *int
  24209. contact_wxid *string
  24210. content_type *int
  24211. addcontent_type *int
  24212. content *string
  24213. meta *custom_types.Meta
  24214. error_detail *string
  24215. send_time *time.Time
  24216. source_type *int
  24217. addsource_type *int
  24218. organization_id *uint64
  24219. addorganization_id *int64
  24220. clearedFields map[string]struct{}
  24221. sop_stage *uint64
  24222. clearedsop_stage bool
  24223. sop_node *uint64
  24224. clearedsop_node bool
  24225. message_contact *uint64
  24226. clearedmessage_contact bool
  24227. done bool
  24228. oldValue func(context.Context) (*MessageRecords, error)
  24229. predicates []predicate.MessageRecords
  24230. }
  24231. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  24232. // messagerecordsOption allows management of the mutation configuration using functional options.
  24233. type messagerecordsOption func(*MessageRecordsMutation)
  24234. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  24235. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  24236. m := &MessageRecordsMutation{
  24237. config: c,
  24238. op: op,
  24239. typ: TypeMessageRecords,
  24240. clearedFields: make(map[string]struct{}),
  24241. }
  24242. for _, opt := range opts {
  24243. opt(m)
  24244. }
  24245. return m
  24246. }
  24247. // withMessageRecordsID sets the ID field of the mutation.
  24248. func withMessageRecordsID(id uint64) messagerecordsOption {
  24249. return func(m *MessageRecordsMutation) {
  24250. var (
  24251. err error
  24252. once sync.Once
  24253. value *MessageRecords
  24254. )
  24255. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  24256. once.Do(func() {
  24257. if m.done {
  24258. err = errors.New("querying old values post mutation is not allowed")
  24259. } else {
  24260. value, err = m.Client().MessageRecords.Get(ctx, id)
  24261. }
  24262. })
  24263. return value, err
  24264. }
  24265. m.id = &id
  24266. }
  24267. }
  24268. // withMessageRecords sets the old MessageRecords of the mutation.
  24269. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  24270. return func(m *MessageRecordsMutation) {
  24271. m.oldValue = func(context.Context) (*MessageRecords, error) {
  24272. return node, nil
  24273. }
  24274. m.id = &node.ID
  24275. }
  24276. }
  24277. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24278. // executed in a transaction (ent.Tx), a transactional client is returned.
  24279. func (m MessageRecordsMutation) Client() *Client {
  24280. client := &Client{config: m.config}
  24281. client.init()
  24282. return client
  24283. }
  24284. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24285. // it returns an error otherwise.
  24286. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  24287. if _, ok := m.driver.(*txDriver); !ok {
  24288. return nil, errors.New("ent: mutation is not running in a transaction")
  24289. }
  24290. tx := &Tx{config: m.config}
  24291. tx.init()
  24292. return tx, nil
  24293. }
  24294. // SetID sets the value of the id field. Note that this
  24295. // operation is only accepted on creation of MessageRecords entities.
  24296. func (m *MessageRecordsMutation) SetID(id uint64) {
  24297. m.id = &id
  24298. }
  24299. // ID returns the ID value in the mutation. Note that the ID is only available
  24300. // if it was provided to the builder or after it was returned from the database.
  24301. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  24302. if m.id == nil {
  24303. return
  24304. }
  24305. return *m.id, true
  24306. }
  24307. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24308. // That means, if the mutation is applied within a transaction with an isolation level such
  24309. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24310. // or updated by the mutation.
  24311. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  24312. switch {
  24313. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24314. id, exists := m.ID()
  24315. if exists {
  24316. return []uint64{id}, nil
  24317. }
  24318. fallthrough
  24319. case m.op.Is(OpUpdate | OpDelete):
  24320. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  24321. default:
  24322. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24323. }
  24324. }
  24325. // SetCreatedAt sets the "created_at" field.
  24326. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  24327. m.created_at = &t
  24328. }
  24329. // CreatedAt returns the value of the "created_at" field in the mutation.
  24330. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  24331. v := m.created_at
  24332. if v == nil {
  24333. return
  24334. }
  24335. return *v, true
  24336. }
  24337. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  24338. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24340. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24341. if !m.op.Is(OpUpdateOne) {
  24342. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24343. }
  24344. if m.id == nil || m.oldValue == nil {
  24345. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24346. }
  24347. oldValue, err := m.oldValue(ctx)
  24348. if err != nil {
  24349. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24350. }
  24351. return oldValue.CreatedAt, nil
  24352. }
  24353. // ResetCreatedAt resets all changes to the "created_at" field.
  24354. func (m *MessageRecordsMutation) ResetCreatedAt() {
  24355. m.created_at = nil
  24356. }
  24357. // SetUpdatedAt sets the "updated_at" field.
  24358. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  24359. m.updated_at = &t
  24360. }
  24361. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24362. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  24363. v := m.updated_at
  24364. if v == nil {
  24365. return
  24366. }
  24367. return *v, true
  24368. }
  24369. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  24370. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24372. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24373. if !m.op.Is(OpUpdateOne) {
  24374. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24375. }
  24376. if m.id == nil || m.oldValue == nil {
  24377. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24378. }
  24379. oldValue, err := m.oldValue(ctx)
  24380. if err != nil {
  24381. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24382. }
  24383. return oldValue.UpdatedAt, nil
  24384. }
  24385. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24386. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  24387. m.updated_at = nil
  24388. }
  24389. // SetStatus sets the "status" field.
  24390. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  24391. m.status = &u
  24392. m.addstatus = nil
  24393. }
  24394. // Status returns the value of the "status" field in the mutation.
  24395. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  24396. v := m.status
  24397. if v == nil {
  24398. return
  24399. }
  24400. return *v, true
  24401. }
  24402. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  24403. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24405. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24406. if !m.op.Is(OpUpdateOne) {
  24407. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24408. }
  24409. if m.id == nil || m.oldValue == nil {
  24410. return v, errors.New("OldStatus requires an ID field in the mutation")
  24411. }
  24412. oldValue, err := m.oldValue(ctx)
  24413. if err != nil {
  24414. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24415. }
  24416. return oldValue.Status, nil
  24417. }
  24418. // AddStatus adds u to the "status" field.
  24419. func (m *MessageRecordsMutation) AddStatus(u int8) {
  24420. if m.addstatus != nil {
  24421. *m.addstatus += u
  24422. } else {
  24423. m.addstatus = &u
  24424. }
  24425. }
  24426. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24427. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  24428. v := m.addstatus
  24429. if v == nil {
  24430. return
  24431. }
  24432. return *v, true
  24433. }
  24434. // ClearStatus clears the value of the "status" field.
  24435. func (m *MessageRecordsMutation) ClearStatus() {
  24436. m.status = nil
  24437. m.addstatus = nil
  24438. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  24439. }
  24440. // StatusCleared returns if the "status" field was cleared in this mutation.
  24441. func (m *MessageRecordsMutation) StatusCleared() bool {
  24442. _, ok := m.clearedFields[messagerecords.FieldStatus]
  24443. return ok
  24444. }
  24445. // ResetStatus resets all changes to the "status" field.
  24446. func (m *MessageRecordsMutation) ResetStatus() {
  24447. m.status = nil
  24448. m.addstatus = nil
  24449. delete(m.clearedFields, messagerecords.FieldStatus)
  24450. }
  24451. // SetBotWxid sets the "bot_wxid" field.
  24452. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  24453. m.bot_wxid = &s
  24454. }
  24455. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  24456. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  24457. v := m.bot_wxid
  24458. if v == nil {
  24459. return
  24460. }
  24461. return *v, true
  24462. }
  24463. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  24464. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24466. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  24467. if !m.op.Is(OpUpdateOne) {
  24468. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  24469. }
  24470. if m.id == nil || m.oldValue == nil {
  24471. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  24472. }
  24473. oldValue, err := m.oldValue(ctx)
  24474. if err != nil {
  24475. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  24476. }
  24477. return oldValue.BotWxid, nil
  24478. }
  24479. // ResetBotWxid resets all changes to the "bot_wxid" field.
  24480. func (m *MessageRecordsMutation) ResetBotWxid() {
  24481. m.bot_wxid = nil
  24482. }
  24483. // SetContactID sets the "contact_id" field.
  24484. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  24485. m.message_contact = &u
  24486. }
  24487. // ContactID returns the value of the "contact_id" field in the mutation.
  24488. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  24489. v := m.message_contact
  24490. if v == nil {
  24491. return
  24492. }
  24493. return *v, true
  24494. }
  24495. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  24496. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24498. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  24499. if !m.op.Is(OpUpdateOne) {
  24500. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  24501. }
  24502. if m.id == nil || m.oldValue == nil {
  24503. return v, errors.New("OldContactID requires an ID field in the mutation")
  24504. }
  24505. oldValue, err := m.oldValue(ctx)
  24506. if err != nil {
  24507. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  24508. }
  24509. return oldValue.ContactID, nil
  24510. }
  24511. // ClearContactID clears the value of the "contact_id" field.
  24512. func (m *MessageRecordsMutation) ClearContactID() {
  24513. m.message_contact = nil
  24514. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  24515. }
  24516. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  24517. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  24518. _, ok := m.clearedFields[messagerecords.FieldContactID]
  24519. return ok
  24520. }
  24521. // ResetContactID resets all changes to the "contact_id" field.
  24522. func (m *MessageRecordsMutation) ResetContactID() {
  24523. m.message_contact = nil
  24524. delete(m.clearedFields, messagerecords.FieldContactID)
  24525. }
  24526. // SetContactType sets the "contact_type" field.
  24527. func (m *MessageRecordsMutation) SetContactType(i int) {
  24528. m.contact_type = &i
  24529. m.addcontact_type = nil
  24530. }
  24531. // ContactType returns the value of the "contact_type" field in the mutation.
  24532. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  24533. v := m.contact_type
  24534. if v == nil {
  24535. return
  24536. }
  24537. return *v, true
  24538. }
  24539. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  24540. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24542. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  24543. if !m.op.Is(OpUpdateOne) {
  24544. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  24545. }
  24546. if m.id == nil || m.oldValue == nil {
  24547. return v, errors.New("OldContactType requires an ID field in the mutation")
  24548. }
  24549. oldValue, err := m.oldValue(ctx)
  24550. if err != nil {
  24551. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  24552. }
  24553. return oldValue.ContactType, nil
  24554. }
  24555. // AddContactType adds i to the "contact_type" field.
  24556. func (m *MessageRecordsMutation) AddContactType(i int) {
  24557. if m.addcontact_type != nil {
  24558. *m.addcontact_type += i
  24559. } else {
  24560. m.addcontact_type = &i
  24561. }
  24562. }
  24563. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  24564. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  24565. v := m.addcontact_type
  24566. if v == nil {
  24567. return
  24568. }
  24569. return *v, true
  24570. }
  24571. // ResetContactType resets all changes to the "contact_type" field.
  24572. func (m *MessageRecordsMutation) ResetContactType() {
  24573. m.contact_type = nil
  24574. m.addcontact_type = nil
  24575. }
  24576. // SetContactWxid sets the "contact_wxid" field.
  24577. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  24578. m.contact_wxid = &s
  24579. }
  24580. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  24581. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  24582. v := m.contact_wxid
  24583. if v == nil {
  24584. return
  24585. }
  24586. return *v, true
  24587. }
  24588. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  24589. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24591. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  24592. if !m.op.Is(OpUpdateOne) {
  24593. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  24594. }
  24595. if m.id == nil || m.oldValue == nil {
  24596. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  24597. }
  24598. oldValue, err := m.oldValue(ctx)
  24599. if err != nil {
  24600. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  24601. }
  24602. return oldValue.ContactWxid, nil
  24603. }
  24604. // ResetContactWxid resets all changes to the "contact_wxid" field.
  24605. func (m *MessageRecordsMutation) ResetContactWxid() {
  24606. m.contact_wxid = nil
  24607. }
  24608. // SetContentType sets the "content_type" field.
  24609. func (m *MessageRecordsMutation) SetContentType(i int) {
  24610. m.content_type = &i
  24611. m.addcontent_type = nil
  24612. }
  24613. // ContentType returns the value of the "content_type" field in the mutation.
  24614. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  24615. v := m.content_type
  24616. if v == nil {
  24617. return
  24618. }
  24619. return *v, true
  24620. }
  24621. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  24622. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24624. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  24625. if !m.op.Is(OpUpdateOne) {
  24626. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  24627. }
  24628. if m.id == nil || m.oldValue == nil {
  24629. return v, errors.New("OldContentType requires an ID field in the mutation")
  24630. }
  24631. oldValue, err := m.oldValue(ctx)
  24632. if err != nil {
  24633. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  24634. }
  24635. return oldValue.ContentType, nil
  24636. }
  24637. // AddContentType adds i to the "content_type" field.
  24638. func (m *MessageRecordsMutation) AddContentType(i int) {
  24639. if m.addcontent_type != nil {
  24640. *m.addcontent_type += i
  24641. } else {
  24642. m.addcontent_type = &i
  24643. }
  24644. }
  24645. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  24646. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  24647. v := m.addcontent_type
  24648. if v == nil {
  24649. return
  24650. }
  24651. return *v, true
  24652. }
  24653. // ResetContentType resets all changes to the "content_type" field.
  24654. func (m *MessageRecordsMutation) ResetContentType() {
  24655. m.content_type = nil
  24656. m.addcontent_type = nil
  24657. }
  24658. // SetContent sets the "content" field.
  24659. func (m *MessageRecordsMutation) SetContent(s string) {
  24660. m.content = &s
  24661. }
  24662. // Content returns the value of the "content" field in the mutation.
  24663. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  24664. v := m.content
  24665. if v == nil {
  24666. return
  24667. }
  24668. return *v, true
  24669. }
  24670. // OldContent returns the old "content" field's value of the MessageRecords entity.
  24671. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24673. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  24674. if !m.op.Is(OpUpdateOne) {
  24675. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  24676. }
  24677. if m.id == nil || m.oldValue == nil {
  24678. return v, errors.New("OldContent requires an ID field in the mutation")
  24679. }
  24680. oldValue, err := m.oldValue(ctx)
  24681. if err != nil {
  24682. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  24683. }
  24684. return oldValue.Content, nil
  24685. }
  24686. // ResetContent resets all changes to the "content" field.
  24687. func (m *MessageRecordsMutation) ResetContent() {
  24688. m.content = nil
  24689. }
  24690. // SetMeta sets the "meta" field.
  24691. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  24692. m.meta = &ct
  24693. }
  24694. // Meta returns the value of the "meta" field in the mutation.
  24695. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  24696. v := m.meta
  24697. if v == nil {
  24698. return
  24699. }
  24700. return *v, true
  24701. }
  24702. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  24703. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24705. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  24706. if !m.op.Is(OpUpdateOne) {
  24707. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  24708. }
  24709. if m.id == nil || m.oldValue == nil {
  24710. return v, errors.New("OldMeta requires an ID field in the mutation")
  24711. }
  24712. oldValue, err := m.oldValue(ctx)
  24713. if err != nil {
  24714. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  24715. }
  24716. return oldValue.Meta, nil
  24717. }
  24718. // ClearMeta clears the value of the "meta" field.
  24719. func (m *MessageRecordsMutation) ClearMeta() {
  24720. m.meta = nil
  24721. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  24722. }
  24723. // MetaCleared returns if the "meta" field was cleared in this mutation.
  24724. func (m *MessageRecordsMutation) MetaCleared() bool {
  24725. _, ok := m.clearedFields[messagerecords.FieldMeta]
  24726. return ok
  24727. }
  24728. // ResetMeta resets all changes to the "meta" field.
  24729. func (m *MessageRecordsMutation) ResetMeta() {
  24730. m.meta = nil
  24731. delete(m.clearedFields, messagerecords.FieldMeta)
  24732. }
  24733. // SetErrorDetail sets the "error_detail" field.
  24734. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  24735. m.error_detail = &s
  24736. }
  24737. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  24738. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  24739. v := m.error_detail
  24740. if v == nil {
  24741. return
  24742. }
  24743. return *v, true
  24744. }
  24745. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  24746. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24748. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  24749. if !m.op.Is(OpUpdateOne) {
  24750. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  24751. }
  24752. if m.id == nil || m.oldValue == nil {
  24753. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  24754. }
  24755. oldValue, err := m.oldValue(ctx)
  24756. if err != nil {
  24757. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  24758. }
  24759. return oldValue.ErrorDetail, nil
  24760. }
  24761. // ResetErrorDetail resets all changes to the "error_detail" field.
  24762. func (m *MessageRecordsMutation) ResetErrorDetail() {
  24763. m.error_detail = nil
  24764. }
  24765. // SetSendTime sets the "send_time" field.
  24766. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  24767. m.send_time = &t
  24768. }
  24769. // SendTime returns the value of the "send_time" field in the mutation.
  24770. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  24771. v := m.send_time
  24772. if v == nil {
  24773. return
  24774. }
  24775. return *v, true
  24776. }
  24777. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  24778. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24780. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  24781. if !m.op.Is(OpUpdateOne) {
  24782. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  24783. }
  24784. if m.id == nil || m.oldValue == nil {
  24785. return v, errors.New("OldSendTime requires an ID field in the mutation")
  24786. }
  24787. oldValue, err := m.oldValue(ctx)
  24788. if err != nil {
  24789. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  24790. }
  24791. return oldValue.SendTime, nil
  24792. }
  24793. // ClearSendTime clears the value of the "send_time" field.
  24794. func (m *MessageRecordsMutation) ClearSendTime() {
  24795. m.send_time = nil
  24796. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  24797. }
  24798. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  24799. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  24800. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  24801. return ok
  24802. }
  24803. // ResetSendTime resets all changes to the "send_time" field.
  24804. func (m *MessageRecordsMutation) ResetSendTime() {
  24805. m.send_time = nil
  24806. delete(m.clearedFields, messagerecords.FieldSendTime)
  24807. }
  24808. // SetSourceType sets the "source_type" field.
  24809. func (m *MessageRecordsMutation) SetSourceType(i int) {
  24810. m.source_type = &i
  24811. m.addsource_type = nil
  24812. }
  24813. // SourceType returns the value of the "source_type" field in the mutation.
  24814. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  24815. v := m.source_type
  24816. if v == nil {
  24817. return
  24818. }
  24819. return *v, true
  24820. }
  24821. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  24822. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24824. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  24825. if !m.op.Is(OpUpdateOne) {
  24826. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  24827. }
  24828. if m.id == nil || m.oldValue == nil {
  24829. return v, errors.New("OldSourceType requires an ID field in the mutation")
  24830. }
  24831. oldValue, err := m.oldValue(ctx)
  24832. if err != nil {
  24833. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  24834. }
  24835. return oldValue.SourceType, nil
  24836. }
  24837. // AddSourceType adds i to the "source_type" field.
  24838. func (m *MessageRecordsMutation) AddSourceType(i int) {
  24839. if m.addsource_type != nil {
  24840. *m.addsource_type += i
  24841. } else {
  24842. m.addsource_type = &i
  24843. }
  24844. }
  24845. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  24846. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  24847. v := m.addsource_type
  24848. if v == nil {
  24849. return
  24850. }
  24851. return *v, true
  24852. }
  24853. // ResetSourceType resets all changes to the "source_type" field.
  24854. func (m *MessageRecordsMutation) ResetSourceType() {
  24855. m.source_type = nil
  24856. m.addsource_type = nil
  24857. }
  24858. // SetSourceID sets the "source_id" field.
  24859. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  24860. m.sop_stage = &u
  24861. }
  24862. // SourceID returns the value of the "source_id" field in the mutation.
  24863. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  24864. v := m.sop_stage
  24865. if v == nil {
  24866. return
  24867. }
  24868. return *v, true
  24869. }
  24870. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  24871. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24873. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  24874. if !m.op.Is(OpUpdateOne) {
  24875. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  24876. }
  24877. if m.id == nil || m.oldValue == nil {
  24878. return v, errors.New("OldSourceID requires an ID field in the mutation")
  24879. }
  24880. oldValue, err := m.oldValue(ctx)
  24881. if err != nil {
  24882. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  24883. }
  24884. return oldValue.SourceID, nil
  24885. }
  24886. // ClearSourceID clears the value of the "source_id" field.
  24887. func (m *MessageRecordsMutation) ClearSourceID() {
  24888. m.sop_stage = nil
  24889. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24890. }
  24891. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  24892. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  24893. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  24894. return ok
  24895. }
  24896. // ResetSourceID resets all changes to the "source_id" field.
  24897. func (m *MessageRecordsMutation) ResetSourceID() {
  24898. m.sop_stage = nil
  24899. delete(m.clearedFields, messagerecords.FieldSourceID)
  24900. }
  24901. // SetSubSourceID sets the "sub_source_id" field.
  24902. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  24903. m.sop_node = &u
  24904. }
  24905. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  24906. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  24907. v := m.sop_node
  24908. if v == nil {
  24909. return
  24910. }
  24911. return *v, true
  24912. }
  24913. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  24914. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24916. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  24917. if !m.op.Is(OpUpdateOne) {
  24918. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  24919. }
  24920. if m.id == nil || m.oldValue == nil {
  24921. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  24922. }
  24923. oldValue, err := m.oldValue(ctx)
  24924. if err != nil {
  24925. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  24926. }
  24927. return oldValue.SubSourceID, nil
  24928. }
  24929. // ClearSubSourceID clears the value of the "sub_source_id" field.
  24930. func (m *MessageRecordsMutation) ClearSubSourceID() {
  24931. m.sop_node = nil
  24932. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  24933. }
  24934. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  24935. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  24936. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  24937. return ok
  24938. }
  24939. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  24940. func (m *MessageRecordsMutation) ResetSubSourceID() {
  24941. m.sop_node = nil
  24942. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  24943. }
  24944. // SetOrganizationID sets the "organization_id" field.
  24945. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  24946. m.organization_id = &u
  24947. m.addorganization_id = nil
  24948. }
  24949. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24950. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  24951. v := m.organization_id
  24952. if v == nil {
  24953. return
  24954. }
  24955. return *v, true
  24956. }
  24957. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  24958. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24960. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24961. if !m.op.Is(OpUpdateOne) {
  24962. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24963. }
  24964. if m.id == nil || m.oldValue == nil {
  24965. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24966. }
  24967. oldValue, err := m.oldValue(ctx)
  24968. if err != nil {
  24969. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24970. }
  24971. return oldValue.OrganizationID, nil
  24972. }
  24973. // AddOrganizationID adds u to the "organization_id" field.
  24974. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  24975. if m.addorganization_id != nil {
  24976. *m.addorganization_id += u
  24977. } else {
  24978. m.addorganization_id = &u
  24979. }
  24980. }
  24981. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24982. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  24983. v := m.addorganization_id
  24984. if v == nil {
  24985. return
  24986. }
  24987. return *v, true
  24988. }
  24989. // ClearOrganizationID clears the value of the "organization_id" field.
  24990. func (m *MessageRecordsMutation) ClearOrganizationID() {
  24991. m.organization_id = nil
  24992. m.addorganization_id = nil
  24993. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  24994. }
  24995. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24996. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  24997. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  24998. return ok
  24999. }
  25000. // ResetOrganizationID resets all changes to the "organization_id" field.
  25001. func (m *MessageRecordsMutation) ResetOrganizationID() {
  25002. m.organization_id = nil
  25003. m.addorganization_id = nil
  25004. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  25005. }
  25006. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25007. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  25008. m.sop_stage = &id
  25009. }
  25010. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  25011. func (m *MessageRecordsMutation) ClearSopStage() {
  25012. m.clearedsop_stage = true
  25013. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  25014. }
  25015. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  25016. func (m *MessageRecordsMutation) SopStageCleared() bool {
  25017. return m.SourceIDCleared() || m.clearedsop_stage
  25018. }
  25019. // SopStageID returns the "sop_stage" edge ID in the mutation.
  25020. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  25021. if m.sop_stage != nil {
  25022. return *m.sop_stage, true
  25023. }
  25024. return
  25025. }
  25026. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  25027. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25028. // SopStageID instead. It exists only for internal usage by the builders.
  25029. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  25030. if id := m.sop_stage; id != nil {
  25031. ids = append(ids, *id)
  25032. }
  25033. return
  25034. }
  25035. // ResetSopStage resets all changes to the "sop_stage" edge.
  25036. func (m *MessageRecordsMutation) ResetSopStage() {
  25037. m.sop_stage = nil
  25038. m.clearedsop_stage = false
  25039. }
  25040. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  25041. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  25042. m.sop_node = &id
  25043. }
  25044. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  25045. func (m *MessageRecordsMutation) ClearSopNode() {
  25046. m.clearedsop_node = true
  25047. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  25048. }
  25049. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  25050. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  25051. return m.SubSourceIDCleared() || m.clearedsop_node
  25052. }
  25053. // SopNodeID returns the "sop_node" edge ID in the mutation.
  25054. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  25055. if m.sop_node != nil {
  25056. return *m.sop_node, true
  25057. }
  25058. return
  25059. }
  25060. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  25061. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25062. // SopNodeID instead. It exists only for internal usage by the builders.
  25063. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  25064. if id := m.sop_node; id != nil {
  25065. ids = append(ids, *id)
  25066. }
  25067. return
  25068. }
  25069. // ResetSopNode resets all changes to the "sop_node" edge.
  25070. func (m *MessageRecordsMutation) ResetSopNode() {
  25071. m.sop_node = nil
  25072. m.clearedsop_node = false
  25073. }
  25074. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  25075. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  25076. m.message_contact = &id
  25077. }
  25078. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  25079. func (m *MessageRecordsMutation) ClearMessageContact() {
  25080. m.clearedmessage_contact = true
  25081. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  25082. }
  25083. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  25084. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  25085. return m.ContactIDCleared() || m.clearedmessage_contact
  25086. }
  25087. // MessageContactID returns the "message_contact" edge ID in the mutation.
  25088. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  25089. if m.message_contact != nil {
  25090. return *m.message_contact, true
  25091. }
  25092. return
  25093. }
  25094. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  25095. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25096. // MessageContactID instead. It exists only for internal usage by the builders.
  25097. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  25098. if id := m.message_contact; id != nil {
  25099. ids = append(ids, *id)
  25100. }
  25101. return
  25102. }
  25103. // ResetMessageContact resets all changes to the "message_contact" edge.
  25104. func (m *MessageRecordsMutation) ResetMessageContact() {
  25105. m.message_contact = nil
  25106. m.clearedmessage_contact = false
  25107. }
  25108. // Where appends a list predicates to the MessageRecordsMutation builder.
  25109. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  25110. m.predicates = append(m.predicates, ps...)
  25111. }
  25112. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  25113. // users can use type-assertion to append predicates that do not depend on any generated package.
  25114. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  25115. p := make([]predicate.MessageRecords, len(ps))
  25116. for i := range ps {
  25117. p[i] = ps[i]
  25118. }
  25119. m.Where(p...)
  25120. }
  25121. // Op returns the operation name.
  25122. func (m *MessageRecordsMutation) Op() Op {
  25123. return m.op
  25124. }
  25125. // SetOp allows setting the mutation operation.
  25126. func (m *MessageRecordsMutation) SetOp(op Op) {
  25127. m.op = op
  25128. }
  25129. // Type returns the node type of this mutation (MessageRecords).
  25130. func (m *MessageRecordsMutation) Type() string {
  25131. return m.typ
  25132. }
  25133. // Fields returns all fields that were changed during this mutation. Note that in
  25134. // order to get all numeric fields that were incremented/decremented, call
  25135. // AddedFields().
  25136. func (m *MessageRecordsMutation) Fields() []string {
  25137. fields := make([]string, 0, 16)
  25138. if m.created_at != nil {
  25139. fields = append(fields, messagerecords.FieldCreatedAt)
  25140. }
  25141. if m.updated_at != nil {
  25142. fields = append(fields, messagerecords.FieldUpdatedAt)
  25143. }
  25144. if m.status != nil {
  25145. fields = append(fields, messagerecords.FieldStatus)
  25146. }
  25147. if m.bot_wxid != nil {
  25148. fields = append(fields, messagerecords.FieldBotWxid)
  25149. }
  25150. if m.message_contact != nil {
  25151. fields = append(fields, messagerecords.FieldContactID)
  25152. }
  25153. if m.contact_type != nil {
  25154. fields = append(fields, messagerecords.FieldContactType)
  25155. }
  25156. if m.contact_wxid != nil {
  25157. fields = append(fields, messagerecords.FieldContactWxid)
  25158. }
  25159. if m.content_type != nil {
  25160. fields = append(fields, messagerecords.FieldContentType)
  25161. }
  25162. if m.content != nil {
  25163. fields = append(fields, messagerecords.FieldContent)
  25164. }
  25165. if m.meta != nil {
  25166. fields = append(fields, messagerecords.FieldMeta)
  25167. }
  25168. if m.error_detail != nil {
  25169. fields = append(fields, messagerecords.FieldErrorDetail)
  25170. }
  25171. if m.send_time != nil {
  25172. fields = append(fields, messagerecords.FieldSendTime)
  25173. }
  25174. if m.source_type != nil {
  25175. fields = append(fields, messagerecords.FieldSourceType)
  25176. }
  25177. if m.sop_stage != nil {
  25178. fields = append(fields, messagerecords.FieldSourceID)
  25179. }
  25180. if m.sop_node != nil {
  25181. fields = append(fields, messagerecords.FieldSubSourceID)
  25182. }
  25183. if m.organization_id != nil {
  25184. fields = append(fields, messagerecords.FieldOrganizationID)
  25185. }
  25186. return fields
  25187. }
  25188. // Field returns the value of a field with the given name. The second boolean
  25189. // return value indicates that this field was not set, or was not defined in the
  25190. // schema.
  25191. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  25192. switch name {
  25193. case messagerecords.FieldCreatedAt:
  25194. return m.CreatedAt()
  25195. case messagerecords.FieldUpdatedAt:
  25196. return m.UpdatedAt()
  25197. case messagerecords.FieldStatus:
  25198. return m.Status()
  25199. case messagerecords.FieldBotWxid:
  25200. return m.BotWxid()
  25201. case messagerecords.FieldContactID:
  25202. return m.ContactID()
  25203. case messagerecords.FieldContactType:
  25204. return m.ContactType()
  25205. case messagerecords.FieldContactWxid:
  25206. return m.ContactWxid()
  25207. case messagerecords.FieldContentType:
  25208. return m.ContentType()
  25209. case messagerecords.FieldContent:
  25210. return m.Content()
  25211. case messagerecords.FieldMeta:
  25212. return m.Meta()
  25213. case messagerecords.FieldErrorDetail:
  25214. return m.ErrorDetail()
  25215. case messagerecords.FieldSendTime:
  25216. return m.SendTime()
  25217. case messagerecords.FieldSourceType:
  25218. return m.SourceType()
  25219. case messagerecords.FieldSourceID:
  25220. return m.SourceID()
  25221. case messagerecords.FieldSubSourceID:
  25222. return m.SubSourceID()
  25223. case messagerecords.FieldOrganizationID:
  25224. return m.OrganizationID()
  25225. }
  25226. return nil, false
  25227. }
  25228. // OldField returns the old value of the field from the database. An error is
  25229. // returned if the mutation operation is not UpdateOne, or the query to the
  25230. // database failed.
  25231. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25232. switch name {
  25233. case messagerecords.FieldCreatedAt:
  25234. return m.OldCreatedAt(ctx)
  25235. case messagerecords.FieldUpdatedAt:
  25236. return m.OldUpdatedAt(ctx)
  25237. case messagerecords.FieldStatus:
  25238. return m.OldStatus(ctx)
  25239. case messagerecords.FieldBotWxid:
  25240. return m.OldBotWxid(ctx)
  25241. case messagerecords.FieldContactID:
  25242. return m.OldContactID(ctx)
  25243. case messagerecords.FieldContactType:
  25244. return m.OldContactType(ctx)
  25245. case messagerecords.FieldContactWxid:
  25246. return m.OldContactWxid(ctx)
  25247. case messagerecords.FieldContentType:
  25248. return m.OldContentType(ctx)
  25249. case messagerecords.FieldContent:
  25250. return m.OldContent(ctx)
  25251. case messagerecords.FieldMeta:
  25252. return m.OldMeta(ctx)
  25253. case messagerecords.FieldErrorDetail:
  25254. return m.OldErrorDetail(ctx)
  25255. case messagerecords.FieldSendTime:
  25256. return m.OldSendTime(ctx)
  25257. case messagerecords.FieldSourceType:
  25258. return m.OldSourceType(ctx)
  25259. case messagerecords.FieldSourceID:
  25260. return m.OldSourceID(ctx)
  25261. case messagerecords.FieldSubSourceID:
  25262. return m.OldSubSourceID(ctx)
  25263. case messagerecords.FieldOrganizationID:
  25264. return m.OldOrganizationID(ctx)
  25265. }
  25266. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  25267. }
  25268. // SetField sets the value of a field with the given name. It returns an error if
  25269. // the field is not defined in the schema, or if the type mismatched the field
  25270. // type.
  25271. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  25272. switch name {
  25273. case messagerecords.FieldCreatedAt:
  25274. v, ok := value.(time.Time)
  25275. if !ok {
  25276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25277. }
  25278. m.SetCreatedAt(v)
  25279. return nil
  25280. case messagerecords.FieldUpdatedAt:
  25281. v, ok := value.(time.Time)
  25282. if !ok {
  25283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25284. }
  25285. m.SetUpdatedAt(v)
  25286. return nil
  25287. case messagerecords.FieldStatus:
  25288. v, ok := value.(uint8)
  25289. if !ok {
  25290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25291. }
  25292. m.SetStatus(v)
  25293. return nil
  25294. case messagerecords.FieldBotWxid:
  25295. v, ok := value.(string)
  25296. if !ok {
  25297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25298. }
  25299. m.SetBotWxid(v)
  25300. return nil
  25301. case messagerecords.FieldContactID:
  25302. v, ok := value.(uint64)
  25303. if !ok {
  25304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25305. }
  25306. m.SetContactID(v)
  25307. return nil
  25308. case messagerecords.FieldContactType:
  25309. v, ok := value.(int)
  25310. if !ok {
  25311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25312. }
  25313. m.SetContactType(v)
  25314. return nil
  25315. case messagerecords.FieldContactWxid:
  25316. v, ok := value.(string)
  25317. if !ok {
  25318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25319. }
  25320. m.SetContactWxid(v)
  25321. return nil
  25322. case messagerecords.FieldContentType:
  25323. v, ok := value.(int)
  25324. if !ok {
  25325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25326. }
  25327. m.SetContentType(v)
  25328. return nil
  25329. case messagerecords.FieldContent:
  25330. v, ok := value.(string)
  25331. if !ok {
  25332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25333. }
  25334. m.SetContent(v)
  25335. return nil
  25336. case messagerecords.FieldMeta:
  25337. v, ok := value.(custom_types.Meta)
  25338. if !ok {
  25339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25340. }
  25341. m.SetMeta(v)
  25342. return nil
  25343. case messagerecords.FieldErrorDetail:
  25344. v, ok := value.(string)
  25345. if !ok {
  25346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25347. }
  25348. m.SetErrorDetail(v)
  25349. return nil
  25350. case messagerecords.FieldSendTime:
  25351. v, ok := value.(time.Time)
  25352. if !ok {
  25353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25354. }
  25355. m.SetSendTime(v)
  25356. return nil
  25357. case messagerecords.FieldSourceType:
  25358. v, ok := value.(int)
  25359. if !ok {
  25360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25361. }
  25362. m.SetSourceType(v)
  25363. return nil
  25364. case messagerecords.FieldSourceID:
  25365. v, ok := value.(uint64)
  25366. if !ok {
  25367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25368. }
  25369. m.SetSourceID(v)
  25370. return nil
  25371. case messagerecords.FieldSubSourceID:
  25372. v, ok := value.(uint64)
  25373. if !ok {
  25374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25375. }
  25376. m.SetSubSourceID(v)
  25377. return nil
  25378. case messagerecords.FieldOrganizationID:
  25379. v, ok := value.(uint64)
  25380. if !ok {
  25381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25382. }
  25383. m.SetOrganizationID(v)
  25384. return nil
  25385. }
  25386. return fmt.Errorf("unknown MessageRecords field %s", name)
  25387. }
  25388. // AddedFields returns all numeric fields that were incremented/decremented during
  25389. // this mutation.
  25390. func (m *MessageRecordsMutation) AddedFields() []string {
  25391. var fields []string
  25392. if m.addstatus != nil {
  25393. fields = append(fields, messagerecords.FieldStatus)
  25394. }
  25395. if m.addcontact_type != nil {
  25396. fields = append(fields, messagerecords.FieldContactType)
  25397. }
  25398. if m.addcontent_type != nil {
  25399. fields = append(fields, messagerecords.FieldContentType)
  25400. }
  25401. if m.addsource_type != nil {
  25402. fields = append(fields, messagerecords.FieldSourceType)
  25403. }
  25404. if m.addorganization_id != nil {
  25405. fields = append(fields, messagerecords.FieldOrganizationID)
  25406. }
  25407. return fields
  25408. }
  25409. // AddedField returns the numeric value that was incremented/decremented on a field
  25410. // with the given name. The second boolean return value indicates that this field
  25411. // was not set, or was not defined in the schema.
  25412. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  25413. switch name {
  25414. case messagerecords.FieldStatus:
  25415. return m.AddedStatus()
  25416. case messagerecords.FieldContactType:
  25417. return m.AddedContactType()
  25418. case messagerecords.FieldContentType:
  25419. return m.AddedContentType()
  25420. case messagerecords.FieldSourceType:
  25421. return m.AddedSourceType()
  25422. case messagerecords.FieldOrganizationID:
  25423. return m.AddedOrganizationID()
  25424. }
  25425. return nil, false
  25426. }
  25427. // AddField adds the value to the field with the given name. It returns an error if
  25428. // the field is not defined in the schema, or if the type mismatched the field
  25429. // type.
  25430. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  25431. switch name {
  25432. case messagerecords.FieldStatus:
  25433. v, ok := value.(int8)
  25434. if !ok {
  25435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25436. }
  25437. m.AddStatus(v)
  25438. return nil
  25439. case messagerecords.FieldContactType:
  25440. v, ok := value.(int)
  25441. if !ok {
  25442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25443. }
  25444. m.AddContactType(v)
  25445. return nil
  25446. case messagerecords.FieldContentType:
  25447. v, ok := value.(int)
  25448. if !ok {
  25449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25450. }
  25451. m.AddContentType(v)
  25452. return nil
  25453. case messagerecords.FieldSourceType:
  25454. v, ok := value.(int)
  25455. if !ok {
  25456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25457. }
  25458. m.AddSourceType(v)
  25459. return nil
  25460. case messagerecords.FieldOrganizationID:
  25461. v, ok := value.(int64)
  25462. if !ok {
  25463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25464. }
  25465. m.AddOrganizationID(v)
  25466. return nil
  25467. }
  25468. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  25469. }
  25470. // ClearedFields returns all nullable fields that were cleared during this
  25471. // mutation.
  25472. func (m *MessageRecordsMutation) ClearedFields() []string {
  25473. var fields []string
  25474. if m.FieldCleared(messagerecords.FieldStatus) {
  25475. fields = append(fields, messagerecords.FieldStatus)
  25476. }
  25477. if m.FieldCleared(messagerecords.FieldContactID) {
  25478. fields = append(fields, messagerecords.FieldContactID)
  25479. }
  25480. if m.FieldCleared(messagerecords.FieldMeta) {
  25481. fields = append(fields, messagerecords.FieldMeta)
  25482. }
  25483. if m.FieldCleared(messagerecords.FieldSendTime) {
  25484. fields = append(fields, messagerecords.FieldSendTime)
  25485. }
  25486. if m.FieldCleared(messagerecords.FieldSourceID) {
  25487. fields = append(fields, messagerecords.FieldSourceID)
  25488. }
  25489. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  25490. fields = append(fields, messagerecords.FieldSubSourceID)
  25491. }
  25492. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  25493. fields = append(fields, messagerecords.FieldOrganizationID)
  25494. }
  25495. return fields
  25496. }
  25497. // FieldCleared returns a boolean indicating if a field with the given name was
  25498. // cleared in this mutation.
  25499. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  25500. _, ok := m.clearedFields[name]
  25501. return ok
  25502. }
  25503. // ClearField clears the value of the field with the given name. It returns an
  25504. // error if the field is not defined in the schema.
  25505. func (m *MessageRecordsMutation) ClearField(name string) error {
  25506. switch name {
  25507. case messagerecords.FieldStatus:
  25508. m.ClearStatus()
  25509. return nil
  25510. case messagerecords.FieldContactID:
  25511. m.ClearContactID()
  25512. return nil
  25513. case messagerecords.FieldMeta:
  25514. m.ClearMeta()
  25515. return nil
  25516. case messagerecords.FieldSendTime:
  25517. m.ClearSendTime()
  25518. return nil
  25519. case messagerecords.FieldSourceID:
  25520. m.ClearSourceID()
  25521. return nil
  25522. case messagerecords.FieldSubSourceID:
  25523. m.ClearSubSourceID()
  25524. return nil
  25525. case messagerecords.FieldOrganizationID:
  25526. m.ClearOrganizationID()
  25527. return nil
  25528. }
  25529. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  25530. }
  25531. // ResetField resets all changes in the mutation for the field with the given name.
  25532. // It returns an error if the field is not defined in the schema.
  25533. func (m *MessageRecordsMutation) ResetField(name string) error {
  25534. switch name {
  25535. case messagerecords.FieldCreatedAt:
  25536. m.ResetCreatedAt()
  25537. return nil
  25538. case messagerecords.FieldUpdatedAt:
  25539. m.ResetUpdatedAt()
  25540. return nil
  25541. case messagerecords.FieldStatus:
  25542. m.ResetStatus()
  25543. return nil
  25544. case messagerecords.FieldBotWxid:
  25545. m.ResetBotWxid()
  25546. return nil
  25547. case messagerecords.FieldContactID:
  25548. m.ResetContactID()
  25549. return nil
  25550. case messagerecords.FieldContactType:
  25551. m.ResetContactType()
  25552. return nil
  25553. case messagerecords.FieldContactWxid:
  25554. m.ResetContactWxid()
  25555. return nil
  25556. case messagerecords.FieldContentType:
  25557. m.ResetContentType()
  25558. return nil
  25559. case messagerecords.FieldContent:
  25560. m.ResetContent()
  25561. return nil
  25562. case messagerecords.FieldMeta:
  25563. m.ResetMeta()
  25564. return nil
  25565. case messagerecords.FieldErrorDetail:
  25566. m.ResetErrorDetail()
  25567. return nil
  25568. case messagerecords.FieldSendTime:
  25569. m.ResetSendTime()
  25570. return nil
  25571. case messagerecords.FieldSourceType:
  25572. m.ResetSourceType()
  25573. return nil
  25574. case messagerecords.FieldSourceID:
  25575. m.ResetSourceID()
  25576. return nil
  25577. case messagerecords.FieldSubSourceID:
  25578. m.ResetSubSourceID()
  25579. return nil
  25580. case messagerecords.FieldOrganizationID:
  25581. m.ResetOrganizationID()
  25582. return nil
  25583. }
  25584. return fmt.Errorf("unknown MessageRecords field %s", name)
  25585. }
  25586. // AddedEdges returns all edge names that were set/added in this mutation.
  25587. func (m *MessageRecordsMutation) AddedEdges() []string {
  25588. edges := make([]string, 0, 3)
  25589. if m.sop_stage != nil {
  25590. edges = append(edges, messagerecords.EdgeSopStage)
  25591. }
  25592. if m.sop_node != nil {
  25593. edges = append(edges, messagerecords.EdgeSopNode)
  25594. }
  25595. if m.message_contact != nil {
  25596. edges = append(edges, messagerecords.EdgeMessageContact)
  25597. }
  25598. return edges
  25599. }
  25600. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25601. // name in this mutation.
  25602. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  25603. switch name {
  25604. case messagerecords.EdgeSopStage:
  25605. if id := m.sop_stage; id != nil {
  25606. return []ent.Value{*id}
  25607. }
  25608. case messagerecords.EdgeSopNode:
  25609. if id := m.sop_node; id != nil {
  25610. return []ent.Value{*id}
  25611. }
  25612. case messagerecords.EdgeMessageContact:
  25613. if id := m.message_contact; id != nil {
  25614. return []ent.Value{*id}
  25615. }
  25616. }
  25617. return nil
  25618. }
  25619. // RemovedEdges returns all edge names that were removed in this mutation.
  25620. func (m *MessageRecordsMutation) RemovedEdges() []string {
  25621. edges := make([]string, 0, 3)
  25622. return edges
  25623. }
  25624. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25625. // the given name in this mutation.
  25626. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  25627. return nil
  25628. }
  25629. // ClearedEdges returns all edge names that were cleared in this mutation.
  25630. func (m *MessageRecordsMutation) ClearedEdges() []string {
  25631. edges := make([]string, 0, 3)
  25632. if m.clearedsop_stage {
  25633. edges = append(edges, messagerecords.EdgeSopStage)
  25634. }
  25635. if m.clearedsop_node {
  25636. edges = append(edges, messagerecords.EdgeSopNode)
  25637. }
  25638. if m.clearedmessage_contact {
  25639. edges = append(edges, messagerecords.EdgeMessageContact)
  25640. }
  25641. return edges
  25642. }
  25643. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25644. // was cleared in this mutation.
  25645. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  25646. switch name {
  25647. case messagerecords.EdgeSopStage:
  25648. return m.clearedsop_stage
  25649. case messagerecords.EdgeSopNode:
  25650. return m.clearedsop_node
  25651. case messagerecords.EdgeMessageContact:
  25652. return m.clearedmessage_contact
  25653. }
  25654. return false
  25655. }
  25656. // ClearEdge clears the value of the edge with the given name. It returns an error
  25657. // if that edge is not defined in the schema.
  25658. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  25659. switch name {
  25660. case messagerecords.EdgeSopStage:
  25661. m.ClearSopStage()
  25662. return nil
  25663. case messagerecords.EdgeSopNode:
  25664. m.ClearSopNode()
  25665. return nil
  25666. case messagerecords.EdgeMessageContact:
  25667. m.ClearMessageContact()
  25668. return nil
  25669. }
  25670. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  25671. }
  25672. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25673. // It returns an error if the edge is not defined in the schema.
  25674. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  25675. switch name {
  25676. case messagerecords.EdgeSopStage:
  25677. m.ResetSopStage()
  25678. return nil
  25679. case messagerecords.EdgeSopNode:
  25680. m.ResetSopNode()
  25681. return nil
  25682. case messagerecords.EdgeMessageContact:
  25683. m.ResetMessageContact()
  25684. return nil
  25685. }
  25686. return fmt.Errorf("unknown MessageRecords edge %s", name)
  25687. }
  25688. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  25689. type MsgMutation struct {
  25690. config
  25691. op Op
  25692. typ string
  25693. id *uint64
  25694. created_at *time.Time
  25695. updated_at *time.Time
  25696. deleted_at *time.Time
  25697. status *uint8
  25698. addstatus *int8
  25699. fromwxid *string
  25700. toid *string
  25701. msgtype *int32
  25702. addmsgtype *int32
  25703. msg *string
  25704. batch_no *string
  25705. cc *string
  25706. phone *string
  25707. clearedFields map[string]struct{}
  25708. done bool
  25709. oldValue func(context.Context) (*Msg, error)
  25710. predicates []predicate.Msg
  25711. }
  25712. var _ ent.Mutation = (*MsgMutation)(nil)
  25713. // msgOption allows management of the mutation configuration using functional options.
  25714. type msgOption func(*MsgMutation)
  25715. // newMsgMutation creates new mutation for the Msg entity.
  25716. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  25717. m := &MsgMutation{
  25718. config: c,
  25719. op: op,
  25720. typ: TypeMsg,
  25721. clearedFields: make(map[string]struct{}),
  25722. }
  25723. for _, opt := range opts {
  25724. opt(m)
  25725. }
  25726. return m
  25727. }
  25728. // withMsgID sets the ID field of the mutation.
  25729. func withMsgID(id uint64) msgOption {
  25730. return func(m *MsgMutation) {
  25731. var (
  25732. err error
  25733. once sync.Once
  25734. value *Msg
  25735. )
  25736. m.oldValue = func(ctx context.Context) (*Msg, error) {
  25737. once.Do(func() {
  25738. if m.done {
  25739. err = errors.New("querying old values post mutation is not allowed")
  25740. } else {
  25741. value, err = m.Client().Msg.Get(ctx, id)
  25742. }
  25743. })
  25744. return value, err
  25745. }
  25746. m.id = &id
  25747. }
  25748. }
  25749. // withMsg sets the old Msg of the mutation.
  25750. func withMsg(node *Msg) msgOption {
  25751. return func(m *MsgMutation) {
  25752. m.oldValue = func(context.Context) (*Msg, error) {
  25753. return node, nil
  25754. }
  25755. m.id = &node.ID
  25756. }
  25757. }
  25758. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25759. // executed in a transaction (ent.Tx), a transactional client is returned.
  25760. func (m MsgMutation) Client() *Client {
  25761. client := &Client{config: m.config}
  25762. client.init()
  25763. return client
  25764. }
  25765. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25766. // it returns an error otherwise.
  25767. func (m MsgMutation) Tx() (*Tx, error) {
  25768. if _, ok := m.driver.(*txDriver); !ok {
  25769. return nil, errors.New("ent: mutation is not running in a transaction")
  25770. }
  25771. tx := &Tx{config: m.config}
  25772. tx.init()
  25773. return tx, nil
  25774. }
  25775. // SetID sets the value of the id field. Note that this
  25776. // operation is only accepted on creation of Msg entities.
  25777. func (m *MsgMutation) SetID(id uint64) {
  25778. m.id = &id
  25779. }
  25780. // ID returns the ID value in the mutation. Note that the ID is only available
  25781. // if it was provided to the builder or after it was returned from the database.
  25782. func (m *MsgMutation) ID() (id uint64, exists bool) {
  25783. if m.id == nil {
  25784. return
  25785. }
  25786. return *m.id, true
  25787. }
  25788. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25789. // That means, if the mutation is applied within a transaction with an isolation level such
  25790. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25791. // or updated by the mutation.
  25792. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  25793. switch {
  25794. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25795. id, exists := m.ID()
  25796. if exists {
  25797. return []uint64{id}, nil
  25798. }
  25799. fallthrough
  25800. case m.op.Is(OpUpdate | OpDelete):
  25801. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  25802. default:
  25803. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25804. }
  25805. }
  25806. // SetCreatedAt sets the "created_at" field.
  25807. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  25808. m.created_at = &t
  25809. }
  25810. // CreatedAt returns the value of the "created_at" field in the mutation.
  25811. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  25812. v := m.created_at
  25813. if v == nil {
  25814. return
  25815. }
  25816. return *v, true
  25817. }
  25818. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  25819. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25821. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25822. if !m.op.Is(OpUpdateOne) {
  25823. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25824. }
  25825. if m.id == nil || m.oldValue == nil {
  25826. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25827. }
  25828. oldValue, err := m.oldValue(ctx)
  25829. if err != nil {
  25830. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25831. }
  25832. return oldValue.CreatedAt, nil
  25833. }
  25834. // ResetCreatedAt resets all changes to the "created_at" field.
  25835. func (m *MsgMutation) ResetCreatedAt() {
  25836. m.created_at = nil
  25837. }
  25838. // SetUpdatedAt sets the "updated_at" field.
  25839. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  25840. m.updated_at = &t
  25841. }
  25842. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25843. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  25844. v := m.updated_at
  25845. if v == nil {
  25846. return
  25847. }
  25848. return *v, true
  25849. }
  25850. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  25851. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25853. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25854. if !m.op.Is(OpUpdateOne) {
  25855. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25856. }
  25857. if m.id == nil || m.oldValue == nil {
  25858. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25859. }
  25860. oldValue, err := m.oldValue(ctx)
  25861. if err != nil {
  25862. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25863. }
  25864. return oldValue.UpdatedAt, nil
  25865. }
  25866. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25867. func (m *MsgMutation) ResetUpdatedAt() {
  25868. m.updated_at = nil
  25869. }
  25870. // SetDeletedAt sets the "deleted_at" field.
  25871. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  25872. m.deleted_at = &t
  25873. }
  25874. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25875. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  25876. v := m.deleted_at
  25877. if v == nil {
  25878. return
  25879. }
  25880. return *v, true
  25881. }
  25882. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  25883. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25885. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25886. if !m.op.Is(OpUpdateOne) {
  25887. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25888. }
  25889. if m.id == nil || m.oldValue == nil {
  25890. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25891. }
  25892. oldValue, err := m.oldValue(ctx)
  25893. if err != nil {
  25894. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25895. }
  25896. return oldValue.DeletedAt, nil
  25897. }
  25898. // ClearDeletedAt clears the value of the "deleted_at" field.
  25899. func (m *MsgMutation) ClearDeletedAt() {
  25900. m.deleted_at = nil
  25901. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  25902. }
  25903. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25904. func (m *MsgMutation) DeletedAtCleared() bool {
  25905. _, ok := m.clearedFields[msg.FieldDeletedAt]
  25906. return ok
  25907. }
  25908. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25909. func (m *MsgMutation) ResetDeletedAt() {
  25910. m.deleted_at = nil
  25911. delete(m.clearedFields, msg.FieldDeletedAt)
  25912. }
  25913. // SetStatus sets the "status" field.
  25914. func (m *MsgMutation) SetStatus(u uint8) {
  25915. m.status = &u
  25916. m.addstatus = nil
  25917. }
  25918. // Status returns the value of the "status" field in the mutation.
  25919. func (m *MsgMutation) Status() (r uint8, exists bool) {
  25920. v := m.status
  25921. if v == nil {
  25922. return
  25923. }
  25924. return *v, true
  25925. }
  25926. // OldStatus returns the old "status" field's value of the Msg entity.
  25927. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25929. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25930. if !m.op.Is(OpUpdateOne) {
  25931. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25932. }
  25933. if m.id == nil || m.oldValue == nil {
  25934. return v, errors.New("OldStatus requires an ID field in the mutation")
  25935. }
  25936. oldValue, err := m.oldValue(ctx)
  25937. if err != nil {
  25938. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25939. }
  25940. return oldValue.Status, nil
  25941. }
  25942. // AddStatus adds u to the "status" field.
  25943. func (m *MsgMutation) AddStatus(u int8) {
  25944. if m.addstatus != nil {
  25945. *m.addstatus += u
  25946. } else {
  25947. m.addstatus = &u
  25948. }
  25949. }
  25950. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25951. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  25952. v := m.addstatus
  25953. if v == nil {
  25954. return
  25955. }
  25956. return *v, true
  25957. }
  25958. // ClearStatus clears the value of the "status" field.
  25959. func (m *MsgMutation) ClearStatus() {
  25960. m.status = nil
  25961. m.addstatus = nil
  25962. m.clearedFields[msg.FieldStatus] = struct{}{}
  25963. }
  25964. // StatusCleared returns if the "status" field was cleared in this mutation.
  25965. func (m *MsgMutation) StatusCleared() bool {
  25966. _, ok := m.clearedFields[msg.FieldStatus]
  25967. return ok
  25968. }
  25969. // ResetStatus resets all changes to the "status" field.
  25970. func (m *MsgMutation) ResetStatus() {
  25971. m.status = nil
  25972. m.addstatus = nil
  25973. delete(m.clearedFields, msg.FieldStatus)
  25974. }
  25975. // SetFromwxid sets the "fromwxid" field.
  25976. func (m *MsgMutation) SetFromwxid(s string) {
  25977. m.fromwxid = &s
  25978. }
  25979. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  25980. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  25981. v := m.fromwxid
  25982. if v == nil {
  25983. return
  25984. }
  25985. return *v, true
  25986. }
  25987. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  25988. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25990. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  25991. if !m.op.Is(OpUpdateOne) {
  25992. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  25993. }
  25994. if m.id == nil || m.oldValue == nil {
  25995. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  25996. }
  25997. oldValue, err := m.oldValue(ctx)
  25998. if err != nil {
  25999. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  26000. }
  26001. return oldValue.Fromwxid, nil
  26002. }
  26003. // ClearFromwxid clears the value of the "fromwxid" field.
  26004. func (m *MsgMutation) ClearFromwxid() {
  26005. m.fromwxid = nil
  26006. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  26007. }
  26008. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  26009. func (m *MsgMutation) FromwxidCleared() bool {
  26010. _, ok := m.clearedFields[msg.FieldFromwxid]
  26011. return ok
  26012. }
  26013. // ResetFromwxid resets all changes to the "fromwxid" field.
  26014. func (m *MsgMutation) ResetFromwxid() {
  26015. m.fromwxid = nil
  26016. delete(m.clearedFields, msg.FieldFromwxid)
  26017. }
  26018. // SetToid sets the "toid" field.
  26019. func (m *MsgMutation) SetToid(s string) {
  26020. m.toid = &s
  26021. }
  26022. // Toid returns the value of the "toid" field in the mutation.
  26023. func (m *MsgMutation) Toid() (r string, exists bool) {
  26024. v := m.toid
  26025. if v == nil {
  26026. return
  26027. }
  26028. return *v, true
  26029. }
  26030. // OldToid returns the old "toid" field's value of the Msg entity.
  26031. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26033. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  26034. if !m.op.Is(OpUpdateOne) {
  26035. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  26036. }
  26037. if m.id == nil || m.oldValue == nil {
  26038. return v, errors.New("OldToid requires an ID field in the mutation")
  26039. }
  26040. oldValue, err := m.oldValue(ctx)
  26041. if err != nil {
  26042. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  26043. }
  26044. return oldValue.Toid, nil
  26045. }
  26046. // ClearToid clears the value of the "toid" field.
  26047. func (m *MsgMutation) ClearToid() {
  26048. m.toid = nil
  26049. m.clearedFields[msg.FieldToid] = struct{}{}
  26050. }
  26051. // ToidCleared returns if the "toid" field was cleared in this mutation.
  26052. func (m *MsgMutation) ToidCleared() bool {
  26053. _, ok := m.clearedFields[msg.FieldToid]
  26054. return ok
  26055. }
  26056. // ResetToid resets all changes to the "toid" field.
  26057. func (m *MsgMutation) ResetToid() {
  26058. m.toid = nil
  26059. delete(m.clearedFields, msg.FieldToid)
  26060. }
  26061. // SetMsgtype sets the "msgtype" field.
  26062. func (m *MsgMutation) SetMsgtype(i int32) {
  26063. m.msgtype = &i
  26064. m.addmsgtype = nil
  26065. }
  26066. // Msgtype returns the value of the "msgtype" field in the mutation.
  26067. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  26068. v := m.msgtype
  26069. if v == nil {
  26070. return
  26071. }
  26072. return *v, true
  26073. }
  26074. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  26075. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26077. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  26078. if !m.op.Is(OpUpdateOne) {
  26079. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  26080. }
  26081. if m.id == nil || m.oldValue == nil {
  26082. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  26083. }
  26084. oldValue, err := m.oldValue(ctx)
  26085. if err != nil {
  26086. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  26087. }
  26088. return oldValue.Msgtype, nil
  26089. }
  26090. // AddMsgtype adds i to the "msgtype" field.
  26091. func (m *MsgMutation) AddMsgtype(i int32) {
  26092. if m.addmsgtype != nil {
  26093. *m.addmsgtype += i
  26094. } else {
  26095. m.addmsgtype = &i
  26096. }
  26097. }
  26098. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  26099. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  26100. v := m.addmsgtype
  26101. if v == nil {
  26102. return
  26103. }
  26104. return *v, true
  26105. }
  26106. // ClearMsgtype clears the value of the "msgtype" field.
  26107. func (m *MsgMutation) ClearMsgtype() {
  26108. m.msgtype = nil
  26109. m.addmsgtype = nil
  26110. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  26111. }
  26112. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  26113. func (m *MsgMutation) MsgtypeCleared() bool {
  26114. _, ok := m.clearedFields[msg.FieldMsgtype]
  26115. return ok
  26116. }
  26117. // ResetMsgtype resets all changes to the "msgtype" field.
  26118. func (m *MsgMutation) ResetMsgtype() {
  26119. m.msgtype = nil
  26120. m.addmsgtype = nil
  26121. delete(m.clearedFields, msg.FieldMsgtype)
  26122. }
  26123. // SetMsg sets the "msg" field.
  26124. func (m *MsgMutation) SetMsg(s string) {
  26125. m.msg = &s
  26126. }
  26127. // Msg returns the value of the "msg" field in the mutation.
  26128. func (m *MsgMutation) Msg() (r string, exists bool) {
  26129. v := m.msg
  26130. if v == nil {
  26131. return
  26132. }
  26133. return *v, true
  26134. }
  26135. // OldMsg returns the old "msg" field's value of the Msg entity.
  26136. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26138. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  26139. if !m.op.Is(OpUpdateOne) {
  26140. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  26141. }
  26142. if m.id == nil || m.oldValue == nil {
  26143. return v, errors.New("OldMsg requires an ID field in the mutation")
  26144. }
  26145. oldValue, err := m.oldValue(ctx)
  26146. if err != nil {
  26147. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  26148. }
  26149. return oldValue.Msg, nil
  26150. }
  26151. // ClearMsg clears the value of the "msg" field.
  26152. func (m *MsgMutation) ClearMsg() {
  26153. m.msg = nil
  26154. m.clearedFields[msg.FieldMsg] = struct{}{}
  26155. }
  26156. // MsgCleared returns if the "msg" field was cleared in this mutation.
  26157. func (m *MsgMutation) MsgCleared() bool {
  26158. _, ok := m.clearedFields[msg.FieldMsg]
  26159. return ok
  26160. }
  26161. // ResetMsg resets all changes to the "msg" field.
  26162. func (m *MsgMutation) ResetMsg() {
  26163. m.msg = nil
  26164. delete(m.clearedFields, msg.FieldMsg)
  26165. }
  26166. // SetBatchNo sets the "batch_no" field.
  26167. func (m *MsgMutation) SetBatchNo(s string) {
  26168. m.batch_no = &s
  26169. }
  26170. // BatchNo returns the value of the "batch_no" field in the mutation.
  26171. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  26172. v := m.batch_no
  26173. if v == nil {
  26174. return
  26175. }
  26176. return *v, true
  26177. }
  26178. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  26179. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26181. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  26182. if !m.op.Is(OpUpdateOne) {
  26183. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  26184. }
  26185. if m.id == nil || m.oldValue == nil {
  26186. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  26187. }
  26188. oldValue, err := m.oldValue(ctx)
  26189. if err != nil {
  26190. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  26191. }
  26192. return oldValue.BatchNo, nil
  26193. }
  26194. // ClearBatchNo clears the value of the "batch_no" field.
  26195. func (m *MsgMutation) ClearBatchNo() {
  26196. m.batch_no = nil
  26197. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  26198. }
  26199. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  26200. func (m *MsgMutation) BatchNoCleared() bool {
  26201. _, ok := m.clearedFields[msg.FieldBatchNo]
  26202. return ok
  26203. }
  26204. // ResetBatchNo resets all changes to the "batch_no" field.
  26205. func (m *MsgMutation) ResetBatchNo() {
  26206. m.batch_no = nil
  26207. delete(m.clearedFields, msg.FieldBatchNo)
  26208. }
  26209. // SetCc sets the "cc" field.
  26210. func (m *MsgMutation) SetCc(s string) {
  26211. m.cc = &s
  26212. }
  26213. // Cc returns the value of the "cc" field in the mutation.
  26214. func (m *MsgMutation) Cc() (r string, exists bool) {
  26215. v := m.cc
  26216. if v == nil {
  26217. return
  26218. }
  26219. return *v, true
  26220. }
  26221. // OldCc returns the old "cc" field's value of the Msg entity.
  26222. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26224. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  26225. if !m.op.Is(OpUpdateOne) {
  26226. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  26227. }
  26228. if m.id == nil || m.oldValue == nil {
  26229. return v, errors.New("OldCc requires an ID field in the mutation")
  26230. }
  26231. oldValue, err := m.oldValue(ctx)
  26232. if err != nil {
  26233. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  26234. }
  26235. return oldValue.Cc, nil
  26236. }
  26237. // ResetCc resets all changes to the "cc" field.
  26238. func (m *MsgMutation) ResetCc() {
  26239. m.cc = nil
  26240. }
  26241. // SetPhone sets the "phone" field.
  26242. func (m *MsgMutation) SetPhone(s string) {
  26243. m.phone = &s
  26244. }
  26245. // Phone returns the value of the "phone" field in the mutation.
  26246. func (m *MsgMutation) Phone() (r string, exists bool) {
  26247. v := m.phone
  26248. if v == nil {
  26249. return
  26250. }
  26251. return *v, true
  26252. }
  26253. // OldPhone returns the old "phone" field's value of the Msg entity.
  26254. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26256. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  26257. if !m.op.Is(OpUpdateOne) {
  26258. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26259. }
  26260. if m.id == nil || m.oldValue == nil {
  26261. return v, errors.New("OldPhone requires an ID field in the mutation")
  26262. }
  26263. oldValue, err := m.oldValue(ctx)
  26264. if err != nil {
  26265. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26266. }
  26267. return oldValue.Phone, nil
  26268. }
  26269. // ResetPhone resets all changes to the "phone" field.
  26270. func (m *MsgMutation) ResetPhone() {
  26271. m.phone = nil
  26272. }
  26273. // Where appends a list predicates to the MsgMutation builder.
  26274. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  26275. m.predicates = append(m.predicates, ps...)
  26276. }
  26277. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  26278. // users can use type-assertion to append predicates that do not depend on any generated package.
  26279. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  26280. p := make([]predicate.Msg, len(ps))
  26281. for i := range ps {
  26282. p[i] = ps[i]
  26283. }
  26284. m.Where(p...)
  26285. }
  26286. // Op returns the operation name.
  26287. func (m *MsgMutation) Op() Op {
  26288. return m.op
  26289. }
  26290. // SetOp allows setting the mutation operation.
  26291. func (m *MsgMutation) SetOp(op Op) {
  26292. m.op = op
  26293. }
  26294. // Type returns the node type of this mutation (Msg).
  26295. func (m *MsgMutation) Type() string {
  26296. return m.typ
  26297. }
  26298. // Fields returns all fields that were changed during this mutation. Note that in
  26299. // order to get all numeric fields that were incremented/decremented, call
  26300. // AddedFields().
  26301. func (m *MsgMutation) Fields() []string {
  26302. fields := make([]string, 0, 11)
  26303. if m.created_at != nil {
  26304. fields = append(fields, msg.FieldCreatedAt)
  26305. }
  26306. if m.updated_at != nil {
  26307. fields = append(fields, msg.FieldUpdatedAt)
  26308. }
  26309. if m.deleted_at != nil {
  26310. fields = append(fields, msg.FieldDeletedAt)
  26311. }
  26312. if m.status != nil {
  26313. fields = append(fields, msg.FieldStatus)
  26314. }
  26315. if m.fromwxid != nil {
  26316. fields = append(fields, msg.FieldFromwxid)
  26317. }
  26318. if m.toid != nil {
  26319. fields = append(fields, msg.FieldToid)
  26320. }
  26321. if m.msgtype != nil {
  26322. fields = append(fields, msg.FieldMsgtype)
  26323. }
  26324. if m.msg != nil {
  26325. fields = append(fields, msg.FieldMsg)
  26326. }
  26327. if m.batch_no != nil {
  26328. fields = append(fields, msg.FieldBatchNo)
  26329. }
  26330. if m.cc != nil {
  26331. fields = append(fields, msg.FieldCc)
  26332. }
  26333. if m.phone != nil {
  26334. fields = append(fields, msg.FieldPhone)
  26335. }
  26336. return fields
  26337. }
  26338. // Field returns the value of a field with the given name. The second boolean
  26339. // return value indicates that this field was not set, or was not defined in the
  26340. // schema.
  26341. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  26342. switch name {
  26343. case msg.FieldCreatedAt:
  26344. return m.CreatedAt()
  26345. case msg.FieldUpdatedAt:
  26346. return m.UpdatedAt()
  26347. case msg.FieldDeletedAt:
  26348. return m.DeletedAt()
  26349. case msg.FieldStatus:
  26350. return m.Status()
  26351. case msg.FieldFromwxid:
  26352. return m.Fromwxid()
  26353. case msg.FieldToid:
  26354. return m.Toid()
  26355. case msg.FieldMsgtype:
  26356. return m.Msgtype()
  26357. case msg.FieldMsg:
  26358. return m.Msg()
  26359. case msg.FieldBatchNo:
  26360. return m.BatchNo()
  26361. case msg.FieldCc:
  26362. return m.Cc()
  26363. case msg.FieldPhone:
  26364. return m.Phone()
  26365. }
  26366. return nil, false
  26367. }
  26368. // OldField returns the old value of the field from the database. An error is
  26369. // returned if the mutation operation is not UpdateOne, or the query to the
  26370. // database failed.
  26371. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26372. switch name {
  26373. case msg.FieldCreatedAt:
  26374. return m.OldCreatedAt(ctx)
  26375. case msg.FieldUpdatedAt:
  26376. return m.OldUpdatedAt(ctx)
  26377. case msg.FieldDeletedAt:
  26378. return m.OldDeletedAt(ctx)
  26379. case msg.FieldStatus:
  26380. return m.OldStatus(ctx)
  26381. case msg.FieldFromwxid:
  26382. return m.OldFromwxid(ctx)
  26383. case msg.FieldToid:
  26384. return m.OldToid(ctx)
  26385. case msg.FieldMsgtype:
  26386. return m.OldMsgtype(ctx)
  26387. case msg.FieldMsg:
  26388. return m.OldMsg(ctx)
  26389. case msg.FieldBatchNo:
  26390. return m.OldBatchNo(ctx)
  26391. case msg.FieldCc:
  26392. return m.OldCc(ctx)
  26393. case msg.FieldPhone:
  26394. return m.OldPhone(ctx)
  26395. }
  26396. return nil, fmt.Errorf("unknown Msg field %s", name)
  26397. }
  26398. // SetField sets the value of a field with the given name. It returns an error if
  26399. // the field is not defined in the schema, or if the type mismatched the field
  26400. // type.
  26401. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  26402. switch name {
  26403. case msg.FieldCreatedAt:
  26404. v, ok := value.(time.Time)
  26405. if !ok {
  26406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26407. }
  26408. m.SetCreatedAt(v)
  26409. return nil
  26410. case msg.FieldUpdatedAt:
  26411. v, ok := value.(time.Time)
  26412. if !ok {
  26413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26414. }
  26415. m.SetUpdatedAt(v)
  26416. return nil
  26417. case msg.FieldDeletedAt:
  26418. v, ok := value.(time.Time)
  26419. if !ok {
  26420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26421. }
  26422. m.SetDeletedAt(v)
  26423. return nil
  26424. case msg.FieldStatus:
  26425. v, ok := value.(uint8)
  26426. if !ok {
  26427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26428. }
  26429. m.SetStatus(v)
  26430. return nil
  26431. case msg.FieldFromwxid:
  26432. v, ok := value.(string)
  26433. if !ok {
  26434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26435. }
  26436. m.SetFromwxid(v)
  26437. return nil
  26438. case msg.FieldToid:
  26439. v, ok := value.(string)
  26440. if !ok {
  26441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26442. }
  26443. m.SetToid(v)
  26444. return nil
  26445. case msg.FieldMsgtype:
  26446. v, ok := value.(int32)
  26447. if !ok {
  26448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26449. }
  26450. m.SetMsgtype(v)
  26451. return nil
  26452. case msg.FieldMsg:
  26453. v, ok := value.(string)
  26454. if !ok {
  26455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26456. }
  26457. m.SetMsg(v)
  26458. return nil
  26459. case msg.FieldBatchNo:
  26460. v, ok := value.(string)
  26461. if !ok {
  26462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26463. }
  26464. m.SetBatchNo(v)
  26465. return nil
  26466. case msg.FieldCc:
  26467. v, ok := value.(string)
  26468. if !ok {
  26469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26470. }
  26471. m.SetCc(v)
  26472. return nil
  26473. case msg.FieldPhone:
  26474. v, ok := value.(string)
  26475. if !ok {
  26476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26477. }
  26478. m.SetPhone(v)
  26479. return nil
  26480. }
  26481. return fmt.Errorf("unknown Msg field %s", name)
  26482. }
  26483. // AddedFields returns all numeric fields that were incremented/decremented during
  26484. // this mutation.
  26485. func (m *MsgMutation) AddedFields() []string {
  26486. var fields []string
  26487. if m.addstatus != nil {
  26488. fields = append(fields, msg.FieldStatus)
  26489. }
  26490. if m.addmsgtype != nil {
  26491. fields = append(fields, msg.FieldMsgtype)
  26492. }
  26493. return fields
  26494. }
  26495. // AddedField returns the numeric value that was incremented/decremented on a field
  26496. // with the given name. The second boolean return value indicates that this field
  26497. // was not set, or was not defined in the schema.
  26498. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  26499. switch name {
  26500. case msg.FieldStatus:
  26501. return m.AddedStatus()
  26502. case msg.FieldMsgtype:
  26503. return m.AddedMsgtype()
  26504. }
  26505. return nil, false
  26506. }
  26507. // AddField adds the value to the field with the given name. It returns an error if
  26508. // the field is not defined in the schema, or if the type mismatched the field
  26509. // type.
  26510. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  26511. switch name {
  26512. case msg.FieldStatus:
  26513. v, ok := value.(int8)
  26514. if !ok {
  26515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26516. }
  26517. m.AddStatus(v)
  26518. return nil
  26519. case msg.FieldMsgtype:
  26520. v, ok := value.(int32)
  26521. if !ok {
  26522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26523. }
  26524. m.AddMsgtype(v)
  26525. return nil
  26526. }
  26527. return fmt.Errorf("unknown Msg numeric field %s", name)
  26528. }
  26529. // ClearedFields returns all nullable fields that were cleared during this
  26530. // mutation.
  26531. func (m *MsgMutation) ClearedFields() []string {
  26532. var fields []string
  26533. if m.FieldCleared(msg.FieldDeletedAt) {
  26534. fields = append(fields, msg.FieldDeletedAt)
  26535. }
  26536. if m.FieldCleared(msg.FieldStatus) {
  26537. fields = append(fields, msg.FieldStatus)
  26538. }
  26539. if m.FieldCleared(msg.FieldFromwxid) {
  26540. fields = append(fields, msg.FieldFromwxid)
  26541. }
  26542. if m.FieldCleared(msg.FieldToid) {
  26543. fields = append(fields, msg.FieldToid)
  26544. }
  26545. if m.FieldCleared(msg.FieldMsgtype) {
  26546. fields = append(fields, msg.FieldMsgtype)
  26547. }
  26548. if m.FieldCleared(msg.FieldMsg) {
  26549. fields = append(fields, msg.FieldMsg)
  26550. }
  26551. if m.FieldCleared(msg.FieldBatchNo) {
  26552. fields = append(fields, msg.FieldBatchNo)
  26553. }
  26554. return fields
  26555. }
  26556. // FieldCleared returns a boolean indicating if a field with the given name was
  26557. // cleared in this mutation.
  26558. func (m *MsgMutation) FieldCleared(name string) bool {
  26559. _, ok := m.clearedFields[name]
  26560. return ok
  26561. }
  26562. // ClearField clears the value of the field with the given name. It returns an
  26563. // error if the field is not defined in the schema.
  26564. func (m *MsgMutation) ClearField(name string) error {
  26565. switch name {
  26566. case msg.FieldDeletedAt:
  26567. m.ClearDeletedAt()
  26568. return nil
  26569. case msg.FieldStatus:
  26570. m.ClearStatus()
  26571. return nil
  26572. case msg.FieldFromwxid:
  26573. m.ClearFromwxid()
  26574. return nil
  26575. case msg.FieldToid:
  26576. m.ClearToid()
  26577. return nil
  26578. case msg.FieldMsgtype:
  26579. m.ClearMsgtype()
  26580. return nil
  26581. case msg.FieldMsg:
  26582. m.ClearMsg()
  26583. return nil
  26584. case msg.FieldBatchNo:
  26585. m.ClearBatchNo()
  26586. return nil
  26587. }
  26588. return fmt.Errorf("unknown Msg nullable field %s", name)
  26589. }
  26590. // ResetField resets all changes in the mutation for the field with the given name.
  26591. // It returns an error if the field is not defined in the schema.
  26592. func (m *MsgMutation) ResetField(name string) error {
  26593. switch name {
  26594. case msg.FieldCreatedAt:
  26595. m.ResetCreatedAt()
  26596. return nil
  26597. case msg.FieldUpdatedAt:
  26598. m.ResetUpdatedAt()
  26599. return nil
  26600. case msg.FieldDeletedAt:
  26601. m.ResetDeletedAt()
  26602. return nil
  26603. case msg.FieldStatus:
  26604. m.ResetStatus()
  26605. return nil
  26606. case msg.FieldFromwxid:
  26607. m.ResetFromwxid()
  26608. return nil
  26609. case msg.FieldToid:
  26610. m.ResetToid()
  26611. return nil
  26612. case msg.FieldMsgtype:
  26613. m.ResetMsgtype()
  26614. return nil
  26615. case msg.FieldMsg:
  26616. m.ResetMsg()
  26617. return nil
  26618. case msg.FieldBatchNo:
  26619. m.ResetBatchNo()
  26620. return nil
  26621. case msg.FieldCc:
  26622. m.ResetCc()
  26623. return nil
  26624. case msg.FieldPhone:
  26625. m.ResetPhone()
  26626. return nil
  26627. }
  26628. return fmt.Errorf("unknown Msg field %s", name)
  26629. }
  26630. // AddedEdges returns all edge names that were set/added in this mutation.
  26631. func (m *MsgMutation) AddedEdges() []string {
  26632. edges := make([]string, 0, 0)
  26633. return edges
  26634. }
  26635. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26636. // name in this mutation.
  26637. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  26638. return nil
  26639. }
  26640. // RemovedEdges returns all edge names that were removed in this mutation.
  26641. func (m *MsgMutation) RemovedEdges() []string {
  26642. edges := make([]string, 0, 0)
  26643. return edges
  26644. }
  26645. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26646. // the given name in this mutation.
  26647. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  26648. return nil
  26649. }
  26650. // ClearedEdges returns all edge names that were cleared in this mutation.
  26651. func (m *MsgMutation) ClearedEdges() []string {
  26652. edges := make([]string, 0, 0)
  26653. return edges
  26654. }
  26655. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26656. // was cleared in this mutation.
  26657. func (m *MsgMutation) EdgeCleared(name string) bool {
  26658. return false
  26659. }
  26660. // ClearEdge clears the value of the edge with the given name. It returns an error
  26661. // if that edge is not defined in the schema.
  26662. func (m *MsgMutation) ClearEdge(name string) error {
  26663. return fmt.Errorf("unknown Msg unique edge %s", name)
  26664. }
  26665. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26666. // It returns an error if the edge is not defined in the schema.
  26667. func (m *MsgMutation) ResetEdge(name string) error {
  26668. return fmt.Errorf("unknown Msg edge %s", name)
  26669. }
  26670. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  26671. type PayRechargeMutation struct {
  26672. config
  26673. op Op
  26674. typ string
  26675. id *uint64
  26676. created_at *time.Time
  26677. updated_at *time.Time
  26678. deleted_at *time.Time
  26679. user_id *string
  26680. number *float32
  26681. addnumber *float32
  26682. status *int
  26683. addstatus *int
  26684. money *float32
  26685. addmoney *float32
  26686. out_trade_no *string
  26687. organization_id *uint64
  26688. addorganization_id *int64
  26689. clearedFields map[string]struct{}
  26690. done bool
  26691. oldValue func(context.Context) (*PayRecharge, error)
  26692. predicates []predicate.PayRecharge
  26693. }
  26694. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  26695. // payrechargeOption allows management of the mutation configuration using functional options.
  26696. type payrechargeOption func(*PayRechargeMutation)
  26697. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  26698. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  26699. m := &PayRechargeMutation{
  26700. config: c,
  26701. op: op,
  26702. typ: TypePayRecharge,
  26703. clearedFields: make(map[string]struct{}),
  26704. }
  26705. for _, opt := range opts {
  26706. opt(m)
  26707. }
  26708. return m
  26709. }
  26710. // withPayRechargeID sets the ID field of the mutation.
  26711. func withPayRechargeID(id uint64) payrechargeOption {
  26712. return func(m *PayRechargeMutation) {
  26713. var (
  26714. err error
  26715. once sync.Once
  26716. value *PayRecharge
  26717. )
  26718. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  26719. once.Do(func() {
  26720. if m.done {
  26721. err = errors.New("querying old values post mutation is not allowed")
  26722. } else {
  26723. value, err = m.Client().PayRecharge.Get(ctx, id)
  26724. }
  26725. })
  26726. return value, err
  26727. }
  26728. m.id = &id
  26729. }
  26730. }
  26731. // withPayRecharge sets the old PayRecharge of the mutation.
  26732. func withPayRecharge(node *PayRecharge) payrechargeOption {
  26733. return func(m *PayRechargeMutation) {
  26734. m.oldValue = func(context.Context) (*PayRecharge, error) {
  26735. return node, nil
  26736. }
  26737. m.id = &node.ID
  26738. }
  26739. }
  26740. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26741. // executed in a transaction (ent.Tx), a transactional client is returned.
  26742. func (m PayRechargeMutation) Client() *Client {
  26743. client := &Client{config: m.config}
  26744. client.init()
  26745. return client
  26746. }
  26747. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26748. // it returns an error otherwise.
  26749. func (m PayRechargeMutation) Tx() (*Tx, error) {
  26750. if _, ok := m.driver.(*txDriver); !ok {
  26751. return nil, errors.New("ent: mutation is not running in a transaction")
  26752. }
  26753. tx := &Tx{config: m.config}
  26754. tx.init()
  26755. return tx, nil
  26756. }
  26757. // SetID sets the value of the id field. Note that this
  26758. // operation is only accepted on creation of PayRecharge entities.
  26759. func (m *PayRechargeMutation) SetID(id uint64) {
  26760. m.id = &id
  26761. }
  26762. // ID returns the ID value in the mutation. Note that the ID is only available
  26763. // if it was provided to the builder or after it was returned from the database.
  26764. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  26765. if m.id == nil {
  26766. return
  26767. }
  26768. return *m.id, true
  26769. }
  26770. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26771. // That means, if the mutation is applied within a transaction with an isolation level such
  26772. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26773. // or updated by the mutation.
  26774. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26775. switch {
  26776. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26777. id, exists := m.ID()
  26778. if exists {
  26779. return []uint64{id}, nil
  26780. }
  26781. fallthrough
  26782. case m.op.Is(OpUpdate | OpDelete):
  26783. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  26784. default:
  26785. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26786. }
  26787. }
  26788. // SetCreatedAt sets the "created_at" field.
  26789. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  26790. m.created_at = &t
  26791. }
  26792. // CreatedAt returns the value of the "created_at" field in the mutation.
  26793. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  26794. v := m.created_at
  26795. if v == nil {
  26796. return
  26797. }
  26798. return *v, true
  26799. }
  26800. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  26801. // If the PayRecharge 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 *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26804. if !m.op.Is(OpUpdateOne) {
  26805. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26806. }
  26807. if m.id == nil || m.oldValue == nil {
  26808. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  26813. }
  26814. return oldValue.CreatedAt, nil
  26815. }
  26816. // ResetCreatedAt resets all changes to the "created_at" field.
  26817. func (m *PayRechargeMutation) ResetCreatedAt() {
  26818. m.created_at = nil
  26819. }
  26820. // SetUpdatedAt sets the "updated_at" field.
  26821. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  26822. m.updated_at = &t
  26823. }
  26824. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26825. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  26826. v := m.updated_at
  26827. if v == nil {
  26828. return
  26829. }
  26830. return *v, true
  26831. }
  26832. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  26833. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26835. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26836. if !m.op.Is(OpUpdateOne) {
  26837. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26838. }
  26839. if m.id == nil || m.oldValue == nil {
  26840. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26841. }
  26842. oldValue, err := m.oldValue(ctx)
  26843. if err != nil {
  26844. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26845. }
  26846. return oldValue.UpdatedAt, nil
  26847. }
  26848. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26849. func (m *PayRechargeMutation) ResetUpdatedAt() {
  26850. m.updated_at = nil
  26851. }
  26852. // SetDeletedAt sets the "deleted_at" field.
  26853. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  26854. m.deleted_at = &t
  26855. }
  26856. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26857. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  26858. v := m.deleted_at
  26859. if v == nil {
  26860. return
  26861. }
  26862. return *v, true
  26863. }
  26864. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  26865. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26867. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26868. if !m.op.Is(OpUpdateOne) {
  26869. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26870. }
  26871. if m.id == nil || m.oldValue == nil {
  26872. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26873. }
  26874. oldValue, err := m.oldValue(ctx)
  26875. if err != nil {
  26876. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26877. }
  26878. return oldValue.DeletedAt, nil
  26879. }
  26880. // ClearDeletedAt clears the value of the "deleted_at" field.
  26881. func (m *PayRechargeMutation) ClearDeletedAt() {
  26882. m.deleted_at = nil
  26883. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  26884. }
  26885. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26886. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  26887. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  26888. return ok
  26889. }
  26890. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26891. func (m *PayRechargeMutation) ResetDeletedAt() {
  26892. m.deleted_at = nil
  26893. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  26894. }
  26895. // SetUserID sets the "user_id" field.
  26896. func (m *PayRechargeMutation) SetUserID(s string) {
  26897. m.user_id = &s
  26898. }
  26899. // UserID returns the value of the "user_id" field in the mutation.
  26900. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  26901. v := m.user_id
  26902. if v == nil {
  26903. return
  26904. }
  26905. return *v, true
  26906. }
  26907. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  26908. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26910. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  26911. if !m.op.Is(OpUpdateOne) {
  26912. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  26913. }
  26914. if m.id == nil || m.oldValue == nil {
  26915. return v, errors.New("OldUserID requires an ID field in the mutation")
  26916. }
  26917. oldValue, err := m.oldValue(ctx)
  26918. if err != nil {
  26919. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  26920. }
  26921. return oldValue.UserID, nil
  26922. }
  26923. // ResetUserID resets all changes to the "user_id" field.
  26924. func (m *PayRechargeMutation) ResetUserID() {
  26925. m.user_id = nil
  26926. }
  26927. // SetNumber sets the "number" field.
  26928. func (m *PayRechargeMutation) SetNumber(f float32) {
  26929. m.number = &f
  26930. m.addnumber = nil
  26931. }
  26932. // Number returns the value of the "number" field in the mutation.
  26933. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  26934. v := m.number
  26935. if v == nil {
  26936. return
  26937. }
  26938. return *v, true
  26939. }
  26940. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  26941. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26943. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  26944. if !m.op.Is(OpUpdateOne) {
  26945. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  26946. }
  26947. if m.id == nil || m.oldValue == nil {
  26948. return v, errors.New("OldNumber requires an ID field in the mutation")
  26949. }
  26950. oldValue, err := m.oldValue(ctx)
  26951. if err != nil {
  26952. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  26953. }
  26954. return oldValue.Number, nil
  26955. }
  26956. // AddNumber adds f to the "number" field.
  26957. func (m *PayRechargeMutation) AddNumber(f float32) {
  26958. if m.addnumber != nil {
  26959. *m.addnumber += f
  26960. } else {
  26961. m.addnumber = &f
  26962. }
  26963. }
  26964. // AddedNumber returns the value that was added to the "number" field in this mutation.
  26965. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  26966. v := m.addnumber
  26967. if v == nil {
  26968. return
  26969. }
  26970. return *v, true
  26971. }
  26972. // ResetNumber resets all changes to the "number" field.
  26973. func (m *PayRechargeMutation) ResetNumber() {
  26974. m.number = nil
  26975. m.addnumber = nil
  26976. }
  26977. // SetStatus sets the "status" field.
  26978. func (m *PayRechargeMutation) SetStatus(i int) {
  26979. m.status = &i
  26980. m.addstatus = nil
  26981. }
  26982. // Status returns the value of the "status" field in the mutation.
  26983. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  26984. v := m.status
  26985. if v == nil {
  26986. return
  26987. }
  26988. return *v, true
  26989. }
  26990. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  26991. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26993. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  26994. if !m.op.Is(OpUpdateOne) {
  26995. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26996. }
  26997. if m.id == nil || m.oldValue == nil {
  26998. return v, errors.New("OldStatus requires an ID field in the mutation")
  26999. }
  27000. oldValue, err := m.oldValue(ctx)
  27001. if err != nil {
  27002. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27003. }
  27004. return oldValue.Status, nil
  27005. }
  27006. // AddStatus adds i to the "status" field.
  27007. func (m *PayRechargeMutation) AddStatus(i int) {
  27008. if m.addstatus != nil {
  27009. *m.addstatus += i
  27010. } else {
  27011. m.addstatus = &i
  27012. }
  27013. }
  27014. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27015. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  27016. v := m.addstatus
  27017. if v == nil {
  27018. return
  27019. }
  27020. return *v, true
  27021. }
  27022. // ClearStatus clears the value of the "status" field.
  27023. func (m *PayRechargeMutation) ClearStatus() {
  27024. m.status = nil
  27025. m.addstatus = nil
  27026. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  27027. }
  27028. // StatusCleared returns if the "status" field was cleared in this mutation.
  27029. func (m *PayRechargeMutation) StatusCleared() bool {
  27030. _, ok := m.clearedFields[payrecharge.FieldStatus]
  27031. return ok
  27032. }
  27033. // ResetStatus resets all changes to the "status" field.
  27034. func (m *PayRechargeMutation) ResetStatus() {
  27035. m.status = nil
  27036. m.addstatus = nil
  27037. delete(m.clearedFields, payrecharge.FieldStatus)
  27038. }
  27039. // SetMoney sets the "money" field.
  27040. func (m *PayRechargeMutation) SetMoney(f float32) {
  27041. m.money = &f
  27042. m.addmoney = nil
  27043. }
  27044. // Money returns the value of the "money" field in the mutation.
  27045. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  27046. v := m.money
  27047. if v == nil {
  27048. return
  27049. }
  27050. return *v, true
  27051. }
  27052. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  27053. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27055. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  27056. if !m.op.Is(OpUpdateOne) {
  27057. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  27058. }
  27059. if m.id == nil || m.oldValue == nil {
  27060. return v, errors.New("OldMoney requires an ID field in the mutation")
  27061. }
  27062. oldValue, err := m.oldValue(ctx)
  27063. if err != nil {
  27064. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  27065. }
  27066. return oldValue.Money, nil
  27067. }
  27068. // AddMoney adds f to the "money" field.
  27069. func (m *PayRechargeMutation) AddMoney(f float32) {
  27070. if m.addmoney != nil {
  27071. *m.addmoney += f
  27072. } else {
  27073. m.addmoney = &f
  27074. }
  27075. }
  27076. // AddedMoney returns the value that was added to the "money" field in this mutation.
  27077. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  27078. v := m.addmoney
  27079. if v == nil {
  27080. return
  27081. }
  27082. return *v, true
  27083. }
  27084. // ClearMoney clears the value of the "money" field.
  27085. func (m *PayRechargeMutation) ClearMoney() {
  27086. m.money = nil
  27087. m.addmoney = nil
  27088. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  27089. }
  27090. // MoneyCleared returns if the "money" field was cleared in this mutation.
  27091. func (m *PayRechargeMutation) MoneyCleared() bool {
  27092. _, ok := m.clearedFields[payrecharge.FieldMoney]
  27093. return ok
  27094. }
  27095. // ResetMoney resets all changes to the "money" field.
  27096. func (m *PayRechargeMutation) ResetMoney() {
  27097. m.money = nil
  27098. m.addmoney = nil
  27099. delete(m.clearedFields, payrecharge.FieldMoney)
  27100. }
  27101. // SetOutTradeNo sets the "out_trade_no" field.
  27102. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  27103. m.out_trade_no = &s
  27104. }
  27105. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  27106. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  27107. v := m.out_trade_no
  27108. if v == nil {
  27109. return
  27110. }
  27111. return *v, true
  27112. }
  27113. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  27114. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27116. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  27117. if !m.op.Is(OpUpdateOne) {
  27118. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  27119. }
  27120. if m.id == nil || m.oldValue == nil {
  27121. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  27122. }
  27123. oldValue, err := m.oldValue(ctx)
  27124. if err != nil {
  27125. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  27126. }
  27127. return oldValue.OutTradeNo, nil
  27128. }
  27129. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  27130. func (m *PayRechargeMutation) ClearOutTradeNo() {
  27131. m.out_trade_no = nil
  27132. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  27133. }
  27134. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  27135. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  27136. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  27137. return ok
  27138. }
  27139. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  27140. func (m *PayRechargeMutation) ResetOutTradeNo() {
  27141. m.out_trade_no = nil
  27142. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  27143. }
  27144. // SetOrganizationID sets the "organization_id" field.
  27145. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  27146. m.organization_id = &u
  27147. m.addorganization_id = nil
  27148. }
  27149. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27150. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  27151. v := m.organization_id
  27152. if v == nil {
  27153. return
  27154. }
  27155. return *v, true
  27156. }
  27157. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  27158. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27160. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27161. if !m.op.Is(OpUpdateOne) {
  27162. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27163. }
  27164. if m.id == nil || m.oldValue == nil {
  27165. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27166. }
  27167. oldValue, err := m.oldValue(ctx)
  27168. if err != nil {
  27169. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27170. }
  27171. return oldValue.OrganizationID, nil
  27172. }
  27173. // AddOrganizationID adds u to the "organization_id" field.
  27174. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  27175. if m.addorganization_id != nil {
  27176. *m.addorganization_id += u
  27177. } else {
  27178. m.addorganization_id = &u
  27179. }
  27180. }
  27181. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27182. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  27183. v := m.addorganization_id
  27184. if v == nil {
  27185. return
  27186. }
  27187. return *v, true
  27188. }
  27189. // ResetOrganizationID resets all changes to the "organization_id" field.
  27190. func (m *PayRechargeMutation) ResetOrganizationID() {
  27191. m.organization_id = nil
  27192. m.addorganization_id = nil
  27193. }
  27194. // Where appends a list predicates to the PayRechargeMutation builder.
  27195. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  27196. m.predicates = append(m.predicates, ps...)
  27197. }
  27198. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  27199. // users can use type-assertion to append predicates that do not depend on any generated package.
  27200. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  27201. p := make([]predicate.PayRecharge, len(ps))
  27202. for i := range ps {
  27203. p[i] = ps[i]
  27204. }
  27205. m.Where(p...)
  27206. }
  27207. // Op returns the operation name.
  27208. func (m *PayRechargeMutation) Op() Op {
  27209. return m.op
  27210. }
  27211. // SetOp allows setting the mutation operation.
  27212. func (m *PayRechargeMutation) SetOp(op Op) {
  27213. m.op = op
  27214. }
  27215. // Type returns the node type of this mutation (PayRecharge).
  27216. func (m *PayRechargeMutation) Type() string {
  27217. return m.typ
  27218. }
  27219. // Fields returns all fields that were changed during this mutation. Note that in
  27220. // order to get all numeric fields that were incremented/decremented, call
  27221. // AddedFields().
  27222. func (m *PayRechargeMutation) Fields() []string {
  27223. fields := make([]string, 0, 9)
  27224. if m.created_at != nil {
  27225. fields = append(fields, payrecharge.FieldCreatedAt)
  27226. }
  27227. if m.updated_at != nil {
  27228. fields = append(fields, payrecharge.FieldUpdatedAt)
  27229. }
  27230. if m.deleted_at != nil {
  27231. fields = append(fields, payrecharge.FieldDeletedAt)
  27232. }
  27233. if m.user_id != nil {
  27234. fields = append(fields, payrecharge.FieldUserID)
  27235. }
  27236. if m.number != nil {
  27237. fields = append(fields, payrecharge.FieldNumber)
  27238. }
  27239. if m.status != nil {
  27240. fields = append(fields, payrecharge.FieldStatus)
  27241. }
  27242. if m.money != nil {
  27243. fields = append(fields, payrecharge.FieldMoney)
  27244. }
  27245. if m.out_trade_no != nil {
  27246. fields = append(fields, payrecharge.FieldOutTradeNo)
  27247. }
  27248. if m.organization_id != nil {
  27249. fields = append(fields, payrecharge.FieldOrganizationID)
  27250. }
  27251. return fields
  27252. }
  27253. // Field returns the value of a field with the given name. The second boolean
  27254. // return value indicates that this field was not set, or was not defined in the
  27255. // schema.
  27256. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  27257. switch name {
  27258. case payrecharge.FieldCreatedAt:
  27259. return m.CreatedAt()
  27260. case payrecharge.FieldUpdatedAt:
  27261. return m.UpdatedAt()
  27262. case payrecharge.FieldDeletedAt:
  27263. return m.DeletedAt()
  27264. case payrecharge.FieldUserID:
  27265. return m.UserID()
  27266. case payrecharge.FieldNumber:
  27267. return m.Number()
  27268. case payrecharge.FieldStatus:
  27269. return m.Status()
  27270. case payrecharge.FieldMoney:
  27271. return m.Money()
  27272. case payrecharge.FieldOutTradeNo:
  27273. return m.OutTradeNo()
  27274. case payrecharge.FieldOrganizationID:
  27275. return m.OrganizationID()
  27276. }
  27277. return nil, false
  27278. }
  27279. // OldField returns the old value of the field from the database. An error is
  27280. // returned if the mutation operation is not UpdateOne, or the query to the
  27281. // database failed.
  27282. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27283. switch name {
  27284. case payrecharge.FieldCreatedAt:
  27285. return m.OldCreatedAt(ctx)
  27286. case payrecharge.FieldUpdatedAt:
  27287. return m.OldUpdatedAt(ctx)
  27288. case payrecharge.FieldDeletedAt:
  27289. return m.OldDeletedAt(ctx)
  27290. case payrecharge.FieldUserID:
  27291. return m.OldUserID(ctx)
  27292. case payrecharge.FieldNumber:
  27293. return m.OldNumber(ctx)
  27294. case payrecharge.FieldStatus:
  27295. return m.OldStatus(ctx)
  27296. case payrecharge.FieldMoney:
  27297. return m.OldMoney(ctx)
  27298. case payrecharge.FieldOutTradeNo:
  27299. return m.OldOutTradeNo(ctx)
  27300. case payrecharge.FieldOrganizationID:
  27301. return m.OldOrganizationID(ctx)
  27302. }
  27303. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  27304. }
  27305. // SetField sets the value of a field with the given name. It returns an error if
  27306. // the field is not defined in the schema, or if the type mismatched the field
  27307. // type.
  27308. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  27309. switch name {
  27310. case payrecharge.FieldCreatedAt:
  27311. v, ok := value.(time.Time)
  27312. if !ok {
  27313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27314. }
  27315. m.SetCreatedAt(v)
  27316. return nil
  27317. case payrecharge.FieldUpdatedAt:
  27318. v, ok := value.(time.Time)
  27319. if !ok {
  27320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27321. }
  27322. m.SetUpdatedAt(v)
  27323. return nil
  27324. case payrecharge.FieldDeletedAt:
  27325. v, ok := value.(time.Time)
  27326. if !ok {
  27327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27328. }
  27329. m.SetDeletedAt(v)
  27330. return nil
  27331. case payrecharge.FieldUserID:
  27332. v, ok := value.(string)
  27333. if !ok {
  27334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27335. }
  27336. m.SetUserID(v)
  27337. return nil
  27338. case payrecharge.FieldNumber:
  27339. v, ok := value.(float32)
  27340. if !ok {
  27341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27342. }
  27343. m.SetNumber(v)
  27344. return nil
  27345. case payrecharge.FieldStatus:
  27346. v, ok := value.(int)
  27347. if !ok {
  27348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27349. }
  27350. m.SetStatus(v)
  27351. return nil
  27352. case payrecharge.FieldMoney:
  27353. v, ok := value.(float32)
  27354. if !ok {
  27355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27356. }
  27357. m.SetMoney(v)
  27358. return nil
  27359. case payrecharge.FieldOutTradeNo:
  27360. v, ok := value.(string)
  27361. if !ok {
  27362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27363. }
  27364. m.SetOutTradeNo(v)
  27365. return nil
  27366. case payrecharge.FieldOrganizationID:
  27367. v, ok := value.(uint64)
  27368. if !ok {
  27369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27370. }
  27371. m.SetOrganizationID(v)
  27372. return nil
  27373. }
  27374. return fmt.Errorf("unknown PayRecharge field %s", name)
  27375. }
  27376. // AddedFields returns all numeric fields that were incremented/decremented during
  27377. // this mutation.
  27378. func (m *PayRechargeMutation) AddedFields() []string {
  27379. var fields []string
  27380. if m.addnumber != nil {
  27381. fields = append(fields, payrecharge.FieldNumber)
  27382. }
  27383. if m.addstatus != nil {
  27384. fields = append(fields, payrecharge.FieldStatus)
  27385. }
  27386. if m.addmoney != nil {
  27387. fields = append(fields, payrecharge.FieldMoney)
  27388. }
  27389. if m.addorganization_id != nil {
  27390. fields = append(fields, payrecharge.FieldOrganizationID)
  27391. }
  27392. return fields
  27393. }
  27394. // AddedField returns the numeric value that was incremented/decremented on a field
  27395. // with the given name. The second boolean return value indicates that this field
  27396. // was not set, or was not defined in the schema.
  27397. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  27398. switch name {
  27399. case payrecharge.FieldNumber:
  27400. return m.AddedNumber()
  27401. case payrecharge.FieldStatus:
  27402. return m.AddedStatus()
  27403. case payrecharge.FieldMoney:
  27404. return m.AddedMoney()
  27405. case payrecharge.FieldOrganizationID:
  27406. return m.AddedOrganizationID()
  27407. }
  27408. return nil, false
  27409. }
  27410. // AddField adds the value to the field with the given name. It returns an error if
  27411. // the field is not defined in the schema, or if the type mismatched the field
  27412. // type.
  27413. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  27414. switch name {
  27415. case payrecharge.FieldNumber:
  27416. v, ok := value.(float32)
  27417. if !ok {
  27418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27419. }
  27420. m.AddNumber(v)
  27421. return nil
  27422. case payrecharge.FieldStatus:
  27423. v, ok := value.(int)
  27424. if !ok {
  27425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27426. }
  27427. m.AddStatus(v)
  27428. return nil
  27429. case payrecharge.FieldMoney:
  27430. v, ok := value.(float32)
  27431. if !ok {
  27432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27433. }
  27434. m.AddMoney(v)
  27435. return nil
  27436. case payrecharge.FieldOrganizationID:
  27437. v, ok := value.(int64)
  27438. if !ok {
  27439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27440. }
  27441. m.AddOrganizationID(v)
  27442. return nil
  27443. }
  27444. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  27445. }
  27446. // ClearedFields returns all nullable fields that were cleared during this
  27447. // mutation.
  27448. func (m *PayRechargeMutation) ClearedFields() []string {
  27449. var fields []string
  27450. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  27451. fields = append(fields, payrecharge.FieldDeletedAt)
  27452. }
  27453. if m.FieldCleared(payrecharge.FieldStatus) {
  27454. fields = append(fields, payrecharge.FieldStatus)
  27455. }
  27456. if m.FieldCleared(payrecharge.FieldMoney) {
  27457. fields = append(fields, payrecharge.FieldMoney)
  27458. }
  27459. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  27460. fields = append(fields, payrecharge.FieldOutTradeNo)
  27461. }
  27462. return fields
  27463. }
  27464. // FieldCleared returns a boolean indicating if a field with the given name was
  27465. // cleared in this mutation.
  27466. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  27467. _, ok := m.clearedFields[name]
  27468. return ok
  27469. }
  27470. // ClearField clears the value of the field with the given name. It returns an
  27471. // error if the field is not defined in the schema.
  27472. func (m *PayRechargeMutation) ClearField(name string) error {
  27473. switch name {
  27474. case payrecharge.FieldDeletedAt:
  27475. m.ClearDeletedAt()
  27476. return nil
  27477. case payrecharge.FieldStatus:
  27478. m.ClearStatus()
  27479. return nil
  27480. case payrecharge.FieldMoney:
  27481. m.ClearMoney()
  27482. return nil
  27483. case payrecharge.FieldOutTradeNo:
  27484. m.ClearOutTradeNo()
  27485. return nil
  27486. }
  27487. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  27488. }
  27489. // ResetField resets all changes in the mutation for the field with the given name.
  27490. // It returns an error if the field is not defined in the schema.
  27491. func (m *PayRechargeMutation) ResetField(name string) error {
  27492. switch name {
  27493. case payrecharge.FieldCreatedAt:
  27494. m.ResetCreatedAt()
  27495. return nil
  27496. case payrecharge.FieldUpdatedAt:
  27497. m.ResetUpdatedAt()
  27498. return nil
  27499. case payrecharge.FieldDeletedAt:
  27500. m.ResetDeletedAt()
  27501. return nil
  27502. case payrecharge.FieldUserID:
  27503. m.ResetUserID()
  27504. return nil
  27505. case payrecharge.FieldNumber:
  27506. m.ResetNumber()
  27507. return nil
  27508. case payrecharge.FieldStatus:
  27509. m.ResetStatus()
  27510. return nil
  27511. case payrecharge.FieldMoney:
  27512. m.ResetMoney()
  27513. return nil
  27514. case payrecharge.FieldOutTradeNo:
  27515. m.ResetOutTradeNo()
  27516. return nil
  27517. case payrecharge.FieldOrganizationID:
  27518. m.ResetOrganizationID()
  27519. return nil
  27520. }
  27521. return fmt.Errorf("unknown PayRecharge field %s", name)
  27522. }
  27523. // AddedEdges returns all edge names that were set/added in this mutation.
  27524. func (m *PayRechargeMutation) AddedEdges() []string {
  27525. edges := make([]string, 0, 0)
  27526. return edges
  27527. }
  27528. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27529. // name in this mutation.
  27530. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  27531. return nil
  27532. }
  27533. // RemovedEdges returns all edge names that were removed in this mutation.
  27534. func (m *PayRechargeMutation) RemovedEdges() []string {
  27535. edges := make([]string, 0, 0)
  27536. return edges
  27537. }
  27538. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27539. // the given name in this mutation.
  27540. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  27541. return nil
  27542. }
  27543. // ClearedEdges returns all edge names that were cleared in this mutation.
  27544. func (m *PayRechargeMutation) ClearedEdges() []string {
  27545. edges := make([]string, 0, 0)
  27546. return edges
  27547. }
  27548. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27549. // was cleared in this mutation.
  27550. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  27551. return false
  27552. }
  27553. // ClearEdge clears the value of the edge with the given name. It returns an error
  27554. // if that edge is not defined in the schema.
  27555. func (m *PayRechargeMutation) ClearEdge(name string) error {
  27556. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  27557. }
  27558. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27559. // It returns an error if the edge is not defined in the schema.
  27560. func (m *PayRechargeMutation) ResetEdge(name string) error {
  27561. return fmt.Errorf("unknown PayRecharge edge %s", name)
  27562. }
  27563. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  27564. type ServerMutation struct {
  27565. config
  27566. op Op
  27567. typ string
  27568. id *uint64
  27569. created_at *time.Time
  27570. updated_at *time.Time
  27571. status *uint8
  27572. addstatus *int8
  27573. deleted_at *time.Time
  27574. name *string
  27575. public_ip *string
  27576. private_ip *string
  27577. admin_port *string
  27578. clearedFields map[string]struct{}
  27579. wxs map[uint64]struct{}
  27580. removedwxs map[uint64]struct{}
  27581. clearedwxs bool
  27582. done bool
  27583. oldValue func(context.Context) (*Server, error)
  27584. predicates []predicate.Server
  27585. }
  27586. var _ ent.Mutation = (*ServerMutation)(nil)
  27587. // serverOption allows management of the mutation configuration using functional options.
  27588. type serverOption func(*ServerMutation)
  27589. // newServerMutation creates new mutation for the Server entity.
  27590. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  27591. m := &ServerMutation{
  27592. config: c,
  27593. op: op,
  27594. typ: TypeServer,
  27595. clearedFields: make(map[string]struct{}),
  27596. }
  27597. for _, opt := range opts {
  27598. opt(m)
  27599. }
  27600. return m
  27601. }
  27602. // withServerID sets the ID field of the mutation.
  27603. func withServerID(id uint64) serverOption {
  27604. return func(m *ServerMutation) {
  27605. var (
  27606. err error
  27607. once sync.Once
  27608. value *Server
  27609. )
  27610. m.oldValue = func(ctx context.Context) (*Server, error) {
  27611. once.Do(func() {
  27612. if m.done {
  27613. err = errors.New("querying old values post mutation is not allowed")
  27614. } else {
  27615. value, err = m.Client().Server.Get(ctx, id)
  27616. }
  27617. })
  27618. return value, err
  27619. }
  27620. m.id = &id
  27621. }
  27622. }
  27623. // withServer sets the old Server of the mutation.
  27624. func withServer(node *Server) serverOption {
  27625. return func(m *ServerMutation) {
  27626. m.oldValue = func(context.Context) (*Server, error) {
  27627. return node, nil
  27628. }
  27629. m.id = &node.ID
  27630. }
  27631. }
  27632. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27633. // executed in a transaction (ent.Tx), a transactional client is returned.
  27634. func (m ServerMutation) Client() *Client {
  27635. client := &Client{config: m.config}
  27636. client.init()
  27637. return client
  27638. }
  27639. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27640. // it returns an error otherwise.
  27641. func (m ServerMutation) Tx() (*Tx, error) {
  27642. if _, ok := m.driver.(*txDriver); !ok {
  27643. return nil, errors.New("ent: mutation is not running in a transaction")
  27644. }
  27645. tx := &Tx{config: m.config}
  27646. tx.init()
  27647. return tx, nil
  27648. }
  27649. // SetID sets the value of the id field. Note that this
  27650. // operation is only accepted on creation of Server entities.
  27651. func (m *ServerMutation) SetID(id uint64) {
  27652. m.id = &id
  27653. }
  27654. // ID returns the ID value in the mutation. Note that the ID is only available
  27655. // if it was provided to the builder or after it was returned from the database.
  27656. func (m *ServerMutation) ID() (id uint64, exists bool) {
  27657. if m.id == nil {
  27658. return
  27659. }
  27660. return *m.id, true
  27661. }
  27662. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27663. // That means, if the mutation is applied within a transaction with an isolation level such
  27664. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27665. // or updated by the mutation.
  27666. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  27667. switch {
  27668. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27669. id, exists := m.ID()
  27670. if exists {
  27671. return []uint64{id}, nil
  27672. }
  27673. fallthrough
  27674. case m.op.Is(OpUpdate | OpDelete):
  27675. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  27676. default:
  27677. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27678. }
  27679. }
  27680. // SetCreatedAt sets the "created_at" field.
  27681. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  27682. m.created_at = &t
  27683. }
  27684. // CreatedAt returns the value of the "created_at" field in the mutation.
  27685. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  27686. v := m.created_at
  27687. if v == nil {
  27688. return
  27689. }
  27690. return *v, true
  27691. }
  27692. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  27693. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27695. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27696. if !m.op.Is(OpUpdateOne) {
  27697. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27698. }
  27699. if m.id == nil || m.oldValue == nil {
  27700. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27701. }
  27702. oldValue, err := m.oldValue(ctx)
  27703. if err != nil {
  27704. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27705. }
  27706. return oldValue.CreatedAt, nil
  27707. }
  27708. // ResetCreatedAt resets all changes to the "created_at" field.
  27709. func (m *ServerMutation) ResetCreatedAt() {
  27710. m.created_at = nil
  27711. }
  27712. // SetUpdatedAt sets the "updated_at" field.
  27713. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  27714. m.updated_at = &t
  27715. }
  27716. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27717. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  27718. v := m.updated_at
  27719. if v == nil {
  27720. return
  27721. }
  27722. return *v, true
  27723. }
  27724. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  27725. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27727. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27728. if !m.op.Is(OpUpdateOne) {
  27729. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27730. }
  27731. if m.id == nil || m.oldValue == nil {
  27732. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27733. }
  27734. oldValue, err := m.oldValue(ctx)
  27735. if err != nil {
  27736. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27737. }
  27738. return oldValue.UpdatedAt, nil
  27739. }
  27740. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27741. func (m *ServerMutation) ResetUpdatedAt() {
  27742. m.updated_at = nil
  27743. }
  27744. // SetStatus sets the "status" field.
  27745. func (m *ServerMutation) SetStatus(u uint8) {
  27746. m.status = &u
  27747. m.addstatus = nil
  27748. }
  27749. // Status returns the value of the "status" field in the mutation.
  27750. func (m *ServerMutation) Status() (r uint8, exists bool) {
  27751. v := m.status
  27752. if v == nil {
  27753. return
  27754. }
  27755. return *v, true
  27756. }
  27757. // OldStatus returns the old "status" field's value of the Server entity.
  27758. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27760. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27761. if !m.op.Is(OpUpdateOne) {
  27762. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27763. }
  27764. if m.id == nil || m.oldValue == nil {
  27765. return v, errors.New("OldStatus requires an ID field in the mutation")
  27766. }
  27767. oldValue, err := m.oldValue(ctx)
  27768. if err != nil {
  27769. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27770. }
  27771. return oldValue.Status, nil
  27772. }
  27773. // AddStatus adds u to the "status" field.
  27774. func (m *ServerMutation) AddStatus(u int8) {
  27775. if m.addstatus != nil {
  27776. *m.addstatus += u
  27777. } else {
  27778. m.addstatus = &u
  27779. }
  27780. }
  27781. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27782. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  27783. v := m.addstatus
  27784. if v == nil {
  27785. return
  27786. }
  27787. return *v, true
  27788. }
  27789. // ClearStatus clears the value of the "status" field.
  27790. func (m *ServerMutation) ClearStatus() {
  27791. m.status = nil
  27792. m.addstatus = nil
  27793. m.clearedFields[server.FieldStatus] = struct{}{}
  27794. }
  27795. // StatusCleared returns if the "status" field was cleared in this mutation.
  27796. func (m *ServerMutation) StatusCleared() bool {
  27797. _, ok := m.clearedFields[server.FieldStatus]
  27798. return ok
  27799. }
  27800. // ResetStatus resets all changes to the "status" field.
  27801. func (m *ServerMutation) ResetStatus() {
  27802. m.status = nil
  27803. m.addstatus = nil
  27804. delete(m.clearedFields, server.FieldStatus)
  27805. }
  27806. // SetDeletedAt sets the "deleted_at" field.
  27807. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  27808. m.deleted_at = &t
  27809. }
  27810. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27811. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  27812. v := m.deleted_at
  27813. if v == nil {
  27814. return
  27815. }
  27816. return *v, true
  27817. }
  27818. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  27819. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27821. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27822. if !m.op.Is(OpUpdateOne) {
  27823. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27824. }
  27825. if m.id == nil || m.oldValue == nil {
  27826. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27827. }
  27828. oldValue, err := m.oldValue(ctx)
  27829. if err != nil {
  27830. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27831. }
  27832. return oldValue.DeletedAt, nil
  27833. }
  27834. // ClearDeletedAt clears the value of the "deleted_at" field.
  27835. func (m *ServerMutation) ClearDeletedAt() {
  27836. m.deleted_at = nil
  27837. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  27838. }
  27839. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27840. func (m *ServerMutation) DeletedAtCleared() bool {
  27841. _, ok := m.clearedFields[server.FieldDeletedAt]
  27842. return ok
  27843. }
  27844. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27845. func (m *ServerMutation) ResetDeletedAt() {
  27846. m.deleted_at = nil
  27847. delete(m.clearedFields, server.FieldDeletedAt)
  27848. }
  27849. // SetName sets the "name" field.
  27850. func (m *ServerMutation) SetName(s string) {
  27851. m.name = &s
  27852. }
  27853. // Name returns the value of the "name" field in the mutation.
  27854. func (m *ServerMutation) Name() (r string, exists bool) {
  27855. v := m.name
  27856. if v == nil {
  27857. return
  27858. }
  27859. return *v, true
  27860. }
  27861. // OldName returns the old "name" field's value of the Server entity.
  27862. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27864. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  27865. if !m.op.Is(OpUpdateOne) {
  27866. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27867. }
  27868. if m.id == nil || m.oldValue == nil {
  27869. return v, errors.New("OldName requires an ID field in the mutation")
  27870. }
  27871. oldValue, err := m.oldValue(ctx)
  27872. if err != nil {
  27873. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27874. }
  27875. return oldValue.Name, nil
  27876. }
  27877. // ResetName resets all changes to the "name" field.
  27878. func (m *ServerMutation) ResetName() {
  27879. m.name = nil
  27880. }
  27881. // SetPublicIP sets the "public_ip" field.
  27882. func (m *ServerMutation) SetPublicIP(s string) {
  27883. m.public_ip = &s
  27884. }
  27885. // PublicIP returns the value of the "public_ip" field in the mutation.
  27886. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  27887. v := m.public_ip
  27888. if v == nil {
  27889. return
  27890. }
  27891. return *v, true
  27892. }
  27893. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  27894. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27896. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  27897. if !m.op.Is(OpUpdateOne) {
  27898. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  27899. }
  27900. if m.id == nil || m.oldValue == nil {
  27901. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  27902. }
  27903. oldValue, err := m.oldValue(ctx)
  27904. if err != nil {
  27905. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  27906. }
  27907. return oldValue.PublicIP, nil
  27908. }
  27909. // ResetPublicIP resets all changes to the "public_ip" field.
  27910. func (m *ServerMutation) ResetPublicIP() {
  27911. m.public_ip = nil
  27912. }
  27913. // SetPrivateIP sets the "private_ip" field.
  27914. func (m *ServerMutation) SetPrivateIP(s string) {
  27915. m.private_ip = &s
  27916. }
  27917. // PrivateIP returns the value of the "private_ip" field in the mutation.
  27918. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  27919. v := m.private_ip
  27920. if v == nil {
  27921. return
  27922. }
  27923. return *v, true
  27924. }
  27925. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  27926. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27928. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  27929. if !m.op.Is(OpUpdateOne) {
  27930. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  27931. }
  27932. if m.id == nil || m.oldValue == nil {
  27933. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  27934. }
  27935. oldValue, err := m.oldValue(ctx)
  27936. if err != nil {
  27937. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  27938. }
  27939. return oldValue.PrivateIP, nil
  27940. }
  27941. // ResetPrivateIP resets all changes to the "private_ip" field.
  27942. func (m *ServerMutation) ResetPrivateIP() {
  27943. m.private_ip = nil
  27944. }
  27945. // SetAdminPort sets the "admin_port" field.
  27946. func (m *ServerMutation) SetAdminPort(s string) {
  27947. m.admin_port = &s
  27948. }
  27949. // AdminPort returns the value of the "admin_port" field in the mutation.
  27950. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  27951. v := m.admin_port
  27952. if v == nil {
  27953. return
  27954. }
  27955. return *v, true
  27956. }
  27957. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  27958. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27960. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  27961. if !m.op.Is(OpUpdateOne) {
  27962. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  27963. }
  27964. if m.id == nil || m.oldValue == nil {
  27965. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  27966. }
  27967. oldValue, err := m.oldValue(ctx)
  27968. if err != nil {
  27969. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  27970. }
  27971. return oldValue.AdminPort, nil
  27972. }
  27973. // ResetAdminPort resets all changes to the "admin_port" field.
  27974. func (m *ServerMutation) ResetAdminPort() {
  27975. m.admin_port = nil
  27976. }
  27977. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  27978. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  27979. if m.wxs == nil {
  27980. m.wxs = make(map[uint64]struct{})
  27981. }
  27982. for i := range ids {
  27983. m.wxs[ids[i]] = struct{}{}
  27984. }
  27985. }
  27986. // ClearWxs clears the "wxs" edge to the Wx entity.
  27987. func (m *ServerMutation) ClearWxs() {
  27988. m.clearedwxs = true
  27989. }
  27990. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  27991. func (m *ServerMutation) WxsCleared() bool {
  27992. return m.clearedwxs
  27993. }
  27994. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  27995. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  27996. if m.removedwxs == nil {
  27997. m.removedwxs = make(map[uint64]struct{})
  27998. }
  27999. for i := range ids {
  28000. delete(m.wxs, ids[i])
  28001. m.removedwxs[ids[i]] = struct{}{}
  28002. }
  28003. }
  28004. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  28005. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  28006. for id := range m.removedwxs {
  28007. ids = append(ids, id)
  28008. }
  28009. return
  28010. }
  28011. // WxsIDs returns the "wxs" edge IDs in the mutation.
  28012. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  28013. for id := range m.wxs {
  28014. ids = append(ids, id)
  28015. }
  28016. return
  28017. }
  28018. // ResetWxs resets all changes to the "wxs" edge.
  28019. func (m *ServerMutation) ResetWxs() {
  28020. m.wxs = nil
  28021. m.clearedwxs = false
  28022. m.removedwxs = nil
  28023. }
  28024. // Where appends a list predicates to the ServerMutation builder.
  28025. func (m *ServerMutation) Where(ps ...predicate.Server) {
  28026. m.predicates = append(m.predicates, ps...)
  28027. }
  28028. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  28029. // users can use type-assertion to append predicates that do not depend on any generated package.
  28030. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  28031. p := make([]predicate.Server, len(ps))
  28032. for i := range ps {
  28033. p[i] = ps[i]
  28034. }
  28035. m.Where(p...)
  28036. }
  28037. // Op returns the operation name.
  28038. func (m *ServerMutation) Op() Op {
  28039. return m.op
  28040. }
  28041. // SetOp allows setting the mutation operation.
  28042. func (m *ServerMutation) SetOp(op Op) {
  28043. m.op = op
  28044. }
  28045. // Type returns the node type of this mutation (Server).
  28046. func (m *ServerMutation) Type() string {
  28047. return m.typ
  28048. }
  28049. // Fields returns all fields that were changed during this mutation. Note that in
  28050. // order to get all numeric fields that were incremented/decremented, call
  28051. // AddedFields().
  28052. func (m *ServerMutation) Fields() []string {
  28053. fields := make([]string, 0, 8)
  28054. if m.created_at != nil {
  28055. fields = append(fields, server.FieldCreatedAt)
  28056. }
  28057. if m.updated_at != nil {
  28058. fields = append(fields, server.FieldUpdatedAt)
  28059. }
  28060. if m.status != nil {
  28061. fields = append(fields, server.FieldStatus)
  28062. }
  28063. if m.deleted_at != nil {
  28064. fields = append(fields, server.FieldDeletedAt)
  28065. }
  28066. if m.name != nil {
  28067. fields = append(fields, server.FieldName)
  28068. }
  28069. if m.public_ip != nil {
  28070. fields = append(fields, server.FieldPublicIP)
  28071. }
  28072. if m.private_ip != nil {
  28073. fields = append(fields, server.FieldPrivateIP)
  28074. }
  28075. if m.admin_port != nil {
  28076. fields = append(fields, server.FieldAdminPort)
  28077. }
  28078. return fields
  28079. }
  28080. // Field returns the value of a field with the given name. The second boolean
  28081. // return value indicates that this field was not set, or was not defined in the
  28082. // schema.
  28083. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  28084. switch name {
  28085. case server.FieldCreatedAt:
  28086. return m.CreatedAt()
  28087. case server.FieldUpdatedAt:
  28088. return m.UpdatedAt()
  28089. case server.FieldStatus:
  28090. return m.Status()
  28091. case server.FieldDeletedAt:
  28092. return m.DeletedAt()
  28093. case server.FieldName:
  28094. return m.Name()
  28095. case server.FieldPublicIP:
  28096. return m.PublicIP()
  28097. case server.FieldPrivateIP:
  28098. return m.PrivateIP()
  28099. case server.FieldAdminPort:
  28100. return m.AdminPort()
  28101. }
  28102. return nil, false
  28103. }
  28104. // OldField returns the old value of the field from the database. An error is
  28105. // returned if the mutation operation is not UpdateOne, or the query to the
  28106. // database failed.
  28107. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28108. switch name {
  28109. case server.FieldCreatedAt:
  28110. return m.OldCreatedAt(ctx)
  28111. case server.FieldUpdatedAt:
  28112. return m.OldUpdatedAt(ctx)
  28113. case server.FieldStatus:
  28114. return m.OldStatus(ctx)
  28115. case server.FieldDeletedAt:
  28116. return m.OldDeletedAt(ctx)
  28117. case server.FieldName:
  28118. return m.OldName(ctx)
  28119. case server.FieldPublicIP:
  28120. return m.OldPublicIP(ctx)
  28121. case server.FieldPrivateIP:
  28122. return m.OldPrivateIP(ctx)
  28123. case server.FieldAdminPort:
  28124. return m.OldAdminPort(ctx)
  28125. }
  28126. return nil, fmt.Errorf("unknown Server field %s", name)
  28127. }
  28128. // SetField sets the value of a field with the given name. It returns an error if
  28129. // the field is not defined in the schema, or if the type mismatched the field
  28130. // type.
  28131. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  28132. switch name {
  28133. case server.FieldCreatedAt:
  28134. v, ok := value.(time.Time)
  28135. if !ok {
  28136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28137. }
  28138. m.SetCreatedAt(v)
  28139. return nil
  28140. case server.FieldUpdatedAt:
  28141. v, ok := value.(time.Time)
  28142. if !ok {
  28143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28144. }
  28145. m.SetUpdatedAt(v)
  28146. return nil
  28147. case server.FieldStatus:
  28148. v, ok := value.(uint8)
  28149. if !ok {
  28150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28151. }
  28152. m.SetStatus(v)
  28153. return nil
  28154. case server.FieldDeletedAt:
  28155. v, ok := value.(time.Time)
  28156. if !ok {
  28157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28158. }
  28159. m.SetDeletedAt(v)
  28160. return nil
  28161. case server.FieldName:
  28162. v, ok := value.(string)
  28163. if !ok {
  28164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28165. }
  28166. m.SetName(v)
  28167. return nil
  28168. case server.FieldPublicIP:
  28169. v, ok := value.(string)
  28170. if !ok {
  28171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28172. }
  28173. m.SetPublicIP(v)
  28174. return nil
  28175. case server.FieldPrivateIP:
  28176. v, ok := value.(string)
  28177. if !ok {
  28178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28179. }
  28180. m.SetPrivateIP(v)
  28181. return nil
  28182. case server.FieldAdminPort:
  28183. v, ok := value.(string)
  28184. if !ok {
  28185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28186. }
  28187. m.SetAdminPort(v)
  28188. return nil
  28189. }
  28190. return fmt.Errorf("unknown Server field %s", name)
  28191. }
  28192. // AddedFields returns all numeric fields that were incremented/decremented during
  28193. // this mutation.
  28194. func (m *ServerMutation) AddedFields() []string {
  28195. var fields []string
  28196. if m.addstatus != nil {
  28197. fields = append(fields, server.FieldStatus)
  28198. }
  28199. return fields
  28200. }
  28201. // AddedField returns the numeric value that was incremented/decremented on a field
  28202. // with the given name. The second boolean return value indicates that this field
  28203. // was not set, or was not defined in the schema.
  28204. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  28205. switch name {
  28206. case server.FieldStatus:
  28207. return m.AddedStatus()
  28208. }
  28209. return nil, false
  28210. }
  28211. // AddField adds the value to the field with the given name. It returns an error if
  28212. // the field is not defined in the schema, or if the type mismatched the field
  28213. // type.
  28214. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  28215. switch name {
  28216. case server.FieldStatus:
  28217. v, ok := value.(int8)
  28218. if !ok {
  28219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28220. }
  28221. m.AddStatus(v)
  28222. return nil
  28223. }
  28224. return fmt.Errorf("unknown Server numeric field %s", name)
  28225. }
  28226. // ClearedFields returns all nullable fields that were cleared during this
  28227. // mutation.
  28228. func (m *ServerMutation) ClearedFields() []string {
  28229. var fields []string
  28230. if m.FieldCleared(server.FieldStatus) {
  28231. fields = append(fields, server.FieldStatus)
  28232. }
  28233. if m.FieldCleared(server.FieldDeletedAt) {
  28234. fields = append(fields, server.FieldDeletedAt)
  28235. }
  28236. return fields
  28237. }
  28238. // FieldCleared returns a boolean indicating if a field with the given name was
  28239. // cleared in this mutation.
  28240. func (m *ServerMutation) FieldCleared(name string) bool {
  28241. _, ok := m.clearedFields[name]
  28242. return ok
  28243. }
  28244. // ClearField clears the value of the field with the given name. It returns an
  28245. // error if the field is not defined in the schema.
  28246. func (m *ServerMutation) ClearField(name string) error {
  28247. switch name {
  28248. case server.FieldStatus:
  28249. m.ClearStatus()
  28250. return nil
  28251. case server.FieldDeletedAt:
  28252. m.ClearDeletedAt()
  28253. return nil
  28254. }
  28255. return fmt.Errorf("unknown Server nullable field %s", name)
  28256. }
  28257. // ResetField resets all changes in the mutation for the field with the given name.
  28258. // It returns an error if the field is not defined in the schema.
  28259. func (m *ServerMutation) ResetField(name string) error {
  28260. switch name {
  28261. case server.FieldCreatedAt:
  28262. m.ResetCreatedAt()
  28263. return nil
  28264. case server.FieldUpdatedAt:
  28265. m.ResetUpdatedAt()
  28266. return nil
  28267. case server.FieldStatus:
  28268. m.ResetStatus()
  28269. return nil
  28270. case server.FieldDeletedAt:
  28271. m.ResetDeletedAt()
  28272. return nil
  28273. case server.FieldName:
  28274. m.ResetName()
  28275. return nil
  28276. case server.FieldPublicIP:
  28277. m.ResetPublicIP()
  28278. return nil
  28279. case server.FieldPrivateIP:
  28280. m.ResetPrivateIP()
  28281. return nil
  28282. case server.FieldAdminPort:
  28283. m.ResetAdminPort()
  28284. return nil
  28285. }
  28286. return fmt.Errorf("unknown Server field %s", name)
  28287. }
  28288. // AddedEdges returns all edge names that were set/added in this mutation.
  28289. func (m *ServerMutation) AddedEdges() []string {
  28290. edges := make([]string, 0, 1)
  28291. if m.wxs != nil {
  28292. edges = append(edges, server.EdgeWxs)
  28293. }
  28294. return edges
  28295. }
  28296. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28297. // name in this mutation.
  28298. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  28299. switch name {
  28300. case server.EdgeWxs:
  28301. ids := make([]ent.Value, 0, len(m.wxs))
  28302. for id := range m.wxs {
  28303. ids = append(ids, id)
  28304. }
  28305. return ids
  28306. }
  28307. return nil
  28308. }
  28309. // RemovedEdges returns all edge names that were removed in this mutation.
  28310. func (m *ServerMutation) RemovedEdges() []string {
  28311. edges := make([]string, 0, 1)
  28312. if m.removedwxs != nil {
  28313. edges = append(edges, server.EdgeWxs)
  28314. }
  28315. return edges
  28316. }
  28317. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28318. // the given name in this mutation.
  28319. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  28320. switch name {
  28321. case server.EdgeWxs:
  28322. ids := make([]ent.Value, 0, len(m.removedwxs))
  28323. for id := range m.removedwxs {
  28324. ids = append(ids, id)
  28325. }
  28326. return ids
  28327. }
  28328. return nil
  28329. }
  28330. // ClearedEdges returns all edge names that were cleared in this mutation.
  28331. func (m *ServerMutation) ClearedEdges() []string {
  28332. edges := make([]string, 0, 1)
  28333. if m.clearedwxs {
  28334. edges = append(edges, server.EdgeWxs)
  28335. }
  28336. return edges
  28337. }
  28338. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28339. // was cleared in this mutation.
  28340. func (m *ServerMutation) EdgeCleared(name string) bool {
  28341. switch name {
  28342. case server.EdgeWxs:
  28343. return m.clearedwxs
  28344. }
  28345. return false
  28346. }
  28347. // ClearEdge clears the value of the edge with the given name. It returns an error
  28348. // if that edge is not defined in the schema.
  28349. func (m *ServerMutation) ClearEdge(name string) error {
  28350. switch name {
  28351. }
  28352. return fmt.Errorf("unknown Server unique edge %s", name)
  28353. }
  28354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28355. // It returns an error if the edge is not defined in the schema.
  28356. func (m *ServerMutation) ResetEdge(name string) error {
  28357. switch name {
  28358. case server.EdgeWxs:
  28359. m.ResetWxs()
  28360. return nil
  28361. }
  28362. return fmt.Errorf("unknown Server edge %s", name)
  28363. }
  28364. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  28365. type SopNodeMutation struct {
  28366. config
  28367. op Op
  28368. typ string
  28369. id *uint64
  28370. created_at *time.Time
  28371. updated_at *time.Time
  28372. status *uint8
  28373. addstatus *int8
  28374. deleted_at *time.Time
  28375. parent_id *uint64
  28376. addparent_id *int64
  28377. name *string
  28378. condition_type *int
  28379. addcondition_type *int
  28380. condition_list *[]string
  28381. appendcondition_list []string
  28382. no_reply_condition *uint64
  28383. addno_reply_condition *int64
  28384. no_reply_unit *string
  28385. action_message *[]custom_types.Action
  28386. appendaction_message []custom_types.Action
  28387. action_label_add *[]uint64
  28388. appendaction_label_add []uint64
  28389. action_label_del *[]uint64
  28390. appendaction_label_del []uint64
  28391. action_forward **custom_types.ActionForward
  28392. clearedFields map[string]struct{}
  28393. sop_stage *uint64
  28394. clearedsop_stage bool
  28395. node_messages map[uint64]struct{}
  28396. removednode_messages map[uint64]struct{}
  28397. clearednode_messages bool
  28398. done bool
  28399. oldValue func(context.Context) (*SopNode, error)
  28400. predicates []predicate.SopNode
  28401. }
  28402. var _ ent.Mutation = (*SopNodeMutation)(nil)
  28403. // sopnodeOption allows management of the mutation configuration using functional options.
  28404. type sopnodeOption func(*SopNodeMutation)
  28405. // newSopNodeMutation creates new mutation for the SopNode entity.
  28406. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  28407. m := &SopNodeMutation{
  28408. config: c,
  28409. op: op,
  28410. typ: TypeSopNode,
  28411. clearedFields: make(map[string]struct{}),
  28412. }
  28413. for _, opt := range opts {
  28414. opt(m)
  28415. }
  28416. return m
  28417. }
  28418. // withSopNodeID sets the ID field of the mutation.
  28419. func withSopNodeID(id uint64) sopnodeOption {
  28420. return func(m *SopNodeMutation) {
  28421. var (
  28422. err error
  28423. once sync.Once
  28424. value *SopNode
  28425. )
  28426. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  28427. once.Do(func() {
  28428. if m.done {
  28429. err = errors.New("querying old values post mutation is not allowed")
  28430. } else {
  28431. value, err = m.Client().SopNode.Get(ctx, id)
  28432. }
  28433. })
  28434. return value, err
  28435. }
  28436. m.id = &id
  28437. }
  28438. }
  28439. // withSopNode sets the old SopNode of the mutation.
  28440. func withSopNode(node *SopNode) sopnodeOption {
  28441. return func(m *SopNodeMutation) {
  28442. m.oldValue = func(context.Context) (*SopNode, error) {
  28443. return node, nil
  28444. }
  28445. m.id = &node.ID
  28446. }
  28447. }
  28448. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28449. // executed in a transaction (ent.Tx), a transactional client is returned.
  28450. func (m SopNodeMutation) Client() *Client {
  28451. client := &Client{config: m.config}
  28452. client.init()
  28453. return client
  28454. }
  28455. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28456. // it returns an error otherwise.
  28457. func (m SopNodeMutation) Tx() (*Tx, error) {
  28458. if _, ok := m.driver.(*txDriver); !ok {
  28459. return nil, errors.New("ent: mutation is not running in a transaction")
  28460. }
  28461. tx := &Tx{config: m.config}
  28462. tx.init()
  28463. return tx, nil
  28464. }
  28465. // SetID sets the value of the id field. Note that this
  28466. // operation is only accepted on creation of SopNode entities.
  28467. func (m *SopNodeMutation) SetID(id uint64) {
  28468. m.id = &id
  28469. }
  28470. // ID returns the ID value in the mutation. Note that the ID is only available
  28471. // if it was provided to the builder or after it was returned from the database.
  28472. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  28473. if m.id == nil {
  28474. return
  28475. }
  28476. return *m.id, true
  28477. }
  28478. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28479. // That means, if the mutation is applied within a transaction with an isolation level such
  28480. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28481. // or updated by the mutation.
  28482. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  28483. switch {
  28484. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28485. id, exists := m.ID()
  28486. if exists {
  28487. return []uint64{id}, nil
  28488. }
  28489. fallthrough
  28490. case m.op.Is(OpUpdate | OpDelete):
  28491. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  28492. default:
  28493. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28494. }
  28495. }
  28496. // SetCreatedAt sets the "created_at" field.
  28497. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  28498. m.created_at = &t
  28499. }
  28500. // CreatedAt returns the value of the "created_at" field in the mutation.
  28501. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  28502. v := m.created_at
  28503. if v == nil {
  28504. return
  28505. }
  28506. return *v, true
  28507. }
  28508. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  28509. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28511. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28512. if !m.op.Is(OpUpdateOne) {
  28513. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28514. }
  28515. if m.id == nil || m.oldValue == nil {
  28516. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28517. }
  28518. oldValue, err := m.oldValue(ctx)
  28519. if err != nil {
  28520. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28521. }
  28522. return oldValue.CreatedAt, nil
  28523. }
  28524. // ResetCreatedAt resets all changes to the "created_at" field.
  28525. func (m *SopNodeMutation) ResetCreatedAt() {
  28526. m.created_at = nil
  28527. }
  28528. // SetUpdatedAt sets the "updated_at" field.
  28529. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  28530. m.updated_at = &t
  28531. }
  28532. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28533. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  28534. v := m.updated_at
  28535. if v == nil {
  28536. return
  28537. }
  28538. return *v, true
  28539. }
  28540. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  28541. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28543. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28544. if !m.op.Is(OpUpdateOne) {
  28545. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28546. }
  28547. if m.id == nil || m.oldValue == nil {
  28548. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28549. }
  28550. oldValue, err := m.oldValue(ctx)
  28551. if err != nil {
  28552. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28553. }
  28554. return oldValue.UpdatedAt, nil
  28555. }
  28556. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28557. func (m *SopNodeMutation) ResetUpdatedAt() {
  28558. m.updated_at = nil
  28559. }
  28560. // SetStatus sets the "status" field.
  28561. func (m *SopNodeMutation) SetStatus(u uint8) {
  28562. m.status = &u
  28563. m.addstatus = nil
  28564. }
  28565. // Status returns the value of the "status" field in the mutation.
  28566. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  28567. v := m.status
  28568. if v == nil {
  28569. return
  28570. }
  28571. return *v, true
  28572. }
  28573. // OldStatus returns the old "status" field's value of the SopNode entity.
  28574. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28576. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28577. if !m.op.Is(OpUpdateOne) {
  28578. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28579. }
  28580. if m.id == nil || m.oldValue == nil {
  28581. return v, errors.New("OldStatus requires an ID field in the mutation")
  28582. }
  28583. oldValue, err := m.oldValue(ctx)
  28584. if err != nil {
  28585. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28586. }
  28587. return oldValue.Status, nil
  28588. }
  28589. // AddStatus adds u to the "status" field.
  28590. func (m *SopNodeMutation) AddStatus(u int8) {
  28591. if m.addstatus != nil {
  28592. *m.addstatus += u
  28593. } else {
  28594. m.addstatus = &u
  28595. }
  28596. }
  28597. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28598. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  28599. v := m.addstatus
  28600. if v == nil {
  28601. return
  28602. }
  28603. return *v, true
  28604. }
  28605. // ClearStatus clears the value of the "status" field.
  28606. func (m *SopNodeMutation) ClearStatus() {
  28607. m.status = nil
  28608. m.addstatus = nil
  28609. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  28610. }
  28611. // StatusCleared returns if the "status" field was cleared in this mutation.
  28612. func (m *SopNodeMutation) StatusCleared() bool {
  28613. _, ok := m.clearedFields[sopnode.FieldStatus]
  28614. return ok
  28615. }
  28616. // ResetStatus resets all changes to the "status" field.
  28617. func (m *SopNodeMutation) ResetStatus() {
  28618. m.status = nil
  28619. m.addstatus = nil
  28620. delete(m.clearedFields, sopnode.FieldStatus)
  28621. }
  28622. // SetDeletedAt sets the "deleted_at" field.
  28623. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  28624. m.deleted_at = &t
  28625. }
  28626. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28627. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  28628. v := m.deleted_at
  28629. if v == nil {
  28630. return
  28631. }
  28632. return *v, true
  28633. }
  28634. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  28635. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28637. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28638. if !m.op.Is(OpUpdateOne) {
  28639. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28640. }
  28641. if m.id == nil || m.oldValue == nil {
  28642. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28643. }
  28644. oldValue, err := m.oldValue(ctx)
  28645. if err != nil {
  28646. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28647. }
  28648. return oldValue.DeletedAt, nil
  28649. }
  28650. // ClearDeletedAt clears the value of the "deleted_at" field.
  28651. func (m *SopNodeMutation) ClearDeletedAt() {
  28652. m.deleted_at = nil
  28653. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  28654. }
  28655. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28656. func (m *SopNodeMutation) DeletedAtCleared() bool {
  28657. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  28658. return ok
  28659. }
  28660. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28661. func (m *SopNodeMutation) ResetDeletedAt() {
  28662. m.deleted_at = nil
  28663. delete(m.clearedFields, sopnode.FieldDeletedAt)
  28664. }
  28665. // SetStageID sets the "stage_id" field.
  28666. func (m *SopNodeMutation) SetStageID(u uint64) {
  28667. m.sop_stage = &u
  28668. }
  28669. // StageID returns the value of the "stage_id" field in the mutation.
  28670. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  28671. v := m.sop_stage
  28672. if v == nil {
  28673. return
  28674. }
  28675. return *v, true
  28676. }
  28677. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  28678. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28680. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  28681. if !m.op.Is(OpUpdateOne) {
  28682. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  28683. }
  28684. if m.id == nil || m.oldValue == nil {
  28685. return v, errors.New("OldStageID requires an ID field in the mutation")
  28686. }
  28687. oldValue, err := m.oldValue(ctx)
  28688. if err != nil {
  28689. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  28690. }
  28691. return oldValue.StageID, nil
  28692. }
  28693. // ResetStageID resets all changes to the "stage_id" field.
  28694. func (m *SopNodeMutation) ResetStageID() {
  28695. m.sop_stage = nil
  28696. }
  28697. // SetParentID sets the "parent_id" field.
  28698. func (m *SopNodeMutation) SetParentID(u uint64) {
  28699. m.parent_id = &u
  28700. m.addparent_id = nil
  28701. }
  28702. // ParentID returns the value of the "parent_id" field in the mutation.
  28703. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  28704. v := m.parent_id
  28705. if v == nil {
  28706. return
  28707. }
  28708. return *v, true
  28709. }
  28710. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  28711. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28713. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  28714. if !m.op.Is(OpUpdateOne) {
  28715. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  28716. }
  28717. if m.id == nil || m.oldValue == nil {
  28718. return v, errors.New("OldParentID requires an ID field in the mutation")
  28719. }
  28720. oldValue, err := m.oldValue(ctx)
  28721. if err != nil {
  28722. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  28723. }
  28724. return oldValue.ParentID, nil
  28725. }
  28726. // AddParentID adds u to the "parent_id" field.
  28727. func (m *SopNodeMutation) AddParentID(u int64) {
  28728. if m.addparent_id != nil {
  28729. *m.addparent_id += u
  28730. } else {
  28731. m.addparent_id = &u
  28732. }
  28733. }
  28734. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  28735. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  28736. v := m.addparent_id
  28737. if v == nil {
  28738. return
  28739. }
  28740. return *v, true
  28741. }
  28742. // ResetParentID resets all changes to the "parent_id" field.
  28743. func (m *SopNodeMutation) ResetParentID() {
  28744. m.parent_id = nil
  28745. m.addparent_id = nil
  28746. }
  28747. // SetName sets the "name" field.
  28748. func (m *SopNodeMutation) SetName(s string) {
  28749. m.name = &s
  28750. }
  28751. // Name returns the value of the "name" field in the mutation.
  28752. func (m *SopNodeMutation) Name() (r string, exists bool) {
  28753. v := m.name
  28754. if v == nil {
  28755. return
  28756. }
  28757. return *v, true
  28758. }
  28759. // OldName returns the old "name" field's value of the SopNode entity.
  28760. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28762. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  28763. if !m.op.Is(OpUpdateOne) {
  28764. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28765. }
  28766. if m.id == nil || m.oldValue == nil {
  28767. return v, errors.New("OldName requires an ID field in the mutation")
  28768. }
  28769. oldValue, err := m.oldValue(ctx)
  28770. if err != nil {
  28771. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28772. }
  28773. return oldValue.Name, nil
  28774. }
  28775. // ResetName resets all changes to the "name" field.
  28776. func (m *SopNodeMutation) ResetName() {
  28777. m.name = nil
  28778. }
  28779. // SetConditionType sets the "condition_type" field.
  28780. func (m *SopNodeMutation) SetConditionType(i int) {
  28781. m.condition_type = &i
  28782. m.addcondition_type = nil
  28783. }
  28784. // ConditionType returns the value of the "condition_type" field in the mutation.
  28785. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  28786. v := m.condition_type
  28787. if v == nil {
  28788. return
  28789. }
  28790. return *v, true
  28791. }
  28792. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  28793. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28795. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28796. if !m.op.Is(OpUpdateOne) {
  28797. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28798. }
  28799. if m.id == nil || m.oldValue == nil {
  28800. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28801. }
  28802. oldValue, err := m.oldValue(ctx)
  28803. if err != nil {
  28804. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28805. }
  28806. return oldValue.ConditionType, nil
  28807. }
  28808. // AddConditionType adds i to the "condition_type" field.
  28809. func (m *SopNodeMutation) AddConditionType(i int) {
  28810. if m.addcondition_type != nil {
  28811. *m.addcondition_type += i
  28812. } else {
  28813. m.addcondition_type = &i
  28814. }
  28815. }
  28816. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28817. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  28818. v := m.addcondition_type
  28819. if v == nil {
  28820. return
  28821. }
  28822. return *v, true
  28823. }
  28824. // ResetConditionType resets all changes to the "condition_type" field.
  28825. func (m *SopNodeMutation) ResetConditionType() {
  28826. m.condition_type = nil
  28827. m.addcondition_type = nil
  28828. }
  28829. // SetConditionList sets the "condition_list" field.
  28830. func (m *SopNodeMutation) SetConditionList(s []string) {
  28831. m.condition_list = &s
  28832. m.appendcondition_list = nil
  28833. }
  28834. // ConditionList returns the value of the "condition_list" field in the mutation.
  28835. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  28836. v := m.condition_list
  28837. if v == nil {
  28838. return
  28839. }
  28840. return *v, true
  28841. }
  28842. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  28843. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28845. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  28846. if !m.op.Is(OpUpdateOne) {
  28847. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28848. }
  28849. if m.id == nil || m.oldValue == nil {
  28850. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28851. }
  28852. oldValue, err := m.oldValue(ctx)
  28853. if err != nil {
  28854. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28855. }
  28856. return oldValue.ConditionList, nil
  28857. }
  28858. // AppendConditionList adds s to the "condition_list" field.
  28859. func (m *SopNodeMutation) AppendConditionList(s []string) {
  28860. m.appendcondition_list = append(m.appendcondition_list, s...)
  28861. }
  28862. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28863. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  28864. if len(m.appendcondition_list) == 0 {
  28865. return nil, false
  28866. }
  28867. return m.appendcondition_list, true
  28868. }
  28869. // ClearConditionList clears the value of the "condition_list" field.
  28870. func (m *SopNodeMutation) ClearConditionList() {
  28871. m.condition_list = nil
  28872. m.appendcondition_list = nil
  28873. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  28874. }
  28875. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  28876. func (m *SopNodeMutation) ConditionListCleared() bool {
  28877. _, ok := m.clearedFields[sopnode.FieldConditionList]
  28878. return ok
  28879. }
  28880. // ResetConditionList resets all changes to the "condition_list" field.
  28881. func (m *SopNodeMutation) ResetConditionList() {
  28882. m.condition_list = nil
  28883. m.appendcondition_list = nil
  28884. delete(m.clearedFields, sopnode.FieldConditionList)
  28885. }
  28886. // SetNoReplyCondition sets the "no_reply_condition" field.
  28887. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  28888. m.no_reply_condition = &u
  28889. m.addno_reply_condition = nil
  28890. }
  28891. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  28892. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  28893. v := m.no_reply_condition
  28894. if v == nil {
  28895. return
  28896. }
  28897. return *v, true
  28898. }
  28899. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  28900. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28902. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  28903. if !m.op.Is(OpUpdateOne) {
  28904. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  28905. }
  28906. if m.id == nil || m.oldValue == nil {
  28907. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  28908. }
  28909. oldValue, err := m.oldValue(ctx)
  28910. if err != nil {
  28911. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  28912. }
  28913. return oldValue.NoReplyCondition, nil
  28914. }
  28915. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  28916. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  28917. if m.addno_reply_condition != nil {
  28918. *m.addno_reply_condition += u
  28919. } else {
  28920. m.addno_reply_condition = &u
  28921. }
  28922. }
  28923. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  28924. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  28925. v := m.addno_reply_condition
  28926. if v == nil {
  28927. return
  28928. }
  28929. return *v, true
  28930. }
  28931. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  28932. func (m *SopNodeMutation) ResetNoReplyCondition() {
  28933. m.no_reply_condition = nil
  28934. m.addno_reply_condition = nil
  28935. }
  28936. // SetNoReplyUnit sets the "no_reply_unit" field.
  28937. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  28938. m.no_reply_unit = &s
  28939. }
  28940. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  28941. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  28942. v := m.no_reply_unit
  28943. if v == nil {
  28944. return
  28945. }
  28946. return *v, true
  28947. }
  28948. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  28949. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28951. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  28952. if !m.op.Is(OpUpdateOne) {
  28953. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  28954. }
  28955. if m.id == nil || m.oldValue == nil {
  28956. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  28957. }
  28958. oldValue, err := m.oldValue(ctx)
  28959. if err != nil {
  28960. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  28961. }
  28962. return oldValue.NoReplyUnit, nil
  28963. }
  28964. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  28965. func (m *SopNodeMutation) ResetNoReplyUnit() {
  28966. m.no_reply_unit = nil
  28967. }
  28968. // SetActionMessage sets the "action_message" field.
  28969. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  28970. m.action_message = &ct
  28971. m.appendaction_message = nil
  28972. }
  28973. // ActionMessage returns the value of the "action_message" field in the mutation.
  28974. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  28975. v := m.action_message
  28976. if v == nil {
  28977. return
  28978. }
  28979. return *v, true
  28980. }
  28981. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  28982. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28984. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28985. if !m.op.Is(OpUpdateOne) {
  28986. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28987. }
  28988. if m.id == nil || m.oldValue == nil {
  28989. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28990. }
  28991. oldValue, err := m.oldValue(ctx)
  28992. if err != nil {
  28993. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28994. }
  28995. return oldValue.ActionMessage, nil
  28996. }
  28997. // AppendActionMessage adds ct to the "action_message" field.
  28998. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  28999. m.appendaction_message = append(m.appendaction_message, ct...)
  29000. }
  29001. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  29002. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  29003. if len(m.appendaction_message) == 0 {
  29004. return nil, false
  29005. }
  29006. return m.appendaction_message, true
  29007. }
  29008. // ClearActionMessage clears the value of the "action_message" field.
  29009. func (m *SopNodeMutation) ClearActionMessage() {
  29010. m.action_message = nil
  29011. m.appendaction_message = nil
  29012. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  29013. }
  29014. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  29015. func (m *SopNodeMutation) ActionMessageCleared() bool {
  29016. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  29017. return ok
  29018. }
  29019. // ResetActionMessage resets all changes to the "action_message" field.
  29020. func (m *SopNodeMutation) ResetActionMessage() {
  29021. m.action_message = nil
  29022. m.appendaction_message = nil
  29023. delete(m.clearedFields, sopnode.FieldActionMessage)
  29024. }
  29025. // SetActionLabelAdd sets the "action_label_add" field.
  29026. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  29027. m.action_label_add = &u
  29028. m.appendaction_label_add = nil
  29029. }
  29030. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  29031. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  29032. v := m.action_label_add
  29033. if v == nil {
  29034. return
  29035. }
  29036. return *v, true
  29037. }
  29038. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  29039. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29041. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  29042. if !m.op.Is(OpUpdateOne) {
  29043. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  29044. }
  29045. if m.id == nil || m.oldValue == nil {
  29046. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  29047. }
  29048. oldValue, err := m.oldValue(ctx)
  29049. if err != nil {
  29050. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  29051. }
  29052. return oldValue.ActionLabelAdd, nil
  29053. }
  29054. // AppendActionLabelAdd adds u to the "action_label_add" field.
  29055. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  29056. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  29057. }
  29058. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  29059. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  29060. if len(m.appendaction_label_add) == 0 {
  29061. return nil, false
  29062. }
  29063. return m.appendaction_label_add, true
  29064. }
  29065. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  29066. func (m *SopNodeMutation) ClearActionLabelAdd() {
  29067. m.action_label_add = nil
  29068. m.appendaction_label_add = nil
  29069. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  29070. }
  29071. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  29072. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  29073. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  29074. return ok
  29075. }
  29076. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  29077. func (m *SopNodeMutation) ResetActionLabelAdd() {
  29078. m.action_label_add = nil
  29079. m.appendaction_label_add = nil
  29080. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  29081. }
  29082. // SetActionLabelDel sets the "action_label_del" field.
  29083. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  29084. m.action_label_del = &u
  29085. m.appendaction_label_del = nil
  29086. }
  29087. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  29088. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  29089. v := m.action_label_del
  29090. if v == nil {
  29091. return
  29092. }
  29093. return *v, true
  29094. }
  29095. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  29096. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29098. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  29099. if !m.op.Is(OpUpdateOne) {
  29100. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  29101. }
  29102. if m.id == nil || m.oldValue == nil {
  29103. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  29104. }
  29105. oldValue, err := m.oldValue(ctx)
  29106. if err != nil {
  29107. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  29108. }
  29109. return oldValue.ActionLabelDel, nil
  29110. }
  29111. // AppendActionLabelDel adds u to the "action_label_del" field.
  29112. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  29113. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  29114. }
  29115. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  29116. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  29117. if len(m.appendaction_label_del) == 0 {
  29118. return nil, false
  29119. }
  29120. return m.appendaction_label_del, true
  29121. }
  29122. // ClearActionLabelDel clears the value of the "action_label_del" field.
  29123. func (m *SopNodeMutation) ClearActionLabelDel() {
  29124. m.action_label_del = nil
  29125. m.appendaction_label_del = nil
  29126. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  29127. }
  29128. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  29129. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  29130. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  29131. return ok
  29132. }
  29133. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  29134. func (m *SopNodeMutation) ResetActionLabelDel() {
  29135. m.action_label_del = nil
  29136. m.appendaction_label_del = nil
  29137. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  29138. }
  29139. // SetActionForward sets the "action_forward" field.
  29140. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  29141. m.action_forward = &ctf
  29142. }
  29143. // ActionForward returns the value of the "action_forward" field in the mutation.
  29144. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  29145. v := m.action_forward
  29146. if v == nil {
  29147. return
  29148. }
  29149. return *v, true
  29150. }
  29151. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  29152. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29154. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  29155. if !m.op.Is(OpUpdateOne) {
  29156. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  29157. }
  29158. if m.id == nil || m.oldValue == nil {
  29159. return v, errors.New("OldActionForward requires an ID field in the mutation")
  29160. }
  29161. oldValue, err := m.oldValue(ctx)
  29162. if err != nil {
  29163. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  29164. }
  29165. return oldValue.ActionForward, nil
  29166. }
  29167. // ClearActionForward clears the value of the "action_forward" field.
  29168. func (m *SopNodeMutation) ClearActionForward() {
  29169. m.action_forward = nil
  29170. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  29171. }
  29172. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  29173. func (m *SopNodeMutation) ActionForwardCleared() bool {
  29174. _, ok := m.clearedFields[sopnode.FieldActionForward]
  29175. return ok
  29176. }
  29177. // ResetActionForward resets all changes to the "action_forward" field.
  29178. func (m *SopNodeMutation) ResetActionForward() {
  29179. m.action_forward = nil
  29180. delete(m.clearedFields, sopnode.FieldActionForward)
  29181. }
  29182. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  29183. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  29184. m.sop_stage = &id
  29185. }
  29186. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  29187. func (m *SopNodeMutation) ClearSopStage() {
  29188. m.clearedsop_stage = true
  29189. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  29190. }
  29191. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  29192. func (m *SopNodeMutation) SopStageCleared() bool {
  29193. return m.clearedsop_stage
  29194. }
  29195. // SopStageID returns the "sop_stage" edge ID in the mutation.
  29196. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  29197. if m.sop_stage != nil {
  29198. return *m.sop_stage, true
  29199. }
  29200. return
  29201. }
  29202. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  29203. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29204. // SopStageID instead. It exists only for internal usage by the builders.
  29205. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  29206. if id := m.sop_stage; id != nil {
  29207. ids = append(ids, *id)
  29208. }
  29209. return
  29210. }
  29211. // ResetSopStage resets all changes to the "sop_stage" edge.
  29212. func (m *SopNodeMutation) ResetSopStage() {
  29213. m.sop_stage = nil
  29214. m.clearedsop_stage = false
  29215. }
  29216. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  29217. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  29218. if m.node_messages == nil {
  29219. m.node_messages = make(map[uint64]struct{})
  29220. }
  29221. for i := range ids {
  29222. m.node_messages[ids[i]] = struct{}{}
  29223. }
  29224. }
  29225. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  29226. func (m *SopNodeMutation) ClearNodeMessages() {
  29227. m.clearednode_messages = true
  29228. }
  29229. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  29230. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  29231. return m.clearednode_messages
  29232. }
  29233. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  29234. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  29235. if m.removednode_messages == nil {
  29236. m.removednode_messages = make(map[uint64]struct{})
  29237. }
  29238. for i := range ids {
  29239. delete(m.node_messages, ids[i])
  29240. m.removednode_messages[ids[i]] = struct{}{}
  29241. }
  29242. }
  29243. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  29244. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  29245. for id := range m.removednode_messages {
  29246. ids = append(ids, id)
  29247. }
  29248. return
  29249. }
  29250. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  29251. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  29252. for id := range m.node_messages {
  29253. ids = append(ids, id)
  29254. }
  29255. return
  29256. }
  29257. // ResetNodeMessages resets all changes to the "node_messages" edge.
  29258. func (m *SopNodeMutation) ResetNodeMessages() {
  29259. m.node_messages = nil
  29260. m.clearednode_messages = false
  29261. m.removednode_messages = nil
  29262. }
  29263. // Where appends a list predicates to the SopNodeMutation builder.
  29264. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  29265. m.predicates = append(m.predicates, ps...)
  29266. }
  29267. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  29268. // users can use type-assertion to append predicates that do not depend on any generated package.
  29269. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  29270. p := make([]predicate.SopNode, len(ps))
  29271. for i := range ps {
  29272. p[i] = ps[i]
  29273. }
  29274. m.Where(p...)
  29275. }
  29276. // Op returns the operation name.
  29277. func (m *SopNodeMutation) Op() Op {
  29278. return m.op
  29279. }
  29280. // SetOp allows setting the mutation operation.
  29281. func (m *SopNodeMutation) SetOp(op Op) {
  29282. m.op = op
  29283. }
  29284. // Type returns the node type of this mutation (SopNode).
  29285. func (m *SopNodeMutation) Type() string {
  29286. return m.typ
  29287. }
  29288. // Fields returns all fields that were changed during this mutation. Note that in
  29289. // order to get all numeric fields that were incremented/decremented, call
  29290. // AddedFields().
  29291. func (m *SopNodeMutation) Fields() []string {
  29292. fields := make([]string, 0, 15)
  29293. if m.created_at != nil {
  29294. fields = append(fields, sopnode.FieldCreatedAt)
  29295. }
  29296. if m.updated_at != nil {
  29297. fields = append(fields, sopnode.FieldUpdatedAt)
  29298. }
  29299. if m.status != nil {
  29300. fields = append(fields, sopnode.FieldStatus)
  29301. }
  29302. if m.deleted_at != nil {
  29303. fields = append(fields, sopnode.FieldDeletedAt)
  29304. }
  29305. if m.sop_stage != nil {
  29306. fields = append(fields, sopnode.FieldStageID)
  29307. }
  29308. if m.parent_id != nil {
  29309. fields = append(fields, sopnode.FieldParentID)
  29310. }
  29311. if m.name != nil {
  29312. fields = append(fields, sopnode.FieldName)
  29313. }
  29314. if m.condition_type != nil {
  29315. fields = append(fields, sopnode.FieldConditionType)
  29316. }
  29317. if m.condition_list != nil {
  29318. fields = append(fields, sopnode.FieldConditionList)
  29319. }
  29320. if m.no_reply_condition != nil {
  29321. fields = append(fields, sopnode.FieldNoReplyCondition)
  29322. }
  29323. if m.no_reply_unit != nil {
  29324. fields = append(fields, sopnode.FieldNoReplyUnit)
  29325. }
  29326. if m.action_message != nil {
  29327. fields = append(fields, sopnode.FieldActionMessage)
  29328. }
  29329. if m.action_label_add != nil {
  29330. fields = append(fields, sopnode.FieldActionLabelAdd)
  29331. }
  29332. if m.action_label_del != nil {
  29333. fields = append(fields, sopnode.FieldActionLabelDel)
  29334. }
  29335. if m.action_forward != nil {
  29336. fields = append(fields, sopnode.FieldActionForward)
  29337. }
  29338. return fields
  29339. }
  29340. // Field returns the value of a field with the given name. The second boolean
  29341. // return value indicates that this field was not set, or was not defined in the
  29342. // schema.
  29343. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  29344. switch name {
  29345. case sopnode.FieldCreatedAt:
  29346. return m.CreatedAt()
  29347. case sopnode.FieldUpdatedAt:
  29348. return m.UpdatedAt()
  29349. case sopnode.FieldStatus:
  29350. return m.Status()
  29351. case sopnode.FieldDeletedAt:
  29352. return m.DeletedAt()
  29353. case sopnode.FieldStageID:
  29354. return m.StageID()
  29355. case sopnode.FieldParentID:
  29356. return m.ParentID()
  29357. case sopnode.FieldName:
  29358. return m.Name()
  29359. case sopnode.FieldConditionType:
  29360. return m.ConditionType()
  29361. case sopnode.FieldConditionList:
  29362. return m.ConditionList()
  29363. case sopnode.FieldNoReplyCondition:
  29364. return m.NoReplyCondition()
  29365. case sopnode.FieldNoReplyUnit:
  29366. return m.NoReplyUnit()
  29367. case sopnode.FieldActionMessage:
  29368. return m.ActionMessage()
  29369. case sopnode.FieldActionLabelAdd:
  29370. return m.ActionLabelAdd()
  29371. case sopnode.FieldActionLabelDel:
  29372. return m.ActionLabelDel()
  29373. case sopnode.FieldActionForward:
  29374. return m.ActionForward()
  29375. }
  29376. return nil, false
  29377. }
  29378. // OldField returns the old value of the field from the database. An error is
  29379. // returned if the mutation operation is not UpdateOne, or the query to the
  29380. // database failed.
  29381. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29382. switch name {
  29383. case sopnode.FieldCreatedAt:
  29384. return m.OldCreatedAt(ctx)
  29385. case sopnode.FieldUpdatedAt:
  29386. return m.OldUpdatedAt(ctx)
  29387. case sopnode.FieldStatus:
  29388. return m.OldStatus(ctx)
  29389. case sopnode.FieldDeletedAt:
  29390. return m.OldDeletedAt(ctx)
  29391. case sopnode.FieldStageID:
  29392. return m.OldStageID(ctx)
  29393. case sopnode.FieldParentID:
  29394. return m.OldParentID(ctx)
  29395. case sopnode.FieldName:
  29396. return m.OldName(ctx)
  29397. case sopnode.FieldConditionType:
  29398. return m.OldConditionType(ctx)
  29399. case sopnode.FieldConditionList:
  29400. return m.OldConditionList(ctx)
  29401. case sopnode.FieldNoReplyCondition:
  29402. return m.OldNoReplyCondition(ctx)
  29403. case sopnode.FieldNoReplyUnit:
  29404. return m.OldNoReplyUnit(ctx)
  29405. case sopnode.FieldActionMessage:
  29406. return m.OldActionMessage(ctx)
  29407. case sopnode.FieldActionLabelAdd:
  29408. return m.OldActionLabelAdd(ctx)
  29409. case sopnode.FieldActionLabelDel:
  29410. return m.OldActionLabelDel(ctx)
  29411. case sopnode.FieldActionForward:
  29412. return m.OldActionForward(ctx)
  29413. }
  29414. return nil, fmt.Errorf("unknown SopNode field %s", name)
  29415. }
  29416. // SetField sets the value of a field with the given name. It returns an error if
  29417. // the field is not defined in the schema, or if the type mismatched the field
  29418. // type.
  29419. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  29420. switch name {
  29421. case sopnode.FieldCreatedAt:
  29422. v, ok := value.(time.Time)
  29423. if !ok {
  29424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29425. }
  29426. m.SetCreatedAt(v)
  29427. return nil
  29428. case sopnode.FieldUpdatedAt:
  29429. v, ok := value.(time.Time)
  29430. if !ok {
  29431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29432. }
  29433. m.SetUpdatedAt(v)
  29434. return nil
  29435. case sopnode.FieldStatus:
  29436. v, ok := value.(uint8)
  29437. if !ok {
  29438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29439. }
  29440. m.SetStatus(v)
  29441. return nil
  29442. case sopnode.FieldDeletedAt:
  29443. v, ok := value.(time.Time)
  29444. if !ok {
  29445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29446. }
  29447. m.SetDeletedAt(v)
  29448. return nil
  29449. case sopnode.FieldStageID:
  29450. v, ok := value.(uint64)
  29451. if !ok {
  29452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29453. }
  29454. m.SetStageID(v)
  29455. return nil
  29456. case sopnode.FieldParentID:
  29457. v, ok := value.(uint64)
  29458. if !ok {
  29459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29460. }
  29461. m.SetParentID(v)
  29462. return nil
  29463. case sopnode.FieldName:
  29464. v, ok := value.(string)
  29465. if !ok {
  29466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29467. }
  29468. m.SetName(v)
  29469. return nil
  29470. case sopnode.FieldConditionType:
  29471. v, ok := value.(int)
  29472. if !ok {
  29473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29474. }
  29475. m.SetConditionType(v)
  29476. return nil
  29477. case sopnode.FieldConditionList:
  29478. v, ok := value.([]string)
  29479. if !ok {
  29480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29481. }
  29482. m.SetConditionList(v)
  29483. return nil
  29484. case sopnode.FieldNoReplyCondition:
  29485. v, ok := value.(uint64)
  29486. if !ok {
  29487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29488. }
  29489. m.SetNoReplyCondition(v)
  29490. return nil
  29491. case sopnode.FieldNoReplyUnit:
  29492. v, ok := value.(string)
  29493. if !ok {
  29494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29495. }
  29496. m.SetNoReplyUnit(v)
  29497. return nil
  29498. case sopnode.FieldActionMessage:
  29499. v, ok := value.([]custom_types.Action)
  29500. if !ok {
  29501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29502. }
  29503. m.SetActionMessage(v)
  29504. return nil
  29505. case sopnode.FieldActionLabelAdd:
  29506. v, ok := value.([]uint64)
  29507. if !ok {
  29508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29509. }
  29510. m.SetActionLabelAdd(v)
  29511. return nil
  29512. case sopnode.FieldActionLabelDel:
  29513. v, ok := value.([]uint64)
  29514. if !ok {
  29515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29516. }
  29517. m.SetActionLabelDel(v)
  29518. return nil
  29519. case sopnode.FieldActionForward:
  29520. v, ok := value.(*custom_types.ActionForward)
  29521. if !ok {
  29522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29523. }
  29524. m.SetActionForward(v)
  29525. return nil
  29526. }
  29527. return fmt.Errorf("unknown SopNode field %s", name)
  29528. }
  29529. // AddedFields returns all numeric fields that were incremented/decremented during
  29530. // this mutation.
  29531. func (m *SopNodeMutation) AddedFields() []string {
  29532. var fields []string
  29533. if m.addstatus != nil {
  29534. fields = append(fields, sopnode.FieldStatus)
  29535. }
  29536. if m.addparent_id != nil {
  29537. fields = append(fields, sopnode.FieldParentID)
  29538. }
  29539. if m.addcondition_type != nil {
  29540. fields = append(fields, sopnode.FieldConditionType)
  29541. }
  29542. if m.addno_reply_condition != nil {
  29543. fields = append(fields, sopnode.FieldNoReplyCondition)
  29544. }
  29545. return fields
  29546. }
  29547. // AddedField returns the numeric value that was incremented/decremented on a field
  29548. // with the given name. The second boolean return value indicates that this field
  29549. // was not set, or was not defined in the schema.
  29550. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  29551. switch name {
  29552. case sopnode.FieldStatus:
  29553. return m.AddedStatus()
  29554. case sopnode.FieldParentID:
  29555. return m.AddedParentID()
  29556. case sopnode.FieldConditionType:
  29557. return m.AddedConditionType()
  29558. case sopnode.FieldNoReplyCondition:
  29559. return m.AddedNoReplyCondition()
  29560. }
  29561. return nil, false
  29562. }
  29563. // AddField adds the value to the field with the given name. It returns an error if
  29564. // the field is not defined in the schema, or if the type mismatched the field
  29565. // type.
  29566. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  29567. switch name {
  29568. case sopnode.FieldStatus:
  29569. v, ok := value.(int8)
  29570. if !ok {
  29571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29572. }
  29573. m.AddStatus(v)
  29574. return nil
  29575. case sopnode.FieldParentID:
  29576. v, ok := value.(int64)
  29577. if !ok {
  29578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29579. }
  29580. m.AddParentID(v)
  29581. return nil
  29582. case sopnode.FieldConditionType:
  29583. v, ok := value.(int)
  29584. if !ok {
  29585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29586. }
  29587. m.AddConditionType(v)
  29588. return nil
  29589. case sopnode.FieldNoReplyCondition:
  29590. v, ok := value.(int64)
  29591. if !ok {
  29592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29593. }
  29594. m.AddNoReplyCondition(v)
  29595. return nil
  29596. }
  29597. return fmt.Errorf("unknown SopNode numeric field %s", name)
  29598. }
  29599. // ClearedFields returns all nullable fields that were cleared during this
  29600. // mutation.
  29601. func (m *SopNodeMutation) ClearedFields() []string {
  29602. var fields []string
  29603. if m.FieldCleared(sopnode.FieldStatus) {
  29604. fields = append(fields, sopnode.FieldStatus)
  29605. }
  29606. if m.FieldCleared(sopnode.FieldDeletedAt) {
  29607. fields = append(fields, sopnode.FieldDeletedAt)
  29608. }
  29609. if m.FieldCleared(sopnode.FieldConditionList) {
  29610. fields = append(fields, sopnode.FieldConditionList)
  29611. }
  29612. if m.FieldCleared(sopnode.FieldActionMessage) {
  29613. fields = append(fields, sopnode.FieldActionMessage)
  29614. }
  29615. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  29616. fields = append(fields, sopnode.FieldActionLabelAdd)
  29617. }
  29618. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  29619. fields = append(fields, sopnode.FieldActionLabelDel)
  29620. }
  29621. if m.FieldCleared(sopnode.FieldActionForward) {
  29622. fields = append(fields, sopnode.FieldActionForward)
  29623. }
  29624. return fields
  29625. }
  29626. // FieldCleared returns a boolean indicating if a field with the given name was
  29627. // cleared in this mutation.
  29628. func (m *SopNodeMutation) FieldCleared(name string) bool {
  29629. _, ok := m.clearedFields[name]
  29630. return ok
  29631. }
  29632. // ClearField clears the value of the field with the given name. It returns an
  29633. // error if the field is not defined in the schema.
  29634. func (m *SopNodeMutation) ClearField(name string) error {
  29635. switch name {
  29636. case sopnode.FieldStatus:
  29637. m.ClearStatus()
  29638. return nil
  29639. case sopnode.FieldDeletedAt:
  29640. m.ClearDeletedAt()
  29641. return nil
  29642. case sopnode.FieldConditionList:
  29643. m.ClearConditionList()
  29644. return nil
  29645. case sopnode.FieldActionMessage:
  29646. m.ClearActionMessage()
  29647. return nil
  29648. case sopnode.FieldActionLabelAdd:
  29649. m.ClearActionLabelAdd()
  29650. return nil
  29651. case sopnode.FieldActionLabelDel:
  29652. m.ClearActionLabelDel()
  29653. return nil
  29654. case sopnode.FieldActionForward:
  29655. m.ClearActionForward()
  29656. return nil
  29657. }
  29658. return fmt.Errorf("unknown SopNode nullable field %s", name)
  29659. }
  29660. // ResetField resets all changes in the mutation for the field with the given name.
  29661. // It returns an error if the field is not defined in the schema.
  29662. func (m *SopNodeMutation) ResetField(name string) error {
  29663. switch name {
  29664. case sopnode.FieldCreatedAt:
  29665. m.ResetCreatedAt()
  29666. return nil
  29667. case sopnode.FieldUpdatedAt:
  29668. m.ResetUpdatedAt()
  29669. return nil
  29670. case sopnode.FieldStatus:
  29671. m.ResetStatus()
  29672. return nil
  29673. case sopnode.FieldDeletedAt:
  29674. m.ResetDeletedAt()
  29675. return nil
  29676. case sopnode.FieldStageID:
  29677. m.ResetStageID()
  29678. return nil
  29679. case sopnode.FieldParentID:
  29680. m.ResetParentID()
  29681. return nil
  29682. case sopnode.FieldName:
  29683. m.ResetName()
  29684. return nil
  29685. case sopnode.FieldConditionType:
  29686. m.ResetConditionType()
  29687. return nil
  29688. case sopnode.FieldConditionList:
  29689. m.ResetConditionList()
  29690. return nil
  29691. case sopnode.FieldNoReplyCondition:
  29692. m.ResetNoReplyCondition()
  29693. return nil
  29694. case sopnode.FieldNoReplyUnit:
  29695. m.ResetNoReplyUnit()
  29696. return nil
  29697. case sopnode.FieldActionMessage:
  29698. m.ResetActionMessage()
  29699. return nil
  29700. case sopnode.FieldActionLabelAdd:
  29701. m.ResetActionLabelAdd()
  29702. return nil
  29703. case sopnode.FieldActionLabelDel:
  29704. m.ResetActionLabelDel()
  29705. return nil
  29706. case sopnode.FieldActionForward:
  29707. m.ResetActionForward()
  29708. return nil
  29709. }
  29710. return fmt.Errorf("unknown SopNode field %s", name)
  29711. }
  29712. // AddedEdges returns all edge names that were set/added in this mutation.
  29713. func (m *SopNodeMutation) AddedEdges() []string {
  29714. edges := make([]string, 0, 2)
  29715. if m.sop_stage != nil {
  29716. edges = append(edges, sopnode.EdgeSopStage)
  29717. }
  29718. if m.node_messages != nil {
  29719. edges = append(edges, sopnode.EdgeNodeMessages)
  29720. }
  29721. return edges
  29722. }
  29723. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29724. // name in this mutation.
  29725. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  29726. switch name {
  29727. case sopnode.EdgeSopStage:
  29728. if id := m.sop_stage; id != nil {
  29729. return []ent.Value{*id}
  29730. }
  29731. case sopnode.EdgeNodeMessages:
  29732. ids := make([]ent.Value, 0, len(m.node_messages))
  29733. for id := range m.node_messages {
  29734. ids = append(ids, id)
  29735. }
  29736. return ids
  29737. }
  29738. return nil
  29739. }
  29740. // RemovedEdges returns all edge names that were removed in this mutation.
  29741. func (m *SopNodeMutation) RemovedEdges() []string {
  29742. edges := make([]string, 0, 2)
  29743. if m.removednode_messages != nil {
  29744. edges = append(edges, sopnode.EdgeNodeMessages)
  29745. }
  29746. return edges
  29747. }
  29748. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29749. // the given name in this mutation.
  29750. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  29751. switch name {
  29752. case sopnode.EdgeNodeMessages:
  29753. ids := make([]ent.Value, 0, len(m.removednode_messages))
  29754. for id := range m.removednode_messages {
  29755. ids = append(ids, id)
  29756. }
  29757. return ids
  29758. }
  29759. return nil
  29760. }
  29761. // ClearedEdges returns all edge names that were cleared in this mutation.
  29762. func (m *SopNodeMutation) ClearedEdges() []string {
  29763. edges := make([]string, 0, 2)
  29764. if m.clearedsop_stage {
  29765. edges = append(edges, sopnode.EdgeSopStage)
  29766. }
  29767. if m.clearednode_messages {
  29768. edges = append(edges, sopnode.EdgeNodeMessages)
  29769. }
  29770. return edges
  29771. }
  29772. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29773. // was cleared in this mutation.
  29774. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  29775. switch name {
  29776. case sopnode.EdgeSopStage:
  29777. return m.clearedsop_stage
  29778. case sopnode.EdgeNodeMessages:
  29779. return m.clearednode_messages
  29780. }
  29781. return false
  29782. }
  29783. // ClearEdge clears the value of the edge with the given name. It returns an error
  29784. // if that edge is not defined in the schema.
  29785. func (m *SopNodeMutation) ClearEdge(name string) error {
  29786. switch name {
  29787. case sopnode.EdgeSopStage:
  29788. m.ClearSopStage()
  29789. return nil
  29790. }
  29791. return fmt.Errorf("unknown SopNode unique edge %s", name)
  29792. }
  29793. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29794. // It returns an error if the edge is not defined in the schema.
  29795. func (m *SopNodeMutation) ResetEdge(name string) error {
  29796. switch name {
  29797. case sopnode.EdgeSopStage:
  29798. m.ResetSopStage()
  29799. return nil
  29800. case sopnode.EdgeNodeMessages:
  29801. m.ResetNodeMessages()
  29802. return nil
  29803. }
  29804. return fmt.Errorf("unknown SopNode edge %s", name)
  29805. }
  29806. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  29807. type SopStageMutation struct {
  29808. config
  29809. op Op
  29810. typ string
  29811. id *uint64
  29812. created_at *time.Time
  29813. updated_at *time.Time
  29814. status *uint8
  29815. addstatus *int8
  29816. deleted_at *time.Time
  29817. name *string
  29818. condition_type *int
  29819. addcondition_type *int
  29820. condition_operator *int
  29821. addcondition_operator *int
  29822. condition_list *[]custom_types.Condition
  29823. appendcondition_list []custom_types.Condition
  29824. action_message *[]custom_types.Action
  29825. appendaction_message []custom_types.Action
  29826. action_label_add *[]uint64
  29827. appendaction_label_add []uint64
  29828. action_label_del *[]uint64
  29829. appendaction_label_del []uint64
  29830. action_forward **custom_types.ActionForward
  29831. index_sort *int
  29832. addindex_sort *int
  29833. clearedFields map[string]struct{}
  29834. sop_task *uint64
  29835. clearedsop_task bool
  29836. stage_nodes map[uint64]struct{}
  29837. removedstage_nodes map[uint64]struct{}
  29838. clearedstage_nodes bool
  29839. stage_messages map[uint64]struct{}
  29840. removedstage_messages map[uint64]struct{}
  29841. clearedstage_messages bool
  29842. done bool
  29843. oldValue func(context.Context) (*SopStage, error)
  29844. predicates []predicate.SopStage
  29845. }
  29846. var _ ent.Mutation = (*SopStageMutation)(nil)
  29847. // sopstageOption allows management of the mutation configuration using functional options.
  29848. type sopstageOption func(*SopStageMutation)
  29849. // newSopStageMutation creates new mutation for the SopStage entity.
  29850. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  29851. m := &SopStageMutation{
  29852. config: c,
  29853. op: op,
  29854. typ: TypeSopStage,
  29855. clearedFields: make(map[string]struct{}),
  29856. }
  29857. for _, opt := range opts {
  29858. opt(m)
  29859. }
  29860. return m
  29861. }
  29862. // withSopStageID sets the ID field of the mutation.
  29863. func withSopStageID(id uint64) sopstageOption {
  29864. return func(m *SopStageMutation) {
  29865. var (
  29866. err error
  29867. once sync.Once
  29868. value *SopStage
  29869. )
  29870. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  29871. once.Do(func() {
  29872. if m.done {
  29873. err = errors.New("querying old values post mutation is not allowed")
  29874. } else {
  29875. value, err = m.Client().SopStage.Get(ctx, id)
  29876. }
  29877. })
  29878. return value, err
  29879. }
  29880. m.id = &id
  29881. }
  29882. }
  29883. // withSopStage sets the old SopStage of the mutation.
  29884. func withSopStage(node *SopStage) sopstageOption {
  29885. return func(m *SopStageMutation) {
  29886. m.oldValue = func(context.Context) (*SopStage, error) {
  29887. return node, nil
  29888. }
  29889. m.id = &node.ID
  29890. }
  29891. }
  29892. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29893. // executed in a transaction (ent.Tx), a transactional client is returned.
  29894. func (m SopStageMutation) Client() *Client {
  29895. client := &Client{config: m.config}
  29896. client.init()
  29897. return client
  29898. }
  29899. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29900. // it returns an error otherwise.
  29901. func (m SopStageMutation) Tx() (*Tx, error) {
  29902. if _, ok := m.driver.(*txDriver); !ok {
  29903. return nil, errors.New("ent: mutation is not running in a transaction")
  29904. }
  29905. tx := &Tx{config: m.config}
  29906. tx.init()
  29907. return tx, nil
  29908. }
  29909. // SetID sets the value of the id field. Note that this
  29910. // operation is only accepted on creation of SopStage entities.
  29911. func (m *SopStageMutation) SetID(id uint64) {
  29912. m.id = &id
  29913. }
  29914. // ID returns the ID value in the mutation. Note that the ID is only available
  29915. // if it was provided to the builder or after it was returned from the database.
  29916. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  29917. if m.id == nil {
  29918. return
  29919. }
  29920. return *m.id, true
  29921. }
  29922. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29923. // That means, if the mutation is applied within a transaction with an isolation level such
  29924. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29925. // or updated by the mutation.
  29926. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  29927. switch {
  29928. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29929. id, exists := m.ID()
  29930. if exists {
  29931. return []uint64{id}, nil
  29932. }
  29933. fallthrough
  29934. case m.op.Is(OpUpdate | OpDelete):
  29935. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  29936. default:
  29937. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29938. }
  29939. }
  29940. // SetCreatedAt sets the "created_at" field.
  29941. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  29942. m.created_at = &t
  29943. }
  29944. // CreatedAt returns the value of the "created_at" field in the mutation.
  29945. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  29946. v := m.created_at
  29947. if v == nil {
  29948. return
  29949. }
  29950. return *v, true
  29951. }
  29952. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  29953. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29955. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29956. if !m.op.Is(OpUpdateOne) {
  29957. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29958. }
  29959. if m.id == nil || m.oldValue == nil {
  29960. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29961. }
  29962. oldValue, err := m.oldValue(ctx)
  29963. if err != nil {
  29964. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29965. }
  29966. return oldValue.CreatedAt, nil
  29967. }
  29968. // ResetCreatedAt resets all changes to the "created_at" field.
  29969. func (m *SopStageMutation) ResetCreatedAt() {
  29970. m.created_at = nil
  29971. }
  29972. // SetUpdatedAt sets the "updated_at" field.
  29973. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  29974. m.updated_at = &t
  29975. }
  29976. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29977. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  29978. v := m.updated_at
  29979. if v == nil {
  29980. return
  29981. }
  29982. return *v, true
  29983. }
  29984. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  29985. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29987. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29988. if !m.op.Is(OpUpdateOne) {
  29989. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29990. }
  29991. if m.id == nil || m.oldValue == nil {
  29992. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29993. }
  29994. oldValue, err := m.oldValue(ctx)
  29995. if err != nil {
  29996. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29997. }
  29998. return oldValue.UpdatedAt, nil
  29999. }
  30000. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30001. func (m *SopStageMutation) ResetUpdatedAt() {
  30002. m.updated_at = nil
  30003. }
  30004. // SetStatus sets the "status" field.
  30005. func (m *SopStageMutation) SetStatus(u uint8) {
  30006. m.status = &u
  30007. m.addstatus = nil
  30008. }
  30009. // Status returns the value of the "status" field in the mutation.
  30010. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  30011. v := m.status
  30012. if v == nil {
  30013. return
  30014. }
  30015. return *v, true
  30016. }
  30017. // OldStatus returns the old "status" field's value of the SopStage entity.
  30018. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30020. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30021. if !m.op.Is(OpUpdateOne) {
  30022. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30023. }
  30024. if m.id == nil || m.oldValue == nil {
  30025. return v, errors.New("OldStatus requires an ID field in the mutation")
  30026. }
  30027. oldValue, err := m.oldValue(ctx)
  30028. if err != nil {
  30029. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30030. }
  30031. return oldValue.Status, nil
  30032. }
  30033. // AddStatus adds u to the "status" field.
  30034. func (m *SopStageMutation) AddStatus(u int8) {
  30035. if m.addstatus != nil {
  30036. *m.addstatus += u
  30037. } else {
  30038. m.addstatus = &u
  30039. }
  30040. }
  30041. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30042. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  30043. v := m.addstatus
  30044. if v == nil {
  30045. return
  30046. }
  30047. return *v, true
  30048. }
  30049. // ClearStatus clears the value of the "status" field.
  30050. func (m *SopStageMutation) ClearStatus() {
  30051. m.status = nil
  30052. m.addstatus = nil
  30053. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  30054. }
  30055. // StatusCleared returns if the "status" field was cleared in this mutation.
  30056. func (m *SopStageMutation) StatusCleared() bool {
  30057. _, ok := m.clearedFields[sopstage.FieldStatus]
  30058. return ok
  30059. }
  30060. // ResetStatus resets all changes to the "status" field.
  30061. func (m *SopStageMutation) ResetStatus() {
  30062. m.status = nil
  30063. m.addstatus = nil
  30064. delete(m.clearedFields, sopstage.FieldStatus)
  30065. }
  30066. // SetDeletedAt sets the "deleted_at" field.
  30067. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  30068. m.deleted_at = &t
  30069. }
  30070. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30071. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  30072. v := m.deleted_at
  30073. if v == nil {
  30074. return
  30075. }
  30076. return *v, true
  30077. }
  30078. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  30079. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30081. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30082. if !m.op.Is(OpUpdateOne) {
  30083. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30084. }
  30085. if m.id == nil || m.oldValue == nil {
  30086. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30087. }
  30088. oldValue, err := m.oldValue(ctx)
  30089. if err != nil {
  30090. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30091. }
  30092. return oldValue.DeletedAt, nil
  30093. }
  30094. // ClearDeletedAt clears the value of the "deleted_at" field.
  30095. func (m *SopStageMutation) ClearDeletedAt() {
  30096. m.deleted_at = nil
  30097. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  30098. }
  30099. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30100. func (m *SopStageMutation) DeletedAtCleared() bool {
  30101. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  30102. return ok
  30103. }
  30104. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30105. func (m *SopStageMutation) ResetDeletedAt() {
  30106. m.deleted_at = nil
  30107. delete(m.clearedFields, sopstage.FieldDeletedAt)
  30108. }
  30109. // SetTaskID sets the "task_id" field.
  30110. func (m *SopStageMutation) SetTaskID(u uint64) {
  30111. m.sop_task = &u
  30112. }
  30113. // TaskID returns the value of the "task_id" field in the mutation.
  30114. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  30115. v := m.sop_task
  30116. if v == nil {
  30117. return
  30118. }
  30119. return *v, true
  30120. }
  30121. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  30122. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30124. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  30125. if !m.op.Is(OpUpdateOne) {
  30126. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  30127. }
  30128. if m.id == nil || m.oldValue == nil {
  30129. return v, errors.New("OldTaskID requires an ID field in the mutation")
  30130. }
  30131. oldValue, err := m.oldValue(ctx)
  30132. if err != nil {
  30133. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  30134. }
  30135. return oldValue.TaskID, nil
  30136. }
  30137. // ResetTaskID resets all changes to the "task_id" field.
  30138. func (m *SopStageMutation) ResetTaskID() {
  30139. m.sop_task = nil
  30140. }
  30141. // SetName sets the "name" field.
  30142. func (m *SopStageMutation) SetName(s string) {
  30143. m.name = &s
  30144. }
  30145. // Name returns the value of the "name" field in the mutation.
  30146. func (m *SopStageMutation) Name() (r string, exists bool) {
  30147. v := m.name
  30148. if v == nil {
  30149. return
  30150. }
  30151. return *v, true
  30152. }
  30153. // OldName returns the old "name" field's value of the SopStage entity.
  30154. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30156. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  30157. if !m.op.Is(OpUpdateOne) {
  30158. return v, errors.New("OldName is only allowed on UpdateOne operations")
  30159. }
  30160. if m.id == nil || m.oldValue == nil {
  30161. return v, errors.New("OldName requires an ID field in the mutation")
  30162. }
  30163. oldValue, err := m.oldValue(ctx)
  30164. if err != nil {
  30165. return v, fmt.Errorf("querying old value for OldName: %w", err)
  30166. }
  30167. return oldValue.Name, nil
  30168. }
  30169. // ResetName resets all changes to the "name" field.
  30170. func (m *SopStageMutation) ResetName() {
  30171. m.name = nil
  30172. }
  30173. // SetConditionType sets the "condition_type" field.
  30174. func (m *SopStageMutation) SetConditionType(i int) {
  30175. m.condition_type = &i
  30176. m.addcondition_type = nil
  30177. }
  30178. // ConditionType returns the value of the "condition_type" field in the mutation.
  30179. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  30180. v := m.condition_type
  30181. if v == nil {
  30182. return
  30183. }
  30184. return *v, true
  30185. }
  30186. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  30187. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30189. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  30190. if !m.op.Is(OpUpdateOne) {
  30191. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  30192. }
  30193. if m.id == nil || m.oldValue == nil {
  30194. return v, errors.New("OldConditionType requires an ID field in the mutation")
  30195. }
  30196. oldValue, err := m.oldValue(ctx)
  30197. if err != nil {
  30198. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  30199. }
  30200. return oldValue.ConditionType, nil
  30201. }
  30202. // AddConditionType adds i to the "condition_type" field.
  30203. func (m *SopStageMutation) AddConditionType(i int) {
  30204. if m.addcondition_type != nil {
  30205. *m.addcondition_type += i
  30206. } else {
  30207. m.addcondition_type = &i
  30208. }
  30209. }
  30210. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  30211. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  30212. v := m.addcondition_type
  30213. if v == nil {
  30214. return
  30215. }
  30216. return *v, true
  30217. }
  30218. // ResetConditionType resets all changes to the "condition_type" field.
  30219. func (m *SopStageMutation) ResetConditionType() {
  30220. m.condition_type = nil
  30221. m.addcondition_type = nil
  30222. }
  30223. // SetConditionOperator sets the "condition_operator" field.
  30224. func (m *SopStageMutation) SetConditionOperator(i int) {
  30225. m.condition_operator = &i
  30226. m.addcondition_operator = nil
  30227. }
  30228. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  30229. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  30230. v := m.condition_operator
  30231. if v == nil {
  30232. return
  30233. }
  30234. return *v, true
  30235. }
  30236. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  30237. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30239. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  30240. if !m.op.Is(OpUpdateOne) {
  30241. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  30242. }
  30243. if m.id == nil || m.oldValue == nil {
  30244. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  30245. }
  30246. oldValue, err := m.oldValue(ctx)
  30247. if err != nil {
  30248. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  30249. }
  30250. return oldValue.ConditionOperator, nil
  30251. }
  30252. // AddConditionOperator adds i to the "condition_operator" field.
  30253. func (m *SopStageMutation) AddConditionOperator(i int) {
  30254. if m.addcondition_operator != nil {
  30255. *m.addcondition_operator += i
  30256. } else {
  30257. m.addcondition_operator = &i
  30258. }
  30259. }
  30260. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  30261. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  30262. v := m.addcondition_operator
  30263. if v == nil {
  30264. return
  30265. }
  30266. return *v, true
  30267. }
  30268. // ResetConditionOperator resets all changes to the "condition_operator" field.
  30269. func (m *SopStageMutation) ResetConditionOperator() {
  30270. m.condition_operator = nil
  30271. m.addcondition_operator = nil
  30272. }
  30273. // SetConditionList sets the "condition_list" field.
  30274. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  30275. m.condition_list = &ct
  30276. m.appendcondition_list = nil
  30277. }
  30278. // ConditionList returns the value of the "condition_list" field in the mutation.
  30279. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  30280. v := m.condition_list
  30281. if v == nil {
  30282. return
  30283. }
  30284. return *v, true
  30285. }
  30286. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  30287. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30289. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  30290. if !m.op.Is(OpUpdateOne) {
  30291. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  30292. }
  30293. if m.id == nil || m.oldValue == nil {
  30294. return v, errors.New("OldConditionList requires an ID field in the mutation")
  30295. }
  30296. oldValue, err := m.oldValue(ctx)
  30297. if err != nil {
  30298. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  30299. }
  30300. return oldValue.ConditionList, nil
  30301. }
  30302. // AppendConditionList adds ct to the "condition_list" field.
  30303. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  30304. m.appendcondition_list = append(m.appendcondition_list, ct...)
  30305. }
  30306. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  30307. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  30308. if len(m.appendcondition_list) == 0 {
  30309. return nil, false
  30310. }
  30311. return m.appendcondition_list, true
  30312. }
  30313. // ResetConditionList resets all changes to the "condition_list" field.
  30314. func (m *SopStageMutation) ResetConditionList() {
  30315. m.condition_list = nil
  30316. m.appendcondition_list = nil
  30317. }
  30318. // SetActionMessage sets the "action_message" field.
  30319. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  30320. m.action_message = &ct
  30321. m.appendaction_message = nil
  30322. }
  30323. // ActionMessage returns the value of the "action_message" field in the mutation.
  30324. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  30325. v := m.action_message
  30326. if v == nil {
  30327. return
  30328. }
  30329. return *v, true
  30330. }
  30331. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  30332. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30334. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  30335. if !m.op.Is(OpUpdateOne) {
  30336. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  30337. }
  30338. if m.id == nil || m.oldValue == nil {
  30339. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  30340. }
  30341. oldValue, err := m.oldValue(ctx)
  30342. if err != nil {
  30343. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  30344. }
  30345. return oldValue.ActionMessage, nil
  30346. }
  30347. // AppendActionMessage adds ct to the "action_message" field.
  30348. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  30349. m.appendaction_message = append(m.appendaction_message, ct...)
  30350. }
  30351. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  30352. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  30353. if len(m.appendaction_message) == 0 {
  30354. return nil, false
  30355. }
  30356. return m.appendaction_message, true
  30357. }
  30358. // ClearActionMessage clears the value of the "action_message" field.
  30359. func (m *SopStageMutation) ClearActionMessage() {
  30360. m.action_message = nil
  30361. m.appendaction_message = nil
  30362. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  30363. }
  30364. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  30365. func (m *SopStageMutation) ActionMessageCleared() bool {
  30366. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  30367. return ok
  30368. }
  30369. // ResetActionMessage resets all changes to the "action_message" field.
  30370. func (m *SopStageMutation) ResetActionMessage() {
  30371. m.action_message = nil
  30372. m.appendaction_message = nil
  30373. delete(m.clearedFields, sopstage.FieldActionMessage)
  30374. }
  30375. // SetActionLabelAdd sets the "action_label_add" field.
  30376. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  30377. m.action_label_add = &u
  30378. m.appendaction_label_add = nil
  30379. }
  30380. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  30381. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  30382. v := m.action_label_add
  30383. if v == nil {
  30384. return
  30385. }
  30386. return *v, true
  30387. }
  30388. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  30389. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30391. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  30392. if !m.op.Is(OpUpdateOne) {
  30393. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  30394. }
  30395. if m.id == nil || m.oldValue == nil {
  30396. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  30397. }
  30398. oldValue, err := m.oldValue(ctx)
  30399. if err != nil {
  30400. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  30401. }
  30402. return oldValue.ActionLabelAdd, nil
  30403. }
  30404. // AppendActionLabelAdd adds u to the "action_label_add" field.
  30405. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  30406. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  30407. }
  30408. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  30409. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  30410. if len(m.appendaction_label_add) == 0 {
  30411. return nil, false
  30412. }
  30413. return m.appendaction_label_add, true
  30414. }
  30415. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  30416. func (m *SopStageMutation) ClearActionLabelAdd() {
  30417. m.action_label_add = nil
  30418. m.appendaction_label_add = nil
  30419. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  30420. }
  30421. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  30422. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  30423. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  30424. return ok
  30425. }
  30426. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  30427. func (m *SopStageMutation) ResetActionLabelAdd() {
  30428. m.action_label_add = nil
  30429. m.appendaction_label_add = nil
  30430. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  30431. }
  30432. // SetActionLabelDel sets the "action_label_del" field.
  30433. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  30434. m.action_label_del = &u
  30435. m.appendaction_label_del = nil
  30436. }
  30437. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  30438. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  30439. v := m.action_label_del
  30440. if v == nil {
  30441. return
  30442. }
  30443. return *v, true
  30444. }
  30445. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  30446. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30448. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  30449. if !m.op.Is(OpUpdateOne) {
  30450. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  30451. }
  30452. if m.id == nil || m.oldValue == nil {
  30453. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  30454. }
  30455. oldValue, err := m.oldValue(ctx)
  30456. if err != nil {
  30457. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  30458. }
  30459. return oldValue.ActionLabelDel, nil
  30460. }
  30461. // AppendActionLabelDel adds u to the "action_label_del" field.
  30462. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  30463. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  30464. }
  30465. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  30466. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  30467. if len(m.appendaction_label_del) == 0 {
  30468. return nil, false
  30469. }
  30470. return m.appendaction_label_del, true
  30471. }
  30472. // ClearActionLabelDel clears the value of the "action_label_del" field.
  30473. func (m *SopStageMutation) ClearActionLabelDel() {
  30474. m.action_label_del = nil
  30475. m.appendaction_label_del = nil
  30476. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  30477. }
  30478. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  30479. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  30480. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  30481. return ok
  30482. }
  30483. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  30484. func (m *SopStageMutation) ResetActionLabelDel() {
  30485. m.action_label_del = nil
  30486. m.appendaction_label_del = nil
  30487. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  30488. }
  30489. // SetActionForward sets the "action_forward" field.
  30490. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  30491. m.action_forward = &ctf
  30492. }
  30493. // ActionForward returns the value of the "action_forward" field in the mutation.
  30494. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  30495. v := m.action_forward
  30496. if v == nil {
  30497. return
  30498. }
  30499. return *v, true
  30500. }
  30501. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  30502. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30504. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  30505. if !m.op.Is(OpUpdateOne) {
  30506. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  30507. }
  30508. if m.id == nil || m.oldValue == nil {
  30509. return v, errors.New("OldActionForward requires an ID field in the mutation")
  30510. }
  30511. oldValue, err := m.oldValue(ctx)
  30512. if err != nil {
  30513. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  30514. }
  30515. return oldValue.ActionForward, nil
  30516. }
  30517. // ClearActionForward clears the value of the "action_forward" field.
  30518. func (m *SopStageMutation) ClearActionForward() {
  30519. m.action_forward = nil
  30520. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  30521. }
  30522. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  30523. func (m *SopStageMutation) ActionForwardCleared() bool {
  30524. _, ok := m.clearedFields[sopstage.FieldActionForward]
  30525. return ok
  30526. }
  30527. // ResetActionForward resets all changes to the "action_forward" field.
  30528. func (m *SopStageMutation) ResetActionForward() {
  30529. m.action_forward = nil
  30530. delete(m.clearedFields, sopstage.FieldActionForward)
  30531. }
  30532. // SetIndexSort sets the "index_sort" field.
  30533. func (m *SopStageMutation) SetIndexSort(i int) {
  30534. m.index_sort = &i
  30535. m.addindex_sort = nil
  30536. }
  30537. // IndexSort returns the value of the "index_sort" field in the mutation.
  30538. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  30539. v := m.index_sort
  30540. if v == nil {
  30541. return
  30542. }
  30543. return *v, true
  30544. }
  30545. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  30546. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30548. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  30549. if !m.op.Is(OpUpdateOne) {
  30550. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  30551. }
  30552. if m.id == nil || m.oldValue == nil {
  30553. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  30554. }
  30555. oldValue, err := m.oldValue(ctx)
  30556. if err != nil {
  30557. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  30558. }
  30559. return oldValue.IndexSort, nil
  30560. }
  30561. // AddIndexSort adds i to the "index_sort" field.
  30562. func (m *SopStageMutation) AddIndexSort(i int) {
  30563. if m.addindex_sort != nil {
  30564. *m.addindex_sort += i
  30565. } else {
  30566. m.addindex_sort = &i
  30567. }
  30568. }
  30569. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  30570. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  30571. v := m.addindex_sort
  30572. if v == nil {
  30573. return
  30574. }
  30575. return *v, true
  30576. }
  30577. // ClearIndexSort clears the value of the "index_sort" field.
  30578. func (m *SopStageMutation) ClearIndexSort() {
  30579. m.index_sort = nil
  30580. m.addindex_sort = nil
  30581. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  30582. }
  30583. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  30584. func (m *SopStageMutation) IndexSortCleared() bool {
  30585. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  30586. return ok
  30587. }
  30588. // ResetIndexSort resets all changes to the "index_sort" field.
  30589. func (m *SopStageMutation) ResetIndexSort() {
  30590. m.index_sort = nil
  30591. m.addindex_sort = nil
  30592. delete(m.clearedFields, sopstage.FieldIndexSort)
  30593. }
  30594. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  30595. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  30596. m.sop_task = &id
  30597. }
  30598. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  30599. func (m *SopStageMutation) ClearSopTask() {
  30600. m.clearedsop_task = true
  30601. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  30602. }
  30603. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  30604. func (m *SopStageMutation) SopTaskCleared() bool {
  30605. return m.clearedsop_task
  30606. }
  30607. // SopTaskID returns the "sop_task" edge ID in the mutation.
  30608. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  30609. if m.sop_task != nil {
  30610. return *m.sop_task, true
  30611. }
  30612. return
  30613. }
  30614. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  30615. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30616. // SopTaskID instead. It exists only for internal usage by the builders.
  30617. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  30618. if id := m.sop_task; id != nil {
  30619. ids = append(ids, *id)
  30620. }
  30621. return
  30622. }
  30623. // ResetSopTask resets all changes to the "sop_task" edge.
  30624. func (m *SopStageMutation) ResetSopTask() {
  30625. m.sop_task = nil
  30626. m.clearedsop_task = false
  30627. }
  30628. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  30629. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  30630. if m.stage_nodes == nil {
  30631. m.stage_nodes = make(map[uint64]struct{})
  30632. }
  30633. for i := range ids {
  30634. m.stage_nodes[ids[i]] = struct{}{}
  30635. }
  30636. }
  30637. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  30638. func (m *SopStageMutation) ClearStageNodes() {
  30639. m.clearedstage_nodes = true
  30640. }
  30641. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  30642. func (m *SopStageMutation) StageNodesCleared() bool {
  30643. return m.clearedstage_nodes
  30644. }
  30645. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  30646. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  30647. if m.removedstage_nodes == nil {
  30648. m.removedstage_nodes = make(map[uint64]struct{})
  30649. }
  30650. for i := range ids {
  30651. delete(m.stage_nodes, ids[i])
  30652. m.removedstage_nodes[ids[i]] = struct{}{}
  30653. }
  30654. }
  30655. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  30656. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  30657. for id := range m.removedstage_nodes {
  30658. ids = append(ids, id)
  30659. }
  30660. return
  30661. }
  30662. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  30663. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  30664. for id := range m.stage_nodes {
  30665. ids = append(ids, id)
  30666. }
  30667. return
  30668. }
  30669. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  30670. func (m *SopStageMutation) ResetStageNodes() {
  30671. m.stage_nodes = nil
  30672. m.clearedstage_nodes = false
  30673. m.removedstage_nodes = nil
  30674. }
  30675. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  30676. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  30677. if m.stage_messages == nil {
  30678. m.stage_messages = make(map[uint64]struct{})
  30679. }
  30680. for i := range ids {
  30681. m.stage_messages[ids[i]] = struct{}{}
  30682. }
  30683. }
  30684. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  30685. func (m *SopStageMutation) ClearStageMessages() {
  30686. m.clearedstage_messages = true
  30687. }
  30688. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  30689. func (m *SopStageMutation) StageMessagesCleared() bool {
  30690. return m.clearedstage_messages
  30691. }
  30692. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  30693. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  30694. if m.removedstage_messages == nil {
  30695. m.removedstage_messages = make(map[uint64]struct{})
  30696. }
  30697. for i := range ids {
  30698. delete(m.stage_messages, ids[i])
  30699. m.removedstage_messages[ids[i]] = struct{}{}
  30700. }
  30701. }
  30702. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  30703. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  30704. for id := range m.removedstage_messages {
  30705. ids = append(ids, id)
  30706. }
  30707. return
  30708. }
  30709. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  30710. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  30711. for id := range m.stage_messages {
  30712. ids = append(ids, id)
  30713. }
  30714. return
  30715. }
  30716. // ResetStageMessages resets all changes to the "stage_messages" edge.
  30717. func (m *SopStageMutation) ResetStageMessages() {
  30718. m.stage_messages = nil
  30719. m.clearedstage_messages = false
  30720. m.removedstage_messages = nil
  30721. }
  30722. // Where appends a list predicates to the SopStageMutation builder.
  30723. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  30724. m.predicates = append(m.predicates, ps...)
  30725. }
  30726. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  30727. // users can use type-assertion to append predicates that do not depend on any generated package.
  30728. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  30729. p := make([]predicate.SopStage, len(ps))
  30730. for i := range ps {
  30731. p[i] = ps[i]
  30732. }
  30733. m.Where(p...)
  30734. }
  30735. // Op returns the operation name.
  30736. func (m *SopStageMutation) Op() Op {
  30737. return m.op
  30738. }
  30739. // SetOp allows setting the mutation operation.
  30740. func (m *SopStageMutation) SetOp(op Op) {
  30741. m.op = op
  30742. }
  30743. // Type returns the node type of this mutation (SopStage).
  30744. func (m *SopStageMutation) Type() string {
  30745. return m.typ
  30746. }
  30747. // Fields returns all fields that were changed during this mutation. Note that in
  30748. // order to get all numeric fields that were incremented/decremented, call
  30749. // AddedFields().
  30750. func (m *SopStageMutation) Fields() []string {
  30751. fields := make([]string, 0, 14)
  30752. if m.created_at != nil {
  30753. fields = append(fields, sopstage.FieldCreatedAt)
  30754. }
  30755. if m.updated_at != nil {
  30756. fields = append(fields, sopstage.FieldUpdatedAt)
  30757. }
  30758. if m.status != nil {
  30759. fields = append(fields, sopstage.FieldStatus)
  30760. }
  30761. if m.deleted_at != nil {
  30762. fields = append(fields, sopstage.FieldDeletedAt)
  30763. }
  30764. if m.sop_task != nil {
  30765. fields = append(fields, sopstage.FieldTaskID)
  30766. }
  30767. if m.name != nil {
  30768. fields = append(fields, sopstage.FieldName)
  30769. }
  30770. if m.condition_type != nil {
  30771. fields = append(fields, sopstage.FieldConditionType)
  30772. }
  30773. if m.condition_operator != nil {
  30774. fields = append(fields, sopstage.FieldConditionOperator)
  30775. }
  30776. if m.condition_list != nil {
  30777. fields = append(fields, sopstage.FieldConditionList)
  30778. }
  30779. if m.action_message != nil {
  30780. fields = append(fields, sopstage.FieldActionMessage)
  30781. }
  30782. if m.action_label_add != nil {
  30783. fields = append(fields, sopstage.FieldActionLabelAdd)
  30784. }
  30785. if m.action_label_del != nil {
  30786. fields = append(fields, sopstage.FieldActionLabelDel)
  30787. }
  30788. if m.action_forward != nil {
  30789. fields = append(fields, sopstage.FieldActionForward)
  30790. }
  30791. if m.index_sort != nil {
  30792. fields = append(fields, sopstage.FieldIndexSort)
  30793. }
  30794. return fields
  30795. }
  30796. // Field returns the value of a field with the given name. The second boolean
  30797. // return value indicates that this field was not set, or was not defined in the
  30798. // schema.
  30799. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  30800. switch name {
  30801. case sopstage.FieldCreatedAt:
  30802. return m.CreatedAt()
  30803. case sopstage.FieldUpdatedAt:
  30804. return m.UpdatedAt()
  30805. case sopstage.FieldStatus:
  30806. return m.Status()
  30807. case sopstage.FieldDeletedAt:
  30808. return m.DeletedAt()
  30809. case sopstage.FieldTaskID:
  30810. return m.TaskID()
  30811. case sopstage.FieldName:
  30812. return m.Name()
  30813. case sopstage.FieldConditionType:
  30814. return m.ConditionType()
  30815. case sopstage.FieldConditionOperator:
  30816. return m.ConditionOperator()
  30817. case sopstage.FieldConditionList:
  30818. return m.ConditionList()
  30819. case sopstage.FieldActionMessage:
  30820. return m.ActionMessage()
  30821. case sopstage.FieldActionLabelAdd:
  30822. return m.ActionLabelAdd()
  30823. case sopstage.FieldActionLabelDel:
  30824. return m.ActionLabelDel()
  30825. case sopstage.FieldActionForward:
  30826. return m.ActionForward()
  30827. case sopstage.FieldIndexSort:
  30828. return m.IndexSort()
  30829. }
  30830. return nil, false
  30831. }
  30832. // OldField returns the old value of the field from the database. An error is
  30833. // returned if the mutation operation is not UpdateOne, or the query to the
  30834. // database failed.
  30835. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30836. switch name {
  30837. case sopstage.FieldCreatedAt:
  30838. return m.OldCreatedAt(ctx)
  30839. case sopstage.FieldUpdatedAt:
  30840. return m.OldUpdatedAt(ctx)
  30841. case sopstage.FieldStatus:
  30842. return m.OldStatus(ctx)
  30843. case sopstage.FieldDeletedAt:
  30844. return m.OldDeletedAt(ctx)
  30845. case sopstage.FieldTaskID:
  30846. return m.OldTaskID(ctx)
  30847. case sopstage.FieldName:
  30848. return m.OldName(ctx)
  30849. case sopstage.FieldConditionType:
  30850. return m.OldConditionType(ctx)
  30851. case sopstage.FieldConditionOperator:
  30852. return m.OldConditionOperator(ctx)
  30853. case sopstage.FieldConditionList:
  30854. return m.OldConditionList(ctx)
  30855. case sopstage.FieldActionMessage:
  30856. return m.OldActionMessage(ctx)
  30857. case sopstage.FieldActionLabelAdd:
  30858. return m.OldActionLabelAdd(ctx)
  30859. case sopstage.FieldActionLabelDel:
  30860. return m.OldActionLabelDel(ctx)
  30861. case sopstage.FieldActionForward:
  30862. return m.OldActionForward(ctx)
  30863. case sopstage.FieldIndexSort:
  30864. return m.OldIndexSort(ctx)
  30865. }
  30866. return nil, fmt.Errorf("unknown SopStage field %s", name)
  30867. }
  30868. // SetField sets the value of a field with the given name. It returns an error if
  30869. // the field is not defined in the schema, or if the type mismatched the field
  30870. // type.
  30871. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  30872. switch name {
  30873. case sopstage.FieldCreatedAt:
  30874. v, ok := value.(time.Time)
  30875. if !ok {
  30876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30877. }
  30878. m.SetCreatedAt(v)
  30879. return nil
  30880. case sopstage.FieldUpdatedAt:
  30881. v, ok := value.(time.Time)
  30882. if !ok {
  30883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30884. }
  30885. m.SetUpdatedAt(v)
  30886. return nil
  30887. case sopstage.FieldStatus:
  30888. v, ok := value.(uint8)
  30889. if !ok {
  30890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30891. }
  30892. m.SetStatus(v)
  30893. return nil
  30894. case sopstage.FieldDeletedAt:
  30895. v, ok := value.(time.Time)
  30896. if !ok {
  30897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30898. }
  30899. m.SetDeletedAt(v)
  30900. return nil
  30901. case sopstage.FieldTaskID:
  30902. v, ok := value.(uint64)
  30903. if !ok {
  30904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30905. }
  30906. m.SetTaskID(v)
  30907. return nil
  30908. case sopstage.FieldName:
  30909. v, ok := value.(string)
  30910. if !ok {
  30911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30912. }
  30913. m.SetName(v)
  30914. return nil
  30915. case sopstage.FieldConditionType:
  30916. v, ok := value.(int)
  30917. if !ok {
  30918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30919. }
  30920. m.SetConditionType(v)
  30921. return nil
  30922. case sopstage.FieldConditionOperator:
  30923. v, ok := value.(int)
  30924. if !ok {
  30925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30926. }
  30927. m.SetConditionOperator(v)
  30928. return nil
  30929. case sopstage.FieldConditionList:
  30930. v, ok := value.([]custom_types.Condition)
  30931. if !ok {
  30932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30933. }
  30934. m.SetConditionList(v)
  30935. return nil
  30936. case sopstage.FieldActionMessage:
  30937. v, ok := value.([]custom_types.Action)
  30938. if !ok {
  30939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30940. }
  30941. m.SetActionMessage(v)
  30942. return nil
  30943. case sopstage.FieldActionLabelAdd:
  30944. v, ok := value.([]uint64)
  30945. if !ok {
  30946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30947. }
  30948. m.SetActionLabelAdd(v)
  30949. return nil
  30950. case sopstage.FieldActionLabelDel:
  30951. v, ok := value.([]uint64)
  30952. if !ok {
  30953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30954. }
  30955. m.SetActionLabelDel(v)
  30956. return nil
  30957. case sopstage.FieldActionForward:
  30958. v, ok := value.(*custom_types.ActionForward)
  30959. if !ok {
  30960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30961. }
  30962. m.SetActionForward(v)
  30963. return nil
  30964. case sopstage.FieldIndexSort:
  30965. v, ok := value.(int)
  30966. if !ok {
  30967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30968. }
  30969. m.SetIndexSort(v)
  30970. return nil
  30971. }
  30972. return fmt.Errorf("unknown SopStage field %s", name)
  30973. }
  30974. // AddedFields returns all numeric fields that were incremented/decremented during
  30975. // this mutation.
  30976. func (m *SopStageMutation) AddedFields() []string {
  30977. var fields []string
  30978. if m.addstatus != nil {
  30979. fields = append(fields, sopstage.FieldStatus)
  30980. }
  30981. if m.addcondition_type != nil {
  30982. fields = append(fields, sopstage.FieldConditionType)
  30983. }
  30984. if m.addcondition_operator != nil {
  30985. fields = append(fields, sopstage.FieldConditionOperator)
  30986. }
  30987. if m.addindex_sort != nil {
  30988. fields = append(fields, sopstage.FieldIndexSort)
  30989. }
  30990. return fields
  30991. }
  30992. // AddedField returns the numeric value that was incremented/decremented on a field
  30993. // with the given name. The second boolean return value indicates that this field
  30994. // was not set, or was not defined in the schema.
  30995. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  30996. switch name {
  30997. case sopstage.FieldStatus:
  30998. return m.AddedStatus()
  30999. case sopstage.FieldConditionType:
  31000. return m.AddedConditionType()
  31001. case sopstage.FieldConditionOperator:
  31002. return m.AddedConditionOperator()
  31003. case sopstage.FieldIndexSort:
  31004. return m.AddedIndexSort()
  31005. }
  31006. return nil, false
  31007. }
  31008. // AddField adds the value to the field with the given name. It returns an error if
  31009. // the field is not defined in the schema, or if the type mismatched the field
  31010. // type.
  31011. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  31012. switch name {
  31013. case sopstage.FieldStatus:
  31014. v, ok := value.(int8)
  31015. if !ok {
  31016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31017. }
  31018. m.AddStatus(v)
  31019. return nil
  31020. case sopstage.FieldConditionType:
  31021. v, ok := value.(int)
  31022. if !ok {
  31023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31024. }
  31025. m.AddConditionType(v)
  31026. return nil
  31027. case sopstage.FieldConditionOperator:
  31028. v, ok := value.(int)
  31029. if !ok {
  31030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31031. }
  31032. m.AddConditionOperator(v)
  31033. return nil
  31034. case sopstage.FieldIndexSort:
  31035. v, ok := value.(int)
  31036. if !ok {
  31037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31038. }
  31039. m.AddIndexSort(v)
  31040. return nil
  31041. }
  31042. return fmt.Errorf("unknown SopStage numeric field %s", name)
  31043. }
  31044. // ClearedFields returns all nullable fields that were cleared during this
  31045. // mutation.
  31046. func (m *SopStageMutation) ClearedFields() []string {
  31047. var fields []string
  31048. if m.FieldCleared(sopstage.FieldStatus) {
  31049. fields = append(fields, sopstage.FieldStatus)
  31050. }
  31051. if m.FieldCleared(sopstage.FieldDeletedAt) {
  31052. fields = append(fields, sopstage.FieldDeletedAt)
  31053. }
  31054. if m.FieldCleared(sopstage.FieldActionMessage) {
  31055. fields = append(fields, sopstage.FieldActionMessage)
  31056. }
  31057. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  31058. fields = append(fields, sopstage.FieldActionLabelAdd)
  31059. }
  31060. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  31061. fields = append(fields, sopstage.FieldActionLabelDel)
  31062. }
  31063. if m.FieldCleared(sopstage.FieldActionForward) {
  31064. fields = append(fields, sopstage.FieldActionForward)
  31065. }
  31066. if m.FieldCleared(sopstage.FieldIndexSort) {
  31067. fields = append(fields, sopstage.FieldIndexSort)
  31068. }
  31069. return fields
  31070. }
  31071. // FieldCleared returns a boolean indicating if a field with the given name was
  31072. // cleared in this mutation.
  31073. func (m *SopStageMutation) FieldCleared(name string) bool {
  31074. _, ok := m.clearedFields[name]
  31075. return ok
  31076. }
  31077. // ClearField clears the value of the field with the given name. It returns an
  31078. // error if the field is not defined in the schema.
  31079. func (m *SopStageMutation) ClearField(name string) error {
  31080. switch name {
  31081. case sopstage.FieldStatus:
  31082. m.ClearStatus()
  31083. return nil
  31084. case sopstage.FieldDeletedAt:
  31085. m.ClearDeletedAt()
  31086. return nil
  31087. case sopstage.FieldActionMessage:
  31088. m.ClearActionMessage()
  31089. return nil
  31090. case sopstage.FieldActionLabelAdd:
  31091. m.ClearActionLabelAdd()
  31092. return nil
  31093. case sopstage.FieldActionLabelDel:
  31094. m.ClearActionLabelDel()
  31095. return nil
  31096. case sopstage.FieldActionForward:
  31097. m.ClearActionForward()
  31098. return nil
  31099. case sopstage.FieldIndexSort:
  31100. m.ClearIndexSort()
  31101. return nil
  31102. }
  31103. return fmt.Errorf("unknown SopStage nullable field %s", name)
  31104. }
  31105. // ResetField resets all changes in the mutation for the field with the given name.
  31106. // It returns an error if the field is not defined in the schema.
  31107. func (m *SopStageMutation) ResetField(name string) error {
  31108. switch name {
  31109. case sopstage.FieldCreatedAt:
  31110. m.ResetCreatedAt()
  31111. return nil
  31112. case sopstage.FieldUpdatedAt:
  31113. m.ResetUpdatedAt()
  31114. return nil
  31115. case sopstage.FieldStatus:
  31116. m.ResetStatus()
  31117. return nil
  31118. case sopstage.FieldDeletedAt:
  31119. m.ResetDeletedAt()
  31120. return nil
  31121. case sopstage.FieldTaskID:
  31122. m.ResetTaskID()
  31123. return nil
  31124. case sopstage.FieldName:
  31125. m.ResetName()
  31126. return nil
  31127. case sopstage.FieldConditionType:
  31128. m.ResetConditionType()
  31129. return nil
  31130. case sopstage.FieldConditionOperator:
  31131. m.ResetConditionOperator()
  31132. return nil
  31133. case sopstage.FieldConditionList:
  31134. m.ResetConditionList()
  31135. return nil
  31136. case sopstage.FieldActionMessage:
  31137. m.ResetActionMessage()
  31138. return nil
  31139. case sopstage.FieldActionLabelAdd:
  31140. m.ResetActionLabelAdd()
  31141. return nil
  31142. case sopstage.FieldActionLabelDel:
  31143. m.ResetActionLabelDel()
  31144. return nil
  31145. case sopstage.FieldActionForward:
  31146. m.ResetActionForward()
  31147. return nil
  31148. case sopstage.FieldIndexSort:
  31149. m.ResetIndexSort()
  31150. return nil
  31151. }
  31152. return fmt.Errorf("unknown SopStage field %s", name)
  31153. }
  31154. // AddedEdges returns all edge names that were set/added in this mutation.
  31155. func (m *SopStageMutation) AddedEdges() []string {
  31156. edges := make([]string, 0, 3)
  31157. if m.sop_task != nil {
  31158. edges = append(edges, sopstage.EdgeSopTask)
  31159. }
  31160. if m.stage_nodes != nil {
  31161. edges = append(edges, sopstage.EdgeStageNodes)
  31162. }
  31163. if m.stage_messages != nil {
  31164. edges = append(edges, sopstage.EdgeStageMessages)
  31165. }
  31166. return edges
  31167. }
  31168. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31169. // name in this mutation.
  31170. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  31171. switch name {
  31172. case sopstage.EdgeSopTask:
  31173. if id := m.sop_task; id != nil {
  31174. return []ent.Value{*id}
  31175. }
  31176. case sopstage.EdgeStageNodes:
  31177. ids := make([]ent.Value, 0, len(m.stage_nodes))
  31178. for id := range m.stage_nodes {
  31179. ids = append(ids, id)
  31180. }
  31181. return ids
  31182. case sopstage.EdgeStageMessages:
  31183. ids := make([]ent.Value, 0, len(m.stage_messages))
  31184. for id := range m.stage_messages {
  31185. ids = append(ids, id)
  31186. }
  31187. return ids
  31188. }
  31189. return nil
  31190. }
  31191. // RemovedEdges returns all edge names that were removed in this mutation.
  31192. func (m *SopStageMutation) RemovedEdges() []string {
  31193. edges := make([]string, 0, 3)
  31194. if m.removedstage_nodes != nil {
  31195. edges = append(edges, sopstage.EdgeStageNodes)
  31196. }
  31197. if m.removedstage_messages != nil {
  31198. edges = append(edges, sopstage.EdgeStageMessages)
  31199. }
  31200. return edges
  31201. }
  31202. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31203. // the given name in this mutation.
  31204. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  31205. switch name {
  31206. case sopstage.EdgeStageNodes:
  31207. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  31208. for id := range m.removedstage_nodes {
  31209. ids = append(ids, id)
  31210. }
  31211. return ids
  31212. case sopstage.EdgeStageMessages:
  31213. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  31214. for id := range m.removedstage_messages {
  31215. ids = append(ids, id)
  31216. }
  31217. return ids
  31218. }
  31219. return nil
  31220. }
  31221. // ClearedEdges returns all edge names that were cleared in this mutation.
  31222. func (m *SopStageMutation) ClearedEdges() []string {
  31223. edges := make([]string, 0, 3)
  31224. if m.clearedsop_task {
  31225. edges = append(edges, sopstage.EdgeSopTask)
  31226. }
  31227. if m.clearedstage_nodes {
  31228. edges = append(edges, sopstage.EdgeStageNodes)
  31229. }
  31230. if m.clearedstage_messages {
  31231. edges = append(edges, sopstage.EdgeStageMessages)
  31232. }
  31233. return edges
  31234. }
  31235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31236. // was cleared in this mutation.
  31237. func (m *SopStageMutation) EdgeCleared(name string) bool {
  31238. switch name {
  31239. case sopstage.EdgeSopTask:
  31240. return m.clearedsop_task
  31241. case sopstage.EdgeStageNodes:
  31242. return m.clearedstage_nodes
  31243. case sopstage.EdgeStageMessages:
  31244. return m.clearedstage_messages
  31245. }
  31246. return false
  31247. }
  31248. // ClearEdge clears the value of the edge with the given name. It returns an error
  31249. // if that edge is not defined in the schema.
  31250. func (m *SopStageMutation) ClearEdge(name string) error {
  31251. switch name {
  31252. case sopstage.EdgeSopTask:
  31253. m.ClearSopTask()
  31254. return nil
  31255. }
  31256. return fmt.Errorf("unknown SopStage unique edge %s", name)
  31257. }
  31258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31259. // It returns an error if the edge is not defined in the schema.
  31260. func (m *SopStageMutation) ResetEdge(name string) error {
  31261. switch name {
  31262. case sopstage.EdgeSopTask:
  31263. m.ResetSopTask()
  31264. return nil
  31265. case sopstage.EdgeStageNodes:
  31266. m.ResetStageNodes()
  31267. return nil
  31268. case sopstage.EdgeStageMessages:
  31269. m.ResetStageMessages()
  31270. return nil
  31271. }
  31272. return fmt.Errorf("unknown SopStage edge %s", name)
  31273. }
  31274. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  31275. type SopTaskMutation struct {
  31276. config
  31277. op Op
  31278. typ string
  31279. id *uint64
  31280. created_at *time.Time
  31281. updated_at *time.Time
  31282. status *uint8
  31283. addstatus *int8
  31284. deleted_at *time.Time
  31285. name *string
  31286. bot_wxid_list *[]string
  31287. appendbot_wxid_list []string
  31288. _type *int
  31289. add_type *int
  31290. plan_start_time *time.Time
  31291. plan_end_time *time.Time
  31292. creator_id *string
  31293. organization_id *uint64
  31294. addorganization_id *int64
  31295. token *[]string
  31296. appendtoken []string
  31297. clearedFields map[string]struct{}
  31298. task_stages map[uint64]struct{}
  31299. removedtask_stages map[uint64]struct{}
  31300. clearedtask_stages bool
  31301. done bool
  31302. oldValue func(context.Context) (*SopTask, error)
  31303. predicates []predicate.SopTask
  31304. }
  31305. var _ ent.Mutation = (*SopTaskMutation)(nil)
  31306. // soptaskOption allows management of the mutation configuration using functional options.
  31307. type soptaskOption func(*SopTaskMutation)
  31308. // newSopTaskMutation creates new mutation for the SopTask entity.
  31309. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  31310. m := &SopTaskMutation{
  31311. config: c,
  31312. op: op,
  31313. typ: TypeSopTask,
  31314. clearedFields: make(map[string]struct{}),
  31315. }
  31316. for _, opt := range opts {
  31317. opt(m)
  31318. }
  31319. return m
  31320. }
  31321. // withSopTaskID sets the ID field of the mutation.
  31322. func withSopTaskID(id uint64) soptaskOption {
  31323. return func(m *SopTaskMutation) {
  31324. var (
  31325. err error
  31326. once sync.Once
  31327. value *SopTask
  31328. )
  31329. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  31330. once.Do(func() {
  31331. if m.done {
  31332. err = errors.New("querying old values post mutation is not allowed")
  31333. } else {
  31334. value, err = m.Client().SopTask.Get(ctx, id)
  31335. }
  31336. })
  31337. return value, err
  31338. }
  31339. m.id = &id
  31340. }
  31341. }
  31342. // withSopTask sets the old SopTask of the mutation.
  31343. func withSopTask(node *SopTask) soptaskOption {
  31344. return func(m *SopTaskMutation) {
  31345. m.oldValue = func(context.Context) (*SopTask, error) {
  31346. return node, nil
  31347. }
  31348. m.id = &node.ID
  31349. }
  31350. }
  31351. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31352. // executed in a transaction (ent.Tx), a transactional client is returned.
  31353. func (m SopTaskMutation) Client() *Client {
  31354. client := &Client{config: m.config}
  31355. client.init()
  31356. return client
  31357. }
  31358. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31359. // it returns an error otherwise.
  31360. func (m SopTaskMutation) Tx() (*Tx, error) {
  31361. if _, ok := m.driver.(*txDriver); !ok {
  31362. return nil, errors.New("ent: mutation is not running in a transaction")
  31363. }
  31364. tx := &Tx{config: m.config}
  31365. tx.init()
  31366. return tx, nil
  31367. }
  31368. // SetID sets the value of the id field. Note that this
  31369. // operation is only accepted on creation of SopTask entities.
  31370. func (m *SopTaskMutation) SetID(id uint64) {
  31371. m.id = &id
  31372. }
  31373. // ID returns the ID value in the mutation. Note that the ID is only available
  31374. // if it was provided to the builder or after it was returned from the database.
  31375. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  31376. if m.id == nil {
  31377. return
  31378. }
  31379. return *m.id, true
  31380. }
  31381. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31382. // That means, if the mutation is applied within a transaction with an isolation level such
  31383. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31384. // or updated by the mutation.
  31385. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  31386. switch {
  31387. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31388. id, exists := m.ID()
  31389. if exists {
  31390. return []uint64{id}, nil
  31391. }
  31392. fallthrough
  31393. case m.op.Is(OpUpdate | OpDelete):
  31394. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  31395. default:
  31396. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31397. }
  31398. }
  31399. // SetCreatedAt sets the "created_at" field.
  31400. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  31401. m.created_at = &t
  31402. }
  31403. // CreatedAt returns the value of the "created_at" field in the mutation.
  31404. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  31405. v := m.created_at
  31406. if v == nil {
  31407. return
  31408. }
  31409. return *v, true
  31410. }
  31411. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  31412. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31414. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31415. if !m.op.Is(OpUpdateOne) {
  31416. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31417. }
  31418. if m.id == nil || m.oldValue == nil {
  31419. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31420. }
  31421. oldValue, err := m.oldValue(ctx)
  31422. if err != nil {
  31423. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31424. }
  31425. return oldValue.CreatedAt, nil
  31426. }
  31427. // ResetCreatedAt resets all changes to the "created_at" field.
  31428. func (m *SopTaskMutation) ResetCreatedAt() {
  31429. m.created_at = nil
  31430. }
  31431. // SetUpdatedAt sets the "updated_at" field.
  31432. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  31433. m.updated_at = &t
  31434. }
  31435. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31436. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  31437. v := m.updated_at
  31438. if v == nil {
  31439. return
  31440. }
  31441. return *v, true
  31442. }
  31443. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  31444. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31446. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31447. if !m.op.Is(OpUpdateOne) {
  31448. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31449. }
  31450. if m.id == nil || m.oldValue == nil {
  31451. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31452. }
  31453. oldValue, err := m.oldValue(ctx)
  31454. if err != nil {
  31455. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31456. }
  31457. return oldValue.UpdatedAt, nil
  31458. }
  31459. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31460. func (m *SopTaskMutation) ResetUpdatedAt() {
  31461. m.updated_at = nil
  31462. }
  31463. // SetStatus sets the "status" field.
  31464. func (m *SopTaskMutation) SetStatus(u uint8) {
  31465. m.status = &u
  31466. m.addstatus = nil
  31467. }
  31468. // Status returns the value of the "status" field in the mutation.
  31469. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  31470. v := m.status
  31471. if v == nil {
  31472. return
  31473. }
  31474. return *v, true
  31475. }
  31476. // OldStatus returns the old "status" field's value of the SopTask entity.
  31477. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31479. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31480. if !m.op.Is(OpUpdateOne) {
  31481. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31482. }
  31483. if m.id == nil || m.oldValue == nil {
  31484. return v, errors.New("OldStatus requires an ID field in the mutation")
  31485. }
  31486. oldValue, err := m.oldValue(ctx)
  31487. if err != nil {
  31488. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31489. }
  31490. return oldValue.Status, nil
  31491. }
  31492. // AddStatus adds u to the "status" field.
  31493. func (m *SopTaskMutation) AddStatus(u int8) {
  31494. if m.addstatus != nil {
  31495. *m.addstatus += u
  31496. } else {
  31497. m.addstatus = &u
  31498. }
  31499. }
  31500. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31501. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  31502. v := m.addstatus
  31503. if v == nil {
  31504. return
  31505. }
  31506. return *v, true
  31507. }
  31508. // ClearStatus clears the value of the "status" field.
  31509. func (m *SopTaskMutation) ClearStatus() {
  31510. m.status = nil
  31511. m.addstatus = nil
  31512. m.clearedFields[soptask.FieldStatus] = struct{}{}
  31513. }
  31514. // StatusCleared returns if the "status" field was cleared in this mutation.
  31515. func (m *SopTaskMutation) StatusCleared() bool {
  31516. _, ok := m.clearedFields[soptask.FieldStatus]
  31517. return ok
  31518. }
  31519. // ResetStatus resets all changes to the "status" field.
  31520. func (m *SopTaskMutation) ResetStatus() {
  31521. m.status = nil
  31522. m.addstatus = nil
  31523. delete(m.clearedFields, soptask.FieldStatus)
  31524. }
  31525. // SetDeletedAt sets the "deleted_at" field.
  31526. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  31527. m.deleted_at = &t
  31528. }
  31529. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31530. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  31531. v := m.deleted_at
  31532. if v == nil {
  31533. return
  31534. }
  31535. return *v, true
  31536. }
  31537. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  31538. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31540. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31541. if !m.op.Is(OpUpdateOne) {
  31542. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31543. }
  31544. if m.id == nil || m.oldValue == nil {
  31545. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31546. }
  31547. oldValue, err := m.oldValue(ctx)
  31548. if err != nil {
  31549. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31550. }
  31551. return oldValue.DeletedAt, nil
  31552. }
  31553. // ClearDeletedAt clears the value of the "deleted_at" field.
  31554. func (m *SopTaskMutation) ClearDeletedAt() {
  31555. m.deleted_at = nil
  31556. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  31557. }
  31558. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31559. func (m *SopTaskMutation) DeletedAtCleared() bool {
  31560. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  31561. return ok
  31562. }
  31563. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31564. func (m *SopTaskMutation) ResetDeletedAt() {
  31565. m.deleted_at = nil
  31566. delete(m.clearedFields, soptask.FieldDeletedAt)
  31567. }
  31568. // SetName sets the "name" field.
  31569. func (m *SopTaskMutation) SetName(s string) {
  31570. m.name = &s
  31571. }
  31572. // Name returns the value of the "name" field in the mutation.
  31573. func (m *SopTaskMutation) Name() (r string, exists bool) {
  31574. v := m.name
  31575. if v == nil {
  31576. return
  31577. }
  31578. return *v, true
  31579. }
  31580. // OldName returns the old "name" field's value of the SopTask entity.
  31581. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31583. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  31584. if !m.op.Is(OpUpdateOne) {
  31585. return v, errors.New("OldName is only allowed on UpdateOne operations")
  31586. }
  31587. if m.id == nil || m.oldValue == nil {
  31588. return v, errors.New("OldName requires an ID field in the mutation")
  31589. }
  31590. oldValue, err := m.oldValue(ctx)
  31591. if err != nil {
  31592. return v, fmt.Errorf("querying old value for OldName: %w", err)
  31593. }
  31594. return oldValue.Name, nil
  31595. }
  31596. // ResetName resets all changes to the "name" field.
  31597. func (m *SopTaskMutation) ResetName() {
  31598. m.name = nil
  31599. }
  31600. // SetBotWxidList sets the "bot_wxid_list" field.
  31601. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  31602. m.bot_wxid_list = &s
  31603. m.appendbot_wxid_list = nil
  31604. }
  31605. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  31606. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  31607. v := m.bot_wxid_list
  31608. if v == nil {
  31609. return
  31610. }
  31611. return *v, true
  31612. }
  31613. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  31614. // If the SopTask 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 *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  31617. if !m.op.Is(OpUpdateOne) {
  31618. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  31619. }
  31620. if m.id == nil || m.oldValue == nil {
  31621. return v, errors.New("OldBotWxidList 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 OldBotWxidList: %w", err)
  31626. }
  31627. return oldValue.BotWxidList, nil
  31628. }
  31629. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  31630. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  31631. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  31632. }
  31633. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  31634. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  31635. if len(m.appendbot_wxid_list) == 0 {
  31636. return nil, false
  31637. }
  31638. return m.appendbot_wxid_list, true
  31639. }
  31640. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  31641. func (m *SopTaskMutation) ClearBotWxidList() {
  31642. m.bot_wxid_list = nil
  31643. m.appendbot_wxid_list = nil
  31644. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  31645. }
  31646. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  31647. func (m *SopTaskMutation) BotWxidListCleared() bool {
  31648. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  31649. return ok
  31650. }
  31651. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  31652. func (m *SopTaskMutation) ResetBotWxidList() {
  31653. m.bot_wxid_list = nil
  31654. m.appendbot_wxid_list = nil
  31655. delete(m.clearedFields, soptask.FieldBotWxidList)
  31656. }
  31657. // SetType sets the "type" field.
  31658. func (m *SopTaskMutation) SetType(i int) {
  31659. m._type = &i
  31660. m.add_type = nil
  31661. }
  31662. // GetType returns the value of the "type" field in the mutation.
  31663. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  31664. v := m._type
  31665. if v == nil {
  31666. return
  31667. }
  31668. return *v, true
  31669. }
  31670. // OldType returns the old "type" field's value of the SopTask entity.
  31671. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31673. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  31674. if !m.op.Is(OpUpdateOne) {
  31675. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31676. }
  31677. if m.id == nil || m.oldValue == nil {
  31678. return v, errors.New("OldType requires an ID field in the mutation")
  31679. }
  31680. oldValue, err := m.oldValue(ctx)
  31681. if err != nil {
  31682. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31683. }
  31684. return oldValue.Type, nil
  31685. }
  31686. // AddType adds i to the "type" field.
  31687. func (m *SopTaskMutation) AddType(i int) {
  31688. if m.add_type != nil {
  31689. *m.add_type += i
  31690. } else {
  31691. m.add_type = &i
  31692. }
  31693. }
  31694. // AddedType returns the value that was added to the "type" field in this mutation.
  31695. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  31696. v := m.add_type
  31697. if v == nil {
  31698. return
  31699. }
  31700. return *v, true
  31701. }
  31702. // ResetType resets all changes to the "type" field.
  31703. func (m *SopTaskMutation) ResetType() {
  31704. m._type = nil
  31705. m.add_type = nil
  31706. }
  31707. // SetPlanStartTime sets the "plan_start_time" field.
  31708. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  31709. m.plan_start_time = &t
  31710. }
  31711. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  31712. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  31713. v := m.plan_start_time
  31714. if v == nil {
  31715. return
  31716. }
  31717. return *v, true
  31718. }
  31719. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  31720. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31722. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  31723. if !m.op.Is(OpUpdateOne) {
  31724. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  31725. }
  31726. if m.id == nil || m.oldValue == nil {
  31727. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  31728. }
  31729. oldValue, err := m.oldValue(ctx)
  31730. if err != nil {
  31731. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  31732. }
  31733. return oldValue.PlanStartTime, nil
  31734. }
  31735. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  31736. func (m *SopTaskMutation) ClearPlanStartTime() {
  31737. m.plan_start_time = nil
  31738. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  31739. }
  31740. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  31741. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  31742. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  31743. return ok
  31744. }
  31745. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  31746. func (m *SopTaskMutation) ResetPlanStartTime() {
  31747. m.plan_start_time = nil
  31748. delete(m.clearedFields, soptask.FieldPlanStartTime)
  31749. }
  31750. // SetPlanEndTime sets the "plan_end_time" field.
  31751. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  31752. m.plan_end_time = &t
  31753. }
  31754. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  31755. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  31756. v := m.plan_end_time
  31757. if v == nil {
  31758. return
  31759. }
  31760. return *v, true
  31761. }
  31762. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  31763. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31765. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  31766. if !m.op.Is(OpUpdateOne) {
  31767. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  31768. }
  31769. if m.id == nil || m.oldValue == nil {
  31770. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  31771. }
  31772. oldValue, err := m.oldValue(ctx)
  31773. if err != nil {
  31774. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  31775. }
  31776. return oldValue.PlanEndTime, nil
  31777. }
  31778. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  31779. func (m *SopTaskMutation) ClearPlanEndTime() {
  31780. m.plan_end_time = nil
  31781. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  31782. }
  31783. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  31784. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  31785. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  31786. return ok
  31787. }
  31788. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  31789. func (m *SopTaskMutation) ResetPlanEndTime() {
  31790. m.plan_end_time = nil
  31791. delete(m.clearedFields, soptask.FieldPlanEndTime)
  31792. }
  31793. // SetCreatorID sets the "creator_id" field.
  31794. func (m *SopTaskMutation) SetCreatorID(s string) {
  31795. m.creator_id = &s
  31796. }
  31797. // CreatorID returns the value of the "creator_id" field in the mutation.
  31798. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  31799. v := m.creator_id
  31800. if v == nil {
  31801. return
  31802. }
  31803. return *v, true
  31804. }
  31805. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  31806. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31808. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  31809. if !m.op.Is(OpUpdateOne) {
  31810. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  31811. }
  31812. if m.id == nil || m.oldValue == nil {
  31813. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  31814. }
  31815. oldValue, err := m.oldValue(ctx)
  31816. if err != nil {
  31817. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  31818. }
  31819. return oldValue.CreatorID, nil
  31820. }
  31821. // ClearCreatorID clears the value of the "creator_id" field.
  31822. func (m *SopTaskMutation) ClearCreatorID() {
  31823. m.creator_id = nil
  31824. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  31825. }
  31826. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  31827. func (m *SopTaskMutation) CreatorIDCleared() bool {
  31828. _, ok := m.clearedFields[soptask.FieldCreatorID]
  31829. return ok
  31830. }
  31831. // ResetCreatorID resets all changes to the "creator_id" field.
  31832. func (m *SopTaskMutation) ResetCreatorID() {
  31833. m.creator_id = nil
  31834. delete(m.clearedFields, soptask.FieldCreatorID)
  31835. }
  31836. // SetOrganizationID sets the "organization_id" field.
  31837. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  31838. m.organization_id = &u
  31839. m.addorganization_id = nil
  31840. }
  31841. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31842. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  31843. v := m.organization_id
  31844. if v == nil {
  31845. return
  31846. }
  31847. return *v, true
  31848. }
  31849. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  31850. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31852. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31853. if !m.op.Is(OpUpdateOne) {
  31854. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31855. }
  31856. if m.id == nil || m.oldValue == nil {
  31857. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31858. }
  31859. oldValue, err := m.oldValue(ctx)
  31860. if err != nil {
  31861. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31862. }
  31863. return oldValue.OrganizationID, nil
  31864. }
  31865. // AddOrganizationID adds u to the "organization_id" field.
  31866. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  31867. if m.addorganization_id != nil {
  31868. *m.addorganization_id += u
  31869. } else {
  31870. m.addorganization_id = &u
  31871. }
  31872. }
  31873. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31874. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  31875. v := m.addorganization_id
  31876. if v == nil {
  31877. return
  31878. }
  31879. return *v, true
  31880. }
  31881. // ClearOrganizationID clears the value of the "organization_id" field.
  31882. func (m *SopTaskMutation) ClearOrganizationID() {
  31883. m.organization_id = nil
  31884. m.addorganization_id = nil
  31885. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  31886. }
  31887. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31888. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  31889. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  31890. return ok
  31891. }
  31892. // ResetOrganizationID resets all changes to the "organization_id" field.
  31893. func (m *SopTaskMutation) ResetOrganizationID() {
  31894. m.organization_id = nil
  31895. m.addorganization_id = nil
  31896. delete(m.clearedFields, soptask.FieldOrganizationID)
  31897. }
  31898. // SetToken sets the "token" field.
  31899. func (m *SopTaskMutation) SetToken(s []string) {
  31900. m.token = &s
  31901. m.appendtoken = nil
  31902. }
  31903. // Token returns the value of the "token" field in the mutation.
  31904. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  31905. v := m.token
  31906. if v == nil {
  31907. return
  31908. }
  31909. return *v, true
  31910. }
  31911. // OldToken returns the old "token" field's value of the SopTask entity.
  31912. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31914. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  31915. if !m.op.Is(OpUpdateOne) {
  31916. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31917. }
  31918. if m.id == nil || m.oldValue == nil {
  31919. return v, errors.New("OldToken requires an ID field in the mutation")
  31920. }
  31921. oldValue, err := m.oldValue(ctx)
  31922. if err != nil {
  31923. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31924. }
  31925. return oldValue.Token, nil
  31926. }
  31927. // AppendToken adds s to the "token" field.
  31928. func (m *SopTaskMutation) AppendToken(s []string) {
  31929. m.appendtoken = append(m.appendtoken, s...)
  31930. }
  31931. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  31932. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  31933. if len(m.appendtoken) == 0 {
  31934. return nil, false
  31935. }
  31936. return m.appendtoken, true
  31937. }
  31938. // ClearToken clears the value of the "token" field.
  31939. func (m *SopTaskMutation) ClearToken() {
  31940. m.token = nil
  31941. m.appendtoken = nil
  31942. m.clearedFields[soptask.FieldToken] = struct{}{}
  31943. }
  31944. // TokenCleared returns if the "token" field was cleared in this mutation.
  31945. func (m *SopTaskMutation) TokenCleared() bool {
  31946. _, ok := m.clearedFields[soptask.FieldToken]
  31947. return ok
  31948. }
  31949. // ResetToken resets all changes to the "token" field.
  31950. func (m *SopTaskMutation) ResetToken() {
  31951. m.token = nil
  31952. m.appendtoken = nil
  31953. delete(m.clearedFields, soptask.FieldToken)
  31954. }
  31955. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  31956. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  31957. if m.task_stages == nil {
  31958. m.task_stages = make(map[uint64]struct{})
  31959. }
  31960. for i := range ids {
  31961. m.task_stages[ids[i]] = struct{}{}
  31962. }
  31963. }
  31964. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  31965. func (m *SopTaskMutation) ClearTaskStages() {
  31966. m.clearedtask_stages = true
  31967. }
  31968. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  31969. func (m *SopTaskMutation) TaskStagesCleared() bool {
  31970. return m.clearedtask_stages
  31971. }
  31972. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  31973. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  31974. if m.removedtask_stages == nil {
  31975. m.removedtask_stages = make(map[uint64]struct{})
  31976. }
  31977. for i := range ids {
  31978. delete(m.task_stages, ids[i])
  31979. m.removedtask_stages[ids[i]] = struct{}{}
  31980. }
  31981. }
  31982. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  31983. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  31984. for id := range m.removedtask_stages {
  31985. ids = append(ids, id)
  31986. }
  31987. return
  31988. }
  31989. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  31990. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  31991. for id := range m.task_stages {
  31992. ids = append(ids, id)
  31993. }
  31994. return
  31995. }
  31996. // ResetTaskStages resets all changes to the "task_stages" edge.
  31997. func (m *SopTaskMutation) ResetTaskStages() {
  31998. m.task_stages = nil
  31999. m.clearedtask_stages = false
  32000. m.removedtask_stages = nil
  32001. }
  32002. // Where appends a list predicates to the SopTaskMutation builder.
  32003. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  32004. m.predicates = append(m.predicates, ps...)
  32005. }
  32006. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  32007. // users can use type-assertion to append predicates that do not depend on any generated package.
  32008. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  32009. p := make([]predicate.SopTask, len(ps))
  32010. for i := range ps {
  32011. p[i] = ps[i]
  32012. }
  32013. m.Where(p...)
  32014. }
  32015. // Op returns the operation name.
  32016. func (m *SopTaskMutation) Op() Op {
  32017. return m.op
  32018. }
  32019. // SetOp allows setting the mutation operation.
  32020. func (m *SopTaskMutation) SetOp(op Op) {
  32021. m.op = op
  32022. }
  32023. // Type returns the node type of this mutation (SopTask).
  32024. func (m *SopTaskMutation) Type() string {
  32025. return m.typ
  32026. }
  32027. // Fields returns all fields that were changed during this mutation. Note that in
  32028. // order to get all numeric fields that were incremented/decremented, call
  32029. // AddedFields().
  32030. func (m *SopTaskMutation) Fields() []string {
  32031. fields := make([]string, 0, 12)
  32032. if m.created_at != nil {
  32033. fields = append(fields, soptask.FieldCreatedAt)
  32034. }
  32035. if m.updated_at != nil {
  32036. fields = append(fields, soptask.FieldUpdatedAt)
  32037. }
  32038. if m.status != nil {
  32039. fields = append(fields, soptask.FieldStatus)
  32040. }
  32041. if m.deleted_at != nil {
  32042. fields = append(fields, soptask.FieldDeletedAt)
  32043. }
  32044. if m.name != nil {
  32045. fields = append(fields, soptask.FieldName)
  32046. }
  32047. if m.bot_wxid_list != nil {
  32048. fields = append(fields, soptask.FieldBotWxidList)
  32049. }
  32050. if m._type != nil {
  32051. fields = append(fields, soptask.FieldType)
  32052. }
  32053. if m.plan_start_time != nil {
  32054. fields = append(fields, soptask.FieldPlanStartTime)
  32055. }
  32056. if m.plan_end_time != nil {
  32057. fields = append(fields, soptask.FieldPlanEndTime)
  32058. }
  32059. if m.creator_id != nil {
  32060. fields = append(fields, soptask.FieldCreatorID)
  32061. }
  32062. if m.organization_id != nil {
  32063. fields = append(fields, soptask.FieldOrganizationID)
  32064. }
  32065. if m.token != nil {
  32066. fields = append(fields, soptask.FieldToken)
  32067. }
  32068. return fields
  32069. }
  32070. // Field returns the value of a field with the given name. The second boolean
  32071. // return value indicates that this field was not set, or was not defined in the
  32072. // schema.
  32073. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  32074. switch name {
  32075. case soptask.FieldCreatedAt:
  32076. return m.CreatedAt()
  32077. case soptask.FieldUpdatedAt:
  32078. return m.UpdatedAt()
  32079. case soptask.FieldStatus:
  32080. return m.Status()
  32081. case soptask.FieldDeletedAt:
  32082. return m.DeletedAt()
  32083. case soptask.FieldName:
  32084. return m.Name()
  32085. case soptask.FieldBotWxidList:
  32086. return m.BotWxidList()
  32087. case soptask.FieldType:
  32088. return m.GetType()
  32089. case soptask.FieldPlanStartTime:
  32090. return m.PlanStartTime()
  32091. case soptask.FieldPlanEndTime:
  32092. return m.PlanEndTime()
  32093. case soptask.FieldCreatorID:
  32094. return m.CreatorID()
  32095. case soptask.FieldOrganizationID:
  32096. return m.OrganizationID()
  32097. case soptask.FieldToken:
  32098. return m.Token()
  32099. }
  32100. return nil, false
  32101. }
  32102. // OldField returns the old value of the field from the database. An error is
  32103. // returned if the mutation operation is not UpdateOne, or the query to the
  32104. // database failed.
  32105. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32106. switch name {
  32107. case soptask.FieldCreatedAt:
  32108. return m.OldCreatedAt(ctx)
  32109. case soptask.FieldUpdatedAt:
  32110. return m.OldUpdatedAt(ctx)
  32111. case soptask.FieldStatus:
  32112. return m.OldStatus(ctx)
  32113. case soptask.FieldDeletedAt:
  32114. return m.OldDeletedAt(ctx)
  32115. case soptask.FieldName:
  32116. return m.OldName(ctx)
  32117. case soptask.FieldBotWxidList:
  32118. return m.OldBotWxidList(ctx)
  32119. case soptask.FieldType:
  32120. return m.OldType(ctx)
  32121. case soptask.FieldPlanStartTime:
  32122. return m.OldPlanStartTime(ctx)
  32123. case soptask.FieldPlanEndTime:
  32124. return m.OldPlanEndTime(ctx)
  32125. case soptask.FieldCreatorID:
  32126. return m.OldCreatorID(ctx)
  32127. case soptask.FieldOrganizationID:
  32128. return m.OldOrganizationID(ctx)
  32129. case soptask.FieldToken:
  32130. return m.OldToken(ctx)
  32131. }
  32132. return nil, fmt.Errorf("unknown SopTask field %s", name)
  32133. }
  32134. // SetField sets the value of a field with the given name. It returns an error if
  32135. // the field is not defined in the schema, or if the type mismatched the field
  32136. // type.
  32137. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  32138. switch name {
  32139. case soptask.FieldCreatedAt:
  32140. v, ok := value.(time.Time)
  32141. if !ok {
  32142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32143. }
  32144. m.SetCreatedAt(v)
  32145. return nil
  32146. case soptask.FieldUpdatedAt:
  32147. v, ok := value.(time.Time)
  32148. if !ok {
  32149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32150. }
  32151. m.SetUpdatedAt(v)
  32152. return nil
  32153. case soptask.FieldStatus:
  32154. v, ok := value.(uint8)
  32155. if !ok {
  32156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32157. }
  32158. m.SetStatus(v)
  32159. return nil
  32160. case soptask.FieldDeletedAt:
  32161. v, ok := value.(time.Time)
  32162. if !ok {
  32163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32164. }
  32165. m.SetDeletedAt(v)
  32166. return nil
  32167. case soptask.FieldName:
  32168. v, ok := value.(string)
  32169. if !ok {
  32170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32171. }
  32172. m.SetName(v)
  32173. return nil
  32174. case soptask.FieldBotWxidList:
  32175. v, ok := value.([]string)
  32176. if !ok {
  32177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32178. }
  32179. m.SetBotWxidList(v)
  32180. return nil
  32181. case soptask.FieldType:
  32182. v, ok := value.(int)
  32183. if !ok {
  32184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32185. }
  32186. m.SetType(v)
  32187. return nil
  32188. case soptask.FieldPlanStartTime:
  32189. v, ok := value.(time.Time)
  32190. if !ok {
  32191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32192. }
  32193. m.SetPlanStartTime(v)
  32194. return nil
  32195. case soptask.FieldPlanEndTime:
  32196. v, ok := value.(time.Time)
  32197. if !ok {
  32198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32199. }
  32200. m.SetPlanEndTime(v)
  32201. return nil
  32202. case soptask.FieldCreatorID:
  32203. v, ok := value.(string)
  32204. if !ok {
  32205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32206. }
  32207. m.SetCreatorID(v)
  32208. return nil
  32209. case soptask.FieldOrganizationID:
  32210. v, ok := value.(uint64)
  32211. if !ok {
  32212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32213. }
  32214. m.SetOrganizationID(v)
  32215. return nil
  32216. case soptask.FieldToken:
  32217. v, ok := value.([]string)
  32218. if !ok {
  32219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32220. }
  32221. m.SetToken(v)
  32222. return nil
  32223. }
  32224. return fmt.Errorf("unknown SopTask field %s", name)
  32225. }
  32226. // AddedFields returns all numeric fields that were incremented/decremented during
  32227. // this mutation.
  32228. func (m *SopTaskMutation) AddedFields() []string {
  32229. var fields []string
  32230. if m.addstatus != nil {
  32231. fields = append(fields, soptask.FieldStatus)
  32232. }
  32233. if m.add_type != nil {
  32234. fields = append(fields, soptask.FieldType)
  32235. }
  32236. if m.addorganization_id != nil {
  32237. fields = append(fields, soptask.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 *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  32245. switch name {
  32246. case soptask.FieldStatus:
  32247. return m.AddedStatus()
  32248. case soptask.FieldType:
  32249. return m.AddedType()
  32250. case soptask.FieldOrganizationID:
  32251. return m.AddedOrganizationID()
  32252. }
  32253. return nil, false
  32254. }
  32255. // AddField adds the value to the field with the given name. It returns an error if
  32256. // the field is not defined in the schema, or if the type mismatched the field
  32257. // type.
  32258. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  32259. switch name {
  32260. case soptask.FieldStatus:
  32261. v, ok := value.(int8)
  32262. if !ok {
  32263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32264. }
  32265. m.AddStatus(v)
  32266. return nil
  32267. case soptask.FieldType:
  32268. v, ok := value.(int)
  32269. if !ok {
  32270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32271. }
  32272. m.AddType(v)
  32273. return nil
  32274. case soptask.FieldOrganizationID:
  32275. v, ok := value.(int64)
  32276. if !ok {
  32277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32278. }
  32279. m.AddOrganizationID(v)
  32280. return nil
  32281. }
  32282. return fmt.Errorf("unknown SopTask numeric field %s", name)
  32283. }
  32284. // ClearedFields returns all nullable fields that were cleared during this
  32285. // mutation.
  32286. func (m *SopTaskMutation) ClearedFields() []string {
  32287. var fields []string
  32288. if m.FieldCleared(soptask.FieldStatus) {
  32289. fields = append(fields, soptask.FieldStatus)
  32290. }
  32291. if m.FieldCleared(soptask.FieldDeletedAt) {
  32292. fields = append(fields, soptask.FieldDeletedAt)
  32293. }
  32294. if m.FieldCleared(soptask.FieldBotWxidList) {
  32295. fields = append(fields, soptask.FieldBotWxidList)
  32296. }
  32297. if m.FieldCleared(soptask.FieldPlanStartTime) {
  32298. fields = append(fields, soptask.FieldPlanStartTime)
  32299. }
  32300. if m.FieldCleared(soptask.FieldPlanEndTime) {
  32301. fields = append(fields, soptask.FieldPlanEndTime)
  32302. }
  32303. if m.FieldCleared(soptask.FieldCreatorID) {
  32304. fields = append(fields, soptask.FieldCreatorID)
  32305. }
  32306. if m.FieldCleared(soptask.FieldOrganizationID) {
  32307. fields = append(fields, soptask.FieldOrganizationID)
  32308. }
  32309. if m.FieldCleared(soptask.FieldToken) {
  32310. fields = append(fields, soptask.FieldToken)
  32311. }
  32312. return fields
  32313. }
  32314. // FieldCleared returns a boolean indicating if a field with the given name was
  32315. // cleared in this mutation.
  32316. func (m *SopTaskMutation) FieldCleared(name string) bool {
  32317. _, ok := m.clearedFields[name]
  32318. return ok
  32319. }
  32320. // ClearField clears the value of the field with the given name. It returns an
  32321. // error if the field is not defined in the schema.
  32322. func (m *SopTaskMutation) ClearField(name string) error {
  32323. switch name {
  32324. case soptask.FieldStatus:
  32325. m.ClearStatus()
  32326. return nil
  32327. case soptask.FieldDeletedAt:
  32328. m.ClearDeletedAt()
  32329. return nil
  32330. case soptask.FieldBotWxidList:
  32331. m.ClearBotWxidList()
  32332. return nil
  32333. case soptask.FieldPlanStartTime:
  32334. m.ClearPlanStartTime()
  32335. return nil
  32336. case soptask.FieldPlanEndTime:
  32337. m.ClearPlanEndTime()
  32338. return nil
  32339. case soptask.FieldCreatorID:
  32340. m.ClearCreatorID()
  32341. return nil
  32342. case soptask.FieldOrganizationID:
  32343. m.ClearOrganizationID()
  32344. return nil
  32345. case soptask.FieldToken:
  32346. m.ClearToken()
  32347. return nil
  32348. }
  32349. return fmt.Errorf("unknown SopTask nullable field %s", name)
  32350. }
  32351. // ResetField resets all changes in the mutation for the field with the given name.
  32352. // It returns an error if the field is not defined in the schema.
  32353. func (m *SopTaskMutation) ResetField(name string) error {
  32354. switch name {
  32355. case soptask.FieldCreatedAt:
  32356. m.ResetCreatedAt()
  32357. return nil
  32358. case soptask.FieldUpdatedAt:
  32359. m.ResetUpdatedAt()
  32360. return nil
  32361. case soptask.FieldStatus:
  32362. m.ResetStatus()
  32363. return nil
  32364. case soptask.FieldDeletedAt:
  32365. m.ResetDeletedAt()
  32366. return nil
  32367. case soptask.FieldName:
  32368. m.ResetName()
  32369. return nil
  32370. case soptask.FieldBotWxidList:
  32371. m.ResetBotWxidList()
  32372. return nil
  32373. case soptask.FieldType:
  32374. m.ResetType()
  32375. return nil
  32376. case soptask.FieldPlanStartTime:
  32377. m.ResetPlanStartTime()
  32378. return nil
  32379. case soptask.FieldPlanEndTime:
  32380. m.ResetPlanEndTime()
  32381. return nil
  32382. case soptask.FieldCreatorID:
  32383. m.ResetCreatorID()
  32384. return nil
  32385. case soptask.FieldOrganizationID:
  32386. m.ResetOrganizationID()
  32387. return nil
  32388. case soptask.FieldToken:
  32389. m.ResetToken()
  32390. return nil
  32391. }
  32392. return fmt.Errorf("unknown SopTask field %s", name)
  32393. }
  32394. // AddedEdges returns all edge names that were set/added in this mutation.
  32395. func (m *SopTaskMutation) AddedEdges() []string {
  32396. edges := make([]string, 0, 1)
  32397. if m.task_stages != nil {
  32398. edges = append(edges, soptask.EdgeTaskStages)
  32399. }
  32400. return edges
  32401. }
  32402. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32403. // name in this mutation.
  32404. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  32405. switch name {
  32406. case soptask.EdgeTaskStages:
  32407. ids := make([]ent.Value, 0, len(m.task_stages))
  32408. for id := range m.task_stages {
  32409. ids = append(ids, id)
  32410. }
  32411. return ids
  32412. }
  32413. return nil
  32414. }
  32415. // RemovedEdges returns all edge names that were removed in this mutation.
  32416. func (m *SopTaskMutation) RemovedEdges() []string {
  32417. edges := make([]string, 0, 1)
  32418. if m.removedtask_stages != nil {
  32419. edges = append(edges, soptask.EdgeTaskStages)
  32420. }
  32421. return edges
  32422. }
  32423. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32424. // the given name in this mutation.
  32425. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  32426. switch name {
  32427. case soptask.EdgeTaskStages:
  32428. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  32429. for id := range m.removedtask_stages {
  32430. ids = append(ids, id)
  32431. }
  32432. return ids
  32433. }
  32434. return nil
  32435. }
  32436. // ClearedEdges returns all edge names that were cleared in this mutation.
  32437. func (m *SopTaskMutation) ClearedEdges() []string {
  32438. edges := make([]string, 0, 1)
  32439. if m.clearedtask_stages {
  32440. edges = append(edges, soptask.EdgeTaskStages)
  32441. }
  32442. return edges
  32443. }
  32444. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32445. // was cleared in this mutation.
  32446. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  32447. switch name {
  32448. case soptask.EdgeTaskStages:
  32449. return m.clearedtask_stages
  32450. }
  32451. return false
  32452. }
  32453. // ClearEdge clears the value of the edge with the given name. It returns an error
  32454. // if that edge is not defined in the schema.
  32455. func (m *SopTaskMutation) ClearEdge(name string) error {
  32456. switch name {
  32457. }
  32458. return fmt.Errorf("unknown SopTask unique edge %s", name)
  32459. }
  32460. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32461. // It returns an error if the edge is not defined in the schema.
  32462. func (m *SopTaskMutation) ResetEdge(name string) error {
  32463. switch name {
  32464. case soptask.EdgeTaskStages:
  32465. m.ResetTaskStages()
  32466. return nil
  32467. }
  32468. return fmt.Errorf("unknown SopTask edge %s", name)
  32469. }
  32470. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  32471. type TokenMutation struct {
  32472. config
  32473. op Op
  32474. typ string
  32475. id *uint64
  32476. created_at *time.Time
  32477. updated_at *time.Time
  32478. deleted_at *time.Time
  32479. expire_at *time.Time
  32480. token *string
  32481. mac *string
  32482. organization_id *uint64
  32483. addorganization_id *int64
  32484. custom_agent_base *string
  32485. custom_agent_key *string
  32486. openai_base *string
  32487. openai_key *string
  32488. clearedFields map[string]struct{}
  32489. agent *uint64
  32490. clearedagent bool
  32491. done bool
  32492. oldValue func(context.Context) (*Token, error)
  32493. predicates []predicate.Token
  32494. }
  32495. var _ ent.Mutation = (*TokenMutation)(nil)
  32496. // tokenOption allows management of the mutation configuration using functional options.
  32497. type tokenOption func(*TokenMutation)
  32498. // newTokenMutation creates new mutation for the Token entity.
  32499. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  32500. m := &TokenMutation{
  32501. config: c,
  32502. op: op,
  32503. typ: TypeToken,
  32504. clearedFields: make(map[string]struct{}),
  32505. }
  32506. for _, opt := range opts {
  32507. opt(m)
  32508. }
  32509. return m
  32510. }
  32511. // withTokenID sets the ID field of the mutation.
  32512. func withTokenID(id uint64) tokenOption {
  32513. return func(m *TokenMutation) {
  32514. var (
  32515. err error
  32516. once sync.Once
  32517. value *Token
  32518. )
  32519. m.oldValue = func(ctx context.Context) (*Token, error) {
  32520. once.Do(func() {
  32521. if m.done {
  32522. err = errors.New("querying old values post mutation is not allowed")
  32523. } else {
  32524. value, err = m.Client().Token.Get(ctx, id)
  32525. }
  32526. })
  32527. return value, err
  32528. }
  32529. m.id = &id
  32530. }
  32531. }
  32532. // withToken sets the old Token of the mutation.
  32533. func withToken(node *Token) tokenOption {
  32534. return func(m *TokenMutation) {
  32535. m.oldValue = func(context.Context) (*Token, error) {
  32536. return node, nil
  32537. }
  32538. m.id = &node.ID
  32539. }
  32540. }
  32541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32542. // executed in a transaction (ent.Tx), a transactional client is returned.
  32543. func (m TokenMutation) Client() *Client {
  32544. client := &Client{config: m.config}
  32545. client.init()
  32546. return client
  32547. }
  32548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32549. // it returns an error otherwise.
  32550. func (m TokenMutation) Tx() (*Tx, error) {
  32551. if _, ok := m.driver.(*txDriver); !ok {
  32552. return nil, errors.New("ent: mutation is not running in a transaction")
  32553. }
  32554. tx := &Tx{config: m.config}
  32555. tx.init()
  32556. return tx, nil
  32557. }
  32558. // SetID sets the value of the id field. Note that this
  32559. // operation is only accepted on creation of Token entities.
  32560. func (m *TokenMutation) SetID(id uint64) {
  32561. m.id = &id
  32562. }
  32563. // ID returns the ID value in the mutation. Note that the ID is only available
  32564. // if it was provided to the builder or after it was returned from the database.
  32565. func (m *TokenMutation) ID() (id uint64, exists bool) {
  32566. if m.id == nil {
  32567. return
  32568. }
  32569. return *m.id, true
  32570. }
  32571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32572. // That means, if the mutation is applied within a transaction with an isolation level such
  32573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32574. // or updated by the mutation.
  32575. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  32576. switch {
  32577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32578. id, exists := m.ID()
  32579. if exists {
  32580. return []uint64{id}, nil
  32581. }
  32582. fallthrough
  32583. case m.op.Is(OpUpdate | OpDelete):
  32584. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  32585. default:
  32586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32587. }
  32588. }
  32589. // SetCreatedAt sets the "created_at" field.
  32590. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  32591. m.created_at = &t
  32592. }
  32593. // CreatedAt returns the value of the "created_at" field in the mutation.
  32594. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  32595. v := m.created_at
  32596. if v == nil {
  32597. return
  32598. }
  32599. return *v, true
  32600. }
  32601. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  32602. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32604. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32605. if !m.op.Is(OpUpdateOne) {
  32606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32607. }
  32608. if m.id == nil || m.oldValue == nil {
  32609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32610. }
  32611. oldValue, err := m.oldValue(ctx)
  32612. if err != nil {
  32613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32614. }
  32615. return oldValue.CreatedAt, nil
  32616. }
  32617. // ResetCreatedAt resets all changes to the "created_at" field.
  32618. func (m *TokenMutation) ResetCreatedAt() {
  32619. m.created_at = nil
  32620. }
  32621. // SetUpdatedAt sets the "updated_at" field.
  32622. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  32623. m.updated_at = &t
  32624. }
  32625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32626. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  32627. v := m.updated_at
  32628. if v == nil {
  32629. return
  32630. }
  32631. return *v, true
  32632. }
  32633. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  32634. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32636. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32637. if !m.op.Is(OpUpdateOne) {
  32638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32639. }
  32640. if m.id == nil || m.oldValue == nil {
  32641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32642. }
  32643. oldValue, err := m.oldValue(ctx)
  32644. if err != nil {
  32645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32646. }
  32647. return oldValue.UpdatedAt, nil
  32648. }
  32649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32650. func (m *TokenMutation) ResetUpdatedAt() {
  32651. m.updated_at = nil
  32652. }
  32653. // SetDeletedAt sets the "deleted_at" field.
  32654. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  32655. m.deleted_at = &t
  32656. }
  32657. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32658. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  32659. v := m.deleted_at
  32660. if v == nil {
  32661. return
  32662. }
  32663. return *v, true
  32664. }
  32665. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  32666. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32668. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32669. if !m.op.Is(OpUpdateOne) {
  32670. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32671. }
  32672. if m.id == nil || m.oldValue == nil {
  32673. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32674. }
  32675. oldValue, err := m.oldValue(ctx)
  32676. if err != nil {
  32677. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32678. }
  32679. return oldValue.DeletedAt, nil
  32680. }
  32681. // ClearDeletedAt clears the value of the "deleted_at" field.
  32682. func (m *TokenMutation) ClearDeletedAt() {
  32683. m.deleted_at = nil
  32684. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  32685. }
  32686. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32687. func (m *TokenMutation) DeletedAtCleared() bool {
  32688. _, ok := m.clearedFields[token.FieldDeletedAt]
  32689. return ok
  32690. }
  32691. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32692. func (m *TokenMutation) ResetDeletedAt() {
  32693. m.deleted_at = nil
  32694. delete(m.clearedFields, token.FieldDeletedAt)
  32695. }
  32696. // SetExpireAt sets the "expire_at" field.
  32697. func (m *TokenMutation) SetExpireAt(t time.Time) {
  32698. m.expire_at = &t
  32699. }
  32700. // ExpireAt returns the value of the "expire_at" field in the mutation.
  32701. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  32702. v := m.expire_at
  32703. if v == nil {
  32704. return
  32705. }
  32706. return *v, true
  32707. }
  32708. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  32709. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32711. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  32712. if !m.op.Is(OpUpdateOne) {
  32713. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  32714. }
  32715. if m.id == nil || m.oldValue == nil {
  32716. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  32717. }
  32718. oldValue, err := m.oldValue(ctx)
  32719. if err != nil {
  32720. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  32721. }
  32722. return oldValue.ExpireAt, nil
  32723. }
  32724. // ClearExpireAt clears the value of the "expire_at" field.
  32725. func (m *TokenMutation) ClearExpireAt() {
  32726. m.expire_at = nil
  32727. m.clearedFields[token.FieldExpireAt] = struct{}{}
  32728. }
  32729. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  32730. func (m *TokenMutation) ExpireAtCleared() bool {
  32731. _, ok := m.clearedFields[token.FieldExpireAt]
  32732. return ok
  32733. }
  32734. // ResetExpireAt resets all changes to the "expire_at" field.
  32735. func (m *TokenMutation) ResetExpireAt() {
  32736. m.expire_at = nil
  32737. delete(m.clearedFields, token.FieldExpireAt)
  32738. }
  32739. // SetToken sets the "token" field.
  32740. func (m *TokenMutation) SetToken(s string) {
  32741. m.token = &s
  32742. }
  32743. // Token returns the value of the "token" field in the mutation.
  32744. func (m *TokenMutation) Token() (r string, exists bool) {
  32745. v := m.token
  32746. if v == nil {
  32747. return
  32748. }
  32749. return *v, true
  32750. }
  32751. // OldToken returns the old "token" field's value of the Token entity.
  32752. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32754. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  32755. if !m.op.Is(OpUpdateOne) {
  32756. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  32757. }
  32758. if m.id == nil || m.oldValue == nil {
  32759. return v, errors.New("OldToken requires an ID field in the mutation")
  32760. }
  32761. oldValue, err := m.oldValue(ctx)
  32762. if err != nil {
  32763. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  32764. }
  32765. return oldValue.Token, nil
  32766. }
  32767. // ClearToken clears the value of the "token" field.
  32768. func (m *TokenMutation) ClearToken() {
  32769. m.token = nil
  32770. m.clearedFields[token.FieldToken] = struct{}{}
  32771. }
  32772. // TokenCleared returns if the "token" field was cleared in this mutation.
  32773. func (m *TokenMutation) TokenCleared() bool {
  32774. _, ok := m.clearedFields[token.FieldToken]
  32775. return ok
  32776. }
  32777. // ResetToken resets all changes to the "token" field.
  32778. func (m *TokenMutation) ResetToken() {
  32779. m.token = nil
  32780. delete(m.clearedFields, token.FieldToken)
  32781. }
  32782. // SetMAC sets the "mac" field.
  32783. func (m *TokenMutation) SetMAC(s string) {
  32784. m.mac = &s
  32785. }
  32786. // MAC returns the value of the "mac" field in the mutation.
  32787. func (m *TokenMutation) MAC() (r string, exists bool) {
  32788. v := m.mac
  32789. if v == nil {
  32790. return
  32791. }
  32792. return *v, true
  32793. }
  32794. // OldMAC returns the old "mac" field's value of the Token entity.
  32795. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32797. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  32798. if !m.op.Is(OpUpdateOne) {
  32799. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  32800. }
  32801. if m.id == nil || m.oldValue == nil {
  32802. return v, errors.New("OldMAC requires an ID field in the mutation")
  32803. }
  32804. oldValue, err := m.oldValue(ctx)
  32805. if err != nil {
  32806. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  32807. }
  32808. return oldValue.MAC, nil
  32809. }
  32810. // ClearMAC clears the value of the "mac" field.
  32811. func (m *TokenMutation) ClearMAC() {
  32812. m.mac = nil
  32813. m.clearedFields[token.FieldMAC] = struct{}{}
  32814. }
  32815. // MACCleared returns if the "mac" field was cleared in this mutation.
  32816. func (m *TokenMutation) MACCleared() bool {
  32817. _, ok := m.clearedFields[token.FieldMAC]
  32818. return ok
  32819. }
  32820. // ResetMAC resets all changes to the "mac" field.
  32821. func (m *TokenMutation) ResetMAC() {
  32822. m.mac = nil
  32823. delete(m.clearedFields, token.FieldMAC)
  32824. }
  32825. // SetOrganizationID sets the "organization_id" field.
  32826. func (m *TokenMutation) SetOrganizationID(u uint64) {
  32827. m.organization_id = &u
  32828. m.addorganization_id = nil
  32829. }
  32830. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32831. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  32832. v := m.organization_id
  32833. if v == nil {
  32834. return
  32835. }
  32836. return *v, true
  32837. }
  32838. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  32839. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32841. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32842. if !m.op.Is(OpUpdateOne) {
  32843. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32844. }
  32845. if m.id == nil || m.oldValue == nil {
  32846. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32847. }
  32848. oldValue, err := m.oldValue(ctx)
  32849. if err != nil {
  32850. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32851. }
  32852. return oldValue.OrganizationID, nil
  32853. }
  32854. // AddOrganizationID adds u to the "organization_id" field.
  32855. func (m *TokenMutation) AddOrganizationID(u int64) {
  32856. if m.addorganization_id != nil {
  32857. *m.addorganization_id += u
  32858. } else {
  32859. m.addorganization_id = &u
  32860. }
  32861. }
  32862. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32863. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  32864. v := m.addorganization_id
  32865. if v == nil {
  32866. return
  32867. }
  32868. return *v, true
  32869. }
  32870. // ResetOrganizationID resets all changes to the "organization_id" field.
  32871. func (m *TokenMutation) ResetOrganizationID() {
  32872. m.organization_id = nil
  32873. m.addorganization_id = nil
  32874. }
  32875. // SetAgentID sets the "agent_id" field.
  32876. func (m *TokenMutation) SetAgentID(u uint64) {
  32877. m.agent = &u
  32878. }
  32879. // AgentID returns the value of the "agent_id" field in the mutation.
  32880. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  32881. v := m.agent
  32882. if v == nil {
  32883. return
  32884. }
  32885. return *v, true
  32886. }
  32887. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  32888. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32890. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32891. if !m.op.Is(OpUpdateOne) {
  32892. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32893. }
  32894. if m.id == nil || m.oldValue == nil {
  32895. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32896. }
  32897. oldValue, err := m.oldValue(ctx)
  32898. if err != nil {
  32899. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32900. }
  32901. return oldValue.AgentID, nil
  32902. }
  32903. // ResetAgentID resets all changes to the "agent_id" field.
  32904. func (m *TokenMutation) ResetAgentID() {
  32905. m.agent = nil
  32906. }
  32907. // SetCustomAgentBase sets the "custom_agent_base" field.
  32908. func (m *TokenMutation) SetCustomAgentBase(s string) {
  32909. m.custom_agent_base = &s
  32910. }
  32911. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  32912. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  32913. v := m.custom_agent_base
  32914. if v == nil {
  32915. return
  32916. }
  32917. return *v, true
  32918. }
  32919. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  32920. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32922. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  32923. if !m.op.Is(OpUpdateOne) {
  32924. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  32925. }
  32926. if m.id == nil || m.oldValue == nil {
  32927. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  32928. }
  32929. oldValue, err := m.oldValue(ctx)
  32930. if err != nil {
  32931. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  32932. }
  32933. return oldValue.CustomAgentBase, nil
  32934. }
  32935. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  32936. func (m *TokenMutation) ClearCustomAgentBase() {
  32937. m.custom_agent_base = nil
  32938. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  32939. }
  32940. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  32941. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  32942. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  32943. return ok
  32944. }
  32945. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  32946. func (m *TokenMutation) ResetCustomAgentBase() {
  32947. m.custom_agent_base = nil
  32948. delete(m.clearedFields, token.FieldCustomAgentBase)
  32949. }
  32950. // SetCustomAgentKey sets the "custom_agent_key" field.
  32951. func (m *TokenMutation) SetCustomAgentKey(s string) {
  32952. m.custom_agent_key = &s
  32953. }
  32954. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  32955. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  32956. v := m.custom_agent_key
  32957. if v == nil {
  32958. return
  32959. }
  32960. return *v, true
  32961. }
  32962. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  32963. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32965. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  32966. if !m.op.Is(OpUpdateOne) {
  32967. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  32968. }
  32969. if m.id == nil || m.oldValue == nil {
  32970. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  32971. }
  32972. oldValue, err := m.oldValue(ctx)
  32973. if err != nil {
  32974. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  32975. }
  32976. return oldValue.CustomAgentKey, nil
  32977. }
  32978. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  32979. func (m *TokenMutation) ClearCustomAgentKey() {
  32980. m.custom_agent_key = nil
  32981. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  32982. }
  32983. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  32984. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  32985. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  32986. return ok
  32987. }
  32988. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  32989. func (m *TokenMutation) ResetCustomAgentKey() {
  32990. m.custom_agent_key = nil
  32991. delete(m.clearedFields, token.FieldCustomAgentKey)
  32992. }
  32993. // SetOpenaiBase sets the "openai_base" field.
  32994. func (m *TokenMutation) SetOpenaiBase(s string) {
  32995. m.openai_base = &s
  32996. }
  32997. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  32998. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  32999. v := m.openai_base
  33000. if v == nil {
  33001. return
  33002. }
  33003. return *v, true
  33004. }
  33005. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  33006. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  33007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33008. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  33009. if !m.op.Is(OpUpdateOne) {
  33010. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  33011. }
  33012. if m.id == nil || m.oldValue == nil {
  33013. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  33014. }
  33015. oldValue, err := m.oldValue(ctx)
  33016. if err != nil {
  33017. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  33018. }
  33019. return oldValue.OpenaiBase, nil
  33020. }
  33021. // ClearOpenaiBase clears the value of the "openai_base" field.
  33022. func (m *TokenMutation) ClearOpenaiBase() {
  33023. m.openai_base = nil
  33024. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  33025. }
  33026. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  33027. func (m *TokenMutation) OpenaiBaseCleared() bool {
  33028. _, ok := m.clearedFields[token.FieldOpenaiBase]
  33029. return ok
  33030. }
  33031. // ResetOpenaiBase resets all changes to the "openai_base" field.
  33032. func (m *TokenMutation) ResetOpenaiBase() {
  33033. m.openai_base = nil
  33034. delete(m.clearedFields, token.FieldOpenaiBase)
  33035. }
  33036. // SetOpenaiKey sets the "openai_key" field.
  33037. func (m *TokenMutation) SetOpenaiKey(s string) {
  33038. m.openai_key = &s
  33039. }
  33040. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  33041. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  33042. v := m.openai_key
  33043. if v == nil {
  33044. return
  33045. }
  33046. return *v, true
  33047. }
  33048. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  33049. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  33050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33051. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  33052. if !m.op.Is(OpUpdateOne) {
  33053. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  33054. }
  33055. if m.id == nil || m.oldValue == nil {
  33056. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  33057. }
  33058. oldValue, err := m.oldValue(ctx)
  33059. if err != nil {
  33060. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  33061. }
  33062. return oldValue.OpenaiKey, nil
  33063. }
  33064. // ClearOpenaiKey clears the value of the "openai_key" field.
  33065. func (m *TokenMutation) ClearOpenaiKey() {
  33066. m.openai_key = nil
  33067. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  33068. }
  33069. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  33070. func (m *TokenMutation) OpenaiKeyCleared() bool {
  33071. _, ok := m.clearedFields[token.FieldOpenaiKey]
  33072. return ok
  33073. }
  33074. // ResetOpenaiKey resets all changes to the "openai_key" field.
  33075. func (m *TokenMutation) ResetOpenaiKey() {
  33076. m.openai_key = nil
  33077. delete(m.clearedFields, token.FieldOpenaiKey)
  33078. }
  33079. // ClearAgent clears the "agent" edge to the Agent entity.
  33080. func (m *TokenMutation) ClearAgent() {
  33081. m.clearedagent = true
  33082. m.clearedFields[token.FieldAgentID] = struct{}{}
  33083. }
  33084. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  33085. func (m *TokenMutation) AgentCleared() bool {
  33086. return m.clearedagent
  33087. }
  33088. // AgentIDs returns the "agent" edge IDs in the mutation.
  33089. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33090. // AgentID instead. It exists only for internal usage by the builders.
  33091. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  33092. if id := m.agent; id != nil {
  33093. ids = append(ids, *id)
  33094. }
  33095. return
  33096. }
  33097. // ResetAgent resets all changes to the "agent" edge.
  33098. func (m *TokenMutation) ResetAgent() {
  33099. m.agent = nil
  33100. m.clearedagent = false
  33101. }
  33102. // Where appends a list predicates to the TokenMutation builder.
  33103. func (m *TokenMutation) Where(ps ...predicate.Token) {
  33104. m.predicates = append(m.predicates, ps...)
  33105. }
  33106. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  33107. // users can use type-assertion to append predicates that do not depend on any generated package.
  33108. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  33109. p := make([]predicate.Token, len(ps))
  33110. for i := range ps {
  33111. p[i] = ps[i]
  33112. }
  33113. m.Where(p...)
  33114. }
  33115. // Op returns the operation name.
  33116. func (m *TokenMutation) Op() Op {
  33117. return m.op
  33118. }
  33119. // SetOp allows setting the mutation operation.
  33120. func (m *TokenMutation) SetOp(op Op) {
  33121. m.op = op
  33122. }
  33123. // Type returns the node type of this mutation (Token).
  33124. func (m *TokenMutation) Type() string {
  33125. return m.typ
  33126. }
  33127. // Fields returns all fields that were changed during this mutation. Note that in
  33128. // order to get all numeric fields that were incremented/decremented, call
  33129. // AddedFields().
  33130. func (m *TokenMutation) Fields() []string {
  33131. fields := make([]string, 0, 12)
  33132. if m.created_at != nil {
  33133. fields = append(fields, token.FieldCreatedAt)
  33134. }
  33135. if m.updated_at != nil {
  33136. fields = append(fields, token.FieldUpdatedAt)
  33137. }
  33138. if m.deleted_at != nil {
  33139. fields = append(fields, token.FieldDeletedAt)
  33140. }
  33141. if m.expire_at != nil {
  33142. fields = append(fields, token.FieldExpireAt)
  33143. }
  33144. if m.token != nil {
  33145. fields = append(fields, token.FieldToken)
  33146. }
  33147. if m.mac != nil {
  33148. fields = append(fields, token.FieldMAC)
  33149. }
  33150. if m.organization_id != nil {
  33151. fields = append(fields, token.FieldOrganizationID)
  33152. }
  33153. if m.agent != nil {
  33154. fields = append(fields, token.FieldAgentID)
  33155. }
  33156. if m.custom_agent_base != nil {
  33157. fields = append(fields, token.FieldCustomAgentBase)
  33158. }
  33159. if m.custom_agent_key != nil {
  33160. fields = append(fields, token.FieldCustomAgentKey)
  33161. }
  33162. if m.openai_base != nil {
  33163. fields = append(fields, token.FieldOpenaiBase)
  33164. }
  33165. if m.openai_key != nil {
  33166. fields = append(fields, token.FieldOpenaiKey)
  33167. }
  33168. return fields
  33169. }
  33170. // Field returns the value of a field with the given name. The second boolean
  33171. // return value indicates that this field was not set, or was not defined in the
  33172. // schema.
  33173. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  33174. switch name {
  33175. case token.FieldCreatedAt:
  33176. return m.CreatedAt()
  33177. case token.FieldUpdatedAt:
  33178. return m.UpdatedAt()
  33179. case token.FieldDeletedAt:
  33180. return m.DeletedAt()
  33181. case token.FieldExpireAt:
  33182. return m.ExpireAt()
  33183. case token.FieldToken:
  33184. return m.Token()
  33185. case token.FieldMAC:
  33186. return m.MAC()
  33187. case token.FieldOrganizationID:
  33188. return m.OrganizationID()
  33189. case token.FieldAgentID:
  33190. return m.AgentID()
  33191. case token.FieldCustomAgentBase:
  33192. return m.CustomAgentBase()
  33193. case token.FieldCustomAgentKey:
  33194. return m.CustomAgentKey()
  33195. case token.FieldOpenaiBase:
  33196. return m.OpenaiBase()
  33197. case token.FieldOpenaiKey:
  33198. return m.OpenaiKey()
  33199. }
  33200. return nil, false
  33201. }
  33202. // OldField returns the old value of the field from the database. An error is
  33203. // returned if the mutation operation is not UpdateOne, or the query to the
  33204. // database failed.
  33205. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33206. switch name {
  33207. case token.FieldCreatedAt:
  33208. return m.OldCreatedAt(ctx)
  33209. case token.FieldUpdatedAt:
  33210. return m.OldUpdatedAt(ctx)
  33211. case token.FieldDeletedAt:
  33212. return m.OldDeletedAt(ctx)
  33213. case token.FieldExpireAt:
  33214. return m.OldExpireAt(ctx)
  33215. case token.FieldToken:
  33216. return m.OldToken(ctx)
  33217. case token.FieldMAC:
  33218. return m.OldMAC(ctx)
  33219. case token.FieldOrganizationID:
  33220. return m.OldOrganizationID(ctx)
  33221. case token.FieldAgentID:
  33222. return m.OldAgentID(ctx)
  33223. case token.FieldCustomAgentBase:
  33224. return m.OldCustomAgentBase(ctx)
  33225. case token.FieldCustomAgentKey:
  33226. return m.OldCustomAgentKey(ctx)
  33227. case token.FieldOpenaiBase:
  33228. return m.OldOpenaiBase(ctx)
  33229. case token.FieldOpenaiKey:
  33230. return m.OldOpenaiKey(ctx)
  33231. }
  33232. return nil, fmt.Errorf("unknown Token field %s", name)
  33233. }
  33234. // SetField sets the value of a field with the given name. It returns an error if
  33235. // the field is not defined in the schema, or if the type mismatched the field
  33236. // type.
  33237. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  33238. switch name {
  33239. case token.FieldCreatedAt:
  33240. v, ok := value.(time.Time)
  33241. if !ok {
  33242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33243. }
  33244. m.SetCreatedAt(v)
  33245. return nil
  33246. case token.FieldUpdatedAt:
  33247. v, ok := value.(time.Time)
  33248. if !ok {
  33249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33250. }
  33251. m.SetUpdatedAt(v)
  33252. return nil
  33253. case token.FieldDeletedAt:
  33254. v, ok := value.(time.Time)
  33255. if !ok {
  33256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33257. }
  33258. m.SetDeletedAt(v)
  33259. return nil
  33260. case token.FieldExpireAt:
  33261. v, ok := value.(time.Time)
  33262. if !ok {
  33263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33264. }
  33265. m.SetExpireAt(v)
  33266. return nil
  33267. case token.FieldToken:
  33268. v, ok := value.(string)
  33269. if !ok {
  33270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33271. }
  33272. m.SetToken(v)
  33273. return nil
  33274. case token.FieldMAC:
  33275. v, ok := value.(string)
  33276. if !ok {
  33277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33278. }
  33279. m.SetMAC(v)
  33280. return nil
  33281. case token.FieldOrganizationID:
  33282. v, ok := value.(uint64)
  33283. if !ok {
  33284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33285. }
  33286. m.SetOrganizationID(v)
  33287. return nil
  33288. case token.FieldAgentID:
  33289. v, ok := value.(uint64)
  33290. if !ok {
  33291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33292. }
  33293. m.SetAgentID(v)
  33294. return nil
  33295. case token.FieldCustomAgentBase:
  33296. v, ok := value.(string)
  33297. if !ok {
  33298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33299. }
  33300. m.SetCustomAgentBase(v)
  33301. return nil
  33302. case token.FieldCustomAgentKey:
  33303. v, ok := value.(string)
  33304. if !ok {
  33305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33306. }
  33307. m.SetCustomAgentKey(v)
  33308. return nil
  33309. case token.FieldOpenaiBase:
  33310. v, ok := value.(string)
  33311. if !ok {
  33312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33313. }
  33314. m.SetOpenaiBase(v)
  33315. return nil
  33316. case token.FieldOpenaiKey:
  33317. v, ok := value.(string)
  33318. if !ok {
  33319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33320. }
  33321. m.SetOpenaiKey(v)
  33322. return nil
  33323. }
  33324. return fmt.Errorf("unknown Token field %s", name)
  33325. }
  33326. // AddedFields returns all numeric fields that were incremented/decremented during
  33327. // this mutation.
  33328. func (m *TokenMutation) AddedFields() []string {
  33329. var fields []string
  33330. if m.addorganization_id != nil {
  33331. fields = append(fields, token.FieldOrganizationID)
  33332. }
  33333. return fields
  33334. }
  33335. // AddedField returns the numeric value that was incremented/decremented on a field
  33336. // with the given name. The second boolean return value indicates that this field
  33337. // was not set, or was not defined in the schema.
  33338. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  33339. switch name {
  33340. case token.FieldOrganizationID:
  33341. return m.AddedOrganizationID()
  33342. }
  33343. return nil, false
  33344. }
  33345. // AddField adds the value to the field with the given name. It returns an error if
  33346. // the field is not defined in the schema, or if the type mismatched the field
  33347. // type.
  33348. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  33349. switch name {
  33350. case token.FieldOrganizationID:
  33351. v, ok := value.(int64)
  33352. if !ok {
  33353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33354. }
  33355. m.AddOrganizationID(v)
  33356. return nil
  33357. }
  33358. return fmt.Errorf("unknown Token numeric field %s", name)
  33359. }
  33360. // ClearedFields returns all nullable fields that were cleared during this
  33361. // mutation.
  33362. func (m *TokenMutation) ClearedFields() []string {
  33363. var fields []string
  33364. if m.FieldCleared(token.FieldDeletedAt) {
  33365. fields = append(fields, token.FieldDeletedAt)
  33366. }
  33367. if m.FieldCleared(token.FieldExpireAt) {
  33368. fields = append(fields, token.FieldExpireAt)
  33369. }
  33370. if m.FieldCleared(token.FieldToken) {
  33371. fields = append(fields, token.FieldToken)
  33372. }
  33373. if m.FieldCleared(token.FieldMAC) {
  33374. fields = append(fields, token.FieldMAC)
  33375. }
  33376. if m.FieldCleared(token.FieldCustomAgentBase) {
  33377. fields = append(fields, token.FieldCustomAgentBase)
  33378. }
  33379. if m.FieldCleared(token.FieldCustomAgentKey) {
  33380. fields = append(fields, token.FieldCustomAgentKey)
  33381. }
  33382. if m.FieldCleared(token.FieldOpenaiBase) {
  33383. fields = append(fields, token.FieldOpenaiBase)
  33384. }
  33385. if m.FieldCleared(token.FieldOpenaiKey) {
  33386. fields = append(fields, token.FieldOpenaiKey)
  33387. }
  33388. return fields
  33389. }
  33390. // FieldCleared returns a boolean indicating if a field with the given name was
  33391. // cleared in this mutation.
  33392. func (m *TokenMutation) FieldCleared(name string) bool {
  33393. _, ok := m.clearedFields[name]
  33394. return ok
  33395. }
  33396. // ClearField clears the value of the field with the given name. It returns an
  33397. // error if the field is not defined in the schema.
  33398. func (m *TokenMutation) ClearField(name string) error {
  33399. switch name {
  33400. case token.FieldDeletedAt:
  33401. m.ClearDeletedAt()
  33402. return nil
  33403. case token.FieldExpireAt:
  33404. m.ClearExpireAt()
  33405. return nil
  33406. case token.FieldToken:
  33407. m.ClearToken()
  33408. return nil
  33409. case token.FieldMAC:
  33410. m.ClearMAC()
  33411. return nil
  33412. case token.FieldCustomAgentBase:
  33413. m.ClearCustomAgentBase()
  33414. return nil
  33415. case token.FieldCustomAgentKey:
  33416. m.ClearCustomAgentKey()
  33417. return nil
  33418. case token.FieldOpenaiBase:
  33419. m.ClearOpenaiBase()
  33420. return nil
  33421. case token.FieldOpenaiKey:
  33422. m.ClearOpenaiKey()
  33423. return nil
  33424. }
  33425. return fmt.Errorf("unknown Token nullable field %s", name)
  33426. }
  33427. // ResetField resets all changes in the mutation for the field with the given name.
  33428. // It returns an error if the field is not defined in the schema.
  33429. func (m *TokenMutation) ResetField(name string) error {
  33430. switch name {
  33431. case token.FieldCreatedAt:
  33432. m.ResetCreatedAt()
  33433. return nil
  33434. case token.FieldUpdatedAt:
  33435. m.ResetUpdatedAt()
  33436. return nil
  33437. case token.FieldDeletedAt:
  33438. m.ResetDeletedAt()
  33439. return nil
  33440. case token.FieldExpireAt:
  33441. m.ResetExpireAt()
  33442. return nil
  33443. case token.FieldToken:
  33444. m.ResetToken()
  33445. return nil
  33446. case token.FieldMAC:
  33447. m.ResetMAC()
  33448. return nil
  33449. case token.FieldOrganizationID:
  33450. m.ResetOrganizationID()
  33451. return nil
  33452. case token.FieldAgentID:
  33453. m.ResetAgentID()
  33454. return nil
  33455. case token.FieldCustomAgentBase:
  33456. m.ResetCustomAgentBase()
  33457. return nil
  33458. case token.FieldCustomAgentKey:
  33459. m.ResetCustomAgentKey()
  33460. return nil
  33461. case token.FieldOpenaiBase:
  33462. m.ResetOpenaiBase()
  33463. return nil
  33464. case token.FieldOpenaiKey:
  33465. m.ResetOpenaiKey()
  33466. return nil
  33467. }
  33468. return fmt.Errorf("unknown Token field %s", name)
  33469. }
  33470. // AddedEdges returns all edge names that were set/added in this mutation.
  33471. func (m *TokenMutation) AddedEdges() []string {
  33472. edges := make([]string, 0, 1)
  33473. if m.agent != nil {
  33474. edges = append(edges, token.EdgeAgent)
  33475. }
  33476. return edges
  33477. }
  33478. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33479. // name in this mutation.
  33480. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  33481. switch name {
  33482. case token.EdgeAgent:
  33483. if id := m.agent; id != nil {
  33484. return []ent.Value{*id}
  33485. }
  33486. }
  33487. return nil
  33488. }
  33489. // RemovedEdges returns all edge names that were removed in this mutation.
  33490. func (m *TokenMutation) RemovedEdges() []string {
  33491. edges := make([]string, 0, 1)
  33492. return edges
  33493. }
  33494. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33495. // the given name in this mutation.
  33496. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  33497. return nil
  33498. }
  33499. // ClearedEdges returns all edge names that were cleared in this mutation.
  33500. func (m *TokenMutation) ClearedEdges() []string {
  33501. edges := make([]string, 0, 1)
  33502. if m.clearedagent {
  33503. edges = append(edges, token.EdgeAgent)
  33504. }
  33505. return edges
  33506. }
  33507. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33508. // was cleared in this mutation.
  33509. func (m *TokenMutation) EdgeCleared(name string) bool {
  33510. switch name {
  33511. case token.EdgeAgent:
  33512. return m.clearedagent
  33513. }
  33514. return false
  33515. }
  33516. // ClearEdge clears the value of the edge with the given name. It returns an error
  33517. // if that edge is not defined in the schema.
  33518. func (m *TokenMutation) ClearEdge(name string) error {
  33519. switch name {
  33520. case token.EdgeAgent:
  33521. m.ClearAgent()
  33522. return nil
  33523. }
  33524. return fmt.Errorf("unknown Token unique edge %s", name)
  33525. }
  33526. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33527. // It returns an error if the edge is not defined in the schema.
  33528. func (m *TokenMutation) ResetEdge(name string) error {
  33529. switch name {
  33530. case token.EdgeAgent:
  33531. m.ResetAgent()
  33532. return nil
  33533. }
  33534. return fmt.Errorf("unknown Token edge %s", name)
  33535. }
  33536. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  33537. type TutorialMutation struct {
  33538. config
  33539. op Op
  33540. typ string
  33541. id *uint64
  33542. created_at *time.Time
  33543. updated_at *time.Time
  33544. deleted_at *time.Time
  33545. index *int
  33546. addindex *int
  33547. title *string
  33548. content *string
  33549. organization_id *uint64
  33550. addorganization_id *int64
  33551. clearedFields map[string]struct{}
  33552. employee *uint64
  33553. clearedemployee bool
  33554. done bool
  33555. oldValue func(context.Context) (*Tutorial, error)
  33556. predicates []predicate.Tutorial
  33557. }
  33558. var _ ent.Mutation = (*TutorialMutation)(nil)
  33559. // tutorialOption allows management of the mutation configuration using functional options.
  33560. type tutorialOption func(*TutorialMutation)
  33561. // newTutorialMutation creates new mutation for the Tutorial entity.
  33562. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  33563. m := &TutorialMutation{
  33564. config: c,
  33565. op: op,
  33566. typ: TypeTutorial,
  33567. clearedFields: make(map[string]struct{}),
  33568. }
  33569. for _, opt := range opts {
  33570. opt(m)
  33571. }
  33572. return m
  33573. }
  33574. // withTutorialID sets the ID field of the mutation.
  33575. func withTutorialID(id uint64) tutorialOption {
  33576. return func(m *TutorialMutation) {
  33577. var (
  33578. err error
  33579. once sync.Once
  33580. value *Tutorial
  33581. )
  33582. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  33583. once.Do(func() {
  33584. if m.done {
  33585. err = errors.New("querying old values post mutation is not allowed")
  33586. } else {
  33587. value, err = m.Client().Tutorial.Get(ctx, id)
  33588. }
  33589. })
  33590. return value, err
  33591. }
  33592. m.id = &id
  33593. }
  33594. }
  33595. // withTutorial sets the old Tutorial of the mutation.
  33596. func withTutorial(node *Tutorial) tutorialOption {
  33597. return func(m *TutorialMutation) {
  33598. m.oldValue = func(context.Context) (*Tutorial, error) {
  33599. return node, nil
  33600. }
  33601. m.id = &node.ID
  33602. }
  33603. }
  33604. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33605. // executed in a transaction (ent.Tx), a transactional client is returned.
  33606. func (m TutorialMutation) Client() *Client {
  33607. client := &Client{config: m.config}
  33608. client.init()
  33609. return client
  33610. }
  33611. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33612. // it returns an error otherwise.
  33613. func (m TutorialMutation) Tx() (*Tx, error) {
  33614. if _, ok := m.driver.(*txDriver); !ok {
  33615. return nil, errors.New("ent: mutation is not running in a transaction")
  33616. }
  33617. tx := &Tx{config: m.config}
  33618. tx.init()
  33619. return tx, nil
  33620. }
  33621. // SetID sets the value of the id field. Note that this
  33622. // operation is only accepted on creation of Tutorial entities.
  33623. func (m *TutorialMutation) SetID(id uint64) {
  33624. m.id = &id
  33625. }
  33626. // ID returns the ID value in the mutation. Note that the ID is only available
  33627. // if it was provided to the builder or after it was returned from the database.
  33628. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  33629. if m.id == nil {
  33630. return
  33631. }
  33632. return *m.id, true
  33633. }
  33634. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33635. // That means, if the mutation is applied within a transaction with an isolation level such
  33636. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33637. // or updated by the mutation.
  33638. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  33639. switch {
  33640. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33641. id, exists := m.ID()
  33642. if exists {
  33643. return []uint64{id}, nil
  33644. }
  33645. fallthrough
  33646. case m.op.Is(OpUpdate | OpDelete):
  33647. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  33648. default:
  33649. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33650. }
  33651. }
  33652. // SetCreatedAt sets the "created_at" field.
  33653. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  33654. m.created_at = &t
  33655. }
  33656. // CreatedAt returns the value of the "created_at" field in the mutation.
  33657. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  33658. v := m.created_at
  33659. if v == nil {
  33660. return
  33661. }
  33662. return *v, true
  33663. }
  33664. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  33665. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33667. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33668. if !m.op.Is(OpUpdateOne) {
  33669. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33670. }
  33671. if m.id == nil || m.oldValue == nil {
  33672. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33673. }
  33674. oldValue, err := m.oldValue(ctx)
  33675. if err != nil {
  33676. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33677. }
  33678. return oldValue.CreatedAt, nil
  33679. }
  33680. // ResetCreatedAt resets all changes to the "created_at" field.
  33681. func (m *TutorialMutation) ResetCreatedAt() {
  33682. m.created_at = nil
  33683. }
  33684. // SetUpdatedAt sets the "updated_at" field.
  33685. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  33686. m.updated_at = &t
  33687. }
  33688. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33689. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  33690. v := m.updated_at
  33691. if v == nil {
  33692. return
  33693. }
  33694. return *v, true
  33695. }
  33696. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  33697. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33699. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33700. if !m.op.Is(OpUpdateOne) {
  33701. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33702. }
  33703. if m.id == nil || m.oldValue == nil {
  33704. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33705. }
  33706. oldValue, err := m.oldValue(ctx)
  33707. if err != nil {
  33708. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33709. }
  33710. return oldValue.UpdatedAt, nil
  33711. }
  33712. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33713. func (m *TutorialMutation) ResetUpdatedAt() {
  33714. m.updated_at = nil
  33715. }
  33716. // SetDeletedAt sets the "deleted_at" field.
  33717. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  33718. m.deleted_at = &t
  33719. }
  33720. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33721. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  33722. v := m.deleted_at
  33723. if v == nil {
  33724. return
  33725. }
  33726. return *v, true
  33727. }
  33728. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  33729. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33731. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33732. if !m.op.Is(OpUpdateOne) {
  33733. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33734. }
  33735. if m.id == nil || m.oldValue == nil {
  33736. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33737. }
  33738. oldValue, err := m.oldValue(ctx)
  33739. if err != nil {
  33740. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33741. }
  33742. return oldValue.DeletedAt, nil
  33743. }
  33744. // ClearDeletedAt clears the value of the "deleted_at" field.
  33745. func (m *TutorialMutation) ClearDeletedAt() {
  33746. m.deleted_at = nil
  33747. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  33748. }
  33749. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33750. func (m *TutorialMutation) DeletedAtCleared() bool {
  33751. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  33752. return ok
  33753. }
  33754. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33755. func (m *TutorialMutation) ResetDeletedAt() {
  33756. m.deleted_at = nil
  33757. delete(m.clearedFields, tutorial.FieldDeletedAt)
  33758. }
  33759. // SetEmployeeID sets the "employee_id" field.
  33760. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  33761. m.employee = &u
  33762. }
  33763. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33764. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  33765. v := m.employee
  33766. if v == nil {
  33767. return
  33768. }
  33769. return *v, true
  33770. }
  33771. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  33772. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33774. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33775. if !m.op.Is(OpUpdateOne) {
  33776. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33777. }
  33778. if m.id == nil || m.oldValue == nil {
  33779. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33780. }
  33781. oldValue, err := m.oldValue(ctx)
  33782. if err != nil {
  33783. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33784. }
  33785. return oldValue.EmployeeID, nil
  33786. }
  33787. // ResetEmployeeID resets all changes to the "employee_id" field.
  33788. func (m *TutorialMutation) ResetEmployeeID() {
  33789. m.employee = nil
  33790. }
  33791. // SetIndex sets the "index" field.
  33792. func (m *TutorialMutation) SetIndex(i int) {
  33793. m.index = &i
  33794. m.addindex = nil
  33795. }
  33796. // Index returns the value of the "index" field in the mutation.
  33797. func (m *TutorialMutation) Index() (r int, exists bool) {
  33798. v := m.index
  33799. if v == nil {
  33800. return
  33801. }
  33802. return *v, true
  33803. }
  33804. // OldIndex returns the old "index" field's value of the Tutorial entity.
  33805. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33807. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  33808. if !m.op.Is(OpUpdateOne) {
  33809. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  33810. }
  33811. if m.id == nil || m.oldValue == nil {
  33812. return v, errors.New("OldIndex requires an ID field in the mutation")
  33813. }
  33814. oldValue, err := m.oldValue(ctx)
  33815. if err != nil {
  33816. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  33817. }
  33818. return oldValue.Index, nil
  33819. }
  33820. // AddIndex adds i to the "index" field.
  33821. func (m *TutorialMutation) AddIndex(i int) {
  33822. if m.addindex != nil {
  33823. *m.addindex += i
  33824. } else {
  33825. m.addindex = &i
  33826. }
  33827. }
  33828. // AddedIndex returns the value that was added to the "index" field in this mutation.
  33829. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  33830. v := m.addindex
  33831. if v == nil {
  33832. return
  33833. }
  33834. return *v, true
  33835. }
  33836. // ResetIndex resets all changes to the "index" field.
  33837. func (m *TutorialMutation) ResetIndex() {
  33838. m.index = nil
  33839. m.addindex = nil
  33840. }
  33841. // SetTitle sets the "title" field.
  33842. func (m *TutorialMutation) SetTitle(s string) {
  33843. m.title = &s
  33844. }
  33845. // Title returns the value of the "title" field in the mutation.
  33846. func (m *TutorialMutation) Title() (r string, exists bool) {
  33847. v := m.title
  33848. if v == nil {
  33849. return
  33850. }
  33851. return *v, true
  33852. }
  33853. // OldTitle returns the old "title" field's value of the Tutorial entity.
  33854. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33856. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  33857. if !m.op.Is(OpUpdateOne) {
  33858. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  33859. }
  33860. if m.id == nil || m.oldValue == nil {
  33861. return v, errors.New("OldTitle requires an ID field in the mutation")
  33862. }
  33863. oldValue, err := m.oldValue(ctx)
  33864. if err != nil {
  33865. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  33866. }
  33867. return oldValue.Title, nil
  33868. }
  33869. // ResetTitle resets all changes to the "title" field.
  33870. func (m *TutorialMutation) ResetTitle() {
  33871. m.title = nil
  33872. }
  33873. // SetContent sets the "content" field.
  33874. func (m *TutorialMutation) SetContent(s string) {
  33875. m.content = &s
  33876. }
  33877. // Content returns the value of the "content" field in the mutation.
  33878. func (m *TutorialMutation) Content() (r string, exists bool) {
  33879. v := m.content
  33880. if v == nil {
  33881. return
  33882. }
  33883. return *v, true
  33884. }
  33885. // OldContent returns the old "content" field's value of the Tutorial entity.
  33886. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33888. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  33889. if !m.op.Is(OpUpdateOne) {
  33890. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  33891. }
  33892. if m.id == nil || m.oldValue == nil {
  33893. return v, errors.New("OldContent requires an ID field in the mutation")
  33894. }
  33895. oldValue, err := m.oldValue(ctx)
  33896. if err != nil {
  33897. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  33898. }
  33899. return oldValue.Content, nil
  33900. }
  33901. // ResetContent resets all changes to the "content" field.
  33902. func (m *TutorialMutation) ResetContent() {
  33903. m.content = nil
  33904. }
  33905. // SetOrganizationID sets the "organization_id" field.
  33906. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  33907. m.organization_id = &u
  33908. m.addorganization_id = nil
  33909. }
  33910. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33911. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  33912. v := m.organization_id
  33913. if v == nil {
  33914. return
  33915. }
  33916. return *v, true
  33917. }
  33918. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  33919. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33921. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33922. if !m.op.Is(OpUpdateOne) {
  33923. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33924. }
  33925. if m.id == nil || m.oldValue == nil {
  33926. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33927. }
  33928. oldValue, err := m.oldValue(ctx)
  33929. if err != nil {
  33930. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33931. }
  33932. return oldValue.OrganizationID, nil
  33933. }
  33934. // AddOrganizationID adds u to the "organization_id" field.
  33935. func (m *TutorialMutation) AddOrganizationID(u int64) {
  33936. if m.addorganization_id != nil {
  33937. *m.addorganization_id += u
  33938. } else {
  33939. m.addorganization_id = &u
  33940. }
  33941. }
  33942. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33943. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  33944. v := m.addorganization_id
  33945. if v == nil {
  33946. return
  33947. }
  33948. return *v, true
  33949. }
  33950. // ResetOrganizationID resets all changes to the "organization_id" field.
  33951. func (m *TutorialMutation) ResetOrganizationID() {
  33952. m.organization_id = nil
  33953. m.addorganization_id = nil
  33954. }
  33955. // ClearEmployee clears the "employee" edge to the Employee entity.
  33956. func (m *TutorialMutation) ClearEmployee() {
  33957. m.clearedemployee = true
  33958. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  33959. }
  33960. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  33961. func (m *TutorialMutation) EmployeeCleared() bool {
  33962. return m.clearedemployee
  33963. }
  33964. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  33965. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33966. // EmployeeID instead. It exists only for internal usage by the builders.
  33967. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  33968. if id := m.employee; id != nil {
  33969. ids = append(ids, *id)
  33970. }
  33971. return
  33972. }
  33973. // ResetEmployee resets all changes to the "employee" edge.
  33974. func (m *TutorialMutation) ResetEmployee() {
  33975. m.employee = nil
  33976. m.clearedemployee = false
  33977. }
  33978. // Where appends a list predicates to the TutorialMutation builder.
  33979. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  33980. m.predicates = append(m.predicates, ps...)
  33981. }
  33982. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  33983. // users can use type-assertion to append predicates that do not depend on any generated package.
  33984. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  33985. p := make([]predicate.Tutorial, len(ps))
  33986. for i := range ps {
  33987. p[i] = ps[i]
  33988. }
  33989. m.Where(p...)
  33990. }
  33991. // Op returns the operation name.
  33992. func (m *TutorialMutation) Op() Op {
  33993. return m.op
  33994. }
  33995. // SetOp allows setting the mutation operation.
  33996. func (m *TutorialMutation) SetOp(op Op) {
  33997. m.op = op
  33998. }
  33999. // Type returns the node type of this mutation (Tutorial).
  34000. func (m *TutorialMutation) Type() string {
  34001. return m.typ
  34002. }
  34003. // Fields returns all fields that were changed during this mutation. Note that in
  34004. // order to get all numeric fields that were incremented/decremented, call
  34005. // AddedFields().
  34006. func (m *TutorialMutation) Fields() []string {
  34007. fields := make([]string, 0, 8)
  34008. if m.created_at != nil {
  34009. fields = append(fields, tutorial.FieldCreatedAt)
  34010. }
  34011. if m.updated_at != nil {
  34012. fields = append(fields, tutorial.FieldUpdatedAt)
  34013. }
  34014. if m.deleted_at != nil {
  34015. fields = append(fields, tutorial.FieldDeletedAt)
  34016. }
  34017. if m.employee != nil {
  34018. fields = append(fields, tutorial.FieldEmployeeID)
  34019. }
  34020. if m.index != nil {
  34021. fields = append(fields, tutorial.FieldIndex)
  34022. }
  34023. if m.title != nil {
  34024. fields = append(fields, tutorial.FieldTitle)
  34025. }
  34026. if m.content != nil {
  34027. fields = append(fields, tutorial.FieldContent)
  34028. }
  34029. if m.organization_id != nil {
  34030. fields = append(fields, tutorial.FieldOrganizationID)
  34031. }
  34032. return fields
  34033. }
  34034. // Field returns the value of a field with the given name. The second boolean
  34035. // return value indicates that this field was not set, or was not defined in the
  34036. // schema.
  34037. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  34038. switch name {
  34039. case tutorial.FieldCreatedAt:
  34040. return m.CreatedAt()
  34041. case tutorial.FieldUpdatedAt:
  34042. return m.UpdatedAt()
  34043. case tutorial.FieldDeletedAt:
  34044. return m.DeletedAt()
  34045. case tutorial.FieldEmployeeID:
  34046. return m.EmployeeID()
  34047. case tutorial.FieldIndex:
  34048. return m.Index()
  34049. case tutorial.FieldTitle:
  34050. return m.Title()
  34051. case tutorial.FieldContent:
  34052. return m.Content()
  34053. case tutorial.FieldOrganizationID:
  34054. return m.OrganizationID()
  34055. }
  34056. return nil, false
  34057. }
  34058. // OldField returns the old value of the field from the database. An error is
  34059. // returned if the mutation operation is not UpdateOne, or the query to the
  34060. // database failed.
  34061. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34062. switch name {
  34063. case tutorial.FieldCreatedAt:
  34064. return m.OldCreatedAt(ctx)
  34065. case tutorial.FieldUpdatedAt:
  34066. return m.OldUpdatedAt(ctx)
  34067. case tutorial.FieldDeletedAt:
  34068. return m.OldDeletedAt(ctx)
  34069. case tutorial.FieldEmployeeID:
  34070. return m.OldEmployeeID(ctx)
  34071. case tutorial.FieldIndex:
  34072. return m.OldIndex(ctx)
  34073. case tutorial.FieldTitle:
  34074. return m.OldTitle(ctx)
  34075. case tutorial.FieldContent:
  34076. return m.OldContent(ctx)
  34077. case tutorial.FieldOrganizationID:
  34078. return m.OldOrganizationID(ctx)
  34079. }
  34080. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  34081. }
  34082. // SetField sets the value of a field with the given name. It returns an error if
  34083. // the field is not defined in the schema, or if the type mismatched the field
  34084. // type.
  34085. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  34086. switch name {
  34087. case tutorial.FieldCreatedAt:
  34088. v, ok := value.(time.Time)
  34089. if !ok {
  34090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34091. }
  34092. m.SetCreatedAt(v)
  34093. return nil
  34094. case tutorial.FieldUpdatedAt:
  34095. v, ok := value.(time.Time)
  34096. if !ok {
  34097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34098. }
  34099. m.SetUpdatedAt(v)
  34100. return nil
  34101. case tutorial.FieldDeletedAt:
  34102. v, ok := value.(time.Time)
  34103. if !ok {
  34104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34105. }
  34106. m.SetDeletedAt(v)
  34107. return nil
  34108. case tutorial.FieldEmployeeID:
  34109. v, ok := value.(uint64)
  34110. if !ok {
  34111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34112. }
  34113. m.SetEmployeeID(v)
  34114. return nil
  34115. case tutorial.FieldIndex:
  34116. v, ok := value.(int)
  34117. if !ok {
  34118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34119. }
  34120. m.SetIndex(v)
  34121. return nil
  34122. case tutorial.FieldTitle:
  34123. v, ok := value.(string)
  34124. if !ok {
  34125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34126. }
  34127. m.SetTitle(v)
  34128. return nil
  34129. case tutorial.FieldContent:
  34130. v, ok := value.(string)
  34131. if !ok {
  34132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34133. }
  34134. m.SetContent(v)
  34135. return nil
  34136. case tutorial.FieldOrganizationID:
  34137. v, ok := value.(uint64)
  34138. if !ok {
  34139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34140. }
  34141. m.SetOrganizationID(v)
  34142. return nil
  34143. }
  34144. return fmt.Errorf("unknown Tutorial field %s", name)
  34145. }
  34146. // AddedFields returns all numeric fields that were incremented/decremented during
  34147. // this mutation.
  34148. func (m *TutorialMutation) AddedFields() []string {
  34149. var fields []string
  34150. if m.addindex != nil {
  34151. fields = append(fields, tutorial.FieldIndex)
  34152. }
  34153. if m.addorganization_id != nil {
  34154. fields = append(fields, tutorial.FieldOrganizationID)
  34155. }
  34156. return fields
  34157. }
  34158. // AddedField returns the numeric value that was incremented/decremented on a field
  34159. // with the given name. The second boolean return value indicates that this field
  34160. // was not set, or was not defined in the schema.
  34161. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  34162. switch name {
  34163. case tutorial.FieldIndex:
  34164. return m.AddedIndex()
  34165. case tutorial.FieldOrganizationID:
  34166. return m.AddedOrganizationID()
  34167. }
  34168. return nil, false
  34169. }
  34170. // AddField adds the value to the field with the given name. It returns an error if
  34171. // the field is not defined in the schema, or if the type mismatched the field
  34172. // type.
  34173. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  34174. switch name {
  34175. case tutorial.FieldIndex:
  34176. v, ok := value.(int)
  34177. if !ok {
  34178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34179. }
  34180. m.AddIndex(v)
  34181. return nil
  34182. case tutorial.FieldOrganizationID:
  34183. v, ok := value.(int64)
  34184. if !ok {
  34185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34186. }
  34187. m.AddOrganizationID(v)
  34188. return nil
  34189. }
  34190. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  34191. }
  34192. // ClearedFields returns all nullable fields that were cleared during this
  34193. // mutation.
  34194. func (m *TutorialMutation) ClearedFields() []string {
  34195. var fields []string
  34196. if m.FieldCleared(tutorial.FieldDeletedAt) {
  34197. fields = append(fields, tutorial.FieldDeletedAt)
  34198. }
  34199. return fields
  34200. }
  34201. // FieldCleared returns a boolean indicating if a field with the given name was
  34202. // cleared in this mutation.
  34203. func (m *TutorialMutation) FieldCleared(name string) bool {
  34204. _, ok := m.clearedFields[name]
  34205. return ok
  34206. }
  34207. // ClearField clears the value of the field with the given name. It returns an
  34208. // error if the field is not defined in the schema.
  34209. func (m *TutorialMutation) ClearField(name string) error {
  34210. switch name {
  34211. case tutorial.FieldDeletedAt:
  34212. m.ClearDeletedAt()
  34213. return nil
  34214. }
  34215. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  34216. }
  34217. // ResetField resets all changes in the mutation for the field with the given name.
  34218. // It returns an error if the field is not defined in the schema.
  34219. func (m *TutorialMutation) ResetField(name string) error {
  34220. switch name {
  34221. case tutorial.FieldCreatedAt:
  34222. m.ResetCreatedAt()
  34223. return nil
  34224. case tutorial.FieldUpdatedAt:
  34225. m.ResetUpdatedAt()
  34226. return nil
  34227. case tutorial.FieldDeletedAt:
  34228. m.ResetDeletedAt()
  34229. return nil
  34230. case tutorial.FieldEmployeeID:
  34231. m.ResetEmployeeID()
  34232. return nil
  34233. case tutorial.FieldIndex:
  34234. m.ResetIndex()
  34235. return nil
  34236. case tutorial.FieldTitle:
  34237. m.ResetTitle()
  34238. return nil
  34239. case tutorial.FieldContent:
  34240. m.ResetContent()
  34241. return nil
  34242. case tutorial.FieldOrganizationID:
  34243. m.ResetOrganizationID()
  34244. return nil
  34245. }
  34246. return fmt.Errorf("unknown Tutorial field %s", name)
  34247. }
  34248. // AddedEdges returns all edge names that were set/added in this mutation.
  34249. func (m *TutorialMutation) AddedEdges() []string {
  34250. edges := make([]string, 0, 1)
  34251. if m.employee != nil {
  34252. edges = append(edges, tutorial.EdgeEmployee)
  34253. }
  34254. return edges
  34255. }
  34256. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34257. // name in this mutation.
  34258. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  34259. switch name {
  34260. case tutorial.EdgeEmployee:
  34261. if id := m.employee; id != nil {
  34262. return []ent.Value{*id}
  34263. }
  34264. }
  34265. return nil
  34266. }
  34267. // RemovedEdges returns all edge names that were removed in this mutation.
  34268. func (m *TutorialMutation) RemovedEdges() []string {
  34269. edges := make([]string, 0, 1)
  34270. return edges
  34271. }
  34272. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34273. // the given name in this mutation.
  34274. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  34275. return nil
  34276. }
  34277. // ClearedEdges returns all edge names that were cleared in this mutation.
  34278. func (m *TutorialMutation) ClearedEdges() []string {
  34279. edges := make([]string, 0, 1)
  34280. if m.clearedemployee {
  34281. edges = append(edges, tutorial.EdgeEmployee)
  34282. }
  34283. return edges
  34284. }
  34285. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34286. // was cleared in this mutation.
  34287. func (m *TutorialMutation) EdgeCleared(name string) bool {
  34288. switch name {
  34289. case tutorial.EdgeEmployee:
  34290. return m.clearedemployee
  34291. }
  34292. return false
  34293. }
  34294. // ClearEdge clears the value of the edge with the given name. It returns an error
  34295. // if that edge is not defined in the schema.
  34296. func (m *TutorialMutation) ClearEdge(name string) error {
  34297. switch name {
  34298. case tutorial.EdgeEmployee:
  34299. m.ClearEmployee()
  34300. return nil
  34301. }
  34302. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  34303. }
  34304. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34305. // It returns an error if the edge is not defined in the schema.
  34306. func (m *TutorialMutation) ResetEdge(name string) error {
  34307. switch name {
  34308. case tutorial.EdgeEmployee:
  34309. m.ResetEmployee()
  34310. return nil
  34311. }
  34312. return fmt.Errorf("unknown Tutorial edge %s", name)
  34313. }
  34314. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  34315. type UsageDetailMutation struct {
  34316. config
  34317. op Op
  34318. typ string
  34319. id *uint64
  34320. created_at *time.Time
  34321. updated_at *time.Time
  34322. status *uint8
  34323. addstatus *int8
  34324. _type *int
  34325. add_type *int
  34326. bot_id *string
  34327. receiver_id *string
  34328. app *int
  34329. addapp *int
  34330. session_id *uint64
  34331. addsession_id *int64
  34332. request *string
  34333. response *string
  34334. original_data *custom_types.OriginalData
  34335. total_tokens *uint64
  34336. addtotal_tokens *int64
  34337. prompt_tokens *uint64
  34338. addprompt_tokens *int64
  34339. completion_tokens *uint64
  34340. addcompletion_tokens *int64
  34341. organization_id *uint64
  34342. addorganization_id *int64
  34343. model *string
  34344. credits *float64
  34345. addcredits *float64
  34346. clearedFields map[string]struct{}
  34347. done bool
  34348. oldValue func(context.Context) (*UsageDetail, error)
  34349. predicates []predicate.UsageDetail
  34350. }
  34351. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  34352. // usagedetailOption allows management of the mutation configuration using functional options.
  34353. type usagedetailOption func(*UsageDetailMutation)
  34354. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  34355. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  34356. m := &UsageDetailMutation{
  34357. config: c,
  34358. op: op,
  34359. typ: TypeUsageDetail,
  34360. clearedFields: make(map[string]struct{}),
  34361. }
  34362. for _, opt := range opts {
  34363. opt(m)
  34364. }
  34365. return m
  34366. }
  34367. // withUsageDetailID sets the ID field of the mutation.
  34368. func withUsageDetailID(id uint64) usagedetailOption {
  34369. return func(m *UsageDetailMutation) {
  34370. var (
  34371. err error
  34372. once sync.Once
  34373. value *UsageDetail
  34374. )
  34375. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  34376. once.Do(func() {
  34377. if m.done {
  34378. err = errors.New("querying old values post mutation is not allowed")
  34379. } else {
  34380. value, err = m.Client().UsageDetail.Get(ctx, id)
  34381. }
  34382. })
  34383. return value, err
  34384. }
  34385. m.id = &id
  34386. }
  34387. }
  34388. // withUsageDetail sets the old UsageDetail of the mutation.
  34389. func withUsageDetail(node *UsageDetail) usagedetailOption {
  34390. return func(m *UsageDetailMutation) {
  34391. m.oldValue = func(context.Context) (*UsageDetail, error) {
  34392. return node, nil
  34393. }
  34394. m.id = &node.ID
  34395. }
  34396. }
  34397. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34398. // executed in a transaction (ent.Tx), a transactional client is returned.
  34399. func (m UsageDetailMutation) Client() *Client {
  34400. client := &Client{config: m.config}
  34401. client.init()
  34402. return client
  34403. }
  34404. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34405. // it returns an error otherwise.
  34406. func (m UsageDetailMutation) Tx() (*Tx, error) {
  34407. if _, ok := m.driver.(*txDriver); !ok {
  34408. return nil, errors.New("ent: mutation is not running in a transaction")
  34409. }
  34410. tx := &Tx{config: m.config}
  34411. tx.init()
  34412. return tx, nil
  34413. }
  34414. // SetID sets the value of the id field. Note that this
  34415. // operation is only accepted on creation of UsageDetail entities.
  34416. func (m *UsageDetailMutation) SetID(id uint64) {
  34417. m.id = &id
  34418. }
  34419. // ID returns the ID value in the mutation. Note that the ID is only available
  34420. // if it was provided to the builder or after it was returned from the database.
  34421. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  34422. if m.id == nil {
  34423. return
  34424. }
  34425. return *m.id, true
  34426. }
  34427. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34428. // That means, if the mutation is applied within a transaction with an isolation level such
  34429. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34430. // or updated by the mutation.
  34431. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  34432. switch {
  34433. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34434. id, exists := m.ID()
  34435. if exists {
  34436. return []uint64{id}, nil
  34437. }
  34438. fallthrough
  34439. case m.op.Is(OpUpdate | OpDelete):
  34440. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  34441. default:
  34442. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34443. }
  34444. }
  34445. // SetCreatedAt sets the "created_at" field.
  34446. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  34447. m.created_at = &t
  34448. }
  34449. // CreatedAt returns the value of the "created_at" field in the mutation.
  34450. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  34451. v := m.created_at
  34452. if v == nil {
  34453. return
  34454. }
  34455. return *v, true
  34456. }
  34457. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  34458. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34460. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34461. if !m.op.Is(OpUpdateOne) {
  34462. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34463. }
  34464. if m.id == nil || m.oldValue == nil {
  34465. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34466. }
  34467. oldValue, err := m.oldValue(ctx)
  34468. if err != nil {
  34469. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34470. }
  34471. return oldValue.CreatedAt, nil
  34472. }
  34473. // ResetCreatedAt resets all changes to the "created_at" field.
  34474. func (m *UsageDetailMutation) ResetCreatedAt() {
  34475. m.created_at = nil
  34476. }
  34477. // SetUpdatedAt sets the "updated_at" field.
  34478. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  34479. m.updated_at = &t
  34480. }
  34481. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34482. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  34483. v := m.updated_at
  34484. if v == nil {
  34485. return
  34486. }
  34487. return *v, true
  34488. }
  34489. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  34490. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34492. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34493. if !m.op.Is(OpUpdateOne) {
  34494. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34495. }
  34496. if m.id == nil || m.oldValue == nil {
  34497. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34498. }
  34499. oldValue, err := m.oldValue(ctx)
  34500. if err != nil {
  34501. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34502. }
  34503. return oldValue.UpdatedAt, nil
  34504. }
  34505. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34506. func (m *UsageDetailMutation) ResetUpdatedAt() {
  34507. m.updated_at = nil
  34508. }
  34509. // SetStatus sets the "status" field.
  34510. func (m *UsageDetailMutation) SetStatus(u uint8) {
  34511. m.status = &u
  34512. m.addstatus = nil
  34513. }
  34514. // Status returns the value of the "status" field in the mutation.
  34515. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  34516. v := m.status
  34517. if v == nil {
  34518. return
  34519. }
  34520. return *v, true
  34521. }
  34522. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  34523. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34525. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34526. if !m.op.Is(OpUpdateOne) {
  34527. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34528. }
  34529. if m.id == nil || m.oldValue == nil {
  34530. return v, errors.New("OldStatus requires an ID field in the mutation")
  34531. }
  34532. oldValue, err := m.oldValue(ctx)
  34533. if err != nil {
  34534. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34535. }
  34536. return oldValue.Status, nil
  34537. }
  34538. // AddStatus adds u to the "status" field.
  34539. func (m *UsageDetailMutation) AddStatus(u int8) {
  34540. if m.addstatus != nil {
  34541. *m.addstatus += u
  34542. } else {
  34543. m.addstatus = &u
  34544. }
  34545. }
  34546. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34547. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  34548. v := m.addstatus
  34549. if v == nil {
  34550. return
  34551. }
  34552. return *v, true
  34553. }
  34554. // ClearStatus clears the value of the "status" field.
  34555. func (m *UsageDetailMutation) ClearStatus() {
  34556. m.status = nil
  34557. m.addstatus = nil
  34558. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  34559. }
  34560. // StatusCleared returns if the "status" field was cleared in this mutation.
  34561. func (m *UsageDetailMutation) StatusCleared() bool {
  34562. _, ok := m.clearedFields[usagedetail.FieldStatus]
  34563. return ok
  34564. }
  34565. // ResetStatus resets all changes to the "status" field.
  34566. func (m *UsageDetailMutation) ResetStatus() {
  34567. m.status = nil
  34568. m.addstatus = nil
  34569. delete(m.clearedFields, usagedetail.FieldStatus)
  34570. }
  34571. // SetType sets the "type" field.
  34572. func (m *UsageDetailMutation) SetType(i int) {
  34573. m._type = &i
  34574. m.add_type = nil
  34575. }
  34576. // GetType returns the value of the "type" field in the mutation.
  34577. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  34578. v := m._type
  34579. if v == nil {
  34580. return
  34581. }
  34582. return *v, true
  34583. }
  34584. // OldType returns the old "type" field's value of the UsageDetail entity.
  34585. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34587. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  34588. if !m.op.Is(OpUpdateOne) {
  34589. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34590. }
  34591. if m.id == nil || m.oldValue == nil {
  34592. return v, errors.New("OldType requires an ID field in the mutation")
  34593. }
  34594. oldValue, err := m.oldValue(ctx)
  34595. if err != nil {
  34596. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34597. }
  34598. return oldValue.Type, nil
  34599. }
  34600. // AddType adds i to the "type" field.
  34601. func (m *UsageDetailMutation) AddType(i int) {
  34602. if m.add_type != nil {
  34603. *m.add_type += i
  34604. } else {
  34605. m.add_type = &i
  34606. }
  34607. }
  34608. // AddedType returns the value that was added to the "type" field in this mutation.
  34609. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  34610. v := m.add_type
  34611. if v == nil {
  34612. return
  34613. }
  34614. return *v, true
  34615. }
  34616. // ClearType clears the value of the "type" field.
  34617. func (m *UsageDetailMutation) ClearType() {
  34618. m._type = nil
  34619. m.add_type = nil
  34620. m.clearedFields[usagedetail.FieldType] = struct{}{}
  34621. }
  34622. // TypeCleared returns if the "type" field was cleared in this mutation.
  34623. func (m *UsageDetailMutation) TypeCleared() bool {
  34624. _, ok := m.clearedFields[usagedetail.FieldType]
  34625. return ok
  34626. }
  34627. // ResetType resets all changes to the "type" field.
  34628. func (m *UsageDetailMutation) ResetType() {
  34629. m._type = nil
  34630. m.add_type = nil
  34631. delete(m.clearedFields, usagedetail.FieldType)
  34632. }
  34633. // SetBotID sets the "bot_id" field.
  34634. func (m *UsageDetailMutation) SetBotID(s string) {
  34635. m.bot_id = &s
  34636. }
  34637. // BotID returns the value of the "bot_id" field in the mutation.
  34638. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  34639. v := m.bot_id
  34640. if v == nil {
  34641. return
  34642. }
  34643. return *v, true
  34644. }
  34645. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  34646. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34648. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  34649. if !m.op.Is(OpUpdateOne) {
  34650. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34651. }
  34652. if m.id == nil || m.oldValue == nil {
  34653. return v, errors.New("OldBotID requires an ID field in the mutation")
  34654. }
  34655. oldValue, err := m.oldValue(ctx)
  34656. if err != nil {
  34657. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34658. }
  34659. return oldValue.BotID, nil
  34660. }
  34661. // ResetBotID resets all changes to the "bot_id" field.
  34662. func (m *UsageDetailMutation) ResetBotID() {
  34663. m.bot_id = nil
  34664. }
  34665. // SetReceiverID sets the "receiver_id" field.
  34666. func (m *UsageDetailMutation) SetReceiverID(s string) {
  34667. m.receiver_id = &s
  34668. }
  34669. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  34670. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  34671. v := m.receiver_id
  34672. if v == nil {
  34673. return
  34674. }
  34675. return *v, true
  34676. }
  34677. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  34678. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34680. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  34681. if !m.op.Is(OpUpdateOne) {
  34682. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  34683. }
  34684. if m.id == nil || m.oldValue == nil {
  34685. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  34686. }
  34687. oldValue, err := m.oldValue(ctx)
  34688. if err != nil {
  34689. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  34690. }
  34691. return oldValue.ReceiverID, nil
  34692. }
  34693. // ResetReceiverID resets all changes to the "receiver_id" field.
  34694. func (m *UsageDetailMutation) ResetReceiverID() {
  34695. m.receiver_id = nil
  34696. }
  34697. // SetApp sets the "app" field.
  34698. func (m *UsageDetailMutation) SetApp(i int) {
  34699. m.app = &i
  34700. m.addapp = nil
  34701. }
  34702. // App returns the value of the "app" field in the mutation.
  34703. func (m *UsageDetailMutation) App() (r int, exists bool) {
  34704. v := m.app
  34705. if v == nil {
  34706. return
  34707. }
  34708. return *v, true
  34709. }
  34710. // OldApp returns the old "app" field's value of the UsageDetail entity.
  34711. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34713. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  34714. if !m.op.Is(OpUpdateOne) {
  34715. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  34716. }
  34717. if m.id == nil || m.oldValue == nil {
  34718. return v, errors.New("OldApp requires an ID field in the mutation")
  34719. }
  34720. oldValue, err := m.oldValue(ctx)
  34721. if err != nil {
  34722. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  34723. }
  34724. return oldValue.App, nil
  34725. }
  34726. // AddApp adds i to the "app" field.
  34727. func (m *UsageDetailMutation) AddApp(i int) {
  34728. if m.addapp != nil {
  34729. *m.addapp += i
  34730. } else {
  34731. m.addapp = &i
  34732. }
  34733. }
  34734. // AddedApp returns the value that was added to the "app" field in this mutation.
  34735. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  34736. v := m.addapp
  34737. if v == nil {
  34738. return
  34739. }
  34740. return *v, true
  34741. }
  34742. // ClearApp clears the value of the "app" field.
  34743. func (m *UsageDetailMutation) ClearApp() {
  34744. m.app = nil
  34745. m.addapp = nil
  34746. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  34747. }
  34748. // AppCleared returns if the "app" field was cleared in this mutation.
  34749. func (m *UsageDetailMutation) AppCleared() bool {
  34750. _, ok := m.clearedFields[usagedetail.FieldApp]
  34751. return ok
  34752. }
  34753. // ResetApp resets all changes to the "app" field.
  34754. func (m *UsageDetailMutation) ResetApp() {
  34755. m.app = nil
  34756. m.addapp = nil
  34757. delete(m.clearedFields, usagedetail.FieldApp)
  34758. }
  34759. // SetSessionID sets the "session_id" field.
  34760. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  34761. m.session_id = &u
  34762. m.addsession_id = nil
  34763. }
  34764. // SessionID returns the value of the "session_id" field in the mutation.
  34765. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  34766. v := m.session_id
  34767. if v == nil {
  34768. return
  34769. }
  34770. return *v, true
  34771. }
  34772. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  34773. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34775. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  34776. if !m.op.Is(OpUpdateOne) {
  34777. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  34778. }
  34779. if m.id == nil || m.oldValue == nil {
  34780. return v, errors.New("OldSessionID requires an ID field in the mutation")
  34781. }
  34782. oldValue, err := m.oldValue(ctx)
  34783. if err != nil {
  34784. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  34785. }
  34786. return oldValue.SessionID, nil
  34787. }
  34788. // AddSessionID adds u to the "session_id" field.
  34789. func (m *UsageDetailMutation) AddSessionID(u int64) {
  34790. if m.addsession_id != nil {
  34791. *m.addsession_id += u
  34792. } else {
  34793. m.addsession_id = &u
  34794. }
  34795. }
  34796. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  34797. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  34798. v := m.addsession_id
  34799. if v == nil {
  34800. return
  34801. }
  34802. return *v, true
  34803. }
  34804. // ClearSessionID clears the value of the "session_id" field.
  34805. func (m *UsageDetailMutation) ClearSessionID() {
  34806. m.session_id = nil
  34807. m.addsession_id = nil
  34808. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  34809. }
  34810. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  34811. func (m *UsageDetailMutation) SessionIDCleared() bool {
  34812. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  34813. return ok
  34814. }
  34815. // ResetSessionID resets all changes to the "session_id" field.
  34816. func (m *UsageDetailMutation) ResetSessionID() {
  34817. m.session_id = nil
  34818. m.addsession_id = nil
  34819. delete(m.clearedFields, usagedetail.FieldSessionID)
  34820. }
  34821. // SetRequest sets the "request" field.
  34822. func (m *UsageDetailMutation) SetRequest(s string) {
  34823. m.request = &s
  34824. }
  34825. // Request returns the value of the "request" field in the mutation.
  34826. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  34827. v := m.request
  34828. if v == nil {
  34829. return
  34830. }
  34831. return *v, true
  34832. }
  34833. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  34834. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34836. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  34837. if !m.op.Is(OpUpdateOne) {
  34838. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  34839. }
  34840. if m.id == nil || m.oldValue == nil {
  34841. return v, errors.New("OldRequest requires an ID field in the mutation")
  34842. }
  34843. oldValue, err := m.oldValue(ctx)
  34844. if err != nil {
  34845. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  34846. }
  34847. return oldValue.Request, nil
  34848. }
  34849. // ResetRequest resets all changes to the "request" field.
  34850. func (m *UsageDetailMutation) ResetRequest() {
  34851. m.request = nil
  34852. }
  34853. // SetResponse sets the "response" field.
  34854. func (m *UsageDetailMutation) SetResponse(s string) {
  34855. m.response = &s
  34856. }
  34857. // Response returns the value of the "response" field in the mutation.
  34858. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  34859. v := m.response
  34860. if v == nil {
  34861. return
  34862. }
  34863. return *v, true
  34864. }
  34865. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  34866. // If the UsageDetail 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 *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  34869. if !m.op.Is(OpUpdateOne) {
  34870. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  34871. }
  34872. if m.id == nil || m.oldValue == nil {
  34873. return v, errors.New("OldResponse 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 OldResponse: %w", err)
  34878. }
  34879. return oldValue.Response, nil
  34880. }
  34881. // ResetResponse resets all changes to the "response" field.
  34882. func (m *UsageDetailMutation) ResetResponse() {
  34883. m.response = nil
  34884. }
  34885. // SetOriginalData sets the "original_data" field.
  34886. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  34887. m.original_data = &ctd
  34888. }
  34889. // OriginalData returns the value of the "original_data" field in the mutation.
  34890. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  34891. v := m.original_data
  34892. if v == nil {
  34893. return
  34894. }
  34895. return *v, true
  34896. }
  34897. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  34898. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34900. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  34901. if !m.op.Is(OpUpdateOne) {
  34902. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  34903. }
  34904. if m.id == nil || m.oldValue == nil {
  34905. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  34906. }
  34907. oldValue, err := m.oldValue(ctx)
  34908. if err != nil {
  34909. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  34910. }
  34911. return oldValue.OriginalData, nil
  34912. }
  34913. // ResetOriginalData resets all changes to the "original_data" field.
  34914. func (m *UsageDetailMutation) ResetOriginalData() {
  34915. m.original_data = nil
  34916. }
  34917. // SetTotalTokens sets the "total_tokens" field.
  34918. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  34919. m.total_tokens = &u
  34920. m.addtotal_tokens = nil
  34921. }
  34922. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34923. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  34924. v := m.total_tokens
  34925. if v == nil {
  34926. return
  34927. }
  34928. return *v, true
  34929. }
  34930. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  34931. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34933. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34934. if !m.op.Is(OpUpdateOne) {
  34935. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34936. }
  34937. if m.id == nil || m.oldValue == nil {
  34938. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34939. }
  34940. oldValue, err := m.oldValue(ctx)
  34941. if err != nil {
  34942. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34943. }
  34944. return oldValue.TotalTokens, nil
  34945. }
  34946. // AddTotalTokens adds u to the "total_tokens" field.
  34947. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  34948. if m.addtotal_tokens != nil {
  34949. *m.addtotal_tokens += u
  34950. } else {
  34951. m.addtotal_tokens = &u
  34952. }
  34953. }
  34954. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34955. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  34956. v := m.addtotal_tokens
  34957. if v == nil {
  34958. return
  34959. }
  34960. return *v, true
  34961. }
  34962. // ClearTotalTokens clears the value of the "total_tokens" field.
  34963. func (m *UsageDetailMutation) ClearTotalTokens() {
  34964. m.total_tokens = nil
  34965. m.addtotal_tokens = nil
  34966. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  34967. }
  34968. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34969. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  34970. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  34971. return ok
  34972. }
  34973. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34974. func (m *UsageDetailMutation) ResetTotalTokens() {
  34975. m.total_tokens = nil
  34976. m.addtotal_tokens = nil
  34977. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  34978. }
  34979. // SetPromptTokens sets the "prompt_tokens" field.
  34980. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  34981. m.prompt_tokens = &u
  34982. m.addprompt_tokens = nil
  34983. }
  34984. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  34985. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  34986. v := m.prompt_tokens
  34987. if v == nil {
  34988. return
  34989. }
  34990. return *v, true
  34991. }
  34992. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  34993. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34995. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  34996. if !m.op.Is(OpUpdateOne) {
  34997. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  34998. }
  34999. if m.id == nil || m.oldValue == nil {
  35000. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  35001. }
  35002. oldValue, err := m.oldValue(ctx)
  35003. if err != nil {
  35004. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  35005. }
  35006. return oldValue.PromptTokens, nil
  35007. }
  35008. // AddPromptTokens adds u to the "prompt_tokens" field.
  35009. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  35010. if m.addprompt_tokens != nil {
  35011. *m.addprompt_tokens += u
  35012. } else {
  35013. m.addprompt_tokens = &u
  35014. }
  35015. }
  35016. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  35017. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  35018. v := m.addprompt_tokens
  35019. if v == nil {
  35020. return
  35021. }
  35022. return *v, true
  35023. }
  35024. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  35025. func (m *UsageDetailMutation) ClearPromptTokens() {
  35026. m.prompt_tokens = nil
  35027. m.addprompt_tokens = nil
  35028. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  35029. }
  35030. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  35031. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  35032. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  35033. return ok
  35034. }
  35035. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  35036. func (m *UsageDetailMutation) ResetPromptTokens() {
  35037. m.prompt_tokens = nil
  35038. m.addprompt_tokens = nil
  35039. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  35040. }
  35041. // SetCompletionTokens sets the "completion_tokens" field.
  35042. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  35043. m.completion_tokens = &u
  35044. m.addcompletion_tokens = nil
  35045. }
  35046. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  35047. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  35048. v := m.completion_tokens
  35049. if v == nil {
  35050. return
  35051. }
  35052. return *v, true
  35053. }
  35054. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  35055. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35057. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  35058. if !m.op.Is(OpUpdateOne) {
  35059. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  35060. }
  35061. if m.id == nil || m.oldValue == nil {
  35062. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  35063. }
  35064. oldValue, err := m.oldValue(ctx)
  35065. if err != nil {
  35066. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  35067. }
  35068. return oldValue.CompletionTokens, nil
  35069. }
  35070. // AddCompletionTokens adds u to the "completion_tokens" field.
  35071. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  35072. if m.addcompletion_tokens != nil {
  35073. *m.addcompletion_tokens += u
  35074. } else {
  35075. m.addcompletion_tokens = &u
  35076. }
  35077. }
  35078. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  35079. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  35080. v := m.addcompletion_tokens
  35081. if v == nil {
  35082. return
  35083. }
  35084. return *v, true
  35085. }
  35086. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  35087. func (m *UsageDetailMutation) ClearCompletionTokens() {
  35088. m.completion_tokens = nil
  35089. m.addcompletion_tokens = nil
  35090. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  35091. }
  35092. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  35093. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  35094. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  35095. return ok
  35096. }
  35097. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  35098. func (m *UsageDetailMutation) ResetCompletionTokens() {
  35099. m.completion_tokens = nil
  35100. m.addcompletion_tokens = nil
  35101. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  35102. }
  35103. // SetOrganizationID sets the "organization_id" field.
  35104. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  35105. m.organization_id = &u
  35106. m.addorganization_id = nil
  35107. }
  35108. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35109. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  35110. v := m.organization_id
  35111. if v == nil {
  35112. return
  35113. }
  35114. return *v, true
  35115. }
  35116. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  35117. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35119. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35120. if !m.op.Is(OpUpdateOne) {
  35121. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35122. }
  35123. if m.id == nil || m.oldValue == nil {
  35124. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35125. }
  35126. oldValue, err := m.oldValue(ctx)
  35127. if err != nil {
  35128. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35129. }
  35130. return oldValue.OrganizationID, nil
  35131. }
  35132. // AddOrganizationID adds u to the "organization_id" field.
  35133. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  35134. if m.addorganization_id != nil {
  35135. *m.addorganization_id += u
  35136. } else {
  35137. m.addorganization_id = &u
  35138. }
  35139. }
  35140. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35141. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  35142. v := m.addorganization_id
  35143. if v == nil {
  35144. return
  35145. }
  35146. return *v, true
  35147. }
  35148. // ClearOrganizationID clears the value of the "organization_id" field.
  35149. func (m *UsageDetailMutation) ClearOrganizationID() {
  35150. m.organization_id = nil
  35151. m.addorganization_id = nil
  35152. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  35153. }
  35154. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35155. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  35156. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  35157. return ok
  35158. }
  35159. // ResetOrganizationID resets all changes to the "organization_id" field.
  35160. func (m *UsageDetailMutation) ResetOrganizationID() {
  35161. m.organization_id = nil
  35162. m.addorganization_id = nil
  35163. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  35164. }
  35165. // SetModel sets the "model" field.
  35166. func (m *UsageDetailMutation) SetModel(s string) {
  35167. m.model = &s
  35168. }
  35169. // Model returns the value of the "model" field in the mutation.
  35170. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  35171. v := m.model
  35172. if v == nil {
  35173. return
  35174. }
  35175. return *v, true
  35176. }
  35177. // OldModel returns the old "model" field's value of the UsageDetail entity.
  35178. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35180. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  35181. if !m.op.Is(OpUpdateOne) {
  35182. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  35183. }
  35184. if m.id == nil || m.oldValue == nil {
  35185. return v, errors.New("OldModel requires an ID field in the mutation")
  35186. }
  35187. oldValue, err := m.oldValue(ctx)
  35188. if err != nil {
  35189. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  35190. }
  35191. return oldValue.Model, nil
  35192. }
  35193. // ClearModel clears the value of the "model" field.
  35194. func (m *UsageDetailMutation) ClearModel() {
  35195. m.model = nil
  35196. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  35197. }
  35198. // ModelCleared returns if the "model" field was cleared in this mutation.
  35199. func (m *UsageDetailMutation) ModelCleared() bool {
  35200. _, ok := m.clearedFields[usagedetail.FieldModel]
  35201. return ok
  35202. }
  35203. // ResetModel resets all changes to the "model" field.
  35204. func (m *UsageDetailMutation) ResetModel() {
  35205. m.model = nil
  35206. delete(m.clearedFields, usagedetail.FieldModel)
  35207. }
  35208. // SetCredits sets the "credits" field.
  35209. func (m *UsageDetailMutation) SetCredits(f float64) {
  35210. m.credits = &f
  35211. m.addcredits = nil
  35212. }
  35213. // Credits returns the value of the "credits" field in the mutation.
  35214. func (m *UsageDetailMutation) Credits() (r float64, exists bool) {
  35215. v := m.credits
  35216. if v == nil {
  35217. return
  35218. }
  35219. return *v, true
  35220. }
  35221. // OldCredits returns the old "credits" field's value of the UsageDetail entity.
  35222. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35224. func (m *UsageDetailMutation) OldCredits(ctx context.Context) (v float64, err error) {
  35225. if !m.op.Is(OpUpdateOne) {
  35226. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  35227. }
  35228. if m.id == nil || m.oldValue == nil {
  35229. return v, errors.New("OldCredits requires an ID field in the mutation")
  35230. }
  35231. oldValue, err := m.oldValue(ctx)
  35232. if err != nil {
  35233. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  35234. }
  35235. return oldValue.Credits, nil
  35236. }
  35237. // AddCredits adds f to the "credits" field.
  35238. func (m *UsageDetailMutation) AddCredits(f float64) {
  35239. if m.addcredits != nil {
  35240. *m.addcredits += f
  35241. } else {
  35242. m.addcredits = &f
  35243. }
  35244. }
  35245. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  35246. func (m *UsageDetailMutation) AddedCredits() (r float64, exists bool) {
  35247. v := m.addcredits
  35248. if v == nil {
  35249. return
  35250. }
  35251. return *v, true
  35252. }
  35253. // ClearCredits clears the value of the "credits" field.
  35254. func (m *UsageDetailMutation) ClearCredits() {
  35255. m.credits = nil
  35256. m.addcredits = nil
  35257. m.clearedFields[usagedetail.FieldCredits] = struct{}{}
  35258. }
  35259. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  35260. func (m *UsageDetailMutation) CreditsCleared() bool {
  35261. _, ok := m.clearedFields[usagedetail.FieldCredits]
  35262. return ok
  35263. }
  35264. // ResetCredits resets all changes to the "credits" field.
  35265. func (m *UsageDetailMutation) ResetCredits() {
  35266. m.credits = nil
  35267. m.addcredits = nil
  35268. delete(m.clearedFields, usagedetail.FieldCredits)
  35269. }
  35270. // Where appends a list predicates to the UsageDetailMutation builder.
  35271. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  35272. m.predicates = append(m.predicates, ps...)
  35273. }
  35274. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  35275. // users can use type-assertion to append predicates that do not depend on any generated package.
  35276. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  35277. p := make([]predicate.UsageDetail, len(ps))
  35278. for i := range ps {
  35279. p[i] = ps[i]
  35280. }
  35281. m.Where(p...)
  35282. }
  35283. // Op returns the operation name.
  35284. func (m *UsageDetailMutation) Op() Op {
  35285. return m.op
  35286. }
  35287. // SetOp allows setting the mutation operation.
  35288. func (m *UsageDetailMutation) SetOp(op Op) {
  35289. m.op = op
  35290. }
  35291. // Type returns the node type of this mutation (UsageDetail).
  35292. func (m *UsageDetailMutation) Type() string {
  35293. return m.typ
  35294. }
  35295. // Fields returns all fields that were changed during this mutation. Note that in
  35296. // order to get all numeric fields that were incremented/decremented, call
  35297. // AddedFields().
  35298. func (m *UsageDetailMutation) Fields() []string {
  35299. fields := make([]string, 0, 17)
  35300. if m.created_at != nil {
  35301. fields = append(fields, usagedetail.FieldCreatedAt)
  35302. }
  35303. if m.updated_at != nil {
  35304. fields = append(fields, usagedetail.FieldUpdatedAt)
  35305. }
  35306. if m.status != nil {
  35307. fields = append(fields, usagedetail.FieldStatus)
  35308. }
  35309. if m._type != nil {
  35310. fields = append(fields, usagedetail.FieldType)
  35311. }
  35312. if m.bot_id != nil {
  35313. fields = append(fields, usagedetail.FieldBotID)
  35314. }
  35315. if m.receiver_id != nil {
  35316. fields = append(fields, usagedetail.FieldReceiverID)
  35317. }
  35318. if m.app != nil {
  35319. fields = append(fields, usagedetail.FieldApp)
  35320. }
  35321. if m.session_id != nil {
  35322. fields = append(fields, usagedetail.FieldSessionID)
  35323. }
  35324. if m.request != nil {
  35325. fields = append(fields, usagedetail.FieldRequest)
  35326. }
  35327. if m.response != nil {
  35328. fields = append(fields, usagedetail.FieldResponse)
  35329. }
  35330. if m.original_data != nil {
  35331. fields = append(fields, usagedetail.FieldOriginalData)
  35332. }
  35333. if m.total_tokens != nil {
  35334. fields = append(fields, usagedetail.FieldTotalTokens)
  35335. }
  35336. if m.prompt_tokens != nil {
  35337. fields = append(fields, usagedetail.FieldPromptTokens)
  35338. }
  35339. if m.completion_tokens != nil {
  35340. fields = append(fields, usagedetail.FieldCompletionTokens)
  35341. }
  35342. if m.organization_id != nil {
  35343. fields = append(fields, usagedetail.FieldOrganizationID)
  35344. }
  35345. if m.model != nil {
  35346. fields = append(fields, usagedetail.FieldModel)
  35347. }
  35348. if m.credits != nil {
  35349. fields = append(fields, usagedetail.FieldCredits)
  35350. }
  35351. return fields
  35352. }
  35353. // Field returns the value of a field with the given name. The second boolean
  35354. // return value indicates that this field was not set, or was not defined in the
  35355. // schema.
  35356. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  35357. switch name {
  35358. case usagedetail.FieldCreatedAt:
  35359. return m.CreatedAt()
  35360. case usagedetail.FieldUpdatedAt:
  35361. return m.UpdatedAt()
  35362. case usagedetail.FieldStatus:
  35363. return m.Status()
  35364. case usagedetail.FieldType:
  35365. return m.GetType()
  35366. case usagedetail.FieldBotID:
  35367. return m.BotID()
  35368. case usagedetail.FieldReceiverID:
  35369. return m.ReceiverID()
  35370. case usagedetail.FieldApp:
  35371. return m.App()
  35372. case usagedetail.FieldSessionID:
  35373. return m.SessionID()
  35374. case usagedetail.FieldRequest:
  35375. return m.Request()
  35376. case usagedetail.FieldResponse:
  35377. return m.Response()
  35378. case usagedetail.FieldOriginalData:
  35379. return m.OriginalData()
  35380. case usagedetail.FieldTotalTokens:
  35381. return m.TotalTokens()
  35382. case usagedetail.FieldPromptTokens:
  35383. return m.PromptTokens()
  35384. case usagedetail.FieldCompletionTokens:
  35385. return m.CompletionTokens()
  35386. case usagedetail.FieldOrganizationID:
  35387. return m.OrganizationID()
  35388. case usagedetail.FieldModel:
  35389. return m.Model()
  35390. case usagedetail.FieldCredits:
  35391. return m.Credits()
  35392. }
  35393. return nil, false
  35394. }
  35395. // OldField returns the old value of the field from the database. An error is
  35396. // returned if the mutation operation is not UpdateOne, or the query to the
  35397. // database failed.
  35398. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35399. switch name {
  35400. case usagedetail.FieldCreatedAt:
  35401. return m.OldCreatedAt(ctx)
  35402. case usagedetail.FieldUpdatedAt:
  35403. return m.OldUpdatedAt(ctx)
  35404. case usagedetail.FieldStatus:
  35405. return m.OldStatus(ctx)
  35406. case usagedetail.FieldType:
  35407. return m.OldType(ctx)
  35408. case usagedetail.FieldBotID:
  35409. return m.OldBotID(ctx)
  35410. case usagedetail.FieldReceiverID:
  35411. return m.OldReceiverID(ctx)
  35412. case usagedetail.FieldApp:
  35413. return m.OldApp(ctx)
  35414. case usagedetail.FieldSessionID:
  35415. return m.OldSessionID(ctx)
  35416. case usagedetail.FieldRequest:
  35417. return m.OldRequest(ctx)
  35418. case usagedetail.FieldResponse:
  35419. return m.OldResponse(ctx)
  35420. case usagedetail.FieldOriginalData:
  35421. return m.OldOriginalData(ctx)
  35422. case usagedetail.FieldTotalTokens:
  35423. return m.OldTotalTokens(ctx)
  35424. case usagedetail.FieldPromptTokens:
  35425. return m.OldPromptTokens(ctx)
  35426. case usagedetail.FieldCompletionTokens:
  35427. return m.OldCompletionTokens(ctx)
  35428. case usagedetail.FieldOrganizationID:
  35429. return m.OldOrganizationID(ctx)
  35430. case usagedetail.FieldModel:
  35431. return m.OldModel(ctx)
  35432. case usagedetail.FieldCredits:
  35433. return m.OldCredits(ctx)
  35434. }
  35435. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  35436. }
  35437. // SetField sets the value of a field with the given name. It returns an error if
  35438. // the field is not defined in the schema, or if the type mismatched the field
  35439. // type.
  35440. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  35441. switch name {
  35442. case usagedetail.FieldCreatedAt:
  35443. v, ok := value.(time.Time)
  35444. if !ok {
  35445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35446. }
  35447. m.SetCreatedAt(v)
  35448. return nil
  35449. case usagedetail.FieldUpdatedAt:
  35450. v, ok := value.(time.Time)
  35451. if !ok {
  35452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35453. }
  35454. m.SetUpdatedAt(v)
  35455. return nil
  35456. case usagedetail.FieldStatus:
  35457. v, ok := value.(uint8)
  35458. if !ok {
  35459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35460. }
  35461. m.SetStatus(v)
  35462. return nil
  35463. case usagedetail.FieldType:
  35464. v, ok := value.(int)
  35465. if !ok {
  35466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35467. }
  35468. m.SetType(v)
  35469. return nil
  35470. case usagedetail.FieldBotID:
  35471. v, ok := value.(string)
  35472. if !ok {
  35473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35474. }
  35475. m.SetBotID(v)
  35476. return nil
  35477. case usagedetail.FieldReceiverID:
  35478. v, ok := value.(string)
  35479. if !ok {
  35480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35481. }
  35482. m.SetReceiverID(v)
  35483. return nil
  35484. case usagedetail.FieldApp:
  35485. v, ok := value.(int)
  35486. if !ok {
  35487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35488. }
  35489. m.SetApp(v)
  35490. return nil
  35491. case usagedetail.FieldSessionID:
  35492. v, ok := value.(uint64)
  35493. if !ok {
  35494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35495. }
  35496. m.SetSessionID(v)
  35497. return nil
  35498. case usagedetail.FieldRequest:
  35499. v, ok := value.(string)
  35500. if !ok {
  35501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35502. }
  35503. m.SetRequest(v)
  35504. return nil
  35505. case usagedetail.FieldResponse:
  35506. v, ok := value.(string)
  35507. if !ok {
  35508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35509. }
  35510. m.SetResponse(v)
  35511. return nil
  35512. case usagedetail.FieldOriginalData:
  35513. v, ok := value.(custom_types.OriginalData)
  35514. if !ok {
  35515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35516. }
  35517. m.SetOriginalData(v)
  35518. return nil
  35519. case usagedetail.FieldTotalTokens:
  35520. v, ok := value.(uint64)
  35521. if !ok {
  35522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35523. }
  35524. m.SetTotalTokens(v)
  35525. return nil
  35526. case usagedetail.FieldPromptTokens:
  35527. v, ok := value.(uint64)
  35528. if !ok {
  35529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35530. }
  35531. m.SetPromptTokens(v)
  35532. return nil
  35533. case usagedetail.FieldCompletionTokens:
  35534. v, ok := value.(uint64)
  35535. if !ok {
  35536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35537. }
  35538. m.SetCompletionTokens(v)
  35539. return nil
  35540. case usagedetail.FieldOrganizationID:
  35541. v, ok := value.(uint64)
  35542. if !ok {
  35543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35544. }
  35545. m.SetOrganizationID(v)
  35546. return nil
  35547. case usagedetail.FieldModel:
  35548. v, ok := value.(string)
  35549. if !ok {
  35550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35551. }
  35552. m.SetModel(v)
  35553. return nil
  35554. case usagedetail.FieldCredits:
  35555. v, ok := value.(float64)
  35556. if !ok {
  35557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35558. }
  35559. m.SetCredits(v)
  35560. return nil
  35561. }
  35562. return fmt.Errorf("unknown UsageDetail field %s", name)
  35563. }
  35564. // AddedFields returns all numeric fields that were incremented/decremented during
  35565. // this mutation.
  35566. func (m *UsageDetailMutation) AddedFields() []string {
  35567. var fields []string
  35568. if m.addstatus != nil {
  35569. fields = append(fields, usagedetail.FieldStatus)
  35570. }
  35571. if m.add_type != nil {
  35572. fields = append(fields, usagedetail.FieldType)
  35573. }
  35574. if m.addapp != nil {
  35575. fields = append(fields, usagedetail.FieldApp)
  35576. }
  35577. if m.addsession_id != nil {
  35578. fields = append(fields, usagedetail.FieldSessionID)
  35579. }
  35580. if m.addtotal_tokens != nil {
  35581. fields = append(fields, usagedetail.FieldTotalTokens)
  35582. }
  35583. if m.addprompt_tokens != nil {
  35584. fields = append(fields, usagedetail.FieldPromptTokens)
  35585. }
  35586. if m.addcompletion_tokens != nil {
  35587. fields = append(fields, usagedetail.FieldCompletionTokens)
  35588. }
  35589. if m.addorganization_id != nil {
  35590. fields = append(fields, usagedetail.FieldOrganizationID)
  35591. }
  35592. if m.addcredits != nil {
  35593. fields = append(fields, usagedetail.FieldCredits)
  35594. }
  35595. return fields
  35596. }
  35597. // AddedField returns the numeric value that was incremented/decremented on a field
  35598. // with the given name. The second boolean return value indicates that this field
  35599. // was not set, or was not defined in the schema.
  35600. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  35601. switch name {
  35602. case usagedetail.FieldStatus:
  35603. return m.AddedStatus()
  35604. case usagedetail.FieldType:
  35605. return m.AddedType()
  35606. case usagedetail.FieldApp:
  35607. return m.AddedApp()
  35608. case usagedetail.FieldSessionID:
  35609. return m.AddedSessionID()
  35610. case usagedetail.FieldTotalTokens:
  35611. return m.AddedTotalTokens()
  35612. case usagedetail.FieldPromptTokens:
  35613. return m.AddedPromptTokens()
  35614. case usagedetail.FieldCompletionTokens:
  35615. return m.AddedCompletionTokens()
  35616. case usagedetail.FieldOrganizationID:
  35617. return m.AddedOrganizationID()
  35618. case usagedetail.FieldCredits:
  35619. return m.AddedCredits()
  35620. }
  35621. return nil, false
  35622. }
  35623. // AddField adds the value to the field with the given name. It returns an error if
  35624. // the field is not defined in the schema, or if the type mismatched the field
  35625. // type.
  35626. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  35627. switch name {
  35628. case usagedetail.FieldStatus:
  35629. v, ok := value.(int8)
  35630. if !ok {
  35631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35632. }
  35633. m.AddStatus(v)
  35634. return nil
  35635. case usagedetail.FieldType:
  35636. v, ok := value.(int)
  35637. if !ok {
  35638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35639. }
  35640. m.AddType(v)
  35641. return nil
  35642. case usagedetail.FieldApp:
  35643. v, ok := value.(int)
  35644. if !ok {
  35645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35646. }
  35647. m.AddApp(v)
  35648. return nil
  35649. case usagedetail.FieldSessionID:
  35650. v, ok := value.(int64)
  35651. if !ok {
  35652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35653. }
  35654. m.AddSessionID(v)
  35655. return nil
  35656. case usagedetail.FieldTotalTokens:
  35657. v, ok := value.(int64)
  35658. if !ok {
  35659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35660. }
  35661. m.AddTotalTokens(v)
  35662. return nil
  35663. case usagedetail.FieldPromptTokens:
  35664. v, ok := value.(int64)
  35665. if !ok {
  35666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35667. }
  35668. m.AddPromptTokens(v)
  35669. return nil
  35670. case usagedetail.FieldCompletionTokens:
  35671. v, ok := value.(int64)
  35672. if !ok {
  35673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35674. }
  35675. m.AddCompletionTokens(v)
  35676. return nil
  35677. case usagedetail.FieldOrganizationID:
  35678. v, ok := value.(int64)
  35679. if !ok {
  35680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35681. }
  35682. m.AddOrganizationID(v)
  35683. return nil
  35684. case usagedetail.FieldCredits:
  35685. v, ok := value.(float64)
  35686. if !ok {
  35687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35688. }
  35689. m.AddCredits(v)
  35690. return nil
  35691. }
  35692. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  35693. }
  35694. // ClearedFields returns all nullable fields that were cleared during this
  35695. // mutation.
  35696. func (m *UsageDetailMutation) ClearedFields() []string {
  35697. var fields []string
  35698. if m.FieldCleared(usagedetail.FieldStatus) {
  35699. fields = append(fields, usagedetail.FieldStatus)
  35700. }
  35701. if m.FieldCleared(usagedetail.FieldType) {
  35702. fields = append(fields, usagedetail.FieldType)
  35703. }
  35704. if m.FieldCleared(usagedetail.FieldApp) {
  35705. fields = append(fields, usagedetail.FieldApp)
  35706. }
  35707. if m.FieldCleared(usagedetail.FieldSessionID) {
  35708. fields = append(fields, usagedetail.FieldSessionID)
  35709. }
  35710. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  35711. fields = append(fields, usagedetail.FieldTotalTokens)
  35712. }
  35713. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  35714. fields = append(fields, usagedetail.FieldPromptTokens)
  35715. }
  35716. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  35717. fields = append(fields, usagedetail.FieldCompletionTokens)
  35718. }
  35719. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  35720. fields = append(fields, usagedetail.FieldOrganizationID)
  35721. }
  35722. if m.FieldCleared(usagedetail.FieldModel) {
  35723. fields = append(fields, usagedetail.FieldModel)
  35724. }
  35725. if m.FieldCleared(usagedetail.FieldCredits) {
  35726. fields = append(fields, usagedetail.FieldCredits)
  35727. }
  35728. return fields
  35729. }
  35730. // FieldCleared returns a boolean indicating if a field with the given name was
  35731. // cleared in this mutation.
  35732. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  35733. _, ok := m.clearedFields[name]
  35734. return ok
  35735. }
  35736. // ClearField clears the value of the field with the given name. It returns an
  35737. // error if the field is not defined in the schema.
  35738. func (m *UsageDetailMutation) ClearField(name string) error {
  35739. switch name {
  35740. case usagedetail.FieldStatus:
  35741. m.ClearStatus()
  35742. return nil
  35743. case usagedetail.FieldType:
  35744. m.ClearType()
  35745. return nil
  35746. case usagedetail.FieldApp:
  35747. m.ClearApp()
  35748. return nil
  35749. case usagedetail.FieldSessionID:
  35750. m.ClearSessionID()
  35751. return nil
  35752. case usagedetail.FieldTotalTokens:
  35753. m.ClearTotalTokens()
  35754. return nil
  35755. case usagedetail.FieldPromptTokens:
  35756. m.ClearPromptTokens()
  35757. return nil
  35758. case usagedetail.FieldCompletionTokens:
  35759. m.ClearCompletionTokens()
  35760. return nil
  35761. case usagedetail.FieldOrganizationID:
  35762. m.ClearOrganizationID()
  35763. return nil
  35764. case usagedetail.FieldModel:
  35765. m.ClearModel()
  35766. return nil
  35767. case usagedetail.FieldCredits:
  35768. m.ClearCredits()
  35769. return nil
  35770. }
  35771. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  35772. }
  35773. // ResetField resets all changes in the mutation for the field with the given name.
  35774. // It returns an error if the field is not defined in the schema.
  35775. func (m *UsageDetailMutation) ResetField(name string) error {
  35776. switch name {
  35777. case usagedetail.FieldCreatedAt:
  35778. m.ResetCreatedAt()
  35779. return nil
  35780. case usagedetail.FieldUpdatedAt:
  35781. m.ResetUpdatedAt()
  35782. return nil
  35783. case usagedetail.FieldStatus:
  35784. m.ResetStatus()
  35785. return nil
  35786. case usagedetail.FieldType:
  35787. m.ResetType()
  35788. return nil
  35789. case usagedetail.FieldBotID:
  35790. m.ResetBotID()
  35791. return nil
  35792. case usagedetail.FieldReceiverID:
  35793. m.ResetReceiverID()
  35794. return nil
  35795. case usagedetail.FieldApp:
  35796. m.ResetApp()
  35797. return nil
  35798. case usagedetail.FieldSessionID:
  35799. m.ResetSessionID()
  35800. return nil
  35801. case usagedetail.FieldRequest:
  35802. m.ResetRequest()
  35803. return nil
  35804. case usagedetail.FieldResponse:
  35805. m.ResetResponse()
  35806. return nil
  35807. case usagedetail.FieldOriginalData:
  35808. m.ResetOriginalData()
  35809. return nil
  35810. case usagedetail.FieldTotalTokens:
  35811. m.ResetTotalTokens()
  35812. return nil
  35813. case usagedetail.FieldPromptTokens:
  35814. m.ResetPromptTokens()
  35815. return nil
  35816. case usagedetail.FieldCompletionTokens:
  35817. m.ResetCompletionTokens()
  35818. return nil
  35819. case usagedetail.FieldOrganizationID:
  35820. m.ResetOrganizationID()
  35821. return nil
  35822. case usagedetail.FieldModel:
  35823. m.ResetModel()
  35824. return nil
  35825. case usagedetail.FieldCredits:
  35826. m.ResetCredits()
  35827. return nil
  35828. }
  35829. return fmt.Errorf("unknown UsageDetail field %s", name)
  35830. }
  35831. // AddedEdges returns all edge names that were set/added in this mutation.
  35832. func (m *UsageDetailMutation) AddedEdges() []string {
  35833. edges := make([]string, 0, 0)
  35834. return edges
  35835. }
  35836. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35837. // name in this mutation.
  35838. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  35839. return nil
  35840. }
  35841. // RemovedEdges returns all edge names that were removed in this mutation.
  35842. func (m *UsageDetailMutation) RemovedEdges() []string {
  35843. edges := make([]string, 0, 0)
  35844. return edges
  35845. }
  35846. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35847. // the given name in this mutation.
  35848. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  35849. return nil
  35850. }
  35851. // ClearedEdges returns all edge names that were cleared in this mutation.
  35852. func (m *UsageDetailMutation) ClearedEdges() []string {
  35853. edges := make([]string, 0, 0)
  35854. return edges
  35855. }
  35856. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35857. // was cleared in this mutation.
  35858. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  35859. return false
  35860. }
  35861. // ClearEdge clears the value of the edge with the given name. It returns an error
  35862. // if that edge is not defined in the schema.
  35863. func (m *UsageDetailMutation) ClearEdge(name string) error {
  35864. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  35865. }
  35866. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35867. // It returns an error if the edge is not defined in the schema.
  35868. func (m *UsageDetailMutation) ResetEdge(name string) error {
  35869. return fmt.Errorf("unknown UsageDetail edge %s", name)
  35870. }
  35871. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  35872. type UsageStatisticDayMutation struct {
  35873. config
  35874. op Op
  35875. typ string
  35876. id *uint64
  35877. created_at *time.Time
  35878. updated_at *time.Time
  35879. status *uint8
  35880. addstatus *int8
  35881. deleted_at *time.Time
  35882. addtime *uint64
  35883. addaddtime *int64
  35884. _type *int
  35885. add_type *int
  35886. bot_id *string
  35887. organization_id *uint64
  35888. addorganization_id *int64
  35889. ai_response *uint64
  35890. addai_response *int64
  35891. sop_run *uint64
  35892. addsop_run *int64
  35893. total_friend *uint64
  35894. addtotal_friend *int64
  35895. total_group *uint64
  35896. addtotal_group *int64
  35897. account_balance *uint64
  35898. addaccount_balance *int64
  35899. consume_token *uint64
  35900. addconsume_token *int64
  35901. active_user *uint64
  35902. addactive_user *int64
  35903. new_user *int64
  35904. addnew_user *int64
  35905. label_dist *[]custom_types.LabelDist
  35906. appendlabel_dist []custom_types.LabelDist
  35907. consume_coin *float64
  35908. addconsume_coin *float64
  35909. clearedFields map[string]struct{}
  35910. done bool
  35911. oldValue func(context.Context) (*UsageStatisticDay, error)
  35912. predicates []predicate.UsageStatisticDay
  35913. }
  35914. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  35915. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  35916. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  35917. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  35918. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  35919. m := &UsageStatisticDayMutation{
  35920. config: c,
  35921. op: op,
  35922. typ: TypeUsageStatisticDay,
  35923. clearedFields: make(map[string]struct{}),
  35924. }
  35925. for _, opt := range opts {
  35926. opt(m)
  35927. }
  35928. return m
  35929. }
  35930. // withUsageStatisticDayID sets the ID field of the mutation.
  35931. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  35932. return func(m *UsageStatisticDayMutation) {
  35933. var (
  35934. err error
  35935. once sync.Once
  35936. value *UsageStatisticDay
  35937. )
  35938. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  35939. once.Do(func() {
  35940. if m.done {
  35941. err = errors.New("querying old values post mutation is not allowed")
  35942. } else {
  35943. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  35944. }
  35945. })
  35946. return value, err
  35947. }
  35948. m.id = &id
  35949. }
  35950. }
  35951. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  35952. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  35953. return func(m *UsageStatisticDayMutation) {
  35954. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  35955. return node, nil
  35956. }
  35957. m.id = &node.ID
  35958. }
  35959. }
  35960. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35961. // executed in a transaction (ent.Tx), a transactional client is returned.
  35962. func (m UsageStatisticDayMutation) Client() *Client {
  35963. client := &Client{config: m.config}
  35964. client.init()
  35965. return client
  35966. }
  35967. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35968. // it returns an error otherwise.
  35969. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  35970. if _, ok := m.driver.(*txDriver); !ok {
  35971. return nil, errors.New("ent: mutation is not running in a transaction")
  35972. }
  35973. tx := &Tx{config: m.config}
  35974. tx.init()
  35975. return tx, nil
  35976. }
  35977. // SetID sets the value of the id field. Note that this
  35978. // operation is only accepted on creation of UsageStatisticDay entities.
  35979. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  35980. m.id = &id
  35981. }
  35982. // ID returns the ID value in the mutation. Note that the ID is only available
  35983. // if it was provided to the builder or after it was returned from the database.
  35984. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  35985. if m.id == nil {
  35986. return
  35987. }
  35988. return *m.id, true
  35989. }
  35990. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35991. // That means, if the mutation is applied within a transaction with an isolation level such
  35992. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35993. // or updated by the mutation.
  35994. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  35995. switch {
  35996. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35997. id, exists := m.ID()
  35998. if exists {
  35999. return []uint64{id}, nil
  36000. }
  36001. fallthrough
  36002. case m.op.Is(OpUpdate | OpDelete):
  36003. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  36004. default:
  36005. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36006. }
  36007. }
  36008. // SetCreatedAt sets the "created_at" field.
  36009. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  36010. m.created_at = &t
  36011. }
  36012. // CreatedAt returns the value of the "created_at" field in the mutation.
  36013. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  36014. v := m.created_at
  36015. if v == nil {
  36016. return
  36017. }
  36018. return *v, true
  36019. }
  36020. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  36021. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36023. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36024. if !m.op.Is(OpUpdateOne) {
  36025. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36026. }
  36027. if m.id == nil || m.oldValue == nil {
  36028. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36029. }
  36030. oldValue, err := m.oldValue(ctx)
  36031. if err != nil {
  36032. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36033. }
  36034. return oldValue.CreatedAt, nil
  36035. }
  36036. // ResetCreatedAt resets all changes to the "created_at" field.
  36037. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  36038. m.created_at = nil
  36039. }
  36040. // SetUpdatedAt sets the "updated_at" field.
  36041. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  36042. m.updated_at = &t
  36043. }
  36044. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36045. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  36046. v := m.updated_at
  36047. if v == nil {
  36048. return
  36049. }
  36050. return *v, true
  36051. }
  36052. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  36053. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36055. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36056. if !m.op.Is(OpUpdateOne) {
  36057. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36058. }
  36059. if m.id == nil || m.oldValue == nil {
  36060. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36061. }
  36062. oldValue, err := m.oldValue(ctx)
  36063. if err != nil {
  36064. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36065. }
  36066. return oldValue.UpdatedAt, nil
  36067. }
  36068. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36069. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  36070. m.updated_at = nil
  36071. }
  36072. // SetStatus sets the "status" field.
  36073. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  36074. m.status = &u
  36075. m.addstatus = nil
  36076. }
  36077. // Status returns the value of the "status" field in the mutation.
  36078. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  36079. v := m.status
  36080. if v == nil {
  36081. return
  36082. }
  36083. return *v, true
  36084. }
  36085. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  36086. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36088. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36089. if !m.op.Is(OpUpdateOne) {
  36090. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36091. }
  36092. if m.id == nil || m.oldValue == nil {
  36093. return v, errors.New("OldStatus requires an ID field in the mutation")
  36094. }
  36095. oldValue, err := m.oldValue(ctx)
  36096. if err != nil {
  36097. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36098. }
  36099. return oldValue.Status, nil
  36100. }
  36101. // AddStatus adds u to the "status" field.
  36102. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  36103. if m.addstatus != nil {
  36104. *m.addstatus += u
  36105. } else {
  36106. m.addstatus = &u
  36107. }
  36108. }
  36109. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36110. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  36111. v := m.addstatus
  36112. if v == nil {
  36113. return
  36114. }
  36115. return *v, true
  36116. }
  36117. // ClearStatus clears the value of the "status" field.
  36118. func (m *UsageStatisticDayMutation) ClearStatus() {
  36119. m.status = nil
  36120. m.addstatus = nil
  36121. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  36122. }
  36123. // StatusCleared returns if the "status" field was cleared in this mutation.
  36124. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  36125. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  36126. return ok
  36127. }
  36128. // ResetStatus resets all changes to the "status" field.
  36129. func (m *UsageStatisticDayMutation) ResetStatus() {
  36130. m.status = nil
  36131. m.addstatus = nil
  36132. delete(m.clearedFields, usagestatisticday.FieldStatus)
  36133. }
  36134. // SetDeletedAt sets the "deleted_at" field.
  36135. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  36136. m.deleted_at = &t
  36137. }
  36138. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36139. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  36140. v := m.deleted_at
  36141. if v == nil {
  36142. return
  36143. }
  36144. return *v, true
  36145. }
  36146. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  36147. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36149. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36150. if !m.op.Is(OpUpdateOne) {
  36151. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36152. }
  36153. if m.id == nil || m.oldValue == nil {
  36154. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36155. }
  36156. oldValue, err := m.oldValue(ctx)
  36157. if err != nil {
  36158. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36159. }
  36160. return oldValue.DeletedAt, nil
  36161. }
  36162. // ClearDeletedAt clears the value of the "deleted_at" field.
  36163. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  36164. m.deleted_at = nil
  36165. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  36166. }
  36167. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36168. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  36169. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  36170. return ok
  36171. }
  36172. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36173. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  36174. m.deleted_at = nil
  36175. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  36176. }
  36177. // SetAddtime sets the "addtime" field.
  36178. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  36179. m.addtime = &u
  36180. m.addaddtime = nil
  36181. }
  36182. // Addtime returns the value of the "addtime" field in the mutation.
  36183. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  36184. v := m.addtime
  36185. if v == nil {
  36186. return
  36187. }
  36188. return *v, true
  36189. }
  36190. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  36191. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36193. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  36194. if !m.op.Is(OpUpdateOne) {
  36195. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  36196. }
  36197. if m.id == nil || m.oldValue == nil {
  36198. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36199. }
  36200. oldValue, err := m.oldValue(ctx)
  36201. if err != nil {
  36202. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36203. }
  36204. return oldValue.Addtime, nil
  36205. }
  36206. // AddAddtime adds u to the "addtime" field.
  36207. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  36208. if m.addaddtime != nil {
  36209. *m.addaddtime += u
  36210. } else {
  36211. m.addaddtime = &u
  36212. }
  36213. }
  36214. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36215. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  36216. v := m.addaddtime
  36217. if v == nil {
  36218. return
  36219. }
  36220. return *v, true
  36221. }
  36222. // ResetAddtime resets all changes to the "addtime" field.
  36223. func (m *UsageStatisticDayMutation) ResetAddtime() {
  36224. m.addtime = nil
  36225. m.addaddtime = nil
  36226. }
  36227. // SetType sets the "type" field.
  36228. func (m *UsageStatisticDayMutation) SetType(i int) {
  36229. m._type = &i
  36230. m.add_type = nil
  36231. }
  36232. // GetType returns the value of the "type" field in the mutation.
  36233. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  36234. v := m._type
  36235. if v == nil {
  36236. return
  36237. }
  36238. return *v, true
  36239. }
  36240. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  36241. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36243. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  36244. if !m.op.Is(OpUpdateOne) {
  36245. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36246. }
  36247. if m.id == nil || m.oldValue == nil {
  36248. return v, errors.New("OldType requires an ID field in the mutation")
  36249. }
  36250. oldValue, err := m.oldValue(ctx)
  36251. if err != nil {
  36252. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36253. }
  36254. return oldValue.Type, nil
  36255. }
  36256. // AddType adds i to the "type" field.
  36257. func (m *UsageStatisticDayMutation) AddType(i int) {
  36258. if m.add_type != nil {
  36259. *m.add_type += i
  36260. } else {
  36261. m.add_type = &i
  36262. }
  36263. }
  36264. // AddedType returns the value that was added to the "type" field in this mutation.
  36265. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  36266. v := m.add_type
  36267. if v == nil {
  36268. return
  36269. }
  36270. return *v, true
  36271. }
  36272. // ResetType resets all changes to the "type" field.
  36273. func (m *UsageStatisticDayMutation) ResetType() {
  36274. m._type = nil
  36275. m.add_type = nil
  36276. }
  36277. // SetBotID sets the "bot_id" field.
  36278. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  36279. m.bot_id = &s
  36280. }
  36281. // BotID returns the value of the "bot_id" field in the mutation.
  36282. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  36283. v := m.bot_id
  36284. if v == nil {
  36285. return
  36286. }
  36287. return *v, true
  36288. }
  36289. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  36290. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36292. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  36293. if !m.op.Is(OpUpdateOne) {
  36294. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36295. }
  36296. if m.id == nil || m.oldValue == nil {
  36297. return v, errors.New("OldBotID requires an ID field in the mutation")
  36298. }
  36299. oldValue, err := m.oldValue(ctx)
  36300. if err != nil {
  36301. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36302. }
  36303. return oldValue.BotID, nil
  36304. }
  36305. // ClearBotID clears the value of the "bot_id" field.
  36306. func (m *UsageStatisticDayMutation) ClearBotID() {
  36307. m.bot_id = nil
  36308. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  36309. }
  36310. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36311. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  36312. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  36313. return ok
  36314. }
  36315. // ResetBotID resets all changes to the "bot_id" field.
  36316. func (m *UsageStatisticDayMutation) ResetBotID() {
  36317. m.bot_id = nil
  36318. delete(m.clearedFields, usagestatisticday.FieldBotID)
  36319. }
  36320. // SetOrganizationID sets the "organization_id" field.
  36321. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  36322. m.organization_id = &u
  36323. m.addorganization_id = nil
  36324. }
  36325. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36326. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  36327. v := m.organization_id
  36328. if v == nil {
  36329. return
  36330. }
  36331. return *v, true
  36332. }
  36333. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  36334. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36336. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36337. if !m.op.Is(OpUpdateOne) {
  36338. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36339. }
  36340. if m.id == nil || m.oldValue == nil {
  36341. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36342. }
  36343. oldValue, err := m.oldValue(ctx)
  36344. if err != nil {
  36345. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36346. }
  36347. return oldValue.OrganizationID, nil
  36348. }
  36349. // AddOrganizationID adds u to the "organization_id" field.
  36350. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  36351. if m.addorganization_id != nil {
  36352. *m.addorganization_id += u
  36353. } else {
  36354. m.addorganization_id = &u
  36355. }
  36356. }
  36357. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36358. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  36359. v := m.addorganization_id
  36360. if v == nil {
  36361. return
  36362. }
  36363. return *v, true
  36364. }
  36365. // ClearOrganizationID clears the value of the "organization_id" field.
  36366. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  36367. m.organization_id = nil
  36368. m.addorganization_id = nil
  36369. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  36370. }
  36371. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36372. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  36373. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  36374. return ok
  36375. }
  36376. // ResetOrganizationID resets all changes to the "organization_id" field.
  36377. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  36378. m.organization_id = nil
  36379. m.addorganization_id = nil
  36380. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  36381. }
  36382. // SetAiResponse sets the "ai_response" field.
  36383. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  36384. m.ai_response = &u
  36385. m.addai_response = nil
  36386. }
  36387. // AiResponse returns the value of the "ai_response" field in the mutation.
  36388. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  36389. v := m.ai_response
  36390. if v == nil {
  36391. return
  36392. }
  36393. return *v, true
  36394. }
  36395. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  36396. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36398. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36399. if !m.op.Is(OpUpdateOne) {
  36400. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36401. }
  36402. if m.id == nil || m.oldValue == nil {
  36403. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36404. }
  36405. oldValue, err := m.oldValue(ctx)
  36406. if err != nil {
  36407. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36408. }
  36409. return oldValue.AiResponse, nil
  36410. }
  36411. // AddAiResponse adds u to the "ai_response" field.
  36412. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  36413. if m.addai_response != nil {
  36414. *m.addai_response += u
  36415. } else {
  36416. m.addai_response = &u
  36417. }
  36418. }
  36419. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36420. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  36421. v := m.addai_response
  36422. if v == nil {
  36423. return
  36424. }
  36425. return *v, true
  36426. }
  36427. // ResetAiResponse resets all changes to the "ai_response" field.
  36428. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  36429. m.ai_response = nil
  36430. m.addai_response = nil
  36431. }
  36432. // SetSopRun sets the "sop_run" field.
  36433. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  36434. m.sop_run = &u
  36435. m.addsop_run = nil
  36436. }
  36437. // SopRun returns the value of the "sop_run" field in the mutation.
  36438. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  36439. v := m.sop_run
  36440. if v == nil {
  36441. return
  36442. }
  36443. return *v, true
  36444. }
  36445. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  36446. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36448. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36449. if !m.op.Is(OpUpdateOne) {
  36450. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36451. }
  36452. if m.id == nil || m.oldValue == nil {
  36453. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36454. }
  36455. oldValue, err := m.oldValue(ctx)
  36456. if err != nil {
  36457. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36458. }
  36459. return oldValue.SopRun, nil
  36460. }
  36461. // AddSopRun adds u to the "sop_run" field.
  36462. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  36463. if m.addsop_run != nil {
  36464. *m.addsop_run += u
  36465. } else {
  36466. m.addsop_run = &u
  36467. }
  36468. }
  36469. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36470. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  36471. v := m.addsop_run
  36472. if v == nil {
  36473. return
  36474. }
  36475. return *v, true
  36476. }
  36477. // ResetSopRun resets all changes to the "sop_run" field.
  36478. func (m *UsageStatisticDayMutation) ResetSopRun() {
  36479. m.sop_run = nil
  36480. m.addsop_run = nil
  36481. }
  36482. // SetTotalFriend sets the "total_friend" field.
  36483. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  36484. m.total_friend = &u
  36485. m.addtotal_friend = nil
  36486. }
  36487. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36488. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  36489. v := m.total_friend
  36490. if v == nil {
  36491. return
  36492. }
  36493. return *v, true
  36494. }
  36495. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  36496. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36498. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36499. if !m.op.Is(OpUpdateOne) {
  36500. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36501. }
  36502. if m.id == nil || m.oldValue == nil {
  36503. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36504. }
  36505. oldValue, err := m.oldValue(ctx)
  36506. if err != nil {
  36507. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36508. }
  36509. return oldValue.TotalFriend, nil
  36510. }
  36511. // AddTotalFriend adds u to the "total_friend" field.
  36512. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  36513. if m.addtotal_friend != nil {
  36514. *m.addtotal_friend += u
  36515. } else {
  36516. m.addtotal_friend = &u
  36517. }
  36518. }
  36519. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36520. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  36521. v := m.addtotal_friend
  36522. if v == nil {
  36523. return
  36524. }
  36525. return *v, true
  36526. }
  36527. // ResetTotalFriend resets all changes to the "total_friend" field.
  36528. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  36529. m.total_friend = nil
  36530. m.addtotal_friend = nil
  36531. }
  36532. // SetTotalGroup sets the "total_group" field.
  36533. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  36534. m.total_group = &u
  36535. m.addtotal_group = nil
  36536. }
  36537. // TotalGroup returns the value of the "total_group" field in the mutation.
  36538. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  36539. v := m.total_group
  36540. if v == nil {
  36541. return
  36542. }
  36543. return *v, true
  36544. }
  36545. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  36546. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36548. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36549. if !m.op.Is(OpUpdateOne) {
  36550. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36551. }
  36552. if m.id == nil || m.oldValue == nil {
  36553. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36554. }
  36555. oldValue, err := m.oldValue(ctx)
  36556. if err != nil {
  36557. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36558. }
  36559. return oldValue.TotalGroup, nil
  36560. }
  36561. // AddTotalGroup adds u to the "total_group" field.
  36562. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  36563. if m.addtotal_group != nil {
  36564. *m.addtotal_group += u
  36565. } else {
  36566. m.addtotal_group = &u
  36567. }
  36568. }
  36569. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36570. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  36571. v := m.addtotal_group
  36572. if v == nil {
  36573. return
  36574. }
  36575. return *v, true
  36576. }
  36577. // ResetTotalGroup resets all changes to the "total_group" field.
  36578. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  36579. m.total_group = nil
  36580. m.addtotal_group = nil
  36581. }
  36582. // SetAccountBalance sets the "account_balance" field.
  36583. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  36584. m.account_balance = &u
  36585. m.addaccount_balance = nil
  36586. }
  36587. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36588. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  36589. v := m.account_balance
  36590. if v == nil {
  36591. return
  36592. }
  36593. return *v, true
  36594. }
  36595. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  36596. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36598. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36599. if !m.op.Is(OpUpdateOne) {
  36600. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36601. }
  36602. if m.id == nil || m.oldValue == nil {
  36603. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36604. }
  36605. oldValue, err := m.oldValue(ctx)
  36606. if err != nil {
  36607. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36608. }
  36609. return oldValue.AccountBalance, nil
  36610. }
  36611. // AddAccountBalance adds u to the "account_balance" field.
  36612. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  36613. if m.addaccount_balance != nil {
  36614. *m.addaccount_balance += u
  36615. } else {
  36616. m.addaccount_balance = &u
  36617. }
  36618. }
  36619. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36620. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  36621. v := m.addaccount_balance
  36622. if v == nil {
  36623. return
  36624. }
  36625. return *v, true
  36626. }
  36627. // ResetAccountBalance resets all changes to the "account_balance" field.
  36628. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  36629. m.account_balance = nil
  36630. m.addaccount_balance = nil
  36631. }
  36632. // SetConsumeToken sets the "consume_token" field.
  36633. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  36634. m.consume_token = &u
  36635. m.addconsume_token = nil
  36636. }
  36637. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36638. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  36639. v := m.consume_token
  36640. if v == nil {
  36641. return
  36642. }
  36643. return *v, true
  36644. }
  36645. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  36646. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36648. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36649. if !m.op.Is(OpUpdateOne) {
  36650. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36651. }
  36652. if m.id == nil || m.oldValue == nil {
  36653. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36654. }
  36655. oldValue, err := m.oldValue(ctx)
  36656. if err != nil {
  36657. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36658. }
  36659. return oldValue.ConsumeToken, nil
  36660. }
  36661. // AddConsumeToken adds u to the "consume_token" field.
  36662. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  36663. if m.addconsume_token != nil {
  36664. *m.addconsume_token += u
  36665. } else {
  36666. m.addconsume_token = &u
  36667. }
  36668. }
  36669. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36670. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  36671. v := m.addconsume_token
  36672. if v == nil {
  36673. return
  36674. }
  36675. return *v, true
  36676. }
  36677. // ResetConsumeToken resets all changes to the "consume_token" field.
  36678. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  36679. m.consume_token = nil
  36680. m.addconsume_token = nil
  36681. }
  36682. // SetActiveUser sets the "active_user" field.
  36683. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  36684. m.active_user = &u
  36685. m.addactive_user = nil
  36686. }
  36687. // ActiveUser returns the value of the "active_user" field in the mutation.
  36688. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  36689. v := m.active_user
  36690. if v == nil {
  36691. return
  36692. }
  36693. return *v, true
  36694. }
  36695. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  36696. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36698. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36699. if !m.op.Is(OpUpdateOne) {
  36700. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36701. }
  36702. if m.id == nil || m.oldValue == nil {
  36703. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36704. }
  36705. oldValue, err := m.oldValue(ctx)
  36706. if err != nil {
  36707. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36708. }
  36709. return oldValue.ActiveUser, nil
  36710. }
  36711. // AddActiveUser adds u to the "active_user" field.
  36712. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  36713. if m.addactive_user != nil {
  36714. *m.addactive_user += u
  36715. } else {
  36716. m.addactive_user = &u
  36717. }
  36718. }
  36719. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36720. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  36721. v := m.addactive_user
  36722. if v == nil {
  36723. return
  36724. }
  36725. return *v, true
  36726. }
  36727. // ResetActiveUser resets all changes to the "active_user" field.
  36728. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  36729. m.active_user = nil
  36730. m.addactive_user = nil
  36731. }
  36732. // SetNewUser sets the "new_user" field.
  36733. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  36734. m.new_user = &i
  36735. m.addnew_user = nil
  36736. }
  36737. // NewUser returns the value of the "new_user" field in the mutation.
  36738. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  36739. v := m.new_user
  36740. if v == nil {
  36741. return
  36742. }
  36743. return *v, true
  36744. }
  36745. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  36746. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36748. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36749. if !m.op.Is(OpUpdateOne) {
  36750. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36751. }
  36752. if m.id == nil || m.oldValue == nil {
  36753. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36754. }
  36755. oldValue, err := m.oldValue(ctx)
  36756. if err != nil {
  36757. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36758. }
  36759. return oldValue.NewUser, nil
  36760. }
  36761. // AddNewUser adds i to the "new_user" field.
  36762. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  36763. if m.addnew_user != nil {
  36764. *m.addnew_user += i
  36765. } else {
  36766. m.addnew_user = &i
  36767. }
  36768. }
  36769. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36770. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  36771. v := m.addnew_user
  36772. if v == nil {
  36773. return
  36774. }
  36775. return *v, true
  36776. }
  36777. // ResetNewUser resets all changes to the "new_user" field.
  36778. func (m *UsageStatisticDayMutation) ResetNewUser() {
  36779. m.new_user = nil
  36780. m.addnew_user = nil
  36781. }
  36782. // SetLabelDist sets the "label_dist" field.
  36783. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36784. m.label_dist = &ctd
  36785. m.appendlabel_dist = nil
  36786. }
  36787. // LabelDist returns the value of the "label_dist" field in the mutation.
  36788. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36789. v := m.label_dist
  36790. if v == nil {
  36791. return
  36792. }
  36793. return *v, true
  36794. }
  36795. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  36796. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36798. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36799. if !m.op.Is(OpUpdateOne) {
  36800. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36801. }
  36802. if m.id == nil || m.oldValue == nil {
  36803. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36804. }
  36805. oldValue, err := m.oldValue(ctx)
  36806. if err != nil {
  36807. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36808. }
  36809. return oldValue.LabelDist, nil
  36810. }
  36811. // AppendLabelDist adds ctd to the "label_dist" field.
  36812. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36813. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36814. }
  36815. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36816. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36817. if len(m.appendlabel_dist) == 0 {
  36818. return nil, false
  36819. }
  36820. return m.appendlabel_dist, true
  36821. }
  36822. // ResetLabelDist resets all changes to the "label_dist" field.
  36823. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  36824. m.label_dist = nil
  36825. m.appendlabel_dist = nil
  36826. }
  36827. // SetConsumeCoin sets the "consume_coin" field.
  36828. func (m *UsageStatisticDayMutation) SetConsumeCoin(f float64) {
  36829. m.consume_coin = &f
  36830. m.addconsume_coin = nil
  36831. }
  36832. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  36833. func (m *UsageStatisticDayMutation) ConsumeCoin() (r float64, exists bool) {
  36834. v := m.consume_coin
  36835. if v == nil {
  36836. return
  36837. }
  36838. return *v, true
  36839. }
  36840. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  36841. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36843. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  36844. if !m.op.Is(OpUpdateOne) {
  36845. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  36846. }
  36847. if m.id == nil || m.oldValue == nil {
  36848. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  36849. }
  36850. oldValue, err := m.oldValue(ctx)
  36851. if err != nil {
  36852. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  36853. }
  36854. return oldValue.ConsumeCoin, nil
  36855. }
  36856. // AddConsumeCoin adds f to the "consume_coin" field.
  36857. func (m *UsageStatisticDayMutation) AddConsumeCoin(f float64) {
  36858. if m.addconsume_coin != nil {
  36859. *m.addconsume_coin += f
  36860. } else {
  36861. m.addconsume_coin = &f
  36862. }
  36863. }
  36864. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  36865. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r float64, exists bool) {
  36866. v := m.addconsume_coin
  36867. if v == nil {
  36868. return
  36869. }
  36870. return *v, true
  36871. }
  36872. // ClearConsumeCoin clears the value of the "consume_coin" field.
  36873. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  36874. m.consume_coin = nil
  36875. m.addconsume_coin = nil
  36876. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  36877. }
  36878. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  36879. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  36880. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  36881. return ok
  36882. }
  36883. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  36884. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  36885. m.consume_coin = nil
  36886. m.addconsume_coin = nil
  36887. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  36888. }
  36889. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  36890. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  36891. m.predicates = append(m.predicates, ps...)
  36892. }
  36893. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  36894. // users can use type-assertion to append predicates that do not depend on any generated package.
  36895. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  36896. p := make([]predicate.UsageStatisticDay, len(ps))
  36897. for i := range ps {
  36898. p[i] = ps[i]
  36899. }
  36900. m.Where(p...)
  36901. }
  36902. // Op returns the operation name.
  36903. func (m *UsageStatisticDayMutation) Op() Op {
  36904. return m.op
  36905. }
  36906. // SetOp allows setting the mutation operation.
  36907. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  36908. m.op = op
  36909. }
  36910. // Type returns the node type of this mutation (UsageStatisticDay).
  36911. func (m *UsageStatisticDayMutation) Type() string {
  36912. return m.typ
  36913. }
  36914. // Fields returns all fields that were changed during this mutation. Note that in
  36915. // order to get all numeric fields that were incremented/decremented, call
  36916. // AddedFields().
  36917. func (m *UsageStatisticDayMutation) Fields() []string {
  36918. fields := make([]string, 0, 18)
  36919. if m.created_at != nil {
  36920. fields = append(fields, usagestatisticday.FieldCreatedAt)
  36921. }
  36922. if m.updated_at != nil {
  36923. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  36924. }
  36925. if m.status != nil {
  36926. fields = append(fields, usagestatisticday.FieldStatus)
  36927. }
  36928. if m.deleted_at != nil {
  36929. fields = append(fields, usagestatisticday.FieldDeletedAt)
  36930. }
  36931. if m.addtime != nil {
  36932. fields = append(fields, usagestatisticday.FieldAddtime)
  36933. }
  36934. if m._type != nil {
  36935. fields = append(fields, usagestatisticday.FieldType)
  36936. }
  36937. if m.bot_id != nil {
  36938. fields = append(fields, usagestatisticday.FieldBotID)
  36939. }
  36940. if m.organization_id != nil {
  36941. fields = append(fields, usagestatisticday.FieldOrganizationID)
  36942. }
  36943. if m.ai_response != nil {
  36944. fields = append(fields, usagestatisticday.FieldAiResponse)
  36945. }
  36946. if m.sop_run != nil {
  36947. fields = append(fields, usagestatisticday.FieldSopRun)
  36948. }
  36949. if m.total_friend != nil {
  36950. fields = append(fields, usagestatisticday.FieldTotalFriend)
  36951. }
  36952. if m.total_group != nil {
  36953. fields = append(fields, usagestatisticday.FieldTotalGroup)
  36954. }
  36955. if m.account_balance != nil {
  36956. fields = append(fields, usagestatisticday.FieldAccountBalance)
  36957. }
  36958. if m.consume_token != nil {
  36959. fields = append(fields, usagestatisticday.FieldConsumeToken)
  36960. }
  36961. if m.active_user != nil {
  36962. fields = append(fields, usagestatisticday.FieldActiveUser)
  36963. }
  36964. if m.new_user != nil {
  36965. fields = append(fields, usagestatisticday.FieldNewUser)
  36966. }
  36967. if m.label_dist != nil {
  36968. fields = append(fields, usagestatisticday.FieldLabelDist)
  36969. }
  36970. if m.consume_coin != nil {
  36971. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36972. }
  36973. return fields
  36974. }
  36975. // Field returns the value of a field with the given name. The second boolean
  36976. // return value indicates that this field was not set, or was not defined in the
  36977. // schema.
  36978. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  36979. switch name {
  36980. case usagestatisticday.FieldCreatedAt:
  36981. return m.CreatedAt()
  36982. case usagestatisticday.FieldUpdatedAt:
  36983. return m.UpdatedAt()
  36984. case usagestatisticday.FieldStatus:
  36985. return m.Status()
  36986. case usagestatisticday.FieldDeletedAt:
  36987. return m.DeletedAt()
  36988. case usagestatisticday.FieldAddtime:
  36989. return m.Addtime()
  36990. case usagestatisticday.FieldType:
  36991. return m.GetType()
  36992. case usagestatisticday.FieldBotID:
  36993. return m.BotID()
  36994. case usagestatisticday.FieldOrganizationID:
  36995. return m.OrganizationID()
  36996. case usagestatisticday.FieldAiResponse:
  36997. return m.AiResponse()
  36998. case usagestatisticday.FieldSopRun:
  36999. return m.SopRun()
  37000. case usagestatisticday.FieldTotalFriend:
  37001. return m.TotalFriend()
  37002. case usagestatisticday.FieldTotalGroup:
  37003. return m.TotalGroup()
  37004. case usagestatisticday.FieldAccountBalance:
  37005. return m.AccountBalance()
  37006. case usagestatisticday.FieldConsumeToken:
  37007. return m.ConsumeToken()
  37008. case usagestatisticday.FieldActiveUser:
  37009. return m.ActiveUser()
  37010. case usagestatisticday.FieldNewUser:
  37011. return m.NewUser()
  37012. case usagestatisticday.FieldLabelDist:
  37013. return m.LabelDist()
  37014. case usagestatisticday.FieldConsumeCoin:
  37015. return m.ConsumeCoin()
  37016. }
  37017. return nil, false
  37018. }
  37019. // OldField returns the old value of the field from the database. An error is
  37020. // returned if the mutation operation is not UpdateOne, or the query to the
  37021. // database failed.
  37022. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37023. switch name {
  37024. case usagestatisticday.FieldCreatedAt:
  37025. return m.OldCreatedAt(ctx)
  37026. case usagestatisticday.FieldUpdatedAt:
  37027. return m.OldUpdatedAt(ctx)
  37028. case usagestatisticday.FieldStatus:
  37029. return m.OldStatus(ctx)
  37030. case usagestatisticday.FieldDeletedAt:
  37031. return m.OldDeletedAt(ctx)
  37032. case usagestatisticday.FieldAddtime:
  37033. return m.OldAddtime(ctx)
  37034. case usagestatisticday.FieldType:
  37035. return m.OldType(ctx)
  37036. case usagestatisticday.FieldBotID:
  37037. return m.OldBotID(ctx)
  37038. case usagestatisticday.FieldOrganizationID:
  37039. return m.OldOrganizationID(ctx)
  37040. case usagestatisticday.FieldAiResponse:
  37041. return m.OldAiResponse(ctx)
  37042. case usagestatisticday.FieldSopRun:
  37043. return m.OldSopRun(ctx)
  37044. case usagestatisticday.FieldTotalFriend:
  37045. return m.OldTotalFriend(ctx)
  37046. case usagestatisticday.FieldTotalGroup:
  37047. return m.OldTotalGroup(ctx)
  37048. case usagestatisticday.FieldAccountBalance:
  37049. return m.OldAccountBalance(ctx)
  37050. case usagestatisticday.FieldConsumeToken:
  37051. return m.OldConsumeToken(ctx)
  37052. case usagestatisticday.FieldActiveUser:
  37053. return m.OldActiveUser(ctx)
  37054. case usagestatisticday.FieldNewUser:
  37055. return m.OldNewUser(ctx)
  37056. case usagestatisticday.FieldLabelDist:
  37057. return m.OldLabelDist(ctx)
  37058. case usagestatisticday.FieldConsumeCoin:
  37059. return m.OldConsumeCoin(ctx)
  37060. }
  37061. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37062. }
  37063. // SetField sets the value of a field with the given name. It returns an error if
  37064. // the field is not defined in the schema, or if the type mismatched the field
  37065. // type.
  37066. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  37067. switch name {
  37068. case usagestatisticday.FieldCreatedAt:
  37069. v, ok := value.(time.Time)
  37070. if !ok {
  37071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37072. }
  37073. m.SetCreatedAt(v)
  37074. return nil
  37075. case usagestatisticday.FieldUpdatedAt:
  37076. v, ok := value.(time.Time)
  37077. if !ok {
  37078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37079. }
  37080. m.SetUpdatedAt(v)
  37081. return nil
  37082. case usagestatisticday.FieldStatus:
  37083. v, ok := value.(uint8)
  37084. if !ok {
  37085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37086. }
  37087. m.SetStatus(v)
  37088. return nil
  37089. case usagestatisticday.FieldDeletedAt:
  37090. v, ok := value.(time.Time)
  37091. if !ok {
  37092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37093. }
  37094. m.SetDeletedAt(v)
  37095. return nil
  37096. case usagestatisticday.FieldAddtime:
  37097. v, ok := value.(uint64)
  37098. if !ok {
  37099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37100. }
  37101. m.SetAddtime(v)
  37102. return nil
  37103. case usagestatisticday.FieldType:
  37104. v, ok := value.(int)
  37105. if !ok {
  37106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37107. }
  37108. m.SetType(v)
  37109. return nil
  37110. case usagestatisticday.FieldBotID:
  37111. v, ok := value.(string)
  37112. if !ok {
  37113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37114. }
  37115. m.SetBotID(v)
  37116. return nil
  37117. case usagestatisticday.FieldOrganizationID:
  37118. v, ok := value.(uint64)
  37119. if !ok {
  37120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37121. }
  37122. m.SetOrganizationID(v)
  37123. return nil
  37124. case usagestatisticday.FieldAiResponse:
  37125. v, ok := value.(uint64)
  37126. if !ok {
  37127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37128. }
  37129. m.SetAiResponse(v)
  37130. return nil
  37131. case usagestatisticday.FieldSopRun:
  37132. v, ok := value.(uint64)
  37133. if !ok {
  37134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37135. }
  37136. m.SetSopRun(v)
  37137. return nil
  37138. case usagestatisticday.FieldTotalFriend:
  37139. v, ok := value.(uint64)
  37140. if !ok {
  37141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37142. }
  37143. m.SetTotalFriend(v)
  37144. return nil
  37145. case usagestatisticday.FieldTotalGroup:
  37146. v, ok := value.(uint64)
  37147. if !ok {
  37148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37149. }
  37150. m.SetTotalGroup(v)
  37151. return nil
  37152. case usagestatisticday.FieldAccountBalance:
  37153. v, ok := value.(uint64)
  37154. if !ok {
  37155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37156. }
  37157. m.SetAccountBalance(v)
  37158. return nil
  37159. case usagestatisticday.FieldConsumeToken:
  37160. v, ok := value.(uint64)
  37161. if !ok {
  37162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37163. }
  37164. m.SetConsumeToken(v)
  37165. return nil
  37166. case usagestatisticday.FieldActiveUser:
  37167. v, ok := value.(uint64)
  37168. if !ok {
  37169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37170. }
  37171. m.SetActiveUser(v)
  37172. return nil
  37173. case usagestatisticday.FieldNewUser:
  37174. v, ok := value.(int64)
  37175. if !ok {
  37176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37177. }
  37178. m.SetNewUser(v)
  37179. return nil
  37180. case usagestatisticday.FieldLabelDist:
  37181. v, ok := value.([]custom_types.LabelDist)
  37182. if !ok {
  37183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37184. }
  37185. m.SetLabelDist(v)
  37186. return nil
  37187. case usagestatisticday.FieldConsumeCoin:
  37188. v, ok := value.(float64)
  37189. if !ok {
  37190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37191. }
  37192. m.SetConsumeCoin(v)
  37193. return nil
  37194. }
  37195. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37196. }
  37197. // AddedFields returns all numeric fields that were incremented/decremented during
  37198. // this mutation.
  37199. func (m *UsageStatisticDayMutation) AddedFields() []string {
  37200. var fields []string
  37201. if m.addstatus != nil {
  37202. fields = append(fields, usagestatisticday.FieldStatus)
  37203. }
  37204. if m.addaddtime != nil {
  37205. fields = append(fields, usagestatisticday.FieldAddtime)
  37206. }
  37207. if m.add_type != nil {
  37208. fields = append(fields, usagestatisticday.FieldType)
  37209. }
  37210. if m.addorganization_id != nil {
  37211. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37212. }
  37213. if m.addai_response != nil {
  37214. fields = append(fields, usagestatisticday.FieldAiResponse)
  37215. }
  37216. if m.addsop_run != nil {
  37217. fields = append(fields, usagestatisticday.FieldSopRun)
  37218. }
  37219. if m.addtotal_friend != nil {
  37220. fields = append(fields, usagestatisticday.FieldTotalFriend)
  37221. }
  37222. if m.addtotal_group != nil {
  37223. fields = append(fields, usagestatisticday.FieldTotalGroup)
  37224. }
  37225. if m.addaccount_balance != nil {
  37226. fields = append(fields, usagestatisticday.FieldAccountBalance)
  37227. }
  37228. if m.addconsume_token != nil {
  37229. fields = append(fields, usagestatisticday.FieldConsumeToken)
  37230. }
  37231. if m.addactive_user != nil {
  37232. fields = append(fields, usagestatisticday.FieldActiveUser)
  37233. }
  37234. if m.addnew_user != nil {
  37235. fields = append(fields, usagestatisticday.FieldNewUser)
  37236. }
  37237. if m.addconsume_coin != nil {
  37238. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37239. }
  37240. return fields
  37241. }
  37242. // AddedField returns the numeric value that was incremented/decremented on a field
  37243. // with the given name. The second boolean return value indicates that this field
  37244. // was not set, or was not defined in the schema.
  37245. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  37246. switch name {
  37247. case usagestatisticday.FieldStatus:
  37248. return m.AddedStatus()
  37249. case usagestatisticday.FieldAddtime:
  37250. return m.AddedAddtime()
  37251. case usagestatisticday.FieldType:
  37252. return m.AddedType()
  37253. case usagestatisticday.FieldOrganizationID:
  37254. return m.AddedOrganizationID()
  37255. case usagestatisticday.FieldAiResponse:
  37256. return m.AddedAiResponse()
  37257. case usagestatisticday.FieldSopRun:
  37258. return m.AddedSopRun()
  37259. case usagestatisticday.FieldTotalFriend:
  37260. return m.AddedTotalFriend()
  37261. case usagestatisticday.FieldTotalGroup:
  37262. return m.AddedTotalGroup()
  37263. case usagestatisticday.FieldAccountBalance:
  37264. return m.AddedAccountBalance()
  37265. case usagestatisticday.FieldConsumeToken:
  37266. return m.AddedConsumeToken()
  37267. case usagestatisticday.FieldActiveUser:
  37268. return m.AddedActiveUser()
  37269. case usagestatisticday.FieldNewUser:
  37270. return m.AddedNewUser()
  37271. case usagestatisticday.FieldConsumeCoin:
  37272. return m.AddedConsumeCoin()
  37273. }
  37274. return nil, false
  37275. }
  37276. // AddField adds the value to the field with the given name. It returns an error if
  37277. // the field is not defined in the schema, or if the type mismatched the field
  37278. // type.
  37279. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  37280. switch name {
  37281. case usagestatisticday.FieldStatus:
  37282. v, ok := value.(int8)
  37283. if !ok {
  37284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37285. }
  37286. m.AddStatus(v)
  37287. return nil
  37288. case usagestatisticday.FieldAddtime:
  37289. v, ok := value.(int64)
  37290. if !ok {
  37291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37292. }
  37293. m.AddAddtime(v)
  37294. return nil
  37295. case usagestatisticday.FieldType:
  37296. v, ok := value.(int)
  37297. if !ok {
  37298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37299. }
  37300. m.AddType(v)
  37301. return nil
  37302. case usagestatisticday.FieldOrganizationID:
  37303. v, ok := value.(int64)
  37304. if !ok {
  37305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37306. }
  37307. m.AddOrganizationID(v)
  37308. return nil
  37309. case usagestatisticday.FieldAiResponse:
  37310. v, ok := value.(int64)
  37311. if !ok {
  37312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37313. }
  37314. m.AddAiResponse(v)
  37315. return nil
  37316. case usagestatisticday.FieldSopRun:
  37317. v, ok := value.(int64)
  37318. if !ok {
  37319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37320. }
  37321. m.AddSopRun(v)
  37322. return nil
  37323. case usagestatisticday.FieldTotalFriend:
  37324. v, ok := value.(int64)
  37325. if !ok {
  37326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37327. }
  37328. m.AddTotalFriend(v)
  37329. return nil
  37330. case usagestatisticday.FieldTotalGroup:
  37331. v, ok := value.(int64)
  37332. if !ok {
  37333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37334. }
  37335. m.AddTotalGroup(v)
  37336. return nil
  37337. case usagestatisticday.FieldAccountBalance:
  37338. v, ok := value.(int64)
  37339. if !ok {
  37340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37341. }
  37342. m.AddAccountBalance(v)
  37343. return nil
  37344. case usagestatisticday.FieldConsumeToken:
  37345. v, ok := value.(int64)
  37346. if !ok {
  37347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37348. }
  37349. m.AddConsumeToken(v)
  37350. return nil
  37351. case usagestatisticday.FieldActiveUser:
  37352. v, ok := value.(int64)
  37353. if !ok {
  37354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37355. }
  37356. m.AddActiveUser(v)
  37357. return nil
  37358. case usagestatisticday.FieldNewUser:
  37359. v, ok := value.(int64)
  37360. if !ok {
  37361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37362. }
  37363. m.AddNewUser(v)
  37364. return nil
  37365. case usagestatisticday.FieldConsumeCoin:
  37366. v, ok := value.(float64)
  37367. if !ok {
  37368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37369. }
  37370. m.AddConsumeCoin(v)
  37371. return nil
  37372. }
  37373. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  37374. }
  37375. // ClearedFields returns all nullable fields that were cleared during this
  37376. // mutation.
  37377. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  37378. var fields []string
  37379. if m.FieldCleared(usagestatisticday.FieldStatus) {
  37380. fields = append(fields, usagestatisticday.FieldStatus)
  37381. }
  37382. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  37383. fields = append(fields, usagestatisticday.FieldDeletedAt)
  37384. }
  37385. if m.FieldCleared(usagestatisticday.FieldBotID) {
  37386. fields = append(fields, usagestatisticday.FieldBotID)
  37387. }
  37388. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  37389. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37390. }
  37391. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  37392. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37393. }
  37394. return fields
  37395. }
  37396. // FieldCleared returns a boolean indicating if a field with the given name was
  37397. // cleared in this mutation.
  37398. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  37399. _, ok := m.clearedFields[name]
  37400. return ok
  37401. }
  37402. // ClearField clears the value of the field with the given name. It returns an
  37403. // error if the field is not defined in the schema.
  37404. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  37405. switch name {
  37406. case usagestatisticday.FieldStatus:
  37407. m.ClearStatus()
  37408. return nil
  37409. case usagestatisticday.FieldDeletedAt:
  37410. m.ClearDeletedAt()
  37411. return nil
  37412. case usagestatisticday.FieldBotID:
  37413. m.ClearBotID()
  37414. return nil
  37415. case usagestatisticday.FieldOrganizationID:
  37416. m.ClearOrganizationID()
  37417. return nil
  37418. case usagestatisticday.FieldConsumeCoin:
  37419. m.ClearConsumeCoin()
  37420. return nil
  37421. }
  37422. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  37423. }
  37424. // ResetField resets all changes in the mutation for the field with the given name.
  37425. // It returns an error if the field is not defined in the schema.
  37426. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  37427. switch name {
  37428. case usagestatisticday.FieldCreatedAt:
  37429. m.ResetCreatedAt()
  37430. return nil
  37431. case usagestatisticday.FieldUpdatedAt:
  37432. m.ResetUpdatedAt()
  37433. return nil
  37434. case usagestatisticday.FieldStatus:
  37435. m.ResetStatus()
  37436. return nil
  37437. case usagestatisticday.FieldDeletedAt:
  37438. m.ResetDeletedAt()
  37439. return nil
  37440. case usagestatisticday.FieldAddtime:
  37441. m.ResetAddtime()
  37442. return nil
  37443. case usagestatisticday.FieldType:
  37444. m.ResetType()
  37445. return nil
  37446. case usagestatisticday.FieldBotID:
  37447. m.ResetBotID()
  37448. return nil
  37449. case usagestatisticday.FieldOrganizationID:
  37450. m.ResetOrganizationID()
  37451. return nil
  37452. case usagestatisticday.FieldAiResponse:
  37453. m.ResetAiResponse()
  37454. return nil
  37455. case usagestatisticday.FieldSopRun:
  37456. m.ResetSopRun()
  37457. return nil
  37458. case usagestatisticday.FieldTotalFriend:
  37459. m.ResetTotalFriend()
  37460. return nil
  37461. case usagestatisticday.FieldTotalGroup:
  37462. m.ResetTotalGroup()
  37463. return nil
  37464. case usagestatisticday.FieldAccountBalance:
  37465. m.ResetAccountBalance()
  37466. return nil
  37467. case usagestatisticday.FieldConsumeToken:
  37468. m.ResetConsumeToken()
  37469. return nil
  37470. case usagestatisticday.FieldActiveUser:
  37471. m.ResetActiveUser()
  37472. return nil
  37473. case usagestatisticday.FieldNewUser:
  37474. m.ResetNewUser()
  37475. return nil
  37476. case usagestatisticday.FieldLabelDist:
  37477. m.ResetLabelDist()
  37478. return nil
  37479. case usagestatisticday.FieldConsumeCoin:
  37480. m.ResetConsumeCoin()
  37481. return nil
  37482. }
  37483. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37484. }
  37485. // AddedEdges returns all edge names that were set/added in this mutation.
  37486. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  37487. edges := make([]string, 0, 0)
  37488. return edges
  37489. }
  37490. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37491. // name in this mutation.
  37492. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  37493. return nil
  37494. }
  37495. // RemovedEdges returns all edge names that were removed in this mutation.
  37496. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  37497. edges := make([]string, 0, 0)
  37498. return edges
  37499. }
  37500. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37501. // the given name in this mutation.
  37502. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  37503. return nil
  37504. }
  37505. // ClearedEdges returns all edge names that were cleared in this mutation.
  37506. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  37507. edges := make([]string, 0, 0)
  37508. return edges
  37509. }
  37510. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37511. // was cleared in this mutation.
  37512. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  37513. return false
  37514. }
  37515. // ClearEdge clears the value of the edge with the given name. It returns an error
  37516. // if that edge is not defined in the schema.
  37517. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  37518. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  37519. }
  37520. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37521. // It returns an error if the edge is not defined in the schema.
  37522. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  37523. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  37524. }
  37525. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  37526. type UsageStatisticHourMutation struct {
  37527. config
  37528. op Op
  37529. typ string
  37530. id *uint64
  37531. created_at *time.Time
  37532. updated_at *time.Time
  37533. status *uint8
  37534. addstatus *int8
  37535. deleted_at *time.Time
  37536. addtime *uint64
  37537. addaddtime *int64
  37538. _type *int
  37539. add_type *int
  37540. bot_id *string
  37541. organization_id *uint64
  37542. addorganization_id *int64
  37543. ai_response *uint64
  37544. addai_response *int64
  37545. sop_run *uint64
  37546. addsop_run *int64
  37547. total_friend *uint64
  37548. addtotal_friend *int64
  37549. total_group *uint64
  37550. addtotal_group *int64
  37551. account_balance *uint64
  37552. addaccount_balance *int64
  37553. consume_token *uint64
  37554. addconsume_token *int64
  37555. active_user *uint64
  37556. addactive_user *int64
  37557. new_user *int64
  37558. addnew_user *int64
  37559. label_dist *[]custom_types.LabelDist
  37560. appendlabel_dist []custom_types.LabelDist
  37561. consume_coin *float64
  37562. addconsume_coin *float64
  37563. clearedFields map[string]struct{}
  37564. done bool
  37565. oldValue func(context.Context) (*UsageStatisticHour, error)
  37566. predicates []predicate.UsageStatisticHour
  37567. }
  37568. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  37569. // usagestatistichourOption allows management of the mutation configuration using functional options.
  37570. type usagestatistichourOption func(*UsageStatisticHourMutation)
  37571. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  37572. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  37573. m := &UsageStatisticHourMutation{
  37574. config: c,
  37575. op: op,
  37576. typ: TypeUsageStatisticHour,
  37577. clearedFields: make(map[string]struct{}),
  37578. }
  37579. for _, opt := range opts {
  37580. opt(m)
  37581. }
  37582. return m
  37583. }
  37584. // withUsageStatisticHourID sets the ID field of the mutation.
  37585. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  37586. return func(m *UsageStatisticHourMutation) {
  37587. var (
  37588. err error
  37589. once sync.Once
  37590. value *UsageStatisticHour
  37591. )
  37592. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  37593. once.Do(func() {
  37594. if m.done {
  37595. err = errors.New("querying old values post mutation is not allowed")
  37596. } else {
  37597. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  37598. }
  37599. })
  37600. return value, err
  37601. }
  37602. m.id = &id
  37603. }
  37604. }
  37605. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  37606. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  37607. return func(m *UsageStatisticHourMutation) {
  37608. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  37609. return node, nil
  37610. }
  37611. m.id = &node.ID
  37612. }
  37613. }
  37614. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37615. // executed in a transaction (ent.Tx), a transactional client is returned.
  37616. func (m UsageStatisticHourMutation) Client() *Client {
  37617. client := &Client{config: m.config}
  37618. client.init()
  37619. return client
  37620. }
  37621. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37622. // it returns an error otherwise.
  37623. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  37624. if _, ok := m.driver.(*txDriver); !ok {
  37625. return nil, errors.New("ent: mutation is not running in a transaction")
  37626. }
  37627. tx := &Tx{config: m.config}
  37628. tx.init()
  37629. return tx, nil
  37630. }
  37631. // SetID sets the value of the id field. Note that this
  37632. // operation is only accepted on creation of UsageStatisticHour entities.
  37633. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  37634. m.id = &id
  37635. }
  37636. // ID returns the ID value in the mutation. Note that the ID is only available
  37637. // if it was provided to the builder or after it was returned from the database.
  37638. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  37639. if m.id == nil {
  37640. return
  37641. }
  37642. return *m.id, true
  37643. }
  37644. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37645. // That means, if the mutation is applied within a transaction with an isolation level such
  37646. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37647. // or updated by the mutation.
  37648. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  37649. switch {
  37650. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37651. id, exists := m.ID()
  37652. if exists {
  37653. return []uint64{id}, nil
  37654. }
  37655. fallthrough
  37656. case m.op.Is(OpUpdate | OpDelete):
  37657. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  37658. default:
  37659. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37660. }
  37661. }
  37662. // SetCreatedAt sets the "created_at" field.
  37663. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  37664. m.created_at = &t
  37665. }
  37666. // CreatedAt returns the value of the "created_at" field in the mutation.
  37667. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  37668. v := m.created_at
  37669. if v == nil {
  37670. return
  37671. }
  37672. return *v, true
  37673. }
  37674. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  37675. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37677. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37678. if !m.op.Is(OpUpdateOne) {
  37679. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37680. }
  37681. if m.id == nil || m.oldValue == nil {
  37682. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37683. }
  37684. oldValue, err := m.oldValue(ctx)
  37685. if err != nil {
  37686. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37687. }
  37688. return oldValue.CreatedAt, nil
  37689. }
  37690. // ResetCreatedAt resets all changes to the "created_at" field.
  37691. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  37692. m.created_at = nil
  37693. }
  37694. // SetUpdatedAt sets the "updated_at" field.
  37695. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  37696. m.updated_at = &t
  37697. }
  37698. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37699. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  37700. v := m.updated_at
  37701. if v == nil {
  37702. return
  37703. }
  37704. return *v, true
  37705. }
  37706. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  37707. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37709. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37710. if !m.op.Is(OpUpdateOne) {
  37711. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37712. }
  37713. if m.id == nil || m.oldValue == nil {
  37714. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37715. }
  37716. oldValue, err := m.oldValue(ctx)
  37717. if err != nil {
  37718. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37719. }
  37720. return oldValue.UpdatedAt, nil
  37721. }
  37722. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37723. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  37724. m.updated_at = nil
  37725. }
  37726. // SetStatus sets the "status" field.
  37727. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  37728. m.status = &u
  37729. m.addstatus = nil
  37730. }
  37731. // Status returns the value of the "status" field in the mutation.
  37732. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  37733. v := m.status
  37734. if v == nil {
  37735. return
  37736. }
  37737. return *v, true
  37738. }
  37739. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  37740. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37742. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37743. if !m.op.Is(OpUpdateOne) {
  37744. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37745. }
  37746. if m.id == nil || m.oldValue == nil {
  37747. return v, errors.New("OldStatus requires an ID field in the mutation")
  37748. }
  37749. oldValue, err := m.oldValue(ctx)
  37750. if err != nil {
  37751. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37752. }
  37753. return oldValue.Status, nil
  37754. }
  37755. // AddStatus adds u to the "status" field.
  37756. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  37757. if m.addstatus != nil {
  37758. *m.addstatus += u
  37759. } else {
  37760. m.addstatus = &u
  37761. }
  37762. }
  37763. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37764. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  37765. v := m.addstatus
  37766. if v == nil {
  37767. return
  37768. }
  37769. return *v, true
  37770. }
  37771. // ClearStatus clears the value of the "status" field.
  37772. func (m *UsageStatisticHourMutation) ClearStatus() {
  37773. m.status = nil
  37774. m.addstatus = nil
  37775. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  37776. }
  37777. // StatusCleared returns if the "status" field was cleared in this mutation.
  37778. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  37779. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  37780. return ok
  37781. }
  37782. // ResetStatus resets all changes to the "status" field.
  37783. func (m *UsageStatisticHourMutation) ResetStatus() {
  37784. m.status = nil
  37785. m.addstatus = nil
  37786. delete(m.clearedFields, usagestatistichour.FieldStatus)
  37787. }
  37788. // SetDeletedAt sets the "deleted_at" field.
  37789. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  37790. m.deleted_at = &t
  37791. }
  37792. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37793. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  37794. v := m.deleted_at
  37795. if v == nil {
  37796. return
  37797. }
  37798. return *v, true
  37799. }
  37800. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  37801. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37803. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37804. if !m.op.Is(OpUpdateOne) {
  37805. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37806. }
  37807. if m.id == nil || m.oldValue == nil {
  37808. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37809. }
  37810. oldValue, err := m.oldValue(ctx)
  37811. if err != nil {
  37812. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37813. }
  37814. return oldValue.DeletedAt, nil
  37815. }
  37816. // ClearDeletedAt clears the value of the "deleted_at" field.
  37817. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  37818. m.deleted_at = nil
  37819. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  37820. }
  37821. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37822. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  37823. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  37824. return ok
  37825. }
  37826. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37827. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  37828. m.deleted_at = nil
  37829. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  37830. }
  37831. // SetAddtime sets the "addtime" field.
  37832. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  37833. m.addtime = &u
  37834. m.addaddtime = nil
  37835. }
  37836. // Addtime returns the value of the "addtime" field in the mutation.
  37837. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  37838. v := m.addtime
  37839. if v == nil {
  37840. return
  37841. }
  37842. return *v, true
  37843. }
  37844. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  37845. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37847. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37848. if !m.op.Is(OpUpdateOne) {
  37849. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37850. }
  37851. if m.id == nil || m.oldValue == nil {
  37852. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37853. }
  37854. oldValue, err := m.oldValue(ctx)
  37855. if err != nil {
  37856. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37857. }
  37858. return oldValue.Addtime, nil
  37859. }
  37860. // AddAddtime adds u to the "addtime" field.
  37861. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  37862. if m.addaddtime != nil {
  37863. *m.addaddtime += u
  37864. } else {
  37865. m.addaddtime = &u
  37866. }
  37867. }
  37868. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37869. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  37870. v := m.addaddtime
  37871. if v == nil {
  37872. return
  37873. }
  37874. return *v, true
  37875. }
  37876. // ResetAddtime resets all changes to the "addtime" field.
  37877. func (m *UsageStatisticHourMutation) ResetAddtime() {
  37878. m.addtime = nil
  37879. m.addaddtime = nil
  37880. }
  37881. // SetType sets the "type" field.
  37882. func (m *UsageStatisticHourMutation) SetType(i int) {
  37883. m._type = &i
  37884. m.add_type = nil
  37885. }
  37886. // GetType returns the value of the "type" field in the mutation.
  37887. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  37888. v := m._type
  37889. if v == nil {
  37890. return
  37891. }
  37892. return *v, true
  37893. }
  37894. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  37895. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37897. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  37898. if !m.op.Is(OpUpdateOne) {
  37899. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37900. }
  37901. if m.id == nil || m.oldValue == nil {
  37902. return v, errors.New("OldType requires an ID field in the mutation")
  37903. }
  37904. oldValue, err := m.oldValue(ctx)
  37905. if err != nil {
  37906. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37907. }
  37908. return oldValue.Type, nil
  37909. }
  37910. // AddType adds i to the "type" field.
  37911. func (m *UsageStatisticHourMutation) AddType(i int) {
  37912. if m.add_type != nil {
  37913. *m.add_type += i
  37914. } else {
  37915. m.add_type = &i
  37916. }
  37917. }
  37918. // AddedType returns the value that was added to the "type" field in this mutation.
  37919. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  37920. v := m.add_type
  37921. if v == nil {
  37922. return
  37923. }
  37924. return *v, true
  37925. }
  37926. // ResetType resets all changes to the "type" field.
  37927. func (m *UsageStatisticHourMutation) ResetType() {
  37928. m._type = nil
  37929. m.add_type = nil
  37930. }
  37931. // SetBotID sets the "bot_id" field.
  37932. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  37933. m.bot_id = &s
  37934. }
  37935. // BotID returns the value of the "bot_id" field in the mutation.
  37936. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  37937. v := m.bot_id
  37938. if v == nil {
  37939. return
  37940. }
  37941. return *v, true
  37942. }
  37943. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  37944. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37946. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  37947. if !m.op.Is(OpUpdateOne) {
  37948. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37949. }
  37950. if m.id == nil || m.oldValue == nil {
  37951. return v, errors.New("OldBotID requires an ID field in the mutation")
  37952. }
  37953. oldValue, err := m.oldValue(ctx)
  37954. if err != nil {
  37955. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37956. }
  37957. return oldValue.BotID, nil
  37958. }
  37959. // ClearBotID clears the value of the "bot_id" field.
  37960. func (m *UsageStatisticHourMutation) ClearBotID() {
  37961. m.bot_id = nil
  37962. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  37963. }
  37964. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  37965. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  37966. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  37967. return ok
  37968. }
  37969. // ResetBotID resets all changes to the "bot_id" field.
  37970. func (m *UsageStatisticHourMutation) ResetBotID() {
  37971. m.bot_id = nil
  37972. delete(m.clearedFields, usagestatistichour.FieldBotID)
  37973. }
  37974. // SetOrganizationID sets the "organization_id" field.
  37975. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  37976. m.organization_id = &u
  37977. m.addorganization_id = nil
  37978. }
  37979. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37980. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  37981. v := m.organization_id
  37982. if v == nil {
  37983. return
  37984. }
  37985. return *v, true
  37986. }
  37987. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  37988. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37990. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37991. if !m.op.Is(OpUpdateOne) {
  37992. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37993. }
  37994. if m.id == nil || m.oldValue == nil {
  37995. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37996. }
  37997. oldValue, err := m.oldValue(ctx)
  37998. if err != nil {
  37999. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38000. }
  38001. return oldValue.OrganizationID, nil
  38002. }
  38003. // AddOrganizationID adds u to the "organization_id" field.
  38004. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  38005. if m.addorganization_id != nil {
  38006. *m.addorganization_id += u
  38007. } else {
  38008. m.addorganization_id = &u
  38009. }
  38010. }
  38011. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38012. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  38013. v := m.addorganization_id
  38014. if v == nil {
  38015. return
  38016. }
  38017. return *v, true
  38018. }
  38019. // ClearOrganizationID clears the value of the "organization_id" field.
  38020. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  38021. m.organization_id = nil
  38022. m.addorganization_id = nil
  38023. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  38024. }
  38025. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38026. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  38027. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  38028. return ok
  38029. }
  38030. // ResetOrganizationID resets all changes to the "organization_id" field.
  38031. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  38032. m.organization_id = nil
  38033. m.addorganization_id = nil
  38034. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  38035. }
  38036. // SetAiResponse sets the "ai_response" field.
  38037. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  38038. m.ai_response = &u
  38039. m.addai_response = nil
  38040. }
  38041. // AiResponse returns the value of the "ai_response" field in the mutation.
  38042. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  38043. v := m.ai_response
  38044. if v == nil {
  38045. return
  38046. }
  38047. return *v, true
  38048. }
  38049. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  38050. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38052. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  38053. if !m.op.Is(OpUpdateOne) {
  38054. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  38055. }
  38056. if m.id == nil || m.oldValue == nil {
  38057. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  38058. }
  38059. oldValue, err := m.oldValue(ctx)
  38060. if err != nil {
  38061. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  38062. }
  38063. return oldValue.AiResponse, nil
  38064. }
  38065. // AddAiResponse adds u to the "ai_response" field.
  38066. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  38067. if m.addai_response != nil {
  38068. *m.addai_response += u
  38069. } else {
  38070. m.addai_response = &u
  38071. }
  38072. }
  38073. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  38074. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  38075. v := m.addai_response
  38076. if v == nil {
  38077. return
  38078. }
  38079. return *v, true
  38080. }
  38081. // ResetAiResponse resets all changes to the "ai_response" field.
  38082. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  38083. m.ai_response = nil
  38084. m.addai_response = nil
  38085. }
  38086. // SetSopRun sets the "sop_run" field.
  38087. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  38088. m.sop_run = &u
  38089. m.addsop_run = nil
  38090. }
  38091. // SopRun returns the value of the "sop_run" field in the mutation.
  38092. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  38093. v := m.sop_run
  38094. if v == nil {
  38095. return
  38096. }
  38097. return *v, true
  38098. }
  38099. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  38100. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38102. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  38103. if !m.op.Is(OpUpdateOne) {
  38104. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  38105. }
  38106. if m.id == nil || m.oldValue == nil {
  38107. return v, errors.New("OldSopRun requires an ID field in the mutation")
  38108. }
  38109. oldValue, err := m.oldValue(ctx)
  38110. if err != nil {
  38111. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  38112. }
  38113. return oldValue.SopRun, nil
  38114. }
  38115. // AddSopRun adds u to the "sop_run" field.
  38116. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  38117. if m.addsop_run != nil {
  38118. *m.addsop_run += u
  38119. } else {
  38120. m.addsop_run = &u
  38121. }
  38122. }
  38123. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  38124. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  38125. v := m.addsop_run
  38126. if v == nil {
  38127. return
  38128. }
  38129. return *v, true
  38130. }
  38131. // ResetSopRun resets all changes to the "sop_run" field.
  38132. func (m *UsageStatisticHourMutation) ResetSopRun() {
  38133. m.sop_run = nil
  38134. m.addsop_run = nil
  38135. }
  38136. // SetTotalFriend sets the "total_friend" field.
  38137. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  38138. m.total_friend = &u
  38139. m.addtotal_friend = nil
  38140. }
  38141. // TotalFriend returns the value of the "total_friend" field in the mutation.
  38142. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  38143. v := m.total_friend
  38144. if v == nil {
  38145. return
  38146. }
  38147. return *v, true
  38148. }
  38149. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  38150. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38152. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  38153. if !m.op.Is(OpUpdateOne) {
  38154. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  38155. }
  38156. if m.id == nil || m.oldValue == nil {
  38157. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  38158. }
  38159. oldValue, err := m.oldValue(ctx)
  38160. if err != nil {
  38161. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  38162. }
  38163. return oldValue.TotalFriend, nil
  38164. }
  38165. // AddTotalFriend adds u to the "total_friend" field.
  38166. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  38167. if m.addtotal_friend != nil {
  38168. *m.addtotal_friend += u
  38169. } else {
  38170. m.addtotal_friend = &u
  38171. }
  38172. }
  38173. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  38174. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  38175. v := m.addtotal_friend
  38176. if v == nil {
  38177. return
  38178. }
  38179. return *v, true
  38180. }
  38181. // ResetTotalFriend resets all changes to the "total_friend" field.
  38182. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  38183. m.total_friend = nil
  38184. m.addtotal_friend = nil
  38185. }
  38186. // SetTotalGroup sets the "total_group" field.
  38187. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  38188. m.total_group = &u
  38189. m.addtotal_group = nil
  38190. }
  38191. // TotalGroup returns the value of the "total_group" field in the mutation.
  38192. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  38193. v := m.total_group
  38194. if v == nil {
  38195. return
  38196. }
  38197. return *v, true
  38198. }
  38199. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  38200. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38202. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  38203. if !m.op.Is(OpUpdateOne) {
  38204. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  38205. }
  38206. if m.id == nil || m.oldValue == nil {
  38207. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  38208. }
  38209. oldValue, err := m.oldValue(ctx)
  38210. if err != nil {
  38211. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  38212. }
  38213. return oldValue.TotalGroup, nil
  38214. }
  38215. // AddTotalGroup adds u to the "total_group" field.
  38216. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  38217. if m.addtotal_group != nil {
  38218. *m.addtotal_group += u
  38219. } else {
  38220. m.addtotal_group = &u
  38221. }
  38222. }
  38223. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  38224. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  38225. v := m.addtotal_group
  38226. if v == nil {
  38227. return
  38228. }
  38229. return *v, true
  38230. }
  38231. // ResetTotalGroup resets all changes to the "total_group" field.
  38232. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  38233. m.total_group = nil
  38234. m.addtotal_group = nil
  38235. }
  38236. // SetAccountBalance sets the "account_balance" field.
  38237. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  38238. m.account_balance = &u
  38239. m.addaccount_balance = nil
  38240. }
  38241. // AccountBalance returns the value of the "account_balance" field in the mutation.
  38242. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  38243. v := m.account_balance
  38244. if v == nil {
  38245. return
  38246. }
  38247. return *v, true
  38248. }
  38249. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  38250. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38252. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  38253. if !m.op.Is(OpUpdateOne) {
  38254. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  38255. }
  38256. if m.id == nil || m.oldValue == nil {
  38257. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  38258. }
  38259. oldValue, err := m.oldValue(ctx)
  38260. if err != nil {
  38261. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  38262. }
  38263. return oldValue.AccountBalance, nil
  38264. }
  38265. // AddAccountBalance adds u to the "account_balance" field.
  38266. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  38267. if m.addaccount_balance != nil {
  38268. *m.addaccount_balance += u
  38269. } else {
  38270. m.addaccount_balance = &u
  38271. }
  38272. }
  38273. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  38274. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  38275. v := m.addaccount_balance
  38276. if v == nil {
  38277. return
  38278. }
  38279. return *v, true
  38280. }
  38281. // ResetAccountBalance resets all changes to the "account_balance" field.
  38282. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  38283. m.account_balance = nil
  38284. m.addaccount_balance = nil
  38285. }
  38286. // SetConsumeToken sets the "consume_token" field.
  38287. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  38288. m.consume_token = &u
  38289. m.addconsume_token = nil
  38290. }
  38291. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  38292. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  38293. v := m.consume_token
  38294. if v == nil {
  38295. return
  38296. }
  38297. return *v, true
  38298. }
  38299. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  38300. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38302. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38303. if !m.op.Is(OpUpdateOne) {
  38304. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38305. }
  38306. if m.id == nil || m.oldValue == nil {
  38307. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38308. }
  38309. oldValue, err := m.oldValue(ctx)
  38310. if err != nil {
  38311. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38312. }
  38313. return oldValue.ConsumeToken, nil
  38314. }
  38315. // AddConsumeToken adds u to the "consume_token" field.
  38316. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  38317. if m.addconsume_token != nil {
  38318. *m.addconsume_token += u
  38319. } else {
  38320. m.addconsume_token = &u
  38321. }
  38322. }
  38323. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38324. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  38325. v := m.addconsume_token
  38326. if v == nil {
  38327. return
  38328. }
  38329. return *v, true
  38330. }
  38331. // ResetConsumeToken resets all changes to the "consume_token" field.
  38332. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  38333. m.consume_token = nil
  38334. m.addconsume_token = nil
  38335. }
  38336. // SetActiveUser sets the "active_user" field.
  38337. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  38338. m.active_user = &u
  38339. m.addactive_user = nil
  38340. }
  38341. // ActiveUser returns the value of the "active_user" field in the mutation.
  38342. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  38343. v := m.active_user
  38344. if v == nil {
  38345. return
  38346. }
  38347. return *v, true
  38348. }
  38349. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  38350. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38352. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38353. if !m.op.Is(OpUpdateOne) {
  38354. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38355. }
  38356. if m.id == nil || m.oldValue == nil {
  38357. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  38358. }
  38359. oldValue, err := m.oldValue(ctx)
  38360. if err != nil {
  38361. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  38362. }
  38363. return oldValue.ActiveUser, nil
  38364. }
  38365. // AddActiveUser adds u to the "active_user" field.
  38366. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  38367. if m.addactive_user != nil {
  38368. *m.addactive_user += u
  38369. } else {
  38370. m.addactive_user = &u
  38371. }
  38372. }
  38373. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38374. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  38375. v := m.addactive_user
  38376. if v == nil {
  38377. return
  38378. }
  38379. return *v, true
  38380. }
  38381. // ResetActiveUser resets all changes to the "active_user" field.
  38382. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  38383. m.active_user = nil
  38384. m.addactive_user = nil
  38385. }
  38386. // SetNewUser sets the "new_user" field.
  38387. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  38388. m.new_user = &i
  38389. m.addnew_user = nil
  38390. }
  38391. // NewUser returns the value of the "new_user" field in the mutation.
  38392. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  38393. v := m.new_user
  38394. if v == nil {
  38395. return
  38396. }
  38397. return *v, true
  38398. }
  38399. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  38400. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38402. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38403. if !m.op.Is(OpUpdateOne) {
  38404. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38405. }
  38406. if m.id == nil || m.oldValue == nil {
  38407. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38408. }
  38409. oldValue, err := m.oldValue(ctx)
  38410. if err != nil {
  38411. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38412. }
  38413. return oldValue.NewUser, nil
  38414. }
  38415. // AddNewUser adds i to the "new_user" field.
  38416. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  38417. if m.addnew_user != nil {
  38418. *m.addnew_user += i
  38419. } else {
  38420. m.addnew_user = &i
  38421. }
  38422. }
  38423. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38424. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  38425. v := m.addnew_user
  38426. if v == nil {
  38427. return
  38428. }
  38429. return *v, true
  38430. }
  38431. // ResetNewUser resets all changes to the "new_user" field.
  38432. func (m *UsageStatisticHourMutation) ResetNewUser() {
  38433. m.new_user = nil
  38434. m.addnew_user = nil
  38435. }
  38436. // SetLabelDist sets the "label_dist" field.
  38437. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38438. m.label_dist = &ctd
  38439. m.appendlabel_dist = nil
  38440. }
  38441. // LabelDist returns the value of the "label_dist" field in the mutation.
  38442. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38443. v := m.label_dist
  38444. if v == nil {
  38445. return
  38446. }
  38447. return *v, true
  38448. }
  38449. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  38450. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38452. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38453. if !m.op.Is(OpUpdateOne) {
  38454. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38455. }
  38456. if m.id == nil || m.oldValue == nil {
  38457. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38458. }
  38459. oldValue, err := m.oldValue(ctx)
  38460. if err != nil {
  38461. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38462. }
  38463. return oldValue.LabelDist, nil
  38464. }
  38465. // AppendLabelDist adds ctd to the "label_dist" field.
  38466. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38467. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38468. }
  38469. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38470. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38471. if len(m.appendlabel_dist) == 0 {
  38472. return nil, false
  38473. }
  38474. return m.appendlabel_dist, true
  38475. }
  38476. // ResetLabelDist resets all changes to the "label_dist" field.
  38477. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  38478. m.label_dist = nil
  38479. m.appendlabel_dist = nil
  38480. }
  38481. // SetConsumeCoin sets the "consume_coin" field.
  38482. func (m *UsageStatisticHourMutation) SetConsumeCoin(f float64) {
  38483. m.consume_coin = &f
  38484. m.addconsume_coin = nil
  38485. }
  38486. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  38487. func (m *UsageStatisticHourMutation) ConsumeCoin() (r float64, exists bool) {
  38488. v := m.consume_coin
  38489. if v == nil {
  38490. return
  38491. }
  38492. return *v, true
  38493. }
  38494. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  38495. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38497. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  38498. if !m.op.Is(OpUpdateOne) {
  38499. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  38500. }
  38501. if m.id == nil || m.oldValue == nil {
  38502. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  38503. }
  38504. oldValue, err := m.oldValue(ctx)
  38505. if err != nil {
  38506. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  38507. }
  38508. return oldValue.ConsumeCoin, nil
  38509. }
  38510. // AddConsumeCoin adds f to the "consume_coin" field.
  38511. func (m *UsageStatisticHourMutation) AddConsumeCoin(f float64) {
  38512. if m.addconsume_coin != nil {
  38513. *m.addconsume_coin += f
  38514. } else {
  38515. m.addconsume_coin = &f
  38516. }
  38517. }
  38518. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  38519. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r float64, exists bool) {
  38520. v := m.addconsume_coin
  38521. if v == nil {
  38522. return
  38523. }
  38524. return *v, true
  38525. }
  38526. // ClearConsumeCoin clears the value of the "consume_coin" field.
  38527. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  38528. m.consume_coin = nil
  38529. m.addconsume_coin = nil
  38530. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  38531. }
  38532. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  38533. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  38534. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  38535. return ok
  38536. }
  38537. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  38538. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  38539. m.consume_coin = nil
  38540. m.addconsume_coin = nil
  38541. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  38542. }
  38543. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  38544. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  38545. m.predicates = append(m.predicates, ps...)
  38546. }
  38547. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  38548. // users can use type-assertion to append predicates that do not depend on any generated package.
  38549. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  38550. p := make([]predicate.UsageStatisticHour, len(ps))
  38551. for i := range ps {
  38552. p[i] = ps[i]
  38553. }
  38554. m.Where(p...)
  38555. }
  38556. // Op returns the operation name.
  38557. func (m *UsageStatisticHourMutation) Op() Op {
  38558. return m.op
  38559. }
  38560. // SetOp allows setting the mutation operation.
  38561. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  38562. m.op = op
  38563. }
  38564. // Type returns the node type of this mutation (UsageStatisticHour).
  38565. func (m *UsageStatisticHourMutation) Type() string {
  38566. return m.typ
  38567. }
  38568. // Fields returns all fields that were changed during this mutation. Note that in
  38569. // order to get all numeric fields that were incremented/decremented, call
  38570. // AddedFields().
  38571. func (m *UsageStatisticHourMutation) Fields() []string {
  38572. fields := make([]string, 0, 18)
  38573. if m.created_at != nil {
  38574. fields = append(fields, usagestatistichour.FieldCreatedAt)
  38575. }
  38576. if m.updated_at != nil {
  38577. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  38578. }
  38579. if m.status != nil {
  38580. fields = append(fields, usagestatistichour.FieldStatus)
  38581. }
  38582. if m.deleted_at != nil {
  38583. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38584. }
  38585. if m.addtime != nil {
  38586. fields = append(fields, usagestatistichour.FieldAddtime)
  38587. }
  38588. if m._type != nil {
  38589. fields = append(fields, usagestatistichour.FieldType)
  38590. }
  38591. if m.bot_id != nil {
  38592. fields = append(fields, usagestatistichour.FieldBotID)
  38593. }
  38594. if m.organization_id != nil {
  38595. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38596. }
  38597. if m.ai_response != nil {
  38598. fields = append(fields, usagestatistichour.FieldAiResponse)
  38599. }
  38600. if m.sop_run != nil {
  38601. fields = append(fields, usagestatistichour.FieldSopRun)
  38602. }
  38603. if m.total_friend != nil {
  38604. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38605. }
  38606. if m.total_group != nil {
  38607. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38608. }
  38609. if m.account_balance != nil {
  38610. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38611. }
  38612. if m.consume_token != nil {
  38613. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38614. }
  38615. if m.active_user != nil {
  38616. fields = append(fields, usagestatistichour.FieldActiveUser)
  38617. }
  38618. if m.new_user != nil {
  38619. fields = append(fields, usagestatistichour.FieldNewUser)
  38620. }
  38621. if m.label_dist != nil {
  38622. fields = append(fields, usagestatistichour.FieldLabelDist)
  38623. }
  38624. if m.consume_coin != nil {
  38625. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38626. }
  38627. return fields
  38628. }
  38629. // Field returns the value of a field with the given name. The second boolean
  38630. // return value indicates that this field was not set, or was not defined in the
  38631. // schema.
  38632. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  38633. switch name {
  38634. case usagestatistichour.FieldCreatedAt:
  38635. return m.CreatedAt()
  38636. case usagestatistichour.FieldUpdatedAt:
  38637. return m.UpdatedAt()
  38638. case usagestatistichour.FieldStatus:
  38639. return m.Status()
  38640. case usagestatistichour.FieldDeletedAt:
  38641. return m.DeletedAt()
  38642. case usagestatistichour.FieldAddtime:
  38643. return m.Addtime()
  38644. case usagestatistichour.FieldType:
  38645. return m.GetType()
  38646. case usagestatistichour.FieldBotID:
  38647. return m.BotID()
  38648. case usagestatistichour.FieldOrganizationID:
  38649. return m.OrganizationID()
  38650. case usagestatistichour.FieldAiResponse:
  38651. return m.AiResponse()
  38652. case usagestatistichour.FieldSopRun:
  38653. return m.SopRun()
  38654. case usagestatistichour.FieldTotalFriend:
  38655. return m.TotalFriend()
  38656. case usagestatistichour.FieldTotalGroup:
  38657. return m.TotalGroup()
  38658. case usagestatistichour.FieldAccountBalance:
  38659. return m.AccountBalance()
  38660. case usagestatistichour.FieldConsumeToken:
  38661. return m.ConsumeToken()
  38662. case usagestatistichour.FieldActiveUser:
  38663. return m.ActiveUser()
  38664. case usagestatistichour.FieldNewUser:
  38665. return m.NewUser()
  38666. case usagestatistichour.FieldLabelDist:
  38667. return m.LabelDist()
  38668. case usagestatistichour.FieldConsumeCoin:
  38669. return m.ConsumeCoin()
  38670. }
  38671. return nil, false
  38672. }
  38673. // OldField returns the old value of the field from the database. An error is
  38674. // returned if the mutation operation is not UpdateOne, or the query to the
  38675. // database failed.
  38676. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38677. switch name {
  38678. case usagestatistichour.FieldCreatedAt:
  38679. return m.OldCreatedAt(ctx)
  38680. case usagestatistichour.FieldUpdatedAt:
  38681. return m.OldUpdatedAt(ctx)
  38682. case usagestatistichour.FieldStatus:
  38683. return m.OldStatus(ctx)
  38684. case usagestatistichour.FieldDeletedAt:
  38685. return m.OldDeletedAt(ctx)
  38686. case usagestatistichour.FieldAddtime:
  38687. return m.OldAddtime(ctx)
  38688. case usagestatistichour.FieldType:
  38689. return m.OldType(ctx)
  38690. case usagestatistichour.FieldBotID:
  38691. return m.OldBotID(ctx)
  38692. case usagestatistichour.FieldOrganizationID:
  38693. return m.OldOrganizationID(ctx)
  38694. case usagestatistichour.FieldAiResponse:
  38695. return m.OldAiResponse(ctx)
  38696. case usagestatistichour.FieldSopRun:
  38697. return m.OldSopRun(ctx)
  38698. case usagestatistichour.FieldTotalFriend:
  38699. return m.OldTotalFriend(ctx)
  38700. case usagestatistichour.FieldTotalGroup:
  38701. return m.OldTotalGroup(ctx)
  38702. case usagestatistichour.FieldAccountBalance:
  38703. return m.OldAccountBalance(ctx)
  38704. case usagestatistichour.FieldConsumeToken:
  38705. return m.OldConsumeToken(ctx)
  38706. case usagestatistichour.FieldActiveUser:
  38707. return m.OldActiveUser(ctx)
  38708. case usagestatistichour.FieldNewUser:
  38709. return m.OldNewUser(ctx)
  38710. case usagestatistichour.FieldLabelDist:
  38711. return m.OldLabelDist(ctx)
  38712. case usagestatistichour.FieldConsumeCoin:
  38713. return m.OldConsumeCoin(ctx)
  38714. }
  38715. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38716. }
  38717. // SetField sets the value of a field with the given name. It returns an error if
  38718. // the field is not defined in the schema, or if the type mismatched the field
  38719. // type.
  38720. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  38721. switch name {
  38722. case usagestatistichour.FieldCreatedAt:
  38723. v, ok := value.(time.Time)
  38724. if !ok {
  38725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38726. }
  38727. m.SetCreatedAt(v)
  38728. return nil
  38729. case usagestatistichour.FieldUpdatedAt:
  38730. v, ok := value.(time.Time)
  38731. if !ok {
  38732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38733. }
  38734. m.SetUpdatedAt(v)
  38735. return nil
  38736. case usagestatistichour.FieldStatus:
  38737. v, ok := value.(uint8)
  38738. if !ok {
  38739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38740. }
  38741. m.SetStatus(v)
  38742. return nil
  38743. case usagestatistichour.FieldDeletedAt:
  38744. v, ok := value.(time.Time)
  38745. if !ok {
  38746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38747. }
  38748. m.SetDeletedAt(v)
  38749. return nil
  38750. case usagestatistichour.FieldAddtime:
  38751. v, ok := value.(uint64)
  38752. if !ok {
  38753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38754. }
  38755. m.SetAddtime(v)
  38756. return nil
  38757. case usagestatistichour.FieldType:
  38758. v, ok := value.(int)
  38759. if !ok {
  38760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38761. }
  38762. m.SetType(v)
  38763. return nil
  38764. case usagestatistichour.FieldBotID:
  38765. v, ok := value.(string)
  38766. if !ok {
  38767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38768. }
  38769. m.SetBotID(v)
  38770. return nil
  38771. case usagestatistichour.FieldOrganizationID:
  38772. v, ok := value.(uint64)
  38773. if !ok {
  38774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38775. }
  38776. m.SetOrganizationID(v)
  38777. return nil
  38778. case usagestatistichour.FieldAiResponse:
  38779. v, ok := value.(uint64)
  38780. if !ok {
  38781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38782. }
  38783. m.SetAiResponse(v)
  38784. return nil
  38785. case usagestatistichour.FieldSopRun:
  38786. v, ok := value.(uint64)
  38787. if !ok {
  38788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38789. }
  38790. m.SetSopRun(v)
  38791. return nil
  38792. case usagestatistichour.FieldTotalFriend:
  38793. v, ok := value.(uint64)
  38794. if !ok {
  38795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38796. }
  38797. m.SetTotalFriend(v)
  38798. return nil
  38799. case usagestatistichour.FieldTotalGroup:
  38800. v, ok := value.(uint64)
  38801. if !ok {
  38802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38803. }
  38804. m.SetTotalGroup(v)
  38805. return nil
  38806. case usagestatistichour.FieldAccountBalance:
  38807. v, ok := value.(uint64)
  38808. if !ok {
  38809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38810. }
  38811. m.SetAccountBalance(v)
  38812. return nil
  38813. case usagestatistichour.FieldConsumeToken:
  38814. v, ok := value.(uint64)
  38815. if !ok {
  38816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38817. }
  38818. m.SetConsumeToken(v)
  38819. return nil
  38820. case usagestatistichour.FieldActiveUser:
  38821. v, ok := value.(uint64)
  38822. if !ok {
  38823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38824. }
  38825. m.SetActiveUser(v)
  38826. return nil
  38827. case usagestatistichour.FieldNewUser:
  38828. v, ok := value.(int64)
  38829. if !ok {
  38830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38831. }
  38832. m.SetNewUser(v)
  38833. return nil
  38834. case usagestatistichour.FieldLabelDist:
  38835. v, ok := value.([]custom_types.LabelDist)
  38836. if !ok {
  38837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38838. }
  38839. m.SetLabelDist(v)
  38840. return nil
  38841. case usagestatistichour.FieldConsumeCoin:
  38842. v, ok := value.(float64)
  38843. if !ok {
  38844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38845. }
  38846. m.SetConsumeCoin(v)
  38847. return nil
  38848. }
  38849. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38850. }
  38851. // AddedFields returns all numeric fields that were incremented/decremented during
  38852. // this mutation.
  38853. func (m *UsageStatisticHourMutation) AddedFields() []string {
  38854. var fields []string
  38855. if m.addstatus != nil {
  38856. fields = append(fields, usagestatistichour.FieldStatus)
  38857. }
  38858. if m.addaddtime != nil {
  38859. fields = append(fields, usagestatistichour.FieldAddtime)
  38860. }
  38861. if m.add_type != nil {
  38862. fields = append(fields, usagestatistichour.FieldType)
  38863. }
  38864. if m.addorganization_id != nil {
  38865. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38866. }
  38867. if m.addai_response != nil {
  38868. fields = append(fields, usagestatistichour.FieldAiResponse)
  38869. }
  38870. if m.addsop_run != nil {
  38871. fields = append(fields, usagestatistichour.FieldSopRun)
  38872. }
  38873. if m.addtotal_friend != nil {
  38874. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38875. }
  38876. if m.addtotal_group != nil {
  38877. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38878. }
  38879. if m.addaccount_balance != nil {
  38880. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38881. }
  38882. if m.addconsume_token != nil {
  38883. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38884. }
  38885. if m.addactive_user != nil {
  38886. fields = append(fields, usagestatistichour.FieldActiveUser)
  38887. }
  38888. if m.addnew_user != nil {
  38889. fields = append(fields, usagestatistichour.FieldNewUser)
  38890. }
  38891. if m.addconsume_coin != nil {
  38892. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38893. }
  38894. return fields
  38895. }
  38896. // AddedField returns the numeric value that was incremented/decremented on a field
  38897. // with the given name. The second boolean return value indicates that this field
  38898. // was not set, or was not defined in the schema.
  38899. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  38900. switch name {
  38901. case usagestatistichour.FieldStatus:
  38902. return m.AddedStatus()
  38903. case usagestatistichour.FieldAddtime:
  38904. return m.AddedAddtime()
  38905. case usagestatistichour.FieldType:
  38906. return m.AddedType()
  38907. case usagestatistichour.FieldOrganizationID:
  38908. return m.AddedOrganizationID()
  38909. case usagestatistichour.FieldAiResponse:
  38910. return m.AddedAiResponse()
  38911. case usagestatistichour.FieldSopRun:
  38912. return m.AddedSopRun()
  38913. case usagestatistichour.FieldTotalFriend:
  38914. return m.AddedTotalFriend()
  38915. case usagestatistichour.FieldTotalGroup:
  38916. return m.AddedTotalGroup()
  38917. case usagestatistichour.FieldAccountBalance:
  38918. return m.AddedAccountBalance()
  38919. case usagestatistichour.FieldConsumeToken:
  38920. return m.AddedConsumeToken()
  38921. case usagestatistichour.FieldActiveUser:
  38922. return m.AddedActiveUser()
  38923. case usagestatistichour.FieldNewUser:
  38924. return m.AddedNewUser()
  38925. case usagestatistichour.FieldConsumeCoin:
  38926. return m.AddedConsumeCoin()
  38927. }
  38928. return nil, false
  38929. }
  38930. // AddField adds the value to the field with the given name. It returns an error if
  38931. // the field is not defined in the schema, or if the type mismatched the field
  38932. // type.
  38933. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  38934. switch name {
  38935. case usagestatistichour.FieldStatus:
  38936. v, ok := value.(int8)
  38937. if !ok {
  38938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38939. }
  38940. m.AddStatus(v)
  38941. return nil
  38942. case usagestatistichour.FieldAddtime:
  38943. v, ok := value.(int64)
  38944. if !ok {
  38945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38946. }
  38947. m.AddAddtime(v)
  38948. return nil
  38949. case usagestatistichour.FieldType:
  38950. v, ok := value.(int)
  38951. if !ok {
  38952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38953. }
  38954. m.AddType(v)
  38955. return nil
  38956. case usagestatistichour.FieldOrganizationID:
  38957. v, ok := value.(int64)
  38958. if !ok {
  38959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38960. }
  38961. m.AddOrganizationID(v)
  38962. return nil
  38963. case usagestatistichour.FieldAiResponse:
  38964. v, ok := value.(int64)
  38965. if !ok {
  38966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38967. }
  38968. m.AddAiResponse(v)
  38969. return nil
  38970. case usagestatistichour.FieldSopRun:
  38971. v, ok := value.(int64)
  38972. if !ok {
  38973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38974. }
  38975. m.AddSopRun(v)
  38976. return nil
  38977. case usagestatistichour.FieldTotalFriend:
  38978. v, ok := value.(int64)
  38979. if !ok {
  38980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38981. }
  38982. m.AddTotalFriend(v)
  38983. return nil
  38984. case usagestatistichour.FieldTotalGroup:
  38985. v, ok := value.(int64)
  38986. if !ok {
  38987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38988. }
  38989. m.AddTotalGroup(v)
  38990. return nil
  38991. case usagestatistichour.FieldAccountBalance:
  38992. v, ok := value.(int64)
  38993. if !ok {
  38994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38995. }
  38996. m.AddAccountBalance(v)
  38997. return nil
  38998. case usagestatistichour.FieldConsumeToken:
  38999. v, ok := value.(int64)
  39000. if !ok {
  39001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39002. }
  39003. m.AddConsumeToken(v)
  39004. return nil
  39005. case usagestatistichour.FieldActiveUser:
  39006. v, ok := value.(int64)
  39007. if !ok {
  39008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39009. }
  39010. m.AddActiveUser(v)
  39011. return nil
  39012. case usagestatistichour.FieldNewUser:
  39013. v, ok := value.(int64)
  39014. if !ok {
  39015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39016. }
  39017. m.AddNewUser(v)
  39018. return nil
  39019. case usagestatistichour.FieldConsumeCoin:
  39020. v, ok := value.(float64)
  39021. if !ok {
  39022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39023. }
  39024. m.AddConsumeCoin(v)
  39025. return nil
  39026. }
  39027. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  39028. }
  39029. // ClearedFields returns all nullable fields that were cleared during this
  39030. // mutation.
  39031. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  39032. var fields []string
  39033. if m.FieldCleared(usagestatistichour.FieldStatus) {
  39034. fields = append(fields, usagestatistichour.FieldStatus)
  39035. }
  39036. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  39037. fields = append(fields, usagestatistichour.FieldDeletedAt)
  39038. }
  39039. if m.FieldCleared(usagestatistichour.FieldBotID) {
  39040. fields = append(fields, usagestatistichour.FieldBotID)
  39041. }
  39042. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  39043. fields = append(fields, usagestatistichour.FieldOrganizationID)
  39044. }
  39045. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  39046. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  39047. }
  39048. return fields
  39049. }
  39050. // FieldCleared returns a boolean indicating if a field with the given name was
  39051. // cleared in this mutation.
  39052. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  39053. _, ok := m.clearedFields[name]
  39054. return ok
  39055. }
  39056. // ClearField clears the value of the field with the given name. It returns an
  39057. // error if the field is not defined in the schema.
  39058. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  39059. switch name {
  39060. case usagestatistichour.FieldStatus:
  39061. m.ClearStatus()
  39062. return nil
  39063. case usagestatistichour.FieldDeletedAt:
  39064. m.ClearDeletedAt()
  39065. return nil
  39066. case usagestatistichour.FieldBotID:
  39067. m.ClearBotID()
  39068. return nil
  39069. case usagestatistichour.FieldOrganizationID:
  39070. m.ClearOrganizationID()
  39071. return nil
  39072. case usagestatistichour.FieldConsumeCoin:
  39073. m.ClearConsumeCoin()
  39074. return nil
  39075. }
  39076. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  39077. }
  39078. // ResetField resets all changes in the mutation for the field with the given name.
  39079. // It returns an error if the field is not defined in the schema.
  39080. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  39081. switch name {
  39082. case usagestatistichour.FieldCreatedAt:
  39083. m.ResetCreatedAt()
  39084. return nil
  39085. case usagestatistichour.FieldUpdatedAt:
  39086. m.ResetUpdatedAt()
  39087. return nil
  39088. case usagestatistichour.FieldStatus:
  39089. m.ResetStatus()
  39090. return nil
  39091. case usagestatistichour.FieldDeletedAt:
  39092. m.ResetDeletedAt()
  39093. return nil
  39094. case usagestatistichour.FieldAddtime:
  39095. m.ResetAddtime()
  39096. return nil
  39097. case usagestatistichour.FieldType:
  39098. m.ResetType()
  39099. return nil
  39100. case usagestatistichour.FieldBotID:
  39101. m.ResetBotID()
  39102. return nil
  39103. case usagestatistichour.FieldOrganizationID:
  39104. m.ResetOrganizationID()
  39105. return nil
  39106. case usagestatistichour.FieldAiResponse:
  39107. m.ResetAiResponse()
  39108. return nil
  39109. case usagestatistichour.FieldSopRun:
  39110. m.ResetSopRun()
  39111. return nil
  39112. case usagestatistichour.FieldTotalFriend:
  39113. m.ResetTotalFriend()
  39114. return nil
  39115. case usagestatistichour.FieldTotalGroup:
  39116. m.ResetTotalGroup()
  39117. return nil
  39118. case usagestatistichour.FieldAccountBalance:
  39119. m.ResetAccountBalance()
  39120. return nil
  39121. case usagestatistichour.FieldConsumeToken:
  39122. m.ResetConsumeToken()
  39123. return nil
  39124. case usagestatistichour.FieldActiveUser:
  39125. m.ResetActiveUser()
  39126. return nil
  39127. case usagestatistichour.FieldNewUser:
  39128. m.ResetNewUser()
  39129. return nil
  39130. case usagestatistichour.FieldLabelDist:
  39131. m.ResetLabelDist()
  39132. return nil
  39133. case usagestatistichour.FieldConsumeCoin:
  39134. m.ResetConsumeCoin()
  39135. return nil
  39136. }
  39137. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  39138. }
  39139. // AddedEdges returns all edge names that were set/added in this mutation.
  39140. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  39141. edges := make([]string, 0, 0)
  39142. return edges
  39143. }
  39144. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39145. // name in this mutation.
  39146. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  39147. return nil
  39148. }
  39149. // RemovedEdges returns all edge names that were removed in this mutation.
  39150. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  39151. edges := make([]string, 0, 0)
  39152. return edges
  39153. }
  39154. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39155. // the given name in this mutation.
  39156. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  39157. return nil
  39158. }
  39159. // ClearedEdges returns all edge names that were cleared in this mutation.
  39160. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  39161. edges := make([]string, 0, 0)
  39162. return edges
  39163. }
  39164. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39165. // was cleared in this mutation.
  39166. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  39167. return false
  39168. }
  39169. // ClearEdge clears the value of the edge with the given name. It returns an error
  39170. // if that edge is not defined in the schema.
  39171. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  39172. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  39173. }
  39174. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39175. // It returns an error if the edge is not defined in the schema.
  39176. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  39177. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  39178. }
  39179. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  39180. type UsageStatisticMonthMutation struct {
  39181. config
  39182. op Op
  39183. typ string
  39184. id *uint64
  39185. created_at *time.Time
  39186. updated_at *time.Time
  39187. status *uint8
  39188. addstatus *int8
  39189. deleted_at *time.Time
  39190. addtime *uint64
  39191. addaddtime *int64
  39192. _type *int
  39193. add_type *int
  39194. bot_id *string
  39195. organization_id *uint64
  39196. addorganization_id *int64
  39197. ai_response *uint64
  39198. addai_response *int64
  39199. sop_run *uint64
  39200. addsop_run *int64
  39201. total_friend *uint64
  39202. addtotal_friend *int64
  39203. total_group *uint64
  39204. addtotal_group *int64
  39205. account_balance *uint64
  39206. addaccount_balance *int64
  39207. consume_token *uint64
  39208. addconsume_token *int64
  39209. active_user *uint64
  39210. addactive_user *int64
  39211. new_user *int64
  39212. addnew_user *int64
  39213. label_dist *[]custom_types.LabelDist
  39214. appendlabel_dist []custom_types.LabelDist
  39215. consume_coin *float64
  39216. addconsume_coin *float64
  39217. clearedFields map[string]struct{}
  39218. done bool
  39219. oldValue func(context.Context) (*UsageStatisticMonth, error)
  39220. predicates []predicate.UsageStatisticMonth
  39221. }
  39222. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  39223. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  39224. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  39225. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  39226. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  39227. m := &UsageStatisticMonthMutation{
  39228. config: c,
  39229. op: op,
  39230. typ: TypeUsageStatisticMonth,
  39231. clearedFields: make(map[string]struct{}),
  39232. }
  39233. for _, opt := range opts {
  39234. opt(m)
  39235. }
  39236. return m
  39237. }
  39238. // withUsageStatisticMonthID sets the ID field of the mutation.
  39239. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  39240. return func(m *UsageStatisticMonthMutation) {
  39241. var (
  39242. err error
  39243. once sync.Once
  39244. value *UsageStatisticMonth
  39245. )
  39246. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  39247. once.Do(func() {
  39248. if m.done {
  39249. err = errors.New("querying old values post mutation is not allowed")
  39250. } else {
  39251. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  39252. }
  39253. })
  39254. return value, err
  39255. }
  39256. m.id = &id
  39257. }
  39258. }
  39259. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  39260. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  39261. return func(m *UsageStatisticMonthMutation) {
  39262. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  39263. return node, nil
  39264. }
  39265. m.id = &node.ID
  39266. }
  39267. }
  39268. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39269. // executed in a transaction (ent.Tx), a transactional client is returned.
  39270. func (m UsageStatisticMonthMutation) Client() *Client {
  39271. client := &Client{config: m.config}
  39272. client.init()
  39273. return client
  39274. }
  39275. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39276. // it returns an error otherwise.
  39277. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  39278. if _, ok := m.driver.(*txDriver); !ok {
  39279. return nil, errors.New("ent: mutation is not running in a transaction")
  39280. }
  39281. tx := &Tx{config: m.config}
  39282. tx.init()
  39283. return tx, nil
  39284. }
  39285. // SetID sets the value of the id field. Note that this
  39286. // operation is only accepted on creation of UsageStatisticMonth entities.
  39287. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  39288. m.id = &id
  39289. }
  39290. // ID returns the ID value in the mutation. Note that the ID is only available
  39291. // if it was provided to the builder or after it was returned from the database.
  39292. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  39293. if m.id == nil {
  39294. return
  39295. }
  39296. return *m.id, true
  39297. }
  39298. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39299. // That means, if the mutation is applied within a transaction with an isolation level such
  39300. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39301. // or updated by the mutation.
  39302. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  39303. switch {
  39304. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39305. id, exists := m.ID()
  39306. if exists {
  39307. return []uint64{id}, nil
  39308. }
  39309. fallthrough
  39310. case m.op.Is(OpUpdate | OpDelete):
  39311. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  39312. default:
  39313. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39314. }
  39315. }
  39316. // SetCreatedAt sets the "created_at" field.
  39317. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  39318. m.created_at = &t
  39319. }
  39320. // CreatedAt returns the value of the "created_at" field in the mutation.
  39321. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  39322. v := m.created_at
  39323. if v == nil {
  39324. return
  39325. }
  39326. return *v, true
  39327. }
  39328. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  39329. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39331. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39332. if !m.op.Is(OpUpdateOne) {
  39333. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39334. }
  39335. if m.id == nil || m.oldValue == nil {
  39336. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39337. }
  39338. oldValue, err := m.oldValue(ctx)
  39339. if err != nil {
  39340. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39341. }
  39342. return oldValue.CreatedAt, nil
  39343. }
  39344. // ResetCreatedAt resets all changes to the "created_at" field.
  39345. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  39346. m.created_at = nil
  39347. }
  39348. // SetUpdatedAt sets the "updated_at" field.
  39349. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  39350. m.updated_at = &t
  39351. }
  39352. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39353. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  39354. v := m.updated_at
  39355. if v == nil {
  39356. return
  39357. }
  39358. return *v, true
  39359. }
  39360. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  39361. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39363. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39364. if !m.op.Is(OpUpdateOne) {
  39365. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39366. }
  39367. if m.id == nil || m.oldValue == nil {
  39368. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39369. }
  39370. oldValue, err := m.oldValue(ctx)
  39371. if err != nil {
  39372. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39373. }
  39374. return oldValue.UpdatedAt, nil
  39375. }
  39376. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39377. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  39378. m.updated_at = nil
  39379. }
  39380. // SetStatus sets the "status" field.
  39381. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  39382. m.status = &u
  39383. m.addstatus = nil
  39384. }
  39385. // Status returns the value of the "status" field in the mutation.
  39386. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  39387. v := m.status
  39388. if v == nil {
  39389. return
  39390. }
  39391. return *v, true
  39392. }
  39393. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  39394. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39396. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39397. if !m.op.Is(OpUpdateOne) {
  39398. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39399. }
  39400. if m.id == nil || m.oldValue == nil {
  39401. return v, errors.New("OldStatus requires an ID field in the mutation")
  39402. }
  39403. oldValue, err := m.oldValue(ctx)
  39404. if err != nil {
  39405. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39406. }
  39407. return oldValue.Status, nil
  39408. }
  39409. // AddStatus adds u to the "status" field.
  39410. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  39411. if m.addstatus != nil {
  39412. *m.addstatus += u
  39413. } else {
  39414. m.addstatus = &u
  39415. }
  39416. }
  39417. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39418. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  39419. v := m.addstatus
  39420. if v == nil {
  39421. return
  39422. }
  39423. return *v, true
  39424. }
  39425. // ClearStatus clears the value of the "status" field.
  39426. func (m *UsageStatisticMonthMutation) ClearStatus() {
  39427. m.status = nil
  39428. m.addstatus = nil
  39429. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  39430. }
  39431. // StatusCleared returns if the "status" field was cleared in this mutation.
  39432. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  39433. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  39434. return ok
  39435. }
  39436. // ResetStatus resets all changes to the "status" field.
  39437. func (m *UsageStatisticMonthMutation) ResetStatus() {
  39438. m.status = nil
  39439. m.addstatus = nil
  39440. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  39441. }
  39442. // SetDeletedAt sets the "deleted_at" field.
  39443. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  39444. m.deleted_at = &t
  39445. }
  39446. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39447. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  39448. v := m.deleted_at
  39449. if v == nil {
  39450. return
  39451. }
  39452. return *v, true
  39453. }
  39454. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  39455. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39457. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39458. if !m.op.Is(OpUpdateOne) {
  39459. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39460. }
  39461. if m.id == nil || m.oldValue == nil {
  39462. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39463. }
  39464. oldValue, err := m.oldValue(ctx)
  39465. if err != nil {
  39466. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39467. }
  39468. return oldValue.DeletedAt, nil
  39469. }
  39470. // ClearDeletedAt clears the value of the "deleted_at" field.
  39471. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  39472. m.deleted_at = nil
  39473. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  39474. }
  39475. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39476. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  39477. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  39478. return ok
  39479. }
  39480. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39481. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  39482. m.deleted_at = nil
  39483. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  39484. }
  39485. // SetAddtime sets the "addtime" field.
  39486. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  39487. m.addtime = &u
  39488. m.addaddtime = nil
  39489. }
  39490. // Addtime returns the value of the "addtime" field in the mutation.
  39491. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  39492. v := m.addtime
  39493. if v == nil {
  39494. return
  39495. }
  39496. return *v, true
  39497. }
  39498. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  39499. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39501. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  39502. if !m.op.Is(OpUpdateOne) {
  39503. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  39504. }
  39505. if m.id == nil || m.oldValue == nil {
  39506. return v, errors.New("OldAddtime requires an ID field in the mutation")
  39507. }
  39508. oldValue, err := m.oldValue(ctx)
  39509. if err != nil {
  39510. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  39511. }
  39512. return oldValue.Addtime, nil
  39513. }
  39514. // AddAddtime adds u to the "addtime" field.
  39515. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  39516. if m.addaddtime != nil {
  39517. *m.addaddtime += u
  39518. } else {
  39519. m.addaddtime = &u
  39520. }
  39521. }
  39522. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  39523. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  39524. v := m.addaddtime
  39525. if v == nil {
  39526. return
  39527. }
  39528. return *v, true
  39529. }
  39530. // ResetAddtime resets all changes to the "addtime" field.
  39531. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  39532. m.addtime = nil
  39533. m.addaddtime = nil
  39534. }
  39535. // SetType sets the "type" field.
  39536. func (m *UsageStatisticMonthMutation) SetType(i int) {
  39537. m._type = &i
  39538. m.add_type = nil
  39539. }
  39540. // GetType returns the value of the "type" field in the mutation.
  39541. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  39542. v := m._type
  39543. if v == nil {
  39544. return
  39545. }
  39546. return *v, true
  39547. }
  39548. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  39549. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39551. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  39552. if !m.op.Is(OpUpdateOne) {
  39553. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39554. }
  39555. if m.id == nil || m.oldValue == nil {
  39556. return v, errors.New("OldType requires an ID field in the mutation")
  39557. }
  39558. oldValue, err := m.oldValue(ctx)
  39559. if err != nil {
  39560. return v, fmt.Errorf("querying old value for OldType: %w", err)
  39561. }
  39562. return oldValue.Type, nil
  39563. }
  39564. // AddType adds i to the "type" field.
  39565. func (m *UsageStatisticMonthMutation) AddType(i int) {
  39566. if m.add_type != nil {
  39567. *m.add_type += i
  39568. } else {
  39569. m.add_type = &i
  39570. }
  39571. }
  39572. // AddedType returns the value that was added to the "type" field in this mutation.
  39573. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  39574. v := m.add_type
  39575. if v == nil {
  39576. return
  39577. }
  39578. return *v, true
  39579. }
  39580. // ResetType resets all changes to the "type" field.
  39581. func (m *UsageStatisticMonthMutation) ResetType() {
  39582. m._type = nil
  39583. m.add_type = nil
  39584. }
  39585. // SetBotID sets the "bot_id" field.
  39586. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  39587. m.bot_id = &s
  39588. }
  39589. // BotID returns the value of the "bot_id" field in the mutation.
  39590. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  39591. v := m.bot_id
  39592. if v == nil {
  39593. return
  39594. }
  39595. return *v, true
  39596. }
  39597. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  39598. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39600. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  39601. if !m.op.Is(OpUpdateOne) {
  39602. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39603. }
  39604. if m.id == nil || m.oldValue == nil {
  39605. return v, errors.New("OldBotID requires an ID field in the mutation")
  39606. }
  39607. oldValue, err := m.oldValue(ctx)
  39608. if err != nil {
  39609. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39610. }
  39611. return oldValue.BotID, nil
  39612. }
  39613. // ClearBotID clears the value of the "bot_id" field.
  39614. func (m *UsageStatisticMonthMutation) ClearBotID() {
  39615. m.bot_id = nil
  39616. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  39617. }
  39618. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  39619. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  39620. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  39621. return ok
  39622. }
  39623. // ResetBotID resets all changes to the "bot_id" field.
  39624. func (m *UsageStatisticMonthMutation) ResetBotID() {
  39625. m.bot_id = nil
  39626. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  39627. }
  39628. // SetOrganizationID sets the "organization_id" field.
  39629. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  39630. m.organization_id = &u
  39631. m.addorganization_id = nil
  39632. }
  39633. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39634. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  39635. v := m.organization_id
  39636. if v == nil {
  39637. return
  39638. }
  39639. return *v, true
  39640. }
  39641. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  39642. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39644. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39645. if !m.op.Is(OpUpdateOne) {
  39646. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39647. }
  39648. if m.id == nil || m.oldValue == nil {
  39649. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39650. }
  39651. oldValue, err := m.oldValue(ctx)
  39652. if err != nil {
  39653. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39654. }
  39655. return oldValue.OrganizationID, nil
  39656. }
  39657. // AddOrganizationID adds u to the "organization_id" field.
  39658. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  39659. if m.addorganization_id != nil {
  39660. *m.addorganization_id += u
  39661. } else {
  39662. m.addorganization_id = &u
  39663. }
  39664. }
  39665. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39666. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  39667. v := m.addorganization_id
  39668. if v == nil {
  39669. return
  39670. }
  39671. return *v, true
  39672. }
  39673. // ClearOrganizationID clears the value of the "organization_id" field.
  39674. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  39675. m.organization_id = nil
  39676. m.addorganization_id = nil
  39677. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  39678. }
  39679. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39680. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  39681. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  39682. return ok
  39683. }
  39684. // ResetOrganizationID resets all changes to the "organization_id" field.
  39685. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  39686. m.organization_id = nil
  39687. m.addorganization_id = nil
  39688. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  39689. }
  39690. // SetAiResponse sets the "ai_response" field.
  39691. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  39692. m.ai_response = &u
  39693. m.addai_response = nil
  39694. }
  39695. // AiResponse returns the value of the "ai_response" field in the mutation.
  39696. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  39697. v := m.ai_response
  39698. if v == nil {
  39699. return
  39700. }
  39701. return *v, true
  39702. }
  39703. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  39704. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39706. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  39707. if !m.op.Is(OpUpdateOne) {
  39708. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  39709. }
  39710. if m.id == nil || m.oldValue == nil {
  39711. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  39712. }
  39713. oldValue, err := m.oldValue(ctx)
  39714. if err != nil {
  39715. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  39716. }
  39717. return oldValue.AiResponse, nil
  39718. }
  39719. // AddAiResponse adds u to the "ai_response" field.
  39720. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  39721. if m.addai_response != nil {
  39722. *m.addai_response += u
  39723. } else {
  39724. m.addai_response = &u
  39725. }
  39726. }
  39727. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  39728. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  39729. v := m.addai_response
  39730. if v == nil {
  39731. return
  39732. }
  39733. return *v, true
  39734. }
  39735. // ResetAiResponse resets all changes to the "ai_response" field.
  39736. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  39737. m.ai_response = nil
  39738. m.addai_response = nil
  39739. }
  39740. // SetSopRun sets the "sop_run" field.
  39741. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  39742. m.sop_run = &u
  39743. m.addsop_run = nil
  39744. }
  39745. // SopRun returns the value of the "sop_run" field in the mutation.
  39746. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  39747. v := m.sop_run
  39748. if v == nil {
  39749. return
  39750. }
  39751. return *v, true
  39752. }
  39753. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  39754. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39756. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  39757. if !m.op.Is(OpUpdateOne) {
  39758. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  39759. }
  39760. if m.id == nil || m.oldValue == nil {
  39761. return v, errors.New("OldSopRun requires an ID field in the mutation")
  39762. }
  39763. oldValue, err := m.oldValue(ctx)
  39764. if err != nil {
  39765. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  39766. }
  39767. return oldValue.SopRun, nil
  39768. }
  39769. // AddSopRun adds u to the "sop_run" field.
  39770. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  39771. if m.addsop_run != nil {
  39772. *m.addsop_run += u
  39773. } else {
  39774. m.addsop_run = &u
  39775. }
  39776. }
  39777. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  39778. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  39779. v := m.addsop_run
  39780. if v == nil {
  39781. return
  39782. }
  39783. return *v, true
  39784. }
  39785. // ResetSopRun resets all changes to the "sop_run" field.
  39786. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  39787. m.sop_run = nil
  39788. m.addsop_run = nil
  39789. }
  39790. // SetTotalFriend sets the "total_friend" field.
  39791. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  39792. m.total_friend = &u
  39793. m.addtotal_friend = nil
  39794. }
  39795. // TotalFriend returns the value of the "total_friend" field in the mutation.
  39796. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  39797. v := m.total_friend
  39798. if v == nil {
  39799. return
  39800. }
  39801. return *v, true
  39802. }
  39803. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  39804. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39806. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  39807. if !m.op.Is(OpUpdateOne) {
  39808. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  39809. }
  39810. if m.id == nil || m.oldValue == nil {
  39811. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  39812. }
  39813. oldValue, err := m.oldValue(ctx)
  39814. if err != nil {
  39815. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  39816. }
  39817. return oldValue.TotalFriend, nil
  39818. }
  39819. // AddTotalFriend adds u to the "total_friend" field.
  39820. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  39821. if m.addtotal_friend != nil {
  39822. *m.addtotal_friend += u
  39823. } else {
  39824. m.addtotal_friend = &u
  39825. }
  39826. }
  39827. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  39828. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  39829. v := m.addtotal_friend
  39830. if v == nil {
  39831. return
  39832. }
  39833. return *v, true
  39834. }
  39835. // ResetTotalFriend resets all changes to the "total_friend" field.
  39836. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  39837. m.total_friend = nil
  39838. m.addtotal_friend = nil
  39839. }
  39840. // SetTotalGroup sets the "total_group" field.
  39841. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  39842. m.total_group = &u
  39843. m.addtotal_group = nil
  39844. }
  39845. // TotalGroup returns the value of the "total_group" field in the mutation.
  39846. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  39847. v := m.total_group
  39848. if v == nil {
  39849. return
  39850. }
  39851. return *v, true
  39852. }
  39853. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  39854. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39856. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  39857. if !m.op.Is(OpUpdateOne) {
  39858. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  39859. }
  39860. if m.id == nil || m.oldValue == nil {
  39861. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  39862. }
  39863. oldValue, err := m.oldValue(ctx)
  39864. if err != nil {
  39865. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  39866. }
  39867. return oldValue.TotalGroup, nil
  39868. }
  39869. // AddTotalGroup adds u to the "total_group" field.
  39870. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  39871. if m.addtotal_group != nil {
  39872. *m.addtotal_group += u
  39873. } else {
  39874. m.addtotal_group = &u
  39875. }
  39876. }
  39877. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  39878. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  39879. v := m.addtotal_group
  39880. if v == nil {
  39881. return
  39882. }
  39883. return *v, true
  39884. }
  39885. // ResetTotalGroup resets all changes to the "total_group" field.
  39886. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  39887. m.total_group = nil
  39888. m.addtotal_group = nil
  39889. }
  39890. // SetAccountBalance sets the "account_balance" field.
  39891. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  39892. m.account_balance = &u
  39893. m.addaccount_balance = nil
  39894. }
  39895. // AccountBalance returns the value of the "account_balance" field in the mutation.
  39896. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  39897. v := m.account_balance
  39898. if v == nil {
  39899. return
  39900. }
  39901. return *v, true
  39902. }
  39903. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  39904. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39906. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  39907. if !m.op.Is(OpUpdateOne) {
  39908. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  39909. }
  39910. if m.id == nil || m.oldValue == nil {
  39911. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  39912. }
  39913. oldValue, err := m.oldValue(ctx)
  39914. if err != nil {
  39915. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  39916. }
  39917. return oldValue.AccountBalance, nil
  39918. }
  39919. // AddAccountBalance adds u to the "account_balance" field.
  39920. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  39921. if m.addaccount_balance != nil {
  39922. *m.addaccount_balance += u
  39923. } else {
  39924. m.addaccount_balance = &u
  39925. }
  39926. }
  39927. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  39928. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  39929. v := m.addaccount_balance
  39930. if v == nil {
  39931. return
  39932. }
  39933. return *v, true
  39934. }
  39935. // ResetAccountBalance resets all changes to the "account_balance" field.
  39936. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  39937. m.account_balance = nil
  39938. m.addaccount_balance = nil
  39939. }
  39940. // SetConsumeToken sets the "consume_token" field.
  39941. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  39942. m.consume_token = &u
  39943. m.addconsume_token = nil
  39944. }
  39945. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  39946. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  39947. v := m.consume_token
  39948. if v == nil {
  39949. return
  39950. }
  39951. return *v, true
  39952. }
  39953. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  39954. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39956. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  39957. if !m.op.Is(OpUpdateOne) {
  39958. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  39959. }
  39960. if m.id == nil || m.oldValue == nil {
  39961. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  39962. }
  39963. oldValue, err := m.oldValue(ctx)
  39964. if err != nil {
  39965. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  39966. }
  39967. return oldValue.ConsumeToken, nil
  39968. }
  39969. // AddConsumeToken adds u to the "consume_token" field.
  39970. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  39971. if m.addconsume_token != nil {
  39972. *m.addconsume_token += u
  39973. } else {
  39974. m.addconsume_token = &u
  39975. }
  39976. }
  39977. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  39978. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  39979. v := m.addconsume_token
  39980. if v == nil {
  39981. return
  39982. }
  39983. return *v, true
  39984. }
  39985. // ResetConsumeToken resets all changes to the "consume_token" field.
  39986. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  39987. m.consume_token = nil
  39988. m.addconsume_token = nil
  39989. }
  39990. // SetActiveUser sets the "active_user" field.
  39991. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  39992. m.active_user = &u
  39993. m.addactive_user = nil
  39994. }
  39995. // ActiveUser returns the value of the "active_user" field in the mutation.
  39996. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  39997. v := m.active_user
  39998. if v == nil {
  39999. return
  40000. }
  40001. return *v, true
  40002. }
  40003. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  40004. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40006. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  40007. if !m.op.Is(OpUpdateOne) {
  40008. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  40009. }
  40010. if m.id == nil || m.oldValue == nil {
  40011. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  40012. }
  40013. oldValue, err := m.oldValue(ctx)
  40014. if err != nil {
  40015. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  40016. }
  40017. return oldValue.ActiveUser, nil
  40018. }
  40019. // AddActiveUser adds u to the "active_user" field.
  40020. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  40021. if m.addactive_user != nil {
  40022. *m.addactive_user += u
  40023. } else {
  40024. m.addactive_user = &u
  40025. }
  40026. }
  40027. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  40028. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  40029. v := m.addactive_user
  40030. if v == nil {
  40031. return
  40032. }
  40033. return *v, true
  40034. }
  40035. // ResetActiveUser resets all changes to the "active_user" field.
  40036. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  40037. m.active_user = nil
  40038. m.addactive_user = nil
  40039. }
  40040. // SetNewUser sets the "new_user" field.
  40041. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  40042. m.new_user = &i
  40043. m.addnew_user = nil
  40044. }
  40045. // NewUser returns the value of the "new_user" field in the mutation.
  40046. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  40047. v := m.new_user
  40048. if v == nil {
  40049. return
  40050. }
  40051. return *v, true
  40052. }
  40053. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  40054. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40056. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  40057. if !m.op.Is(OpUpdateOne) {
  40058. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  40059. }
  40060. if m.id == nil || m.oldValue == nil {
  40061. return v, errors.New("OldNewUser requires an ID field in the mutation")
  40062. }
  40063. oldValue, err := m.oldValue(ctx)
  40064. if err != nil {
  40065. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  40066. }
  40067. return oldValue.NewUser, nil
  40068. }
  40069. // AddNewUser adds i to the "new_user" field.
  40070. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  40071. if m.addnew_user != nil {
  40072. *m.addnew_user += i
  40073. } else {
  40074. m.addnew_user = &i
  40075. }
  40076. }
  40077. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  40078. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  40079. v := m.addnew_user
  40080. if v == nil {
  40081. return
  40082. }
  40083. return *v, true
  40084. }
  40085. // ResetNewUser resets all changes to the "new_user" field.
  40086. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  40087. m.new_user = nil
  40088. m.addnew_user = nil
  40089. }
  40090. // SetLabelDist sets the "label_dist" field.
  40091. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  40092. m.label_dist = &ctd
  40093. m.appendlabel_dist = nil
  40094. }
  40095. // LabelDist returns the value of the "label_dist" field in the mutation.
  40096. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  40097. v := m.label_dist
  40098. if v == nil {
  40099. return
  40100. }
  40101. return *v, true
  40102. }
  40103. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  40104. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40106. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  40107. if !m.op.Is(OpUpdateOne) {
  40108. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  40109. }
  40110. if m.id == nil || m.oldValue == nil {
  40111. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  40112. }
  40113. oldValue, err := m.oldValue(ctx)
  40114. if err != nil {
  40115. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  40116. }
  40117. return oldValue.LabelDist, nil
  40118. }
  40119. // AppendLabelDist adds ctd to the "label_dist" field.
  40120. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  40121. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  40122. }
  40123. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  40124. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  40125. if len(m.appendlabel_dist) == 0 {
  40126. return nil, false
  40127. }
  40128. return m.appendlabel_dist, true
  40129. }
  40130. // ResetLabelDist resets all changes to the "label_dist" field.
  40131. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  40132. m.label_dist = nil
  40133. m.appendlabel_dist = nil
  40134. }
  40135. // SetConsumeCoin sets the "consume_coin" field.
  40136. func (m *UsageStatisticMonthMutation) SetConsumeCoin(f float64) {
  40137. m.consume_coin = &f
  40138. m.addconsume_coin = nil
  40139. }
  40140. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  40141. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r float64, exists bool) {
  40142. v := m.consume_coin
  40143. if v == nil {
  40144. return
  40145. }
  40146. return *v, true
  40147. }
  40148. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  40149. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40151. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  40152. if !m.op.Is(OpUpdateOne) {
  40153. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  40154. }
  40155. if m.id == nil || m.oldValue == nil {
  40156. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  40157. }
  40158. oldValue, err := m.oldValue(ctx)
  40159. if err != nil {
  40160. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  40161. }
  40162. return oldValue.ConsumeCoin, nil
  40163. }
  40164. // AddConsumeCoin adds f to the "consume_coin" field.
  40165. func (m *UsageStatisticMonthMutation) AddConsumeCoin(f float64) {
  40166. if m.addconsume_coin != nil {
  40167. *m.addconsume_coin += f
  40168. } else {
  40169. m.addconsume_coin = &f
  40170. }
  40171. }
  40172. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  40173. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r float64, exists bool) {
  40174. v := m.addconsume_coin
  40175. if v == nil {
  40176. return
  40177. }
  40178. return *v, true
  40179. }
  40180. // ClearConsumeCoin clears the value of the "consume_coin" field.
  40181. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  40182. m.consume_coin = nil
  40183. m.addconsume_coin = nil
  40184. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  40185. }
  40186. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  40187. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  40188. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  40189. return ok
  40190. }
  40191. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  40192. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  40193. m.consume_coin = nil
  40194. m.addconsume_coin = nil
  40195. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  40196. }
  40197. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  40198. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  40199. m.predicates = append(m.predicates, ps...)
  40200. }
  40201. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  40202. // users can use type-assertion to append predicates that do not depend on any generated package.
  40203. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  40204. p := make([]predicate.UsageStatisticMonth, len(ps))
  40205. for i := range ps {
  40206. p[i] = ps[i]
  40207. }
  40208. m.Where(p...)
  40209. }
  40210. // Op returns the operation name.
  40211. func (m *UsageStatisticMonthMutation) Op() Op {
  40212. return m.op
  40213. }
  40214. // SetOp allows setting the mutation operation.
  40215. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  40216. m.op = op
  40217. }
  40218. // Type returns the node type of this mutation (UsageStatisticMonth).
  40219. func (m *UsageStatisticMonthMutation) Type() string {
  40220. return m.typ
  40221. }
  40222. // Fields returns all fields that were changed during this mutation. Note that in
  40223. // order to get all numeric fields that were incremented/decremented, call
  40224. // AddedFields().
  40225. func (m *UsageStatisticMonthMutation) Fields() []string {
  40226. fields := make([]string, 0, 18)
  40227. if m.created_at != nil {
  40228. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  40229. }
  40230. if m.updated_at != nil {
  40231. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  40232. }
  40233. if m.status != nil {
  40234. fields = append(fields, usagestatisticmonth.FieldStatus)
  40235. }
  40236. if m.deleted_at != nil {
  40237. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40238. }
  40239. if m.addtime != nil {
  40240. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40241. }
  40242. if m._type != nil {
  40243. fields = append(fields, usagestatisticmonth.FieldType)
  40244. }
  40245. if m.bot_id != nil {
  40246. fields = append(fields, usagestatisticmonth.FieldBotID)
  40247. }
  40248. if m.organization_id != nil {
  40249. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40250. }
  40251. if m.ai_response != nil {
  40252. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40253. }
  40254. if m.sop_run != nil {
  40255. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40256. }
  40257. if m.total_friend != nil {
  40258. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40259. }
  40260. if m.total_group != nil {
  40261. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40262. }
  40263. if m.account_balance != nil {
  40264. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40265. }
  40266. if m.consume_token != nil {
  40267. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40268. }
  40269. if m.active_user != nil {
  40270. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40271. }
  40272. if m.new_user != nil {
  40273. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40274. }
  40275. if m.label_dist != nil {
  40276. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  40277. }
  40278. if m.consume_coin != nil {
  40279. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40280. }
  40281. return fields
  40282. }
  40283. // Field returns the value of a field with the given name. The second boolean
  40284. // return value indicates that this field was not set, or was not defined in the
  40285. // schema.
  40286. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  40287. switch name {
  40288. case usagestatisticmonth.FieldCreatedAt:
  40289. return m.CreatedAt()
  40290. case usagestatisticmonth.FieldUpdatedAt:
  40291. return m.UpdatedAt()
  40292. case usagestatisticmonth.FieldStatus:
  40293. return m.Status()
  40294. case usagestatisticmonth.FieldDeletedAt:
  40295. return m.DeletedAt()
  40296. case usagestatisticmonth.FieldAddtime:
  40297. return m.Addtime()
  40298. case usagestatisticmonth.FieldType:
  40299. return m.GetType()
  40300. case usagestatisticmonth.FieldBotID:
  40301. return m.BotID()
  40302. case usagestatisticmonth.FieldOrganizationID:
  40303. return m.OrganizationID()
  40304. case usagestatisticmonth.FieldAiResponse:
  40305. return m.AiResponse()
  40306. case usagestatisticmonth.FieldSopRun:
  40307. return m.SopRun()
  40308. case usagestatisticmonth.FieldTotalFriend:
  40309. return m.TotalFriend()
  40310. case usagestatisticmonth.FieldTotalGroup:
  40311. return m.TotalGroup()
  40312. case usagestatisticmonth.FieldAccountBalance:
  40313. return m.AccountBalance()
  40314. case usagestatisticmonth.FieldConsumeToken:
  40315. return m.ConsumeToken()
  40316. case usagestatisticmonth.FieldActiveUser:
  40317. return m.ActiveUser()
  40318. case usagestatisticmonth.FieldNewUser:
  40319. return m.NewUser()
  40320. case usagestatisticmonth.FieldLabelDist:
  40321. return m.LabelDist()
  40322. case usagestatisticmonth.FieldConsumeCoin:
  40323. return m.ConsumeCoin()
  40324. }
  40325. return nil, false
  40326. }
  40327. // OldField returns the old value of the field from the database. An error is
  40328. // returned if the mutation operation is not UpdateOne, or the query to the
  40329. // database failed.
  40330. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40331. switch name {
  40332. case usagestatisticmonth.FieldCreatedAt:
  40333. return m.OldCreatedAt(ctx)
  40334. case usagestatisticmonth.FieldUpdatedAt:
  40335. return m.OldUpdatedAt(ctx)
  40336. case usagestatisticmonth.FieldStatus:
  40337. return m.OldStatus(ctx)
  40338. case usagestatisticmonth.FieldDeletedAt:
  40339. return m.OldDeletedAt(ctx)
  40340. case usagestatisticmonth.FieldAddtime:
  40341. return m.OldAddtime(ctx)
  40342. case usagestatisticmonth.FieldType:
  40343. return m.OldType(ctx)
  40344. case usagestatisticmonth.FieldBotID:
  40345. return m.OldBotID(ctx)
  40346. case usagestatisticmonth.FieldOrganizationID:
  40347. return m.OldOrganizationID(ctx)
  40348. case usagestatisticmonth.FieldAiResponse:
  40349. return m.OldAiResponse(ctx)
  40350. case usagestatisticmonth.FieldSopRun:
  40351. return m.OldSopRun(ctx)
  40352. case usagestatisticmonth.FieldTotalFriend:
  40353. return m.OldTotalFriend(ctx)
  40354. case usagestatisticmonth.FieldTotalGroup:
  40355. return m.OldTotalGroup(ctx)
  40356. case usagestatisticmonth.FieldAccountBalance:
  40357. return m.OldAccountBalance(ctx)
  40358. case usagestatisticmonth.FieldConsumeToken:
  40359. return m.OldConsumeToken(ctx)
  40360. case usagestatisticmonth.FieldActiveUser:
  40361. return m.OldActiveUser(ctx)
  40362. case usagestatisticmonth.FieldNewUser:
  40363. return m.OldNewUser(ctx)
  40364. case usagestatisticmonth.FieldLabelDist:
  40365. return m.OldLabelDist(ctx)
  40366. case usagestatisticmonth.FieldConsumeCoin:
  40367. return m.OldConsumeCoin(ctx)
  40368. }
  40369. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40370. }
  40371. // SetField sets the value of a field with the given name. It returns an error if
  40372. // the field is not defined in the schema, or if the type mismatched the field
  40373. // type.
  40374. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  40375. switch name {
  40376. case usagestatisticmonth.FieldCreatedAt:
  40377. v, ok := value.(time.Time)
  40378. if !ok {
  40379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40380. }
  40381. m.SetCreatedAt(v)
  40382. return nil
  40383. case usagestatisticmonth.FieldUpdatedAt:
  40384. v, ok := value.(time.Time)
  40385. if !ok {
  40386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40387. }
  40388. m.SetUpdatedAt(v)
  40389. return nil
  40390. case usagestatisticmonth.FieldStatus:
  40391. v, ok := value.(uint8)
  40392. if !ok {
  40393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40394. }
  40395. m.SetStatus(v)
  40396. return nil
  40397. case usagestatisticmonth.FieldDeletedAt:
  40398. v, ok := value.(time.Time)
  40399. if !ok {
  40400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40401. }
  40402. m.SetDeletedAt(v)
  40403. return nil
  40404. case usagestatisticmonth.FieldAddtime:
  40405. v, ok := value.(uint64)
  40406. if !ok {
  40407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40408. }
  40409. m.SetAddtime(v)
  40410. return nil
  40411. case usagestatisticmonth.FieldType:
  40412. v, ok := value.(int)
  40413. if !ok {
  40414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40415. }
  40416. m.SetType(v)
  40417. return nil
  40418. case usagestatisticmonth.FieldBotID:
  40419. v, ok := value.(string)
  40420. if !ok {
  40421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40422. }
  40423. m.SetBotID(v)
  40424. return nil
  40425. case usagestatisticmonth.FieldOrganizationID:
  40426. v, ok := value.(uint64)
  40427. if !ok {
  40428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40429. }
  40430. m.SetOrganizationID(v)
  40431. return nil
  40432. case usagestatisticmonth.FieldAiResponse:
  40433. v, ok := value.(uint64)
  40434. if !ok {
  40435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40436. }
  40437. m.SetAiResponse(v)
  40438. return nil
  40439. case usagestatisticmonth.FieldSopRun:
  40440. v, ok := value.(uint64)
  40441. if !ok {
  40442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40443. }
  40444. m.SetSopRun(v)
  40445. return nil
  40446. case usagestatisticmonth.FieldTotalFriend:
  40447. v, ok := value.(uint64)
  40448. if !ok {
  40449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40450. }
  40451. m.SetTotalFriend(v)
  40452. return nil
  40453. case usagestatisticmonth.FieldTotalGroup:
  40454. v, ok := value.(uint64)
  40455. if !ok {
  40456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40457. }
  40458. m.SetTotalGroup(v)
  40459. return nil
  40460. case usagestatisticmonth.FieldAccountBalance:
  40461. v, ok := value.(uint64)
  40462. if !ok {
  40463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40464. }
  40465. m.SetAccountBalance(v)
  40466. return nil
  40467. case usagestatisticmonth.FieldConsumeToken:
  40468. v, ok := value.(uint64)
  40469. if !ok {
  40470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40471. }
  40472. m.SetConsumeToken(v)
  40473. return nil
  40474. case usagestatisticmonth.FieldActiveUser:
  40475. v, ok := value.(uint64)
  40476. if !ok {
  40477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40478. }
  40479. m.SetActiveUser(v)
  40480. return nil
  40481. case usagestatisticmonth.FieldNewUser:
  40482. v, ok := value.(int64)
  40483. if !ok {
  40484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40485. }
  40486. m.SetNewUser(v)
  40487. return nil
  40488. case usagestatisticmonth.FieldLabelDist:
  40489. v, ok := value.([]custom_types.LabelDist)
  40490. if !ok {
  40491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40492. }
  40493. m.SetLabelDist(v)
  40494. return nil
  40495. case usagestatisticmonth.FieldConsumeCoin:
  40496. v, ok := value.(float64)
  40497. if !ok {
  40498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40499. }
  40500. m.SetConsumeCoin(v)
  40501. return nil
  40502. }
  40503. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40504. }
  40505. // AddedFields returns all numeric fields that were incremented/decremented during
  40506. // this mutation.
  40507. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  40508. var fields []string
  40509. if m.addstatus != nil {
  40510. fields = append(fields, usagestatisticmonth.FieldStatus)
  40511. }
  40512. if m.addaddtime != nil {
  40513. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40514. }
  40515. if m.add_type != nil {
  40516. fields = append(fields, usagestatisticmonth.FieldType)
  40517. }
  40518. if m.addorganization_id != nil {
  40519. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40520. }
  40521. if m.addai_response != nil {
  40522. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40523. }
  40524. if m.addsop_run != nil {
  40525. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40526. }
  40527. if m.addtotal_friend != nil {
  40528. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40529. }
  40530. if m.addtotal_group != nil {
  40531. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40532. }
  40533. if m.addaccount_balance != nil {
  40534. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40535. }
  40536. if m.addconsume_token != nil {
  40537. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40538. }
  40539. if m.addactive_user != nil {
  40540. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40541. }
  40542. if m.addnew_user != nil {
  40543. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40544. }
  40545. if m.addconsume_coin != nil {
  40546. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40547. }
  40548. return fields
  40549. }
  40550. // AddedField returns the numeric value that was incremented/decremented on a field
  40551. // with the given name. The second boolean return value indicates that this field
  40552. // was not set, or was not defined in the schema.
  40553. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  40554. switch name {
  40555. case usagestatisticmonth.FieldStatus:
  40556. return m.AddedStatus()
  40557. case usagestatisticmonth.FieldAddtime:
  40558. return m.AddedAddtime()
  40559. case usagestatisticmonth.FieldType:
  40560. return m.AddedType()
  40561. case usagestatisticmonth.FieldOrganizationID:
  40562. return m.AddedOrganizationID()
  40563. case usagestatisticmonth.FieldAiResponse:
  40564. return m.AddedAiResponse()
  40565. case usagestatisticmonth.FieldSopRun:
  40566. return m.AddedSopRun()
  40567. case usagestatisticmonth.FieldTotalFriend:
  40568. return m.AddedTotalFriend()
  40569. case usagestatisticmonth.FieldTotalGroup:
  40570. return m.AddedTotalGroup()
  40571. case usagestatisticmonth.FieldAccountBalance:
  40572. return m.AddedAccountBalance()
  40573. case usagestatisticmonth.FieldConsumeToken:
  40574. return m.AddedConsumeToken()
  40575. case usagestatisticmonth.FieldActiveUser:
  40576. return m.AddedActiveUser()
  40577. case usagestatisticmonth.FieldNewUser:
  40578. return m.AddedNewUser()
  40579. case usagestatisticmonth.FieldConsumeCoin:
  40580. return m.AddedConsumeCoin()
  40581. }
  40582. return nil, false
  40583. }
  40584. // AddField adds the value to the field with the given name. It returns an error if
  40585. // the field is not defined in the schema, or if the type mismatched the field
  40586. // type.
  40587. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  40588. switch name {
  40589. case usagestatisticmonth.FieldStatus:
  40590. v, ok := value.(int8)
  40591. if !ok {
  40592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40593. }
  40594. m.AddStatus(v)
  40595. return nil
  40596. case usagestatisticmonth.FieldAddtime:
  40597. v, ok := value.(int64)
  40598. if !ok {
  40599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40600. }
  40601. m.AddAddtime(v)
  40602. return nil
  40603. case usagestatisticmonth.FieldType:
  40604. v, ok := value.(int)
  40605. if !ok {
  40606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40607. }
  40608. m.AddType(v)
  40609. return nil
  40610. case usagestatisticmonth.FieldOrganizationID:
  40611. v, ok := value.(int64)
  40612. if !ok {
  40613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40614. }
  40615. m.AddOrganizationID(v)
  40616. return nil
  40617. case usagestatisticmonth.FieldAiResponse:
  40618. v, ok := value.(int64)
  40619. if !ok {
  40620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40621. }
  40622. m.AddAiResponse(v)
  40623. return nil
  40624. case usagestatisticmonth.FieldSopRun:
  40625. v, ok := value.(int64)
  40626. if !ok {
  40627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40628. }
  40629. m.AddSopRun(v)
  40630. return nil
  40631. case usagestatisticmonth.FieldTotalFriend:
  40632. v, ok := value.(int64)
  40633. if !ok {
  40634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40635. }
  40636. m.AddTotalFriend(v)
  40637. return nil
  40638. case usagestatisticmonth.FieldTotalGroup:
  40639. v, ok := value.(int64)
  40640. if !ok {
  40641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40642. }
  40643. m.AddTotalGroup(v)
  40644. return nil
  40645. case usagestatisticmonth.FieldAccountBalance:
  40646. v, ok := value.(int64)
  40647. if !ok {
  40648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40649. }
  40650. m.AddAccountBalance(v)
  40651. return nil
  40652. case usagestatisticmonth.FieldConsumeToken:
  40653. v, ok := value.(int64)
  40654. if !ok {
  40655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40656. }
  40657. m.AddConsumeToken(v)
  40658. return nil
  40659. case usagestatisticmonth.FieldActiveUser:
  40660. v, ok := value.(int64)
  40661. if !ok {
  40662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40663. }
  40664. m.AddActiveUser(v)
  40665. return nil
  40666. case usagestatisticmonth.FieldNewUser:
  40667. v, ok := value.(int64)
  40668. if !ok {
  40669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40670. }
  40671. m.AddNewUser(v)
  40672. return nil
  40673. case usagestatisticmonth.FieldConsumeCoin:
  40674. v, ok := value.(float64)
  40675. if !ok {
  40676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40677. }
  40678. m.AddConsumeCoin(v)
  40679. return nil
  40680. }
  40681. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  40682. }
  40683. // ClearedFields returns all nullable fields that were cleared during this
  40684. // mutation.
  40685. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  40686. var fields []string
  40687. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  40688. fields = append(fields, usagestatisticmonth.FieldStatus)
  40689. }
  40690. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  40691. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40692. }
  40693. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  40694. fields = append(fields, usagestatisticmonth.FieldBotID)
  40695. }
  40696. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  40697. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40698. }
  40699. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  40700. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40701. }
  40702. return fields
  40703. }
  40704. // FieldCleared returns a boolean indicating if a field with the given name was
  40705. // cleared in this mutation.
  40706. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  40707. _, ok := m.clearedFields[name]
  40708. return ok
  40709. }
  40710. // ClearField clears the value of the field with the given name. It returns an
  40711. // error if the field is not defined in the schema.
  40712. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  40713. switch name {
  40714. case usagestatisticmonth.FieldStatus:
  40715. m.ClearStatus()
  40716. return nil
  40717. case usagestatisticmonth.FieldDeletedAt:
  40718. m.ClearDeletedAt()
  40719. return nil
  40720. case usagestatisticmonth.FieldBotID:
  40721. m.ClearBotID()
  40722. return nil
  40723. case usagestatisticmonth.FieldOrganizationID:
  40724. m.ClearOrganizationID()
  40725. return nil
  40726. case usagestatisticmonth.FieldConsumeCoin:
  40727. m.ClearConsumeCoin()
  40728. return nil
  40729. }
  40730. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  40731. }
  40732. // ResetField resets all changes in the mutation for the field with the given name.
  40733. // It returns an error if the field is not defined in the schema.
  40734. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  40735. switch name {
  40736. case usagestatisticmonth.FieldCreatedAt:
  40737. m.ResetCreatedAt()
  40738. return nil
  40739. case usagestatisticmonth.FieldUpdatedAt:
  40740. m.ResetUpdatedAt()
  40741. return nil
  40742. case usagestatisticmonth.FieldStatus:
  40743. m.ResetStatus()
  40744. return nil
  40745. case usagestatisticmonth.FieldDeletedAt:
  40746. m.ResetDeletedAt()
  40747. return nil
  40748. case usagestatisticmonth.FieldAddtime:
  40749. m.ResetAddtime()
  40750. return nil
  40751. case usagestatisticmonth.FieldType:
  40752. m.ResetType()
  40753. return nil
  40754. case usagestatisticmonth.FieldBotID:
  40755. m.ResetBotID()
  40756. return nil
  40757. case usagestatisticmonth.FieldOrganizationID:
  40758. m.ResetOrganizationID()
  40759. return nil
  40760. case usagestatisticmonth.FieldAiResponse:
  40761. m.ResetAiResponse()
  40762. return nil
  40763. case usagestatisticmonth.FieldSopRun:
  40764. m.ResetSopRun()
  40765. return nil
  40766. case usagestatisticmonth.FieldTotalFriend:
  40767. m.ResetTotalFriend()
  40768. return nil
  40769. case usagestatisticmonth.FieldTotalGroup:
  40770. m.ResetTotalGroup()
  40771. return nil
  40772. case usagestatisticmonth.FieldAccountBalance:
  40773. m.ResetAccountBalance()
  40774. return nil
  40775. case usagestatisticmonth.FieldConsumeToken:
  40776. m.ResetConsumeToken()
  40777. return nil
  40778. case usagestatisticmonth.FieldActiveUser:
  40779. m.ResetActiveUser()
  40780. return nil
  40781. case usagestatisticmonth.FieldNewUser:
  40782. m.ResetNewUser()
  40783. return nil
  40784. case usagestatisticmonth.FieldLabelDist:
  40785. m.ResetLabelDist()
  40786. return nil
  40787. case usagestatisticmonth.FieldConsumeCoin:
  40788. m.ResetConsumeCoin()
  40789. return nil
  40790. }
  40791. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40792. }
  40793. // AddedEdges returns all edge names that were set/added in this mutation.
  40794. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  40795. edges := make([]string, 0, 0)
  40796. return edges
  40797. }
  40798. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40799. // name in this mutation.
  40800. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  40801. return nil
  40802. }
  40803. // RemovedEdges returns all edge names that were removed in this mutation.
  40804. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  40805. edges := make([]string, 0, 0)
  40806. return edges
  40807. }
  40808. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40809. // the given name in this mutation.
  40810. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  40811. return nil
  40812. }
  40813. // ClearedEdges returns all edge names that were cleared in this mutation.
  40814. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  40815. edges := make([]string, 0, 0)
  40816. return edges
  40817. }
  40818. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40819. // was cleared in this mutation.
  40820. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  40821. return false
  40822. }
  40823. // ClearEdge clears the value of the edge with the given name. It returns an error
  40824. // if that edge is not defined in the schema.
  40825. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  40826. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  40827. }
  40828. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40829. // It returns an error if the edge is not defined in the schema.
  40830. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  40831. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  40832. }
  40833. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  40834. type UsageTotalMutation struct {
  40835. config
  40836. op Op
  40837. typ string
  40838. id *uint64
  40839. created_at *time.Time
  40840. updated_at *time.Time
  40841. status *uint8
  40842. addstatus *int8
  40843. _type *int
  40844. add_type *int
  40845. bot_id *string
  40846. total_tokens *uint64
  40847. addtotal_tokens *int64
  40848. credits *float64
  40849. addcredits *float64
  40850. start_index *uint64
  40851. addstart_index *int64
  40852. end_index *uint64
  40853. addend_index *int64
  40854. organization_id *uint64
  40855. addorganization_id *int64
  40856. clearedFields map[string]struct{}
  40857. done bool
  40858. oldValue func(context.Context) (*UsageTotal, error)
  40859. predicates []predicate.UsageTotal
  40860. }
  40861. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  40862. // usagetotalOption allows management of the mutation configuration using functional options.
  40863. type usagetotalOption func(*UsageTotalMutation)
  40864. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  40865. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  40866. m := &UsageTotalMutation{
  40867. config: c,
  40868. op: op,
  40869. typ: TypeUsageTotal,
  40870. clearedFields: make(map[string]struct{}),
  40871. }
  40872. for _, opt := range opts {
  40873. opt(m)
  40874. }
  40875. return m
  40876. }
  40877. // withUsageTotalID sets the ID field of the mutation.
  40878. func withUsageTotalID(id uint64) usagetotalOption {
  40879. return func(m *UsageTotalMutation) {
  40880. var (
  40881. err error
  40882. once sync.Once
  40883. value *UsageTotal
  40884. )
  40885. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  40886. once.Do(func() {
  40887. if m.done {
  40888. err = errors.New("querying old values post mutation is not allowed")
  40889. } else {
  40890. value, err = m.Client().UsageTotal.Get(ctx, id)
  40891. }
  40892. })
  40893. return value, err
  40894. }
  40895. m.id = &id
  40896. }
  40897. }
  40898. // withUsageTotal sets the old UsageTotal of the mutation.
  40899. func withUsageTotal(node *UsageTotal) usagetotalOption {
  40900. return func(m *UsageTotalMutation) {
  40901. m.oldValue = func(context.Context) (*UsageTotal, error) {
  40902. return node, nil
  40903. }
  40904. m.id = &node.ID
  40905. }
  40906. }
  40907. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40908. // executed in a transaction (ent.Tx), a transactional client is returned.
  40909. func (m UsageTotalMutation) Client() *Client {
  40910. client := &Client{config: m.config}
  40911. client.init()
  40912. return client
  40913. }
  40914. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40915. // it returns an error otherwise.
  40916. func (m UsageTotalMutation) Tx() (*Tx, error) {
  40917. if _, ok := m.driver.(*txDriver); !ok {
  40918. return nil, errors.New("ent: mutation is not running in a transaction")
  40919. }
  40920. tx := &Tx{config: m.config}
  40921. tx.init()
  40922. return tx, nil
  40923. }
  40924. // SetID sets the value of the id field. Note that this
  40925. // operation is only accepted on creation of UsageTotal entities.
  40926. func (m *UsageTotalMutation) SetID(id uint64) {
  40927. m.id = &id
  40928. }
  40929. // ID returns the ID value in the mutation. Note that the ID is only available
  40930. // if it was provided to the builder or after it was returned from the database.
  40931. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  40932. if m.id == nil {
  40933. return
  40934. }
  40935. return *m.id, true
  40936. }
  40937. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40938. // That means, if the mutation is applied within a transaction with an isolation level such
  40939. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40940. // or updated by the mutation.
  40941. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  40942. switch {
  40943. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40944. id, exists := m.ID()
  40945. if exists {
  40946. return []uint64{id}, nil
  40947. }
  40948. fallthrough
  40949. case m.op.Is(OpUpdate | OpDelete):
  40950. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  40951. default:
  40952. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40953. }
  40954. }
  40955. // SetCreatedAt sets the "created_at" field.
  40956. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  40957. m.created_at = &t
  40958. }
  40959. // CreatedAt returns the value of the "created_at" field in the mutation.
  40960. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  40961. v := m.created_at
  40962. if v == nil {
  40963. return
  40964. }
  40965. return *v, true
  40966. }
  40967. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  40968. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40970. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40971. if !m.op.Is(OpUpdateOne) {
  40972. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40973. }
  40974. if m.id == nil || m.oldValue == nil {
  40975. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40976. }
  40977. oldValue, err := m.oldValue(ctx)
  40978. if err != nil {
  40979. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40980. }
  40981. return oldValue.CreatedAt, nil
  40982. }
  40983. // ResetCreatedAt resets all changes to the "created_at" field.
  40984. func (m *UsageTotalMutation) ResetCreatedAt() {
  40985. m.created_at = nil
  40986. }
  40987. // SetUpdatedAt sets the "updated_at" field.
  40988. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  40989. m.updated_at = &t
  40990. }
  40991. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40992. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  40993. v := m.updated_at
  40994. if v == nil {
  40995. return
  40996. }
  40997. return *v, true
  40998. }
  40999. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  41000. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41002. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41003. if !m.op.Is(OpUpdateOne) {
  41004. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41005. }
  41006. if m.id == nil || m.oldValue == nil {
  41007. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41008. }
  41009. oldValue, err := m.oldValue(ctx)
  41010. if err != nil {
  41011. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41012. }
  41013. return oldValue.UpdatedAt, nil
  41014. }
  41015. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41016. func (m *UsageTotalMutation) ResetUpdatedAt() {
  41017. m.updated_at = nil
  41018. }
  41019. // SetStatus sets the "status" field.
  41020. func (m *UsageTotalMutation) SetStatus(u uint8) {
  41021. m.status = &u
  41022. m.addstatus = nil
  41023. }
  41024. // Status returns the value of the "status" field in the mutation.
  41025. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  41026. v := m.status
  41027. if v == nil {
  41028. return
  41029. }
  41030. return *v, true
  41031. }
  41032. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  41033. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41035. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41036. if !m.op.Is(OpUpdateOne) {
  41037. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41038. }
  41039. if m.id == nil || m.oldValue == nil {
  41040. return v, errors.New("OldStatus requires an ID field in the mutation")
  41041. }
  41042. oldValue, err := m.oldValue(ctx)
  41043. if err != nil {
  41044. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41045. }
  41046. return oldValue.Status, nil
  41047. }
  41048. // AddStatus adds u to the "status" field.
  41049. func (m *UsageTotalMutation) AddStatus(u int8) {
  41050. if m.addstatus != nil {
  41051. *m.addstatus += u
  41052. } else {
  41053. m.addstatus = &u
  41054. }
  41055. }
  41056. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41057. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  41058. v := m.addstatus
  41059. if v == nil {
  41060. return
  41061. }
  41062. return *v, true
  41063. }
  41064. // ClearStatus clears the value of the "status" field.
  41065. func (m *UsageTotalMutation) ClearStatus() {
  41066. m.status = nil
  41067. m.addstatus = nil
  41068. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  41069. }
  41070. // StatusCleared returns if the "status" field was cleared in this mutation.
  41071. func (m *UsageTotalMutation) StatusCleared() bool {
  41072. _, ok := m.clearedFields[usagetotal.FieldStatus]
  41073. return ok
  41074. }
  41075. // ResetStatus resets all changes to the "status" field.
  41076. func (m *UsageTotalMutation) ResetStatus() {
  41077. m.status = nil
  41078. m.addstatus = nil
  41079. delete(m.clearedFields, usagetotal.FieldStatus)
  41080. }
  41081. // SetType sets the "type" field.
  41082. func (m *UsageTotalMutation) SetType(i int) {
  41083. m._type = &i
  41084. m.add_type = nil
  41085. }
  41086. // GetType returns the value of the "type" field in the mutation.
  41087. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  41088. v := m._type
  41089. if v == nil {
  41090. return
  41091. }
  41092. return *v, true
  41093. }
  41094. // OldType returns the old "type" field's value of the UsageTotal entity.
  41095. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41097. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  41098. if !m.op.Is(OpUpdateOne) {
  41099. return v, errors.New("OldType is only allowed on UpdateOne operations")
  41100. }
  41101. if m.id == nil || m.oldValue == nil {
  41102. return v, errors.New("OldType requires an ID field in the mutation")
  41103. }
  41104. oldValue, err := m.oldValue(ctx)
  41105. if err != nil {
  41106. return v, fmt.Errorf("querying old value for OldType: %w", err)
  41107. }
  41108. return oldValue.Type, nil
  41109. }
  41110. // AddType adds i to the "type" field.
  41111. func (m *UsageTotalMutation) AddType(i int) {
  41112. if m.add_type != nil {
  41113. *m.add_type += i
  41114. } else {
  41115. m.add_type = &i
  41116. }
  41117. }
  41118. // AddedType returns the value that was added to the "type" field in this mutation.
  41119. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  41120. v := m.add_type
  41121. if v == nil {
  41122. return
  41123. }
  41124. return *v, true
  41125. }
  41126. // ClearType clears the value of the "type" field.
  41127. func (m *UsageTotalMutation) ClearType() {
  41128. m._type = nil
  41129. m.add_type = nil
  41130. m.clearedFields[usagetotal.FieldType] = struct{}{}
  41131. }
  41132. // TypeCleared returns if the "type" field was cleared in this mutation.
  41133. func (m *UsageTotalMutation) TypeCleared() bool {
  41134. _, ok := m.clearedFields[usagetotal.FieldType]
  41135. return ok
  41136. }
  41137. // ResetType resets all changes to the "type" field.
  41138. func (m *UsageTotalMutation) ResetType() {
  41139. m._type = nil
  41140. m.add_type = nil
  41141. delete(m.clearedFields, usagetotal.FieldType)
  41142. }
  41143. // SetBotID sets the "bot_id" field.
  41144. func (m *UsageTotalMutation) SetBotID(s string) {
  41145. m.bot_id = &s
  41146. }
  41147. // BotID returns the value of the "bot_id" field in the mutation.
  41148. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  41149. v := m.bot_id
  41150. if v == nil {
  41151. return
  41152. }
  41153. return *v, true
  41154. }
  41155. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  41156. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41158. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  41159. if !m.op.Is(OpUpdateOne) {
  41160. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41161. }
  41162. if m.id == nil || m.oldValue == nil {
  41163. return v, errors.New("OldBotID requires an ID field in the mutation")
  41164. }
  41165. oldValue, err := m.oldValue(ctx)
  41166. if err != nil {
  41167. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41168. }
  41169. return oldValue.BotID, nil
  41170. }
  41171. // ResetBotID resets all changes to the "bot_id" field.
  41172. func (m *UsageTotalMutation) ResetBotID() {
  41173. m.bot_id = nil
  41174. }
  41175. // SetTotalTokens sets the "total_tokens" field.
  41176. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  41177. m.total_tokens = &u
  41178. m.addtotal_tokens = nil
  41179. }
  41180. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  41181. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  41182. v := m.total_tokens
  41183. if v == nil {
  41184. return
  41185. }
  41186. return *v, true
  41187. }
  41188. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  41189. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41191. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  41192. if !m.op.Is(OpUpdateOne) {
  41193. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  41194. }
  41195. if m.id == nil || m.oldValue == nil {
  41196. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  41197. }
  41198. oldValue, err := m.oldValue(ctx)
  41199. if err != nil {
  41200. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  41201. }
  41202. return oldValue.TotalTokens, nil
  41203. }
  41204. // AddTotalTokens adds u to the "total_tokens" field.
  41205. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  41206. if m.addtotal_tokens != nil {
  41207. *m.addtotal_tokens += u
  41208. } else {
  41209. m.addtotal_tokens = &u
  41210. }
  41211. }
  41212. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  41213. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  41214. v := m.addtotal_tokens
  41215. if v == nil {
  41216. return
  41217. }
  41218. return *v, true
  41219. }
  41220. // ClearTotalTokens clears the value of the "total_tokens" field.
  41221. func (m *UsageTotalMutation) ClearTotalTokens() {
  41222. m.total_tokens = nil
  41223. m.addtotal_tokens = nil
  41224. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  41225. }
  41226. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  41227. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  41228. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  41229. return ok
  41230. }
  41231. // ResetTotalTokens resets all changes to the "total_tokens" field.
  41232. func (m *UsageTotalMutation) ResetTotalTokens() {
  41233. m.total_tokens = nil
  41234. m.addtotal_tokens = nil
  41235. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  41236. }
  41237. // SetCredits sets the "credits" field.
  41238. func (m *UsageTotalMutation) SetCredits(f float64) {
  41239. m.credits = &f
  41240. m.addcredits = nil
  41241. }
  41242. // Credits returns the value of the "credits" field in the mutation.
  41243. func (m *UsageTotalMutation) Credits() (r float64, exists bool) {
  41244. v := m.credits
  41245. if v == nil {
  41246. return
  41247. }
  41248. return *v, true
  41249. }
  41250. // OldCredits returns the old "credits" field's value of the UsageTotal entity.
  41251. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41253. func (m *UsageTotalMutation) OldCredits(ctx context.Context) (v float64, err error) {
  41254. if !m.op.Is(OpUpdateOne) {
  41255. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  41256. }
  41257. if m.id == nil || m.oldValue == nil {
  41258. return v, errors.New("OldCredits requires an ID field in the mutation")
  41259. }
  41260. oldValue, err := m.oldValue(ctx)
  41261. if err != nil {
  41262. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  41263. }
  41264. return oldValue.Credits, nil
  41265. }
  41266. // AddCredits adds f to the "credits" field.
  41267. func (m *UsageTotalMutation) AddCredits(f float64) {
  41268. if m.addcredits != nil {
  41269. *m.addcredits += f
  41270. } else {
  41271. m.addcredits = &f
  41272. }
  41273. }
  41274. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  41275. func (m *UsageTotalMutation) AddedCredits() (r float64, exists bool) {
  41276. v := m.addcredits
  41277. if v == nil {
  41278. return
  41279. }
  41280. return *v, true
  41281. }
  41282. // ClearCredits clears the value of the "credits" field.
  41283. func (m *UsageTotalMutation) ClearCredits() {
  41284. m.credits = nil
  41285. m.addcredits = nil
  41286. m.clearedFields[usagetotal.FieldCredits] = struct{}{}
  41287. }
  41288. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  41289. func (m *UsageTotalMutation) CreditsCleared() bool {
  41290. _, ok := m.clearedFields[usagetotal.FieldCredits]
  41291. return ok
  41292. }
  41293. // ResetCredits resets all changes to the "credits" field.
  41294. func (m *UsageTotalMutation) ResetCredits() {
  41295. m.credits = nil
  41296. m.addcredits = nil
  41297. delete(m.clearedFields, usagetotal.FieldCredits)
  41298. }
  41299. // SetStartIndex sets the "start_index" field.
  41300. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  41301. m.start_index = &u
  41302. m.addstart_index = nil
  41303. }
  41304. // StartIndex returns the value of the "start_index" field in the mutation.
  41305. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  41306. v := m.start_index
  41307. if v == nil {
  41308. return
  41309. }
  41310. return *v, true
  41311. }
  41312. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  41313. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41315. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  41316. if !m.op.Is(OpUpdateOne) {
  41317. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  41318. }
  41319. if m.id == nil || m.oldValue == nil {
  41320. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  41321. }
  41322. oldValue, err := m.oldValue(ctx)
  41323. if err != nil {
  41324. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  41325. }
  41326. return oldValue.StartIndex, nil
  41327. }
  41328. // AddStartIndex adds u to the "start_index" field.
  41329. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  41330. if m.addstart_index != nil {
  41331. *m.addstart_index += u
  41332. } else {
  41333. m.addstart_index = &u
  41334. }
  41335. }
  41336. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  41337. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  41338. v := m.addstart_index
  41339. if v == nil {
  41340. return
  41341. }
  41342. return *v, true
  41343. }
  41344. // ClearStartIndex clears the value of the "start_index" field.
  41345. func (m *UsageTotalMutation) ClearStartIndex() {
  41346. m.start_index = nil
  41347. m.addstart_index = nil
  41348. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  41349. }
  41350. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  41351. func (m *UsageTotalMutation) StartIndexCleared() bool {
  41352. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  41353. return ok
  41354. }
  41355. // ResetStartIndex resets all changes to the "start_index" field.
  41356. func (m *UsageTotalMutation) ResetStartIndex() {
  41357. m.start_index = nil
  41358. m.addstart_index = nil
  41359. delete(m.clearedFields, usagetotal.FieldStartIndex)
  41360. }
  41361. // SetEndIndex sets the "end_index" field.
  41362. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  41363. m.end_index = &u
  41364. m.addend_index = nil
  41365. }
  41366. // EndIndex returns the value of the "end_index" field in the mutation.
  41367. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  41368. v := m.end_index
  41369. if v == nil {
  41370. return
  41371. }
  41372. return *v, true
  41373. }
  41374. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  41375. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41377. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  41378. if !m.op.Is(OpUpdateOne) {
  41379. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  41380. }
  41381. if m.id == nil || m.oldValue == nil {
  41382. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  41383. }
  41384. oldValue, err := m.oldValue(ctx)
  41385. if err != nil {
  41386. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  41387. }
  41388. return oldValue.EndIndex, nil
  41389. }
  41390. // AddEndIndex adds u to the "end_index" field.
  41391. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  41392. if m.addend_index != nil {
  41393. *m.addend_index += u
  41394. } else {
  41395. m.addend_index = &u
  41396. }
  41397. }
  41398. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  41399. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  41400. v := m.addend_index
  41401. if v == nil {
  41402. return
  41403. }
  41404. return *v, true
  41405. }
  41406. // ClearEndIndex clears the value of the "end_index" field.
  41407. func (m *UsageTotalMutation) ClearEndIndex() {
  41408. m.end_index = nil
  41409. m.addend_index = nil
  41410. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  41411. }
  41412. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  41413. func (m *UsageTotalMutation) EndIndexCleared() bool {
  41414. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  41415. return ok
  41416. }
  41417. // ResetEndIndex resets all changes to the "end_index" field.
  41418. func (m *UsageTotalMutation) ResetEndIndex() {
  41419. m.end_index = nil
  41420. m.addend_index = nil
  41421. delete(m.clearedFields, usagetotal.FieldEndIndex)
  41422. }
  41423. // SetOrganizationID sets the "organization_id" field.
  41424. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  41425. m.organization_id = &u
  41426. m.addorganization_id = nil
  41427. }
  41428. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41429. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  41430. v := m.organization_id
  41431. if v == nil {
  41432. return
  41433. }
  41434. return *v, true
  41435. }
  41436. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  41437. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41439. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41440. if !m.op.Is(OpUpdateOne) {
  41441. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41442. }
  41443. if m.id == nil || m.oldValue == nil {
  41444. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41445. }
  41446. oldValue, err := m.oldValue(ctx)
  41447. if err != nil {
  41448. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41449. }
  41450. return oldValue.OrganizationID, nil
  41451. }
  41452. // AddOrganizationID adds u to the "organization_id" field.
  41453. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  41454. if m.addorganization_id != nil {
  41455. *m.addorganization_id += u
  41456. } else {
  41457. m.addorganization_id = &u
  41458. }
  41459. }
  41460. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41461. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  41462. v := m.addorganization_id
  41463. if v == nil {
  41464. return
  41465. }
  41466. return *v, true
  41467. }
  41468. // ClearOrganizationID clears the value of the "organization_id" field.
  41469. func (m *UsageTotalMutation) ClearOrganizationID() {
  41470. m.organization_id = nil
  41471. m.addorganization_id = nil
  41472. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  41473. }
  41474. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41475. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  41476. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  41477. return ok
  41478. }
  41479. // ResetOrganizationID resets all changes to the "organization_id" field.
  41480. func (m *UsageTotalMutation) ResetOrganizationID() {
  41481. m.organization_id = nil
  41482. m.addorganization_id = nil
  41483. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  41484. }
  41485. // Where appends a list predicates to the UsageTotalMutation builder.
  41486. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  41487. m.predicates = append(m.predicates, ps...)
  41488. }
  41489. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  41490. // users can use type-assertion to append predicates that do not depend on any generated package.
  41491. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  41492. p := make([]predicate.UsageTotal, len(ps))
  41493. for i := range ps {
  41494. p[i] = ps[i]
  41495. }
  41496. m.Where(p...)
  41497. }
  41498. // Op returns the operation name.
  41499. func (m *UsageTotalMutation) Op() Op {
  41500. return m.op
  41501. }
  41502. // SetOp allows setting the mutation operation.
  41503. func (m *UsageTotalMutation) SetOp(op Op) {
  41504. m.op = op
  41505. }
  41506. // Type returns the node type of this mutation (UsageTotal).
  41507. func (m *UsageTotalMutation) Type() string {
  41508. return m.typ
  41509. }
  41510. // Fields returns all fields that were changed during this mutation. Note that in
  41511. // order to get all numeric fields that were incremented/decremented, call
  41512. // AddedFields().
  41513. func (m *UsageTotalMutation) Fields() []string {
  41514. fields := make([]string, 0, 10)
  41515. if m.created_at != nil {
  41516. fields = append(fields, usagetotal.FieldCreatedAt)
  41517. }
  41518. if m.updated_at != nil {
  41519. fields = append(fields, usagetotal.FieldUpdatedAt)
  41520. }
  41521. if m.status != nil {
  41522. fields = append(fields, usagetotal.FieldStatus)
  41523. }
  41524. if m._type != nil {
  41525. fields = append(fields, usagetotal.FieldType)
  41526. }
  41527. if m.bot_id != nil {
  41528. fields = append(fields, usagetotal.FieldBotID)
  41529. }
  41530. if m.total_tokens != nil {
  41531. fields = append(fields, usagetotal.FieldTotalTokens)
  41532. }
  41533. if m.credits != nil {
  41534. fields = append(fields, usagetotal.FieldCredits)
  41535. }
  41536. if m.start_index != nil {
  41537. fields = append(fields, usagetotal.FieldStartIndex)
  41538. }
  41539. if m.end_index != nil {
  41540. fields = append(fields, usagetotal.FieldEndIndex)
  41541. }
  41542. if m.organization_id != nil {
  41543. fields = append(fields, usagetotal.FieldOrganizationID)
  41544. }
  41545. return fields
  41546. }
  41547. // Field returns the value of a field with the given name. The second boolean
  41548. // return value indicates that this field was not set, or was not defined in the
  41549. // schema.
  41550. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  41551. switch name {
  41552. case usagetotal.FieldCreatedAt:
  41553. return m.CreatedAt()
  41554. case usagetotal.FieldUpdatedAt:
  41555. return m.UpdatedAt()
  41556. case usagetotal.FieldStatus:
  41557. return m.Status()
  41558. case usagetotal.FieldType:
  41559. return m.GetType()
  41560. case usagetotal.FieldBotID:
  41561. return m.BotID()
  41562. case usagetotal.FieldTotalTokens:
  41563. return m.TotalTokens()
  41564. case usagetotal.FieldCredits:
  41565. return m.Credits()
  41566. case usagetotal.FieldStartIndex:
  41567. return m.StartIndex()
  41568. case usagetotal.FieldEndIndex:
  41569. return m.EndIndex()
  41570. case usagetotal.FieldOrganizationID:
  41571. return m.OrganizationID()
  41572. }
  41573. return nil, false
  41574. }
  41575. // OldField returns the old value of the field from the database. An error is
  41576. // returned if the mutation operation is not UpdateOne, or the query to the
  41577. // database failed.
  41578. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41579. switch name {
  41580. case usagetotal.FieldCreatedAt:
  41581. return m.OldCreatedAt(ctx)
  41582. case usagetotal.FieldUpdatedAt:
  41583. return m.OldUpdatedAt(ctx)
  41584. case usagetotal.FieldStatus:
  41585. return m.OldStatus(ctx)
  41586. case usagetotal.FieldType:
  41587. return m.OldType(ctx)
  41588. case usagetotal.FieldBotID:
  41589. return m.OldBotID(ctx)
  41590. case usagetotal.FieldTotalTokens:
  41591. return m.OldTotalTokens(ctx)
  41592. case usagetotal.FieldCredits:
  41593. return m.OldCredits(ctx)
  41594. case usagetotal.FieldStartIndex:
  41595. return m.OldStartIndex(ctx)
  41596. case usagetotal.FieldEndIndex:
  41597. return m.OldEndIndex(ctx)
  41598. case usagetotal.FieldOrganizationID:
  41599. return m.OldOrganizationID(ctx)
  41600. }
  41601. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  41602. }
  41603. // SetField sets the value of a field with the given name. It returns an error if
  41604. // the field is not defined in the schema, or if the type mismatched the field
  41605. // type.
  41606. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  41607. switch name {
  41608. case usagetotal.FieldCreatedAt:
  41609. v, ok := value.(time.Time)
  41610. if !ok {
  41611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41612. }
  41613. m.SetCreatedAt(v)
  41614. return nil
  41615. case usagetotal.FieldUpdatedAt:
  41616. v, ok := value.(time.Time)
  41617. if !ok {
  41618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41619. }
  41620. m.SetUpdatedAt(v)
  41621. return nil
  41622. case usagetotal.FieldStatus:
  41623. v, ok := value.(uint8)
  41624. if !ok {
  41625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41626. }
  41627. m.SetStatus(v)
  41628. return nil
  41629. case usagetotal.FieldType:
  41630. v, ok := value.(int)
  41631. if !ok {
  41632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41633. }
  41634. m.SetType(v)
  41635. return nil
  41636. case usagetotal.FieldBotID:
  41637. v, ok := value.(string)
  41638. if !ok {
  41639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41640. }
  41641. m.SetBotID(v)
  41642. return nil
  41643. case usagetotal.FieldTotalTokens:
  41644. v, ok := value.(uint64)
  41645. if !ok {
  41646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41647. }
  41648. m.SetTotalTokens(v)
  41649. return nil
  41650. case usagetotal.FieldCredits:
  41651. v, ok := value.(float64)
  41652. if !ok {
  41653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41654. }
  41655. m.SetCredits(v)
  41656. return nil
  41657. case usagetotal.FieldStartIndex:
  41658. v, ok := value.(uint64)
  41659. if !ok {
  41660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41661. }
  41662. m.SetStartIndex(v)
  41663. return nil
  41664. case usagetotal.FieldEndIndex:
  41665. v, ok := value.(uint64)
  41666. if !ok {
  41667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41668. }
  41669. m.SetEndIndex(v)
  41670. return nil
  41671. case usagetotal.FieldOrganizationID:
  41672. v, ok := value.(uint64)
  41673. if !ok {
  41674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41675. }
  41676. m.SetOrganizationID(v)
  41677. return nil
  41678. }
  41679. return fmt.Errorf("unknown UsageTotal field %s", name)
  41680. }
  41681. // AddedFields returns all numeric fields that were incremented/decremented during
  41682. // this mutation.
  41683. func (m *UsageTotalMutation) AddedFields() []string {
  41684. var fields []string
  41685. if m.addstatus != nil {
  41686. fields = append(fields, usagetotal.FieldStatus)
  41687. }
  41688. if m.add_type != nil {
  41689. fields = append(fields, usagetotal.FieldType)
  41690. }
  41691. if m.addtotal_tokens != nil {
  41692. fields = append(fields, usagetotal.FieldTotalTokens)
  41693. }
  41694. if m.addcredits != nil {
  41695. fields = append(fields, usagetotal.FieldCredits)
  41696. }
  41697. if m.addstart_index != nil {
  41698. fields = append(fields, usagetotal.FieldStartIndex)
  41699. }
  41700. if m.addend_index != nil {
  41701. fields = append(fields, usagetotal.FieldEndIndex)
  41702. }
  41703. if m.addorganization_id != nil {
  41704. fields = append(fields, usagetotal.FieldOrganizationID)
  41705. }
  41706. return fields
  41707. }
  41708. // AddedField returns the numeric value that was incremented/decremented on a field
  41709. // with the given name. The second boolean return value indicates that this field
  41710. // was not set, or was not defined in the schema.
  41711. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  41712. switch name {
  41713. case usagetotal.FieldStatus:
  41714. return m.AddedStatus()
  41715. case usagetotal.FieldType:
  41716. return m.AddedType()
  41717. case usagetotal.FieldTotalTokens:
  41718. return m.AddedTotalTokens()
  41719. case usagetotal.FieldCredits:
  41720. return m.AddedCredits()
  41721. case usagetotal.FieldStartIndex:
  41722. return m.AddedStartIndex()
  41723. case usagetotal.FieldEndIndex:
  41724. return m.AddedEndIndex()
  41725. case usagetotal.FieldOrganizationID:
  41726. return m.AddedOrganizationID()
  41727. }
  41728. return nil, false
  41729. }
  41730. // AddField adds the value to the field with the given name. It returns an error if
  41731. // the field is not defined in the schema, or if the type mismatched the field
  41732. // type.
  41733. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  41734. switch name {
  41735. case usagetotal.FieldStatus:
  41736. v, ok := value.(int8)
  41737. if !ok {
  41738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41739. }
  41740. m.AddStatus(v)
  41741. return nil
  41742. case usagetotal.FieldType:
  41743. v, ok := value.(int)
  41744. if !ok {
  41745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41746. }
  41747. m.AddType(v)
  41748. return nil
  41749. case usagetotal.FieldTotalTokens:
  41750. v, ok := value.(int64)
  41751. if !ok {
  41752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41753. }
  41754. m.AddTotalTokens(v)
  41755. return nil
  41756. case usagetotal.FieldCredits:
  41757. v, ok := value.(float64)
  41758. if !ok {
  41759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41760. }
  41761. m.AddCredits(v)
  41762. return nil
  41763. case usagetotal.FieldStartIndex:
  41764. v, ok := value.(int64)
  41765. if !ok {
  41766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41767. }
  41768. m.AddStartIndex(v)
  41769. return nil
  41770. case usagetotal.FieldEndIndex:
  41771. v, ok := value.(int64)
  41772. if !ok {
  41773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41774. }
  41775. m.AddEndIndex(v)
  41776. return nil
  41777. case usagetotal.FieldOrganizationID:
  41778. v, ok := value.(int64)
  41779. if !ok {
  41780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41781. }
  41782. m.AddOrganizationID(v)
  41783. return nil
  41784. }
  41785. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  41786. }
  41787. // ClearedFields returns all nullable fields that were cleared during this
  41788. // mutation.
  41789. func (m *UsageTotalMutation) ClearedFields() []string {
  41790. var fields []string
  41791. if m.FieldCleared(usagetotal.FieldStatus) {
  41792. fields = append(fields, usagetotal.FieldStatus)
  41793. }
  41794. if m.FieldCleared(usagetotal.FieldType) {
  41795. fields = append(fields, usagetotal.FieldType)
  41796. }
  41797. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  41798. fields = append(fields, usagetotal.FieldTotalTokens)
  41799. }
  41800. if m.FieldCleared(usagetotal.FieldCredits) {
  41801. fields = append(fields, usagetotal.FieldCredits)
  41802. }
  41803. if m.FieldCleared(usagetotal.FieldStartIndex) {
  41804. fields = append(fields, usagetotal.FieldStartIndex)
  41805. }
  41806. if m.FieldCleared(usagetotal.FieldEndIndex) {
  41807. fields = append(fields, usagetotal.FieldEndIndex)
  41808. }
  41809. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  41810. fields = append(fields, usagetotal.FieldOrganizationID)
  41811. }
  41812. return fields
  41813. }
  41814. // FieldCleared returns a boolean indicating if a field with the given name was
  41815. // cleared in this mutation.
  41816. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  41817. _, ok := m.clearedFields[name]
  41818. return ok
  41819. }
  41820. // ClearField clears the value of the field with the given name. It returns an
  41821. // error if the field is not defined in the schema.
  41822. func (m *UsageTotalMutation) ClearField(name string) error {
  41823. switch name {
  41824. case usagetotal.FieldStatus:
  41825. m.ClearStatus()
  41826. return nil
  41827. case usagetotal.FieldType:
  41828. m.ClearType()
  41829. return nil
  41830. case usagetotal.FieldTotalTokens:
  41831. m.ClearTotalTokens()
  41832. return nil
  41833. case usagetotal.FieldCredits:
  41834. m.ClearCredits()
  41835. return nil
  41836. case usagetotal.FieldStartIndex:
  41837. m.ClearStartIndex()
  41838. return nil
  41839. case usagetotal.FieldEndIndex:
  41840. m.ClearEndIndex()
  41841. return nil
  41842. case usagetotal.FieldOrganizationID:
  41843. m.ClearOrganizationID()
  41844. return nil
  41845. }
  41846. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  41847. }
  41848. // ResetField resets all changes in the mutation for the field with the given name.
  41849. // It returns an error if the field is not defined in the schema.
  41850. func (m *UsageTotalMutation) ResetField(name string) error {
  41851. switch name {
  41852. case usagetotal.FieldCreatedAt:
  41853. m.ResetCreatedAt()
  41854. return nil
  41855. case usagetotal.FieldUpdatedAt:
  41856. m.ResetUpdatedAt()
  41857. return nil
  41858. case usagetotal.FieldStatus:
  41859. m.ResetStatus()
  41860. return nil
  41861. case usagetotal.FieldType:
  41862. m.ResetType()
  41863. return nil
  41864. case usagetotal.FieldBotID:
  41865. m.ResetBotID()
  41866. return nil
  41867. case usagetotal.FieldTotalTokens:
  41868. m.ResetTotalTokens()
  41869. return nil
  41870. case usagetotal.FieldCredits:
  41871. m.ResetCredits()
  41872. return nil
  41873. case usagetotal.FieldStartIndex:
  41874. m.ResetStartIndex()
  41875. return nil
  41876. case usagetotal.FieldEndIndex:
  41877. m.ResetEndIndex()
  41878. return nil
  41879. case usagetotal.FieldOrganizationID:
  41880. m.ResetOrganizationID()
  41881. return nil
  41882. }
  41883. return fmt.Errorf("unknown UsageTotal field %s", name)
  41884. }
  41885. // AddedEdges returns all edge names that were set/added in this mutation.
  41886. func (m *UsageTotalMutation) AddedEdges() []string {
  41887. edges := make([]string, 0, 0)
  41888. return edges
  41889. }
  41890. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41891. // name in this mutation.
  41892. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  41893. return nil
  41894. }
  41895. // RemovedEdges returns all edge names that were removed in this mutation.
  41896. func (m *UsageTotalMutation) RemovedEdges() []string {
  41897. edges := make([]string, 0, 0)
  41898. return edges
  41899. }
  41900. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41901. // the given name in this mutation.
  41902. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  41903. return nil
  41904. }
  41905. // ClearedEdges returns all edge names that were cleared in this mutation.
  41906. func (m *UsageTotalMutation) ClearedEdges() []string {
  41907. edges := make([]string, 0, 0)
  41908. return edges
  41909. }
  41910. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41911. // was cleared in this mutation.
  41912. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  41913. return false
  41914. }
  41915. // ClearEdge clears the value of the edge with the given name. It returns an error
  41916. // if that edge is not defined in the schema.
  41917. func (m *UsageTotalMutation) ClearEdge(name string) error {
  41918. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  41919. }
  41920. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41921. // It returns an error if the edge is not defined in the schema.
  41922. func (m *UsageTotalMutation) ResetEdge(name string) error {
  41923. return fmt.Errorf("unknown UsageTotal edge %s", name)
  41924. }
  41925. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  41926. type WhatsappMutation struct {
  41927. config
  41928. op Op
  41929. typ string
  41930. id *uint64
  41931. created_at *time.Time
  41932. updated_at *time.Time
  41933. status *uint8
  41934. addstatus *int8
  41935. deleted_at *time.Time
  41936. wa_id *string
  41937. wa_name *string
  41938. callback *string
  41939. account *string
  41940. cc *string
  41941. phone *string
  41942. cc_phone *string
  41943. phone_name *string
  41944. phone_status *int8
  41945. addphone_status *int8
  41946. organization_id *uint64
  41947. addorganization_id *int64
  41948. api_base *string
  41949. api_key *string
  41950. allow_list *[]string
  41951. appendallow_list []string
  41952. group_allow_list *[]string
  41953. appendgroup_allow_list []string
  41954. block_list *[]string
  41955. appendblock_list []string
  41956. group_block_list *[]string
  41957. appendgroup_block_list []string
  41958. clearedFields map[string]struct{}
  41959. agent *uint64
  41960. clearedagent bool
  41961. done bool
  41962. oldValue func(context.Context) (*Whatsapp, error)
  41963. predicates []predicate.Whatsapp
  41964. }
  41965. var _ ent.Mutation = (*WhatsappMutation)(nil)
  41966. // whatsappOption allows management of the mutation configuration using functional options.
  41967. type whatsappOption func(*WhatsappMutation)
  41968. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  41969. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  41970. m := &WhatsappMutation{
  41971. config: c,
  41972. op: op,
  41973. typ: TypeWhatsapp,
  41974. clearedFields: make(map[string]struct{}),
  41975. }
  41976. for _, opt := range opts {
  41977. opt(m)
  41978. }
  41979. return m
  41980. }
  41981. // withWhatsappID sets the ID field of the mutation.
  41982. func withWhatsappID(id uint64) whatsappOption {
  41983. return func(m *WhatsappMutation) {
  41984. var (
  41985. err error
  41986. once sync.Once
  41987. value *Whatsapp
  41988. )
  41989. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  41990. once.Do(func() {
  41991. if m.done {
  41992. err = errors.New("querying old values post mutation is not allowed")
  41993. } else {
  41994. value, err = m.Client().Whatsapp.Get(ctx, id)
  41995. }
  41996. })
  41997. return value, err
  41998. }
  41999. m.id = &id
  42000. }
  42001. }
  42002. // withWhatsapp sets the old Whatsapp of the mutation.
  42003. func withWhatsapp(node *Whatsapp) whatsappOption {
  42004. return func(m *WhatsappMutation) {
  42005. m.oldValue = func(context.Context) (*Whatsapp, error) {
  42006. return node, nil
  42007. }
  42008. m.id = &node.ID
  42009. }
  42010. }
  42011. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42012. // executed in a transaction (ent.Tx), a transactional client is returned.
  42013. func (m WhatsappMutation) Client() *Client {
  42014. client := &Client{config: m.config}
  42015. client.init()
  42016. return client
  42017. }
  42018. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42019. // it returns an error otherwise.
  42020. func (m WhatsappMutation) Tx() (*Tx, error) {
  42021. if _, ok := m.driver.(*txDriver); !ok {
  42022. return nil, errors.New("ent: mutation is not running in a transaction")
  42023. }
  42024. tx := &Tx{config: m.config}
  42025. tx.init()
  42026. return tx, nil
  42027. }
  42028. // SetID sets the value of the id field. Note that this
  42029. // operation is only accepted on creation of Whatsapp entities.
  42030. func (m *WhatsappMutation) SetID(id uint64) {
  42031. m.id = &id
  42032. }
  42033. // ID returns the ID value in the mutation. Note that the ID is only available
  42034. // if it was provided to the builder or after it was returned from the database.
  42035. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  42036. if m.id == nil {
  42037. return
  42038. }
  42039. return *m.id, true
  42040. }
  42041. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42042. // That means, if the mutation is applied within a transaction with an isolation level such
  42043. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42044. // or updated by the mutation.
  42045. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  42046. switch {
  42047. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42048. id, exists := m.ID()
  42049. if exists {
  42050. return []uint64{id}, nil
  42051. }
  42052. fallthrough
  42053. case m.op.Is(OpUpdate | OpDelete):
  42054. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  42055. default:
  42056. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42057. }
  42058. }
  42059. // SetCreatedAt sets the "created_at" field.
  42060. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  42061. m.created_at = &t
  42062. }
  42063. // CreatedAt returns the value of the "created_at" field in the mutation.
  42064. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  42065. v := m.created_at
  42066. if v == nil {
  42067. return
  42068. }
  42069. return *v, true
  42070. }
  42071. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  42072. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42074. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42075. if !m.op.Is(OpUpdateOne) {
  42076. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42077. }
  42078. if m.id == nil || m.oldValue == nil {
  42079. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42080. }
  42081. oldValue, err := m.oldValue(ctx)
  42082. if err != nil {
  42083. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42084. }
  42085. return oldValue.CreatedAt, nil
  42086. }
  42087. // ResetCreatedAt resets all changes to the "created_at" field.
  42088. func (m *WhatsappMutation) ResetCreatedAt() {
  42089. m.created_at = nil
  42090. }
  42091. // SetUpdatedAt sets the "updated_at" field.
  42092. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  42093. m.updated_at = &t
  42094. }
  42095. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42096. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  42097. v := m.updated_at
  42098. if v == nil {
  42099. return
  42100. }
  42101. return *v, true
  42102. }
  42103. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  42104. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42106. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42107. if !m.op.Is(OpUpdateOne) {
  42108. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42109. }
  42110. if m.id == nil || m.oldValue == nil {
  42111. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42112. }
  42113. oldValue, err := m.oldValue(ctx)
  42114. if err != nil {
  42115. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42116. }
  42117. return oldValue.UpdatedAt, nil
  42118. }
  42119. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42120. func (m *WhatsappMutation) ResetUpdatedAt() {
  42121. m.updated_at = nil
  42122. }
  42123. // SetStatus sets the "status" field.
  42124. func (m *WhatsappMutation) SetStatus(u uint8) {
  42125. m.status = &u
  42126. m.addstatus = nil
  42127. }
  42128. // Status returns the value of the "status" field in the mutation.
  42129. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  42130. v := m.status
  42131. if v == nil {
  42132. return
  42133. }
  42134. return *v, true
  42135. }
  42136. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  42137. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42139. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42140. if !m.op.Is(OpUpdateOne) {
  42141. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42142. }
  42143. if m.id == nil || m.oldValue == nil {
  42144. return v, errors.New("OldStatus requires an ID field in the mutation")
  42145. }
  42146. oldValue, err := m.oldValue(ctx)
  42147. if err != nil {
  42148. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42149. }
  42150. return oldValue.Status, nil
  42151. }
  42152. // AddStatus adds u to the "status" field.
  42153. func (m *WhatsappMutation) AddStatus(u int8) {
  42154. if m.addstatus != nil {
  42155. *m.addstatus += u
  42156. } else {
  42157. m.addstatus = &u
  42158. }
  42159. }
  42160. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42161. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  42162. v := m.addstatus
  42163. if v == nil {
  42164. return
  42165. }
  42166. return *v, true
  42167. }
  42168. // ClearStatus clears the value of the "status" field.
  42169. func (m *WhatsappMutation) ClearStatus() {
  42170. m.status = nil
  42171. m.addstatus = nil
  42172. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  42173. }
  42174. // StatusCleared returns if the "status" field was cleared in this mutation.
  42175. func (m *WhatsappMutation) StatusCleared() bool {
  42176. _, ok := m.clearedFields[whatsapp.FieldStatus]
  42177. return ok
  42178. }
  42179. // ResetStatus resets all changes to the "status" field.
  42180. func (m *WhatsappMutation) ResetStatus() {
  42181. m.status = nil
  42182. m.addstatus = nil
  42183. delete(m.clearedFields, whatsapp.FieldStatus)
  42184. }
  42185. // SetDeletedAt sets the "deleted_at" field.
  42186. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  42187. m.deleted_at = &t
  42188. }
  42189. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42190. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  42191. v := m.deleted_at
  42192. if v == nil {
  42193. return
  42194. }
  42195. return *v, true
  42196. }
  42197. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  42198. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42200. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42201. if !m.op.Is(OpUpdateOne) {
  42202. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42203. }
  42204. if m.id == nil || m.oldValue == nil {
  42205. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42206. }
  42207. oldValue, err := m.oldValue(ctx)
  42208. if err != nil {
  42209. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42210. }
  42211. return oldValue.DeletedAt, nil
  42212. }
  42213. // ClearDeletedAt clears the value of the "deleted_at" field.
  42214. func (m *WhatsappMutation) ClearDeletedAt() {
  42215. m.deleted_at = nil
  42216. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  42217. }
  42218. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42219. func (m *WhatsappMutation) DeletedAtCleared() bool {
  42220. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  42221. return ok
  42222. }
  42223. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42224. func (m *WhatsappMutation) ResetDeletedAt() {
  42225. m.deleted_at = nil
  42226. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  42227. }
  42228. // SetWaID sets the "wa_id" field.
  42229. func (m *WhatsappMutation) SetWaID(s string) {
  42230. m.wa_id = &s
  42231. }
  42232. // WaID returns the value of the "wa_id" field in the mutation.
  42233. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  42234. v := m.wa_id
  42235. if v == nil {
  42236. return
  42237. }
  42238. return *v, true
  42239. }
  42240. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  42241. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42243. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  42244. if !m.op.Is(OpUpdateOne) {
  42245. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  42246. }
  42247. if m.id == nil || m.oldValue == nil {
  42248. return v, errors.New("OldWaID requires an ID field in the mutation")
  42249. }
  42250. oldValue, err := m.oldValue(ctx)
  42251. if err != nil {
  42252. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42253. }
  42254. return oldValue.WaID, nil
  42255. }
  42256. // ClearWaID clears the value of the "wa_id" field.
  42257. func (m *WhatsappMutation) ClearWaID() {
  42258. m.wa_id = nil
  42259. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  42260. }
  42261. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42262. func (m *WhatsappMutation) WaIDCleared() bool {
  42263. _, ok := m.clearedFields[whatsapp.FieldWaID]
  42264. return ok
  42265. }
  42266. // ResetWaID resets all changes to the "wa_id" field.
  42267. func (m *WhatsappMutation) ResetWaID() {
  42268. m.wa_id = nil
  42269. delete(m.clearedFields, whatsapp.FieldWaID)
  42270. }
  42271. // SetWaName sets the "wa_name" field.
  42272. func (m *WhatsappMutation) SetWaName(s string) {
  42273. m.wa_name = &s
  42274. }
  42275. // WaName returns the value of the "wa_name" field in the mutation.
  42276. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  42277. v := m.wa_name
  42278. if v == nil {
  42279. return
  42280. }
  42281. return *v, true
  42282. }
  42283. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  42284. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42286. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  42287. if !m.op.Is(OpUpdateOne) {
  42288. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42289. }
  42290. if m.id == nil || m.oldValue == nil {
  42291. return v, errors.New("OldWaName requires an ID field in the mutation")
  42292. }
  42293. oldValue, err := m.oldValue(ctx)
  42294. if err != nil {
  42295. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42296. }
  42297. return oldValue.WaName, nil
  42298. }
  42299. // ClearWaName clears the value of the "wa_name" field.
  42300. func (m *WhatsappMutation) ClearWaName() {
  42301. m.wa_name = nil
  42302. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  42303. }
  42304. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42305. func (m *WhatsappMutation) WaNameCleared() bool {
  42306. _, ok := m.clearedFields[whatsapp.FieldWaName]
  42307. return ok
  42308. }
  42309. // ResetWaName resets all changes to the "wa_name" field.
  42310. func (m *WhatsappMutation) ResetWaName() {
  42311. m.wa_name = nil
  42312. delete(m.clearedFields, whatsapp.FieldWaName)
  42313. }
  42314. // SetCallback sets the "callback" field.
  42315. func (m *WhatsappMutation) SetCallback(s string) {
  42316. m.callback = &s
  42317. }
  42318. // Callback returns the value of the "callback" field in the mutation.
  42319. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  42320. v := m.callback
  42321. if v == nil {
  42322. return
  42323. }
  42324. return *v, true
  42325. }
  42326. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  42327. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42329. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  42330. if !m.op.Is(OpUpdateOne) {
  42331. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42332. }
  42333. if m.id == nil || m.oldValue == nil {
  42334. return v, errors.New("OldCallback requires an ID field in the mutation")
  42335. }
  42336. oldValue, err := m.oldValue(ctx)
  42337. if err != nil {
  42338. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42339. }
  42340. return oldValue.Callback, nil
  42341. }
  42342. // ClearCallback clears the value of the "callback" field.
  42343. func (m *WhatsappMutation) ClearCallback() {
  42344. m.callback = nil
  42345. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  42346. }
  42347. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  42348. func (m *WhatsappMutation) CallbackCleared() bool {
  42349. _, ok := m.clearedFields[whatsapp.FieldCallback]
  42350. return ok
  42351. }
  42352. // ResetCallback resets all changes to the "callback" field.
  42353. func (m *WhatsappMutation) ResetCallback() {
  42354. m.callback = nil
  42355. delete(m.clearedFields, whatsapp.FieldCallback)
  42356. }
  42357. // SetAgentID sets the "agent_id" field.
  42358. func (m *WhatsappMutation) SetAgentID(u uint64) {
  42359. m.agent = &u
  42360. }
  42361. // AgentID returns the value of the "agent_id" field in the mutation.
  42362. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  42363. v := m.agent
  42364. if v == nil {
  42365. return
  42366. }
  42367. return *v, true
  42368. }
  42369. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  42370. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42372. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42373. if !m.op.Is(OpUpdateOne) {
  42374. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42375. }
  42376. if m.id == nil || m.oldValue == nil {
  42377. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42378. }
  42379. oldValue, err := m.oldValue(ctx)
  42380. if err != nil {
  42381. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42382. }
  42383. return oldValue.AgentID, nil
  42384. }
  42385. // ResetAgentID resets all changes to the "agent_id" field.
  42386. func (m *WhatsappMutation) ResetAgentID() {
  42387. m.agent = nil
  42388. }
  42389. // SetAccount sets the "account" field.
  42390. func (m *WhatsappMutation) SetAccount(s string) {
  42391. m.account = &s
  42392. }
  42393. // Account returns the value of the "account" field in the mutation.
  42394. func (m *WhatsappMutation) Account() (r string, exists bool) {
  42395. v := m.account
  42396. if v == nil {
  42397. return
  42398. }
  42399. return *v, true
  42400. }
  42401. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  42402. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42404. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  42405. if !m.op.Is(OpUpdateOne) {
  42406. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42407. }
  42408. if m.id == nil || m.oldValue == nil {
  42409. return v, errors.New("OldAccount requires an ID field in the mutation")
  42410. }
  42411. oldValue, err := m.oldValue(ctx)
  42412. if err != nil {
  42413. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42414. }
  42415. return oldValue.Account, nil
  42416. }
  42417. // ClearAccount clears the value of the "account" field.
  42418. func (m *WhatsappMutation) ClearAccount() {
  42419. m.account = nil
  42420. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  42421. }
  42422. // AccountCleared returns if the "account" field was cleared in this mutation.
  42423. func (m *WhatsappMutation) AccountCleared() bool {
  42424. _, ok := m.clearedFields[whatsapp.FieldAccount]
  42425. return ok
  42426. }
  42427. // ResetAccount resets all changes to the "account" field.
  42428. func (m *WhatsappMutation) ResetAccount() {
  42429. m.account = nil
  42430. delete(m.clearedFields, whatsapp.FieldAccount)
  42431. }
  42432. // SetCc sets the "cc" field.
  42433. func (m *WhatsappMutation) SetCc(s string) {
  42434. m.cc = &s
  42435. }
  42436. // Cc returns the value of the "cc" field in the mutation.
  42437. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  42438. v := m.cc
  42439. if v == nil {
  42440. return
  42441. }
  42442. return *v, true
  42443. }
  42444. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  42445. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42447. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  42448. if !m.op.Is(OpUpdateOne) {
  42449. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  42450. }
  42451. if m.id == nil || m.oldValue == nil {
  42452. return v, errors.New("OldCc requires an ID field in the mutation")
  42453. }
  42454. oldValue, err := m.oldValue(ctx)
  42455. if err != nil {
  42456. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  42457. }
  42458. return oldValue.Cc, nil
  42459. }
  42460. // ResetCc resets all changes to the "cc" field.
  42461. func (m *WhatsappMutation) ResetCc() {
  42462. m.cc = nil
  42463. }
  42464. // SetPhone sets the "phone" field.
  42465. func (m *WhatsappMutation) SetPhone(s string) {
  42466. m.phone = &s
  42467. }
  42468. // Phone returns the value of the "phone" field in the mutation.
  42469. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  42470. v := m.phone
  42471. if v == nil {
  42472. return
  42473. }
  42474. return *v, true
  42475. }
  42476. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  42477. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42479. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  42480. if !m.op.Is(OpUpdateOne) {
  42481. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42482. }
  42483. if m.id == nil || m.oldValue == nil {
  42484. return v, errors.New("OldPhone requires an ID field in the mutation")
  42485. }
  42486. oldValue, err := m.oldValue(ctx)
  42487. if err != nil {
  42488. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42489. }
  42490. return oldValue.Phone, nil
  42491. }
  42492. // ResetPhone resets all changes to the "phone" field.
  42493. func (m *WhatsappMutation) ResetPhone() {
  42494. m.phone = nil
  42495. }
  42496. // SetCcPhone sets the "cc_phone" field.
  42497. func (m *WhatsappMutation) SetCcPhone(s string) {
  42498. m.cc_phone = &s
  42499. }
  42500. // CcPhone returns the value of the "cc_phone" field in the mutation.
  42501. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  42502. v := m.cc_phone
  42503. if v == nil {
  42504. return
  42505. }
  42506. return *v, true
  42507. }
  42508. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  42509. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42511. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  42512. if !m.op.Is(OpUpdateOne) {
  42513. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  42514. }
  42515. if m.id == nil || m.oldValue == nil {
  42516. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  42517. }
  42518. oldValue, err := m.oldValue(ctx)
  42519. if err != nil {
  42520. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  42521. }
  42522. return oldValue.CcPhone, nil
  42523. }
  42524. // ResetCcPhone resets all changes to the "cc_phone" field.
  42525. func (m *WhatsappMutation) ResetCcPhone() {
  42526. m.cc_phone = nil
  42527. }
  42528. // SetPhoneName sets the "phone_name" field.
  42529. func (m *WhatsappMutation) SetPhoneName(s string) {
  42530. m.phone_name = &s
  42531. }
  42532. // PhoneName returns the value of the "phone_name" field in the mutation.
  42533. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  42534. v := m.phone_name
  42535. if v == nil {
  42536. return
  42537. }
  42538. return *v, true
  42539. }
  42540. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  42541. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42543. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  42544. if !m.op.Is(OpUpdateOne) {
  42545. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  42546. }
  42547. if m.id == nil || m.oldValue == nil {
  42548. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  42549. }
  42550. oldValue, err := m.oldValue(ctx)
  42551. if err != nil {
  42552. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  42553. }
  42554. return oldValue.PhoneName, nil
  42555. }
  42556. // ResetPhoneName resets all changes to the "phone_name" field.
  42557. func (m *WhatsappMutation) ResetPhoneName() {
  42558. m.phone_name = nil
  42559. }
  42560. // SetPhoneStatus sets the "phone_status" field.
  42561. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  42562. m.phone_status = &i
  42563. m.addphone_status = nil
  42564. }
  42565. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  42566. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  42567. v := m.phone_status
  42568. if v == nil {
  42569. return
  42570. }
  42571. return *v, true
  42572. }
  42573. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  42574. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42576. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  42577. if !m.op.Is(OpUpdateOne) {
  42578. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  42579. }
  42580. if m.id == nil || m.oldValue == nil {
  42581. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  42582. }
  42583. oldValue, err := m.oldValue(ctx)
  42584. if err != nil {
  42585. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  42586. }
  42587. return oldValue.PhoneStatus, nil
  42588. }
  42589. // AddPhoneStatus adds i to the "phone_status" field.
  42590. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  42591. if m.addphone_status != nil {
  42592. *m.addphone_status += i
  42593. } else {
  42594. m.addphone_status = &i
  42595. }
  42596. }
  42597. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  42598. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  42599. v := m.addphone_status
  42600. if v == nil {
  42601. return
  42602. }
  42603. return *v, true
  42604. }
  42605. // ResetPhoneStatus resets all changes to the "phone_status" field.
  42606. func (m *WhatsappMutation) ResetPhoneStatus() {
  42607. m.phone_status = nil
  42608. m.addphone_status = nil
  42609. }
  42610. // SetOrganizationID sets the "organization_id" field.
  42611. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  42612. m.organization_id = &u
  42613. m.addorganization_id = nil
  42614. }
  42615. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42616. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  42617. v := m.organization_id
  42618. if v == nil {
  42619. return
  42620. }
  42621. return *v, true
  42622. }
  42623. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  42624. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42626. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42627. if !m.op.Is(OpUpdateOne) {
  42628. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42629. }
  42630. if m.id == nil || m.oldValue == nil {
  42631. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42632. }
  42633. oldValue, err := m.oldValue(ctx)
  42634. if err != nil {
  42635. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42636. }
  42637. return oldValue.OrganizationID, nil
  42638. }
  42639. // AddOrganizationID adds u to the "organization_id" field.
  42640. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  42641. if m.addorganization_id != nil {
  42642. *m.addorganization_id += u
  42643. } else {
  42644. m.addorganization_id = &u
  42645. }
  42646. }
  42647. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42648. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  42649. v := m.addorganization_id
  42650. if v == nil {
  42651. return
  42652. }
  42653. return *v, true
  42654. }
  42655. // ClearOrganizationID clears the value of the "organization_id" field.
  42656. func (m *WhatsappMutation) ClearOrganizationID() {
  42657. m.organization_id = nil
  42658. m.addorganization_id = nil
  42659. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  42660. }
  42661. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42662. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  42663. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  42664. return ok
  42665. }
  42666. // ResetOrganizationID resets all changes to the "organization_id" field.
  42667. func (m *WhatsappMutation) ResetOrganizationID() {
  42668. m.organization_id = nil
  42669. m.addorganization_id = nil
  42670. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  42671. }
  42672. // SetAPIBase sets the "api_base" field.
  42673. func (m *WhatsappMutation) SetAPIBase(s string) {
  42674. m.api_base = &s
  42675. }
  42676. // APIBase returns the value of the "api_base" field in the mutation.
  42677. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  42678. v := m.api_base
  42679. if v == nil {
  42680. return
  42681. }
  42682. return *v, true
  42683. }
  42684. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  42685. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42687. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42688. if !m.op.Is(OpUpdateOne) {
  42689. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42690. }
  42691. if m.id == nil || m.oldValue == nil {
  42692. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42693. }
  42694. oldValue, err := m.oldValue(ctx)
  42695. if err != nil {
  42696. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42697. }
  42698. return oldValue.APIBase, nil
  42699. }
  42700. // ClearAPIBase clears the value of the "api_base" field.
  42701. func (m *WhatsappMutation) ClearAPIBase() {
  42702. m.api_base = nil
  42703. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  42704. }
  42705. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42706. func (m *WhatsappMutation) APIBaseCleared() bool {
  42707. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  42708. return ok
  42709. }
  42710. // ResetAPIBase resets all changes to the "api_base" field.
  42711. func (m *WhatsappMutation) ResetAPIBase() {
  42712. m.api_base = nil
  42713. delete(m.clearedFields, whatsapp.FieldAPIBase)
  42714. }
  42715. // SetAPIKey sets the "api_key" field.
  42716. func (m *WhatsappMutation) SetAPIKey(s string) {
  42717. m.api_key = &s
  42718. }
  42719. // APIKey returns the value of the "api_key" field in the mutation.
  42720. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  42721. v := m.api_key
  42722. if v == nil {
  42723. return
  42724. }
  42725. return *v, true
  42726. }
  42727. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  42728. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42730. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42731. if !m.op.Is(OpUpdateOne) {
  42732. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42733. }
  42734. if m.id == nil || m.oldValue == nil {
  42735. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42736. }
  42737. oldValue, err := m.oldValue(ctx)
  42738. if err != nil {
  42739. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42740. }
  42741. return oldValue.APIKey, nil
  42742. }
  42743. // ClearAPIKey clears the value of the "api_key" field.
  42744. func (m *WhatsappMutation) ClearAPIKey() {
  42745. m.api_key = nil
  42746. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  42747. }
  42748. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42749. func (m *WhatsappMutation) APIKeyCleared() bool {
  42750. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  42751. return ok
  42752. }
  42753. // ResetAPIKey resets all changes to the "api_key" field.
  42754. func (m *WhatsappMutation) ResetAPIKey() {
  42755. m.api_key = nil
  42756. delete(m.clearedFields, whatsapp.FieldAPIKey)
  42757. }
  42758. // SetAllowList sets the "allow_list" field.
  42759. func (m *WhatsappMutation) SetAllowList(s []string) {
  42760. m.allow_list = &s
  42761. m.appendallow_list = nil
  42762. }
  42763. // AllowList returns the value of the "allow_list" field in the mutation.
  42764. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  42765. v := m.allow_list
  42766. if v == nil {
  42767. return
  42768. }
  42769. return *v, true
  42770. }
  42771. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  42772. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42774. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42775. if !m.op.Is(OpUpdateOne) {
  42776. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42777. }
  42778. if m.id == nil || m.oldValue == nil {
  42779. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42780. }
  42781. oldValue, err := m.oldValue(ctx)
  42782. if err != nil {
  42783. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42784. }
  42785. return oldValue.AllowList, nil
  42786. }
  42787. // AppendAllowList adds s to the "allow_list" field.
  42788. func (m *WhatsappMutation) AppendAllowList(s []string) {
  42789. m.appendallow_list = append(m.appendallow_list, s...)
  42790. }
  42791. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42792. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  42793. if len(m.appendallow_list) == 0 {
  42794. return nil, false
  42795. }
  42796. return m.appendallow_list, true
  42797. }
  42798. // ClearAllowList clears the value of the "allow_list" field.
  42799. func (m *WhatsappMutation) ClearAllowList() {
  42800. m.allow_list = nil
  42801. m.appendallow_list = nil
  42802. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  42803. }
  42804. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  42805. func (m *WhatsappMutation) AllowListCleared() bool {
  42806. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  42807. return ok
  42808. }
  42809. // ResetAllowList resets all changes to the "allow_list" field.
  42810. func (m *WhatsappMutation) ResetAllowList() {
  42811. m.allow_list = nil
  42812. m.appendallow_list = nil
  42813. delete(m.clearedFields, whatsapp.FieldAllowList)
  42814. }
  42815. // SetGroupAllowList sets the "group_allow_list" field.
  42816. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  42817. m.group_allow_list = &s
  42818. m.appendgroup_allow_list = nil
  42819. }
  42820. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42821. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  42822. v := m.group_allow_list
  42823. if v == nil {
  42824. return
  42825. }
  42826. return *v, true
  42827. }
  42828. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  42829. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42831. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42832. if !m.op.Is(OpUpdateOne) {
  42833. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42834. }
  42835. if m.id == nil || m.oldValue == nil {
  42836. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42837. }
  42838. oldValue, err := m.oldValue(ctx)
  42839. if err != nil {
  42840. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42841. }
  42842. return oldValue.GroupAllowList, nil
  42843. }
  42844. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42845. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  42846. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42847. }
  42848. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42849. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  42850. if len(m.appendgroup_allow_list) == 0 {
  42851. return nil, false
  42852. }
  42853. return m.appendgroup_allow_list, true
  42854. }
  42855. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  42856. func (m *WhatsappMutation) ClearGroupAllowList() {
  42857. m.group_allow_list = nil
  42858. m.appendgroup_allow_list = nil
  42859. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  42860. }
  42861. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  42862. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  42863. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  42864. return ok
  42865. }
  42866. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42867. func (m *WhatsappMutation) ResetGroupAllowList() {
  42868. m.group_allow_list = nil
  42869. m.appendgroup_allow_list = nil
  42870. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  42871. }
  42872. // SetBlockList sets the "block_list" field.
  42873. func (m *WhatsappMutation) SetBlockList(s []string) {
  42874. m.block_list = &s
  42875. m.appendblock_list = nil
  42876. }
  42877. // BlockList returns the value of the "block_list" field in the mutation.
  42878. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  42879. v := m.block_list
  42880. if v == nil {
  42881. return
  42882. }
  42883. return *v, true
  42884. }
  42885. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  42886. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42888. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42889. if !m.op.Is(OpUpdateOne) {
  42890. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42891. }
  42892. if m.id == nil || m.oldValue == nil {
  42893. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42894. }
  42895. oldValue, err := m.oldValue(ctx)
  42896. if err != nil {
  42897. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42898. }
  42899. return oldValue.BlockList, nil
  42900. }
  42901. // AppendBlockList adds s to the "block_list" field.
  42902. func (m *WhatsappMutation) AppendBlockList(s []string) {
  42903. m.appendblock_list = append(m.appendblock_list, s...)
  42904. }
  42905. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42906. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  42907. if len(m.appendblock_list) == 0 {
  42908. return nil, false
  42909. }
  42910. return m.appendblock_list, true
  42911. }
  42912. // ClearBlockList clears the value of the "block_list" field.
  42913. func (m *WhatsappMutation) ClearBlockList() {
  42914. m.block_list = nil
  42915. m.appendblock_list = nil
  42916. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  42917. }
  42918. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  42919. func (m *WhatsappMutation) BlockListCleared() bool {
  42920. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  42921. return ok
  42922. }
  42923. // ResetBlockList resets all changes to the "block_list" field.
  42924. func (m *WhatsappMutation) ResetBlockList() {
  42925. m.block_list = nil
  42926. m.appendblock_list = nil
  42927. delete(m.clearedFields, whatsapp.FieldBlockList)
  42928. }
  42929. // SetGroupBlockList sets the "group_block_list" field.
  42930. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  42931. m.group_block_list = &s
  42932. m.appendgroup_block_list = nil
  42933. }
  42934. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42935. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  42936. v := m.group_block_list
  42937. if v == nil {
  42938. return
  42939. }
  42940. return *v, true
  42941. }
  42942. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  42943. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42945. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42946. if !m.op.Is(OpUpdateOne) {
  42947. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42948. }
  42949. if m.id == nil || m.oldValue == nil {
  42950. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42951. }
  42952. oldValue, err := m.oldValue(ctx)
  42953. if err != nil {
  42954. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42955. }
  42956. return oldValue.GroupBlockList, nil
  42957. }
  42958. // AppendGroupBlockList adds s to the "group_block_list" field.
  42959. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  42960. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42961. }
  42962. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42963. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  42964. if len(m.appendgroup_block_list) == 0 {
  42965. return nil, false
  42966. }
  42967. return m.appendgroup_block_list, true
  42968. }
  42969. // ClearGroupBlockList clears the value of the "group_block_list" field.
  42970. func (m *WhatsappMutation) ClearGroupBlockList() {
  42971. m.group_block_list = nil
  42972. m.appendgroup_block_list = nil
  42973. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  42974. }
  42975. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  42976. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  42977. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  42978. return ok
  42979. }
  42980. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42981. func (m *WhatsappMutation) ResetGroupBlockList() {
  42982. m.group_block_list = nil
  42983. m.appendgroup_block_list = nil
  42984. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  42985. }
  42986. // ClearAgent clears the "agent" edge to the Agent entity.
  42987. func (m *WhatsappMutation) ClearAgent() {
  42988. m.clearedagent = true
  42989. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  42990. }
  42991. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42992. func (m *WhatsappMutation) AgentCleared() bool {
  42993. return m.clearedagent
  42994. }
  42995. // AgentIDs returns the "agent" edge IDs in the mutation.
  42996. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42997. // AgentID instead. It exists only for internal usage by the builders.
  42998. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  42999. if id := m.agent; id != nil {
  43000. ids = append(ids, *id)
  43001. }
  43002. return
  43003. }
  43004. // ResetAgent resets all changes to the "agent" edge.
  43005. func (m *WhatsappMutation) ResetAgent() {
  43006. m.agent = nil
  43007. m.clearedagent = false
  43008. }
  43009. // Where appends a list predicates to the WhatsappMutation builder.
  43010. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  43011. m.predicates = append(m.predicates, ps...)
  43012. }
  43013. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  43014. // users can use type-assertion to append predicates that do not depend on any generated package.
  43015. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  43016. p := make([]predicate.Whatsapp, len(ps))
  43017. for i := range ps {
  43018. p[i] = ps[i]
  43019. }
  43020. m.Where(p...)
  43021. }
  43022. // Op returns the operation name.
  43023. func (m *WhatsappMutation) Op() Op {
  43024. return m.op
  43025. }
  43026. // SetOp allows setting the mutation operation.
  43027. func (m *WhatsappMutation) SetOp(op Op) {
  43028. m.op = op
  43029. }
  43030. // Type returns the node type of this mutation (Whatsapp).
  43031. func (m *WhatsappMutation) Type() string {
  43032. return m.typ
  43033. }
  43034. // Fields returns all fields that were changed during this mutation. Note that in
  43035. // order to get all numeric fields that were incremented/decremented, call
  43036. // AddedFields().
  43037. func (m *WhatsappMutation) Fields() []string {
  43038. fields := make([]string, 0, 21)
  43039. if m.created_at != nil {
  43040. fields = append(fields, whatsapp.FieldCreatedAt)
  43041. }
  43042. if m.updated_at != nil {
  43043. fields = append(fields, whatsapp.FieldUpdatedAt)
  43044. }
  43045. if m.status != nil {
  43046. fields = append(fields, whatsapp.FieldStatus)
  43047. }
  43048. if m.deleted_at != nil {
  43049. fields = append(fields, whatsapp.FieldDeletedAt)
  43050. }
  43051. if m.wa_id != nil {
  43052. fields = append(fields, whatsapp.FieldWaID)
  43053. }
  43054. if m.wa_name != nil {
  43055. fields = append(fields, whatsapp.FieldWaName)
  43056. }
  43057. if m.callback != nil {
  43058. fields = append(fields, whatsapp.FieldCallback)
  43059. }
  43060. if m.agent != nil {
  43061. fields = append(fields, whatsapp.FieldAgentID)
  43062. }
  43063. if m.account != nil {
  43064. fields = append(fields, whatsapp.FieldAccount)
  43065. }
  43066. if m.cc != nil {
  43067. fields = append(fields, whatsapp.FieldCc)
  43068. }
  43069. if m.phone != nil {
  43070. fields = append(fields, whatsapp.FieldPhone)
  43071. }
  43072. if m.cc_phone != nil {
  43073. fields = append(fields, whatsapp.FieldCcPhone)
  43074. }
  43075. if m.phone_name != nil {
  43076. fields = append(fields, whatsapp.FieldPhoneName)
  43077. }
  43078. if m.phone_status != nil {
  43079. fields = append(fields, whatsapp.FieldPhoneStatus)
  43080. }
  43081. if m.organization_id != nil {
  43082. fields = append(fields, whatsapp.FieldOrganizationID)
  43083. }
  43084. if m.api_base != nil {
  43085. fields = append(fields, whatsapp.FieldAPIBase)
  43086. }
  43087. if m.api_key != nil {
  43088. fields = append(fields, whatsapp.FieldAPIKey)
  43089. }
  43090. if m.allow_list != nil {
  43091. fields = append(fields, whatsapp.FieldAllowList)
  43092. }
  43093. if m.group_allow_list != nil {
  43094. fields = append(fields, whatsapp.FieldGroupAllowList)
  43095. }
  43096. if m.block_list != nil {
  43097. fields = append(fields, whatsapp.FieldBlockList)
  43098. }
  43099. if m.group_block_list != nil {
  43100. fields = append(fields, whatsapp.FieldGroupBlockList)
  43101. }
  43102. return fields
  43103. }
  43104. // Field returns the value of a field with the given name. The second boolean
  43105. // return value indicates that this field was not set, or was not defined in the
  43106. // schema.
  43107. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  43108. switch name {
  43109. case whatsapp.FieldCreatedAt:
  43110. return m.CreatedAt()
  43111. case whatsapp.FieldUpdatedAt:
  43112. return m.UpdatedAt()
  43113. case whatsapp.FieldStatus:
  43114. return m.Status()
  43115. case whatsapp.FieldDeletedAt:
  43116. return m.DeletedAt()
  43117. case whatsapp.FieldWaID:
  43118. return m.WaID()
  43119. case whatsapp.FieldWaName:
  43120. return m.WaName()
  43121. case whatsapp.FieldCallback:
  43122. return m.Callback()
  43123. case whatsapp.FieldAgentID:
  43124. return m.AgentID()
  43125. case whatsapp.FieldAccount:
  43126. return m.Account()
  43127. case whatsapp.FieldCc:
  43128. return m.Cc()
  43129. case whatsapp.FieldPhone:
  43130. return m.Phone()
  43131. case whatsapp.FieldCcPhone:
  43132. return m.CcPhone()
  43133. case whatsapp.FieldPhoneName:
  43134. return m.PhoneName()
  43135. case whatsapp.FieldPhoneStatus:
  43136. return m.PhoneStatus()
  43137. case whatsapp.FieldOrganizationID:
  43138. return m.OrganizationID()
  43139. case whatsapp.FieldAPIBase:
  43140. return m.APIBase()
  43141. case whatsapp.FieldAPIKey:
  43142. return m.APIKey()
  43143. case whatsapp.FieldAllowList:
  43144. return m.AllowList()
  43145. case whatsapp.FieldGroupAllowList:
  43146. return m.GroupAllowList()
  43147. case whatsapp.FieldBlockList:
  43148. return m.BlockList()
  43149. case whatsapp.FieldGroupBlockList:
  43150. return m.GroupBlockList()
  43151. }
  43152. return nil, false
  43153. }
  43154. // OldField returns the old value of the field from the database. An error is
  43155. // returned if the mutation operation is not UpdateOne, or the query to the
  43156. // database failed.
  43157. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43158. switch name {
  43159. case whatsapp.FieldCreatedAt:
  43160. return m.OldCreatedAt(ctx)
  43161. case whatsapp.FieldUpdatedAt:
  43162. return m.OldUpdatedAt(ctx)
  43163. case whatsapp.FieldStatus:
  43164. return m.OldStatus(ctx)
  43165. case whatsapp.FieldDeletedAt:
  43166. return m.OldDeletedAt(ctx)
  43167. case whatsapp.FieldWaID:
  43168. return m.OldWaID(ctx)
  43169. case whatsapp.FieldWaName:
  43170. return m.OldWaName(ctx)
  43171. case whatsapp.FieldCallback:
  43172. return m.OldCallback(ctx)
  43173. case whatsapp.FieldAgentID:
  43174. return m.OldAgentID(ctx)
  43175. case whatsapp.FieldAccount:
  43176. return m.OldAccount(ctx)
  43177. case whatsapp.FieldCc:
  43178. return m.OldCc(ctx)
  43179. case whatsapp.FieldPhone:
  43180. return m.OldPhone(ctx)
  43181. case whatsapp.FieldCcPhone:
  43182. return m.OldCcPhone(ctx)
  43183. case whatsapp.FieldPhoneName:
  43184. return m.OldPhoneName(ctx)
  43185. case whatsapp.FieldPhoneStatus:
  43186. return m.OldPhoneStatus(ctx)
  43187. case whatsapp.FieldOrganizationID:
  43188. return m.OldOrganizationID(ctx)
  43189. case whatsapp.FieldAPIBase:
  43190. return m.OldAPIBase(ctx)
  43191. case whatsapp.FieldAPIKey:
  43192. return m.OldAPIKey(ctx)
  43193. case whatsapp.FieldAllowList:
  43194. return m.OldAllowList(ctx)
  43195. case whatsapp.FieldGroupAllowList:
  43196. return m.OldGroupAllowList(ctx)
  43197. case whatsapp.FieldBlockList:
  43198. return m.OldBlockList(ctx)
  43199. case whatsapp.FieldGroupBlockList:
  43200. return m.OldGroupBlockList(ctx)
  43201. }
  43202. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  43203. }
  43204. // SetField sets the value of a field with the given name. It returns an error if
  43205. // the field is not defined in the schema, or if the type mismatched the field
  43206. // type.
  43207. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  43208. switch name {
  43209. case whatsapp.FieldCreatedAt:
  43210. v, ok := value.(time.Time)
  43211. if !ok {
  43212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43213. }
  43214. m.SetCreatedAt(v)
  43215. return nil
  43216. case whatsapp.FieldUpdatedAt:
  43217. v, ok := value.(time.Time)
  43218. if !ok {
  43219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43220. }
  43221. m.SetUpdatedAt(v)
  43222. return nil
  43223. case whatsapp.FieldStatus:
  43224. v, ok := value.(uint8)
  43225. if !ok {
  43226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43227. }
  43228. m.SetStatus(v)
  43229. return nil
  43230. case whatsapp.FieldDeletedAt:
  43231. v, ok := value.(time.Time)
  43232. if !ok {
  43233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43234. }
  43235. m.SetDeletedAt(v)
  43236. return nil
  43237. case whatsapp.FieldWaID:
  43238. v, ok := value.(string)
  43239. if !ok {
  43240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43241. }
  43242. m.SetWaID(v)
  43243. return nil
  43244. case whatsapp.FieldWaName:
  43245. v, ok := value.(string)
  43246. if !ok {
  43247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43248. }
  43249. m.SetWaName(v)
  43250. return nil
  43251. case whatsapp.FieldCallback:
  43252. v, ok := value.(string)
  43253. if !ok {
  43254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43255. }
  43256. m.SetCallback(v)
  43257. return nil
  43258. case whatsapp.FieldAgentID:
  43259. v, ok := value.(uint64)
  43260. if !ok {
  43261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43262. }
  43263. m.SetAgentID(v)
  43264. return nil
  43265. case whatsapp.FieldAccount:
  43266. v, ok := value.(string)
  43267. if !ok {
  43268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43269. }
  43270. m.SetAccount(v)
  43271. return nil
  43272. case whatsapp.FieldCc:
  43273. v, ok := value.(string)
  43274. if !ok {
  43275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43276. }
  43277. m.SetCc(v)
  43278. return nil
  43279. case whatsapp.FieldPhone:
  43280. v, ok := value.(string)
  43281. if !ok {
  43282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43283. }
  43284. m.SetPhone(v)
  43285. return nil
  43286. case whatsapp.FieldCcPhone:
  43287. v, ok := value.(string)
  43288. if !ok {
  43289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43290. }
  43291. m.SetCcPhone(v)
  43292. return nil
  43293. case whatsapp.FieldPhoneName:
  43294. v, ok := value.(string)
  43295. if !ok {
  43296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43297. }
  43298. m.SetPhoneName(v)
  43299. return nil
  43300. case whatsapp.FieldPhoneStatus:
  43301. v, ok := value.(int8)
  43302. if !ok {
  43303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43304. }
  43305. m.SetPhoneStatus(v)
  43306. return nil
  43307. case whatsapp.FieldOrganizationID:
  43308. v, ok := value.(uint64)
  43309. if !ok {
  43310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43311. }
  43312. m.SetOrganizationID(v)
  43313. return nil
  43314. case whatsapp.FieldAPIBase:
  43315. v, ok := value.(string)
  43316. if !ok {
  43317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43318. }
  43319. m.SetAPIBase(v)
  43320. return nil
  43321. case whatsapp.FieldAPIKey:
  43322. v, ok := value.(string)
  43323. if !ok {
  43324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43325. }
  43326. m.SetAPIKey(v)
  43327. return nil
  43328. case whatsapp.FieldAllowList:
  43329. v, ok := value.([]string)
  43330. if !ok {
  43331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43332. }
  43333. m.SetAllowList(v)
  43334. return nil
  43335. case whatsapp.FieldGroupAllowList:
  43336. v, ok := value.([]string)
  43337. if !ok {
  43338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43339. }
  43340. m.SetGroupAllowList(v)
  43341. return nil
  43342. case whatsapp.FieldBlockList:
  43343. v, ok := value.([]string)
  43344. if !ok {
  43345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43346. }
  43347. m.SetBlockList(v)
  43348. return nil
  43349. case whatsapp.FieldGroupBlockList:
  43350. v, ok := value.([]string)
  43351. if !ok {
  43352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43353. }
  43354. m.SetGroupBlockList(v)
  43355. return nil
  43356. }
  43357. return fmt.Errorf("unknown Whatsapp field %s", name)
  43358. }
  43359. // AddedFields returns all numeric fields that were incremented/decremented during
  43360. // this mutation.
  43361. func (m *WhatsappMutation) AddedFields() []string {
  43362. var fields []string
  43363. if m.addstatus != nil {
  43364. fields = append(fields, whatsapp.FieldStatus)
  43365. }
  43366. if m.addphone_status != nil {
  43367. fields = append(fields, whatsapp.FieldPhoneStatus)
  43368. }
  43369. if m.addorganization_id != nil {
  43370. fields = append(fields, whatsapp.FieldOrganizationID)
  43371. }
  43372. return fields
  43373. }
  43374. // AddedField returns the numeric value that was incremented/decremented on a field
  43375. // with the given name. The second boolean return value indicates that this field
  43376. // was not set, or was not defined in the schema.
  43377. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  43378. switch name {
  43379. case whatsapp.FieldStatus:
  43380. return m.AddedStatus()
  43381. case whatsapp.FieldPhoneStatus:
  43382. return m.AddedPhoneStatus()
  43383. case whatsapp.FieldOrganizationID:
  43384. return m.AddedOrganizationID()
  43385. }
  43386. return nil, false
  43387. }
  43388. // AddField adds the value to the field with the given name. It returns an error if
  43389. // the field is not defined in the schema, or if the type mismatched the field
  43390. // type.
  43391. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  43392. switch name {
  43393. case whatsapp.FieldStatus:
  43394. v, ok := value.(int8)
  43395. if !ok {
  43396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43397. }
  43398. m.AddStatus(v)
  43399. return nil
  43400. case whatsapp.FieldPhoneStatus:
  43401. v, ok := value.(int8)
  43402. if !ok {
  43403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43404. }
  43405. m.AddPhoneStatus(v)
  43406. return nil
  43407. case whatsapp.FieldOrganizationID:
  43408. v, ok := value.(int64)
  43409. if !ok {
  43410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43411. }
  43412. m.AddOrganizationID(v)
  43413. return nil
  43414. }
  43415. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  43416. }
  43417. // ClearedFields returns all nullable fields that were cleared during this
  43418. // mutation.
  43419. func (m *WhatsappMutation) ClearedFields() []string {
  43420. var fields []string
  43421. if m.FieldCleared(whatsapp.FieldStatus) {
  43422. fields = append(fields, whatsapp.FieldStatus)
  43423. }
  43424. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  43425. fields = append(fields, whatsapp.FieldDeletedAt)
  43426. }
  43427. if m.FieldCleared(whatsapp.FieldWaID) {
  43428. fields = append(fields, whatsapp.FieldWaID)
  43429. }
  43430. if m.FieldCleared(whatsapp.FieldWaName) {
  43431. fields = append(fields, whatsapp.FieldWaName)
  43432. }
  43433. if m.FieldCleared(whatsapp.FieldCallback) {
  43434. fields = append(fields, whatsapp.FieldCallback)
  43435. }
  43436. if m.FieldCleared(whatsapp.FieldAccount) {
  43437. fields = append(fields, whatsapp.FieldAccount)
  43438. }
  43439. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  43440. fields = append(fields, whatsapp.FieldOrganizationID)
  43441. }
  43442. if m.FieldCleared(whatsapp.FieldAPIBase) {
  43443. fields = append(fields, whatsapp.FieldAPIBase)
  43444. }
  43445. if m.FieldCleared(whatsapp.FieldAPIKey) {
  43446. fields = append(fields, whatsapp.FieldAPIKey)
  43447. }
  43448. if m.FieldCleared(whatsapp.FieldAllowList) {
  43449. fields = append(fields, whatsapp.FieldAllowList)
  43450. }
  43451. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  43452. fields = append(fields, whatsapp.FieldGroupAllowList)
  43453. }
  43454. if m.FieldCleared(whatsapp.FieldBlockList) {
  43455. fields = append(fields, whatsapp.FieldBlockList)
  43456. }
  43457. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  43458. fields = append(fields, whatsapp.FieldGroupBlockList)
  43459. }
  43460. return fields
  43461. }
  43462. // FieldCleared returns a boolean indicating if a field with the given name was
  43463. // cleared in this mutation.
  43464. func (m *WhatsappMutation) FieldCleared(name string) bool {
  43465. _, ok := m.clearedFields[name]
  43466. return ok
  43467. }
  43468. // ClearField clears the value of the field with the given name. It returns an
  43469. // error if the field is not defined in the schema.
  43470. func (m *WhatsappMutation) ClearField(name string) error {
  43471. switch name {
  43472. case whatsapp.FieldStatus:
  43473. m.ClearStatus()
  43474. return nil
  43475. case whatsapp.FieldDeletedAt:
  43476. m.ClearDeletedAt()
  43477. return nil
  43478. case whatsapp.FieldWaID:
  43479. m.ClearWaID()
  43480. return nil
  43481. case whatsapp.FieldWaName:
  43482. m.ClearWaName()
  43483. return nil
  43484. case whatsapp.FieldCallback:
  43485. m.ClearCallback()
  43486. return nil
  43487. case whatsapp.FieldAccount:
  43488. m.ClearAccount()
  43489. return nil
  43490. case whatsapp.FieldOrganizationID:
  43491. m.ClearOrganizationID()
  43492. return nil
  43493. case whatsapp.FieldAPIBase:
  43494. m.ClearAPIBase()
  43495. return nil
  43496. case whatsapp.FieldAPIKey:
  43497. m.ClearAPIKey()
  43498. return nil
  43499. case whatsapp.FieldAllowList:
  43500. m.ClearAllowList()
  43501. return nil
  43502. case whatsapp.FieldGroupAllowList:
  43503. m.ClearGroupAllowList()
  43504. return nil
  43505. case whatsapp.FieldBlockList:
  43506. m.ClearBlockList()
  43507. return nil
  43508. case whatsapp.FieldGroupBlockList:
  43509. m.ClearGroupBlockList()
  43510. return nil
  43511. }
  43512. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  43513. }
  43514. // ResetField resets all changes in the mutation for the field with the given name.
  43515. // It returns an error if the field is not defined in the schema.
  43516. func (m *WhatsappMutation) ResetField(name string) error {
  43517. switch name {
  43518. case whatsapp.FieldCreatedAt:
  43519. m.ResetCreatedAt()
  43520. return nil
  43521. case whatsapp.FieldUpdatedAt:
  43522. m.ResetUpdatedAt()
  43523. return nil
  43524. case whatsapp.FieldStatus:
  43525. m.ResetStatus()
  43526. return nil
  43527. case whatsapp.FieldDeletedAt:
  43528. m.ResetDeletedAt()
  43529. return nil
  43530. case whatsapp.FieldWaID:
  43531. m.ResetWaID()
  43532. return nil
  43533. case whatsapp.FieldWaName:
  43534. m.ResetWaName()
  43535. return nil
  43536. case whatsapp.FieldCallback:
  43537. m.ResetCallback()
  43538. return nil
  43539. case whatsapp.FieldAgentID:
  43540. m.ResetAgentID()
  43541. return nil
  43542. case whatsapp.FieldAccount:
  43543. m.ResetAccount()
  43544. return nil
  43545. case whatsapp.FieldCc:
  43546. m.ResetCc()
  43547. return nil
  43548. case whatsapp.FieldPhone:
  43549. m.ResetPhone()
  43550. return nil
  43551. case whatsapp.FieldCcPhone:
  43552. m.ResetCcPhone()
  43553. return nil
  43554. case whatsapp.FieldPhoneName:
  43555. m.ResetPhoneName()
  43556. return nil
  43557. case whatsapp.FieldPhoneStatus:
  43558. m.ResetPhoneStatus()
  43559. return nil
  43560. case whatsapp.FieldOrganizationID:
  43561. m.ResetOrganizationID()
  43562. return nil
  43563. case whatsapp.FieldAPIBase:
  43564. m.ResetAPIBase()
  43565. return nil
  43566. case whatsapp.FieldAPIKey:
  43567. m.ResetAPIKey()
  43568. return nil
  43569. case whatsapp.FieldAllowList:
  43570. m.ResetAllowList()
  43571. return nil
  43572. case whatsapp.FieldGroupAllowList:
  43573. m.ResetGroupAllowList()
  43574. return nil
  43575. case whatsapp.FieldBlockList:
  43576. m.ResetBlockList()
  43577. return nil
  43578. case whatsapp.FieldGroupBlockList:
  43579. m.ResetGroupBlockList()
  43580. return nil
  43581. }
  43582. return fmt.Errorf("unknown Whatsapp field %s", name)
  43583. }
  43584. // AddedEdges returns all edge names that were set/added in this mutation.
  43585. func (m *WhatsappMutation) AddedEdges() []string {
  43586. edges := make([]string, 0, 1)
  43587. if m.agent != nil {
  43588. edges = append(edges, whatsapp.EdgeAgent)
  43589. }
  43590. return edges
  43591. }
  43592. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43593. // name in this mutation.
  43594. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  43595. switch name {
  43596. case whatsapp.EdgeAgent:
  43597. if id := m.agent; id != nil {
  43598. return []ent.Value{*id}
  43599. }
  43600. }
  43601. return nil
  43602. }
  43603. // RemovedEdges returns all edge names that were removed in this mutation.
  43604. func (m *WhatsappMutation) RemovedEdges() []string {
  43605. edges := make([]string, 0, 1)
  43606. return edges
  43607. }
  43608. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43609. // the given name in this mutation.
  43610. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  43611. return nil
  43612. }
  43613. // ClearedEdges returns all edge names that were cleared in this mutation.
  43614. func (m *WhatsappMutation) ClearedEdges() []string {
  43615. edges := make([]string, 0, 1)
  43616. if m.clearedagent {
  43617. edges = append(edges, whatsapp.EdgeAgent)
  43618. }
  43619. return edges
  43620. }
  43621. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43622. // was cleared in this mutation.
  43623. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  43624. switch name {
  43625. case whatsapp.EdgeAgent:
  43626. return m.clearedagent
  43627. }
  43628. return false
  43629. }
  43630. // ClearEdge clears the value of the edge with the given name. It returns an error
  43631. // if that edge is not defined in the schema.
  43632. func (m *WhatsappMutation) ClearEdge(name string) error {
  43633. switch name {
  43634. case whatsapp.EdgeAgent:
  43635. m.ClearAgent()
  43636. return nil
  43637. }
  43638. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  43639. }
  43640. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43641. // It returns an error if the edge is not defined in the schema.
  43642. func (m *WhatsappMutation) ResetEdge(name string) error {
  43643. switch name {
  43644. case whatsapp.EdgeAgent:
  43645. m.ResetAgent()
  43646. return nil
  43647. }
  43648. return fmt.Errorf("unknown Whatsapp edge %s", name)
  43649. }
  43650. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  43651. type WhatsappChannelMutation struct {
  43652. config
  43653. op Op
  43654. typ string
  43655. id *uint64
  43656. created_at *time.Time
  43657. updated_at *time.Time
  43658. status *uint8
  43659. addstatus *int8
  43660. deleted_at *time.Time
  43661. ak *string
  43662. sk *string
  43663. wa_id *string
  43664. wa_name *string
  43665. waba_id *uint64
  43666. addwaba_id *int64
  43667. business_id *uint64
  43668. addbusiness_id *int64
  43669. organization_id *uint64
  43670. addorganization_id *int64
  43671. verify_account *string
  43672. clearedFields map[string]struct{}
  43673. done bool
  43674. oldValue func(context.Context) (*WhatsappChannel, error)
  43675. predicates []predicate.WhatsappChannel
  43676. }
  43677. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  43678. // whatsappchannelOption allows management of the mutation configuration using functional options.
  43679. type whatsappchannelOption func(*WhatsappChannelMutation)
  43680. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  43681. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  43682. m := &WhatsappChannelMutation{
  43683. config: c,
  43684. op: op,
  43685. typ: TypeWhatsappChannel,
  43686. clearedFields: make(map[string]struct{}),
  43687. }
  43688. for _, opt := range opts {
  43689. opt(m)
  43690. }
  43691. return m
  43692. }
  43693. // withWhatsappChannelID sets the ID field of the mutation.
  43694. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  43695. return func(m *WhatsappChannelMutation) {
  43696. var (
  43697. err error
  43698. once sync.Once
  43699. value *WhatsappChannel
  43700. )
  43701. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  43702. once.Do(func() {
  43703. if m.done {
  43704. err = errors.New("querying old values post mutation is not allowed")
  43705. } else {
  43706. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  43707. }
  43708. })
  43709. return value, err
  43710. }
  43711. m.id = &id
  43712. }
  43713. }
  43714. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  43715. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  43716. return func(m *WhatsappChannelMutation) {
  43717. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  43718. return node, nil
  43719. }
  43720. m.id = &node.ID
  43721. }
  43722. }
  43723. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43724. // executed in a transaction (ent.Tx), a transactional client is returned.
  43725. func (m WhatsappChannelMutation) Client() *Client {
  43726. client := &Client{config: m.config}
  43727. client.init()
  43728. return client
  43729. }
  43730. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43731. // it returns an error otherwise.
  43732. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  43733. if _, ok := m.driver.(*txDriver); !ok {
  43734. return nil, errors.New("ent: mutation is not running in a transaction")
  43735. }
  43736. tx := &Tx{config: m.config}
  43737. tx.init()
  43738. return tx, nil
  43739. }
  43740. // SetID sets the value of the id field. Note that this
  43741. // operation is only accepted on creation of WhatsappChannel entities.
  43742. func (m *WhatsappChannelMutation) SetID(id uint64) {
  43743. m.id = &id
  43744. }
  43745. // ID returns the ID value in the mutation. Note that the ID is only available
  43746. // if it was provided to the builder or after it was returned from the database.
  43747. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  43748. if m.id == nil {
  43749. return
  43750. }
  43751. return *m.id, true
  43752. }
  43753. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43754. // That means, if the mutation is applied within a transaction with an isolation level such
  43755. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43756. // or updated by the mutation.
  43757. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  43758. switch {
  43759. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43760. id, exists := m.ID()
  43761. if exists {
  43762. return []uint64{id}, nil
  43763. }
  43764. fallthrough
  43765. case m.op.Is(OpUpdate | OpDelete):
  43766. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  43767. default:
  43768. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43769. }
  43770. }
  43771. // SetCreatedAt sets the "created_at" field.
  43772. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  43773. m.created_at = &t
  43774. }
  43775. // CreatedAt returns the value of the "created_at" field in the mutation.
  43776. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  43777. v := m.created_at
  43778. if v == nil {
  43779. return
  43780. }
  43781. return *v, true
  43782. }
  43783. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  43784. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43786. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43787. if !m.op.Is(OpUpdateOne) {
  43788. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43789. }
  43790. if m.id == nil || m.oldValue == nil {
  43791. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43792. }
  43793. oldValue, err := m.oldValue(ctx)
  43794. if err != nil {
  43795. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43796. }
  43797. return oldValue.CreatedAt, nil
  43798. }
  43799. // ResetCreatedAt resets all changes to the "created_at" field.
  43800. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  43801. m.created_at = nil
  43802. }
  43803. // SetUpdatedAt sets the "updated_at" field.
  43804. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  43805. m.updated_at = &t
  43806. }
  43807. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43808. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  43809. v := m.updated_at
  43810. if v == nil {
  43811. return
  43812. }
  43813. return *v, true
  43814. }
  43815. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  43816. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43818. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43819. if !m.op.Is(OpUpdateOne) {
  43820. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43821. }
  43822. if m.id == nil || m.oldValue == nil {
  43823. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43824. }
  43825. oldValue, err := m.oldValue(ctx)
  43826. if err != nil {
  43827. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43828. }
  43829. return oldValue.UpdatedAt, nil
  43830. }
  43831. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43832. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  43833. m.updated_at = nil
  43834. }
  43835. // SetStatus sets the "status" field.
  43836. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  43837. m.status = &u
  43838. m.addstatus = nil
  43839. }
  43840. // Status returns the value of the "status" field in the mutation.
  43841. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  43842. v := m.status
  43843. if v == nil {
  43844. return
  43845. }
  43846. return *v, true
  43847. }
  43848. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  43849. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43851. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43852. if !m.op.Is(OpUpdateOne) {
  43853. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43854. }
  43855. if m.id == nil || m.oldValue == nil {
  43856. return v, errors.New("OldStatus requires an ID field in the mutation")
  43857. }
  43858. oldValue, err := m.oldValue(ctx)
  43859. if err != nil {
  43860. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43861. }
  43862. return oldValue.Status, nil
  43863. }
  43864. // AddStatus adds u to the "status" field.
  43865. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  43866. if m.addstatus != nil {
  43867. *m.addstatus += u
  43868. } else {
  43869. m.addstatus = &u
  43870. }
  43871. }
  43872. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43873. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  43874. v := m.addstatus
  43875. if v == nil {
  43876. return
  43877. }
  43878. return *v, true
  43879. }
  43880. // ClearStatus clears the value of the "status" field.
  43881. func (m *WhatsappChannelMutation) ClearStatus() {
  43882. m.status = nil
  43883. m.addstatus = nil
  43884. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  43885. }
  43886. // StatusCleared returns if the "status" field was cleared in this mutation.
  43887. func (m *WhatsappChannelMutation) StatusCleared() bool {
  43888. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  43889. return ok
  43890. }
  43891. // ResetStatus resets all changes to the "status" field.
  43892. func (m *WhatsappChannelMutation) ResetStatus() {
  43893. m.status = nil
  43894. m.addstatus = nil
  43895. delete(m.clearedFields, whatsappchannel.FieldStatus)
  43896. }
  43897. // SetDeletedAt sets the "deleted_at" field.
  43898. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  43899. m.deleted_at = &t
  43900. }
  43901. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43902. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  43903. v := m.deleted_at
  43904. if v == nil {
  43905. return
  43906. }
  43907. return *v, true
  43908. }
  43909. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  43910. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43912. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43913. if !m.op.Is(OpUpdateOne) {
  43914. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43915. }
  43916. if m.id == nil || m.oldValue == nil {
  43917. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43918. }
  43919. oldValue, err := m.oldValue(ctx)
  43920. if err != nil {
  43921. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43922. }
  43923. return oldValue.DeletedAt, nil
  43924. }
  43925. // ClearDeletedAt clears the value of the "deleted_at" field.
  43926. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  43927. m.deleted_at = nil
  43928. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  43929. }
  43930. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43931. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  43932. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  43933. return ok
  43934. }
  43935. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43936. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  43937. m.deleted_at = nil
  43938. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  43939. }
  43940. // SetAk sets the "ak" field.
  43941. func (m *WhatsappChannelMutation) SetAk(s string) {
  43942. m.ak = &s
  43943. }
  43944. // Ak returns the value of the "ak" field in the mutation.
  43945. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  43946. v := m.ak
  43947. if v == nil {
  43948. return
  43949. }
  43950. return *v, true
  43951. }
  43952. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  43953. // If the WhatsappChannel 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 *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  43956. if !m.op.Is(OpUpdateOne) {
  43957. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  43958. }
  43959. if m.id == nil || m.oldValue == nil {
  43960. return v, errors.New("OldAk 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 OldAk: %w", err)
  43965. }
  43966. return oldValue.Ak, nil
  43967. }
  43968. // ClearAk clears the value of the "ak" field.
  43969. func (m *WhatsappChannelMutation) ClearAk() {
  43970. m.ak = nil
  43971. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  43972. }
  43973. // AkCleared returns if the "ak" field was cleared in this mutation.
  43974. func (m *WhatsappChannelMutation) AkCleared() bool {
  43975. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  43976. return ok
  43977. }
  43978. // ResetAk resets all changes to the "ak" field.
  43979. func (m *WhatsappChannelMutation) ResetAk() {
  43980. m.ak = nil
  43981. delete(m.clearedFields, whatsappchannel.FieldAk)
  43982. }
  43983. // SetSk sets the "sk" field.
  43984. func (m *WhatsappChannelMutation) SetSk(s string) {
  43985. m.sk = &s
  43986. }
  43987. // Sk returns the value of the "sk" field in the mutation.
  43988. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  43989. v := m.sk
  43990. if v == nil {
  43991. return
  43992. }
  43993. return *v, true
  43994. }
  43995. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  43996. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43998. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  43999. if !m.op.Is(OpUpdateOne) {
  44000. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  44001. }
  44002. if m.id == nil || m.oldValue == nil {
  44003. return v, errors.New("OldSk requires an ID field in the mutation")
  44004. }
  44005. oldValue, err := m.oldValue(ctx)
  44006. if err != nil {
  44007. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  44008. }
  44009. return oldValue.Sk, nil
  44010. }
  44011. // ResetSk resets all changes to the "sk" field.
  44012. func (m *WhatsappChannelMutation) ResetSk() {
  44013. m.sk = nil
  44014. }
  44015. // SetWaID sets the "wa_id" field.
  44016. func (m *WhatsappChannelMutation) SetWaID(s string) {
  44017. m.wa_id = &s
  44018. }
  44019. // WaID returns the value of the "wa_id" field in the mutation.
  44020. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  44021. v := m.wa_id
  44022. if v == nil {
  44023. return
  44024. }
  44025. return *v, true
  44026. }
  44027. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  44028. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44030. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  44031. if !m.op.Is(OpUpdateOne) {
  44032. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  44033. }
  44034. if m.id == nil || m.oldValue == nil {
  44035. return v, errors.New("OldWaID requires an ID field in the mutation")
  44036. }
  44037. oldValue, err := m.oldValue(ctx)
  44038. if err != nil {
  44039. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  44040. }
  44041. return oldValue.WaID, nil
  44042. }
  44043. // ClearWaID clears the value of the "wa_id" field.
  44044. func (m *WhatsappChannelMutation) ClearWaID() {
  44045. m.wa_id = nil
  44046. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  44047. }
  44048. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  44049. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  44050. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  44051. return ok
  44052. }
  44053. // ResetWaID resets all changes to the "wa_id" field.
  44054. func (m *WhatsappChannelMutation) ResetWaID() {
  44055. m.wa_id = nil
  44056. delete(m.clearedFields, whatsappchannel.FieldWaID)
  44057. }
  44058. // SetWaName sets the "wa_name" field.
  44059. func (m *WhatsappChannelMutation) SetWaName(s string) {
  44060. m.wa_name = &s
  44061. }
  44062. // WaName returns the value of the "wa_name" field in the mutation.
  44063. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  44064. v := m.wa_name
  44065. if v == nil {
  44066. return
  44067. }
  44068. return *v, true
  44069. }
  44070. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  44071. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44073. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  44074. if !m.op.Is(OpUpdateOne) {
  44075. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  44076. }
  44077. if m.id == nil || m.oldValue == nil {
  44078. return v, errors.New("OldWaName requires an ID field in the mutation")
  44079. }
  44080. oldValue, err := m.oldValue(ctx)
  44081. if err != nil {
  44082. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  44083. }
  44084. return oldValue.WaName, nil
  44085. }
  44086. // ClearWaName clears the value of the "wa_name" field.
  44087. func (m *WhatsappChannelMutation) ClearWaName() {
  44088. m.wa_name = nil
  44089. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  44090. }
  44091. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  44092. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  44093. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  44094. return ok
  44095. }
  44096. // ResetWaName resets all changes to the "wa_name" field.
  44097. func (m *WhatsappChannelMutation) ResetWaName() {
  44098. m.wa_name = nil
  44099. delete(m.clearedFields, whatsappchannel.FieldWaName)
  44100. }
  44101. // SetWabaID sets the "waba_id" field.
  44102. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  44103. m.waba_id = &u
  44104. m.addwaba_id = nil
  44105. }
  44106. // WabaID returns the value of the "waba_id" field in the mutation.
  44107. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  44108. v := m.waba_id
  44109. if v == nil {
  44110. return
  44111. }
  44112. return *v, true
  44113. }
  44114. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  44115. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44117. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  44118. if !m.op.Is(OpUpdateOne) {
  44119. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  44120. }
  44121. if m.id == nil || m.oldValue == nil {
  44122. return v, errors.New("OldWabaID requires an ID field in the mutation")
  44123. }
  44124. oldValue, err := m.oldValue(ctx)
  44125. if err != nil {
  44126. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  44127. }
  44128. return oldValue.WabaID, nil
  44129. }
  44130. // AddWabaID adds u to the "waba_id" field.
  44131. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  44132. if m.addwaba_id != nil {
  44133. *m.addwaba_id += u
  44134. } else {
  44135. m.addwaba_id = &u
  44136. }
  44137. }
  44138. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  44139. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  44140. v := m.addwaba_id
  44141. if v == nil {
  44142. return
  44143. }
  44144. return *v, true
  44145. }
  44146. // ResetWabaID resets all changes to the "waba_id" field.
  44147. func (m *WhatsappChannelMutation) ResetWabaID() {
  44148. m.waba_id = nil
  44149. m.addwaba_id = nil
  44150. }
  44151. // SetBusinessID sets the "business_id" field.
  44152. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  44153. m.business_id = &u
  44154. m.addbusiness_id = nil
  44155. }
  44156. // BusinessID returns the value of the "business_id" field in the mutation.
  44157. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  44158. v := m.business_id
  44159. if v == nil {
  44160. return
  44161. }
  44162. return *v, true
  44163. }
  44164. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  44165. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44167. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  44168. if !m.op.Is(OpUpdateOne) {
  44169. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  44170. }
  44171. if m.id == nil || m.oldValue == nil {
  44172. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  44173. }
  44174. oldValue, err := m.oldValue(ctx)
  44175. if err != nil {
  44176. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  44177. }
  44178. return oldValue.BusinessID, nil
  44179. }
  44180. // AddBusinessID adds u to the "business_id" field.
  44181. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  44182. if m.addbusiness_id != nil {
  44183. *m.addbusiness_id += u
  44184. } else {
  44185. m.addbusiness_id = &u
  44186. }
  44187. }
  44188. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  44189. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  44190. v := m.addbusiness_id
  44191. if v == nil {
  44192. return
  44193. }
  44194. return *v, true
  44195. }
  44196. // ResetBusinessID resets all changes to the "business_id" field.
  44197. func (m *WhatsappChannelMutation) ResetBusinessID() {
  44198. m.business_id = nil
  44199. m.addbusiness_id = nil
  44200. }
  44201. // SetOrganizationID sets the "organization_id" field.
  44202. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  44203. m.organization_id = &u
  44204. m.addorganization_id = nil
  44205. }
  44206. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44207. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  44208. v := m.organization_id
  44209. if v == nil {
  44210. return
  44211. }
  44212. return *v, true
  44213. }
  44214. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  44215. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44217. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44218. if !m.op.Is(OpUpdateOne) {
  44219. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44220. }
  44221. if m.id == nil || m.oldValue == nil {
  44222. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44223. }
  44224. oldValue, err := m.oldValue(ctx)
  44225. if err != nil {
  44226. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44227. }
  44228. return oldValue.OrganizationID, nil
  44229. }
  44230. // AddOrganizationID adds u to the "organization_id" field.
  44231. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  44232. if m.addorganization_id != nil {
  44233. *m.addorganization_id += u
  44234. } else {
  44235. m.addorganization_id = &u
  44236. }
  44237. }
  44238. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44239. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  44240. v := m.addorganization_id
  44241. if v == nil {
  44242. return
  44243. }
  44244. return *v, true
  44245. }
  44246. // ClearOrganizationID clears the value of the "organization_id" field.
  44247. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  44248. m.organization_id = nil
  44249. m.addorganization_id = nil
  44250. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  44251. }
  44252. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  44253. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  44254. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  44255. return ok
  44256. }
  44257. // ResetOrganizationID resets all changes to the "organization_id" field.
  44258. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  44259. m.organization_id = nil
  44260. m.addorganization_id = nil
  44261. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  44262. }
  44263. // SetVerifyAccount sets the "verify_account" field.
  44264. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  44265. m.verify_account = &s
  44266. }
  44267. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  44268. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  44269. v := m.verify_account
  44270. if v == nil {
  44271. return
  44272. }
  44273. return *v, true
  44274. }
  44275. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  44276. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44278. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  44279. if !m.op.Is(OpUpdateOne) {
  44280. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  44281. }
  44282. if m.id == nil || m.oldValue == nil {
  44283. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  44284. }
  44285. oldValue, err := m.oldValue(ctx)
  44286. if err != nil {
  44287. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  44288. }
  44289. return oldValue.VerifyAccount, nil
  44290. }
  44291. // ResetVerifyAccount resets all changes to the "verify_account" field.
  44292. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  44293. m.verify_account = nil
  44294. }
  44295. // Where appends a list predicates to the WhatsappChannelMutation builder.
  44296. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  44297. m.predicates = append(m.predicates, ps...)
  44298. }
  44299. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  44300. // users can use type-assertion to append predicates that do not depend on any generated package.
  44301. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  44302. p := make([]predicate.WhatsappChannel, len(ps))
  44303. for i := range ps {
  44304. p[i] = ps[i]
  44305. }
  44306. m.Where(p...)
  44307. }
  44308. // Op returns the operation name.
  44309. func (m *WhatsappChannelMutation) Op() Op {
  44310. return m.op
  44311. }
  44312. // SetOp allows setting the mutation operation.
  44313. func (m *WhatsappChannelMutation) SetOp(op Op) {
  44314. m.op = op
  44315. }
  44316. // Type returns the node type of this mutation (WhatsappChannel).
  44317. func (m *WhatsappChannelMutation) Type() string {
  44318. return m.typ
  44319. }
  44320. // Fields returns all fields that were changed during this mutation. Note that in
  44321. // order to get all numeric fields that were incremented/decremented, call
  44322. // AddedFields().
  44323. func (m *WhatsappChannelMutation) Fields() []string {
  44324. fields := make([]string, 0, 12)
  44325. if m.created_at != nil {
  44326. fields = append(fields, whatsappchannel.FieldCreatedAt)
  44327. }
  44328. if m.updated_at != nil {
  44329. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  44330. }
  44331. if m.status != nil {
  44332. fields = append(fields, whatsappchannel.FieldStatus)
  44333. }
  44334. if m.deleted_at != nil {
  44335. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44336. }
  44337. if m.ak != nil {
  44338. fields = append(fields, whatsappchannel.FieldAk)
  44339. }
  44340. if m.sk != nil {
  44341. fields = append(fields, whatsappchannel.FieldSk)
  44342. }
  44343. if m.wa_id != nil {
  44344. fields = append(fields, whatsappchannel.FieldWaID)
  44345. }
  44346. if m.wa_name != nil {
  44347. fields = append(fields, whatsappchannel.FieldWaName)
  44348. }
  44349. if m.waba_id != nil {
  44350. fields = append(fields, whatsappchannel.FieldWabaID)
  44351. }
  44352. if m.business_id != nil {
  44353. fields = append(fields, whatsappchannel.FieldBusinessID)
  44354. }
  44355. if m.organization_id != nil {
  44356. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44357. }
  44358. if m.verify_account != nil {
  44359. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  44360. }
  44361. return fields
  44362. }
  44363. // Field returns the value of a field with the given name. The second boolean
  44364. // return value indicates that this field was not set, or was not defined in the
  44365. // schema.
  44366. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  44367. switch name {
  44368. case whatsappchannel.FieldCreatedAt:
  44369. return m.CreatedAt()
  44370. case whatsappchannel.FieldUpdatedAt:
  44371. return m.UpdatedAt()
  44372. case whatsappchannel.FieldStatus:
  44373. return m.Status()
  44374. case whatsappchannel.FieldDeletedAt:
  44375. return m.DeletedAt()
  44376. case whatsappchannel.FieldAk:
  44377. return m.Ak()
  44378. case whatsappchannel.FieldSk:
  44379. return m.Sk()
  44380. case whatsappchannel.FieldWaID:
  44381. return m.WaID()
  44382. case whatsappchannel.FieldWaName:
  44383. return m.WaName()
  44384. case whatsappchannel.FieldWabaID:
  44385. return m.WabaID()
  44386. case whatsappchannel.FieldBusinessID:
  44387. return m.BusinessID()
  44388. case whatsappchannel.FieldOrganizationID:
  44389. return m.OrganizationID()
  44390. case whatsappchannel.FieldVerifyAccount:
  44391. return m.VerifyAccount()
  44392. }
  44393. return nil, false
  44394. }
  44395. // OldField returns the old value of the field from the database. An error is
  44396. // returned if the mutation operation is not UpdateOne, or the query to the
  44397. // database failed.
  44398. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44399. switch name {
  44400. case whatsappchannel.FieldCreatedAt:
  44401. return m.OldCreatedAt(ctx)
  44402. case whatsappchannel.FieldUpdatedAt:
  44403. return m.OldUpdatedAt(ctx)
  44404. case whatsappchannel.FieldStatus:
  44405. return m.OldStatus(ctx)
  44406. case whatsappchannel.FieldDeletedAt:
  44407. return m.OldDeletedAt(ctx)
  44408. case whatsappchannel.FieldAk:
  44409. return m.OldAk(ctx)
  44410. case whatsappchannel.FieldSk:
  44411. return m.OldSk(ctx)
  44412. case whatsappchannel.FieldWaID:
  44413. return m.OldWaID(ctx)
  44414. case whatsappchannel.FieldWaName:
  44415. return m.OldWaName(ctx)
  44416. case whatsappchannel.FieldWabaID:
  44417. return m.OldWabaID(ctx)
  44418. case whatsappchannel.FieldBusinessID:
  44419. return m.OldBusinessID(ctx)
  44420. case whatsappchannel.FieldOrganizationID:
  44421. return m.OldOrganizationID(ctx)
  44422. case whatsappchannel.FieldVerifyAccount:
  44423. return m.OldVerifyAccount(ctx)
  44424. }
  44425. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  44426. }
  44427. // SetField sets the value of a field with the given name. It returns an error if
  44428. // the field is not defined in the schema, or if the type mismatched the field
  44429. // type.
  44430. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  44431. switch name {
  44432. case whatsappchannel.FieldCreatedAt:
  44433. v, ok := value.(time.Time)
  44434. if !ok {
  44435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44436. }
  44437. m.SetCreatedAt(v)
  44438. return nil
  44439. case whatsappchannel.FieldUpdatedAt:
  44440. v, ok := value.(time.Time)
  44441. if !ok {
  44442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44443. }
  44444. m.SetUpdatedAt(v)
  44445. return nil
  44446. case whatsappchannel.FieldStatus:
  44447. v, ok := value.(uint8)
  44448. if !ok {
  44449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44450. }
  44451. m.SetStatus(v)
  44452. return nil
  44453. case whatsappchannel.FieldDeletedAt:
  44454. v, ok := value.(time.Time)
  44455. if !ok {
  44456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44457. }
  44458. m.SetDeletedAt(v)
  44459. return nil
  44460. case whatsappchannel.FieldAk:
  44461. v, ok := value.(string)
  44462. if !ok {
  44463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44464. }
  44465. m.SetAk(v)
  44466. return nil
  44467. case whatsappchannel.FieldSk:
  44468. v, ok := value.(string)
  44469. if !ok {
  44470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44471. }
  44472. m.SetSk(v)
  44473. return nil
  44474. case whatsappchannel.FieldWaID:
  44475. v, ok := value.(string)
  44476. if !ok {
  44477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44478. }
  44479. m.SetWaID(v)
  44480. return nil
  44481. case whatsappchannel.FieldWaName:
  44482. v, ok := value.(string)
  44483. if !ok {
  44484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44485. }
  44486. m.SetWaName(v)
  44487. return nil
  44488. case whatsappchannel.FieldWabaID:
  44489. v, ok := value.(uint64)
  44490. if !ok {
  44491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44492. }
  44493. m.SetWabaID(v)
  44494. return nil
  44495. case whatsappchannel.FieldBusinessID:
  44496. v, ok := value.(uint64)
  44497. if !ok {
  44498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44499. }
  44500. m.SetBusinessID(v)
  44501. return nil
  44502. case whatsappchannel.FieldOrganizationID:
  44503. v, ok := value.(uint64)
  44504. if !ok {
  44505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44506. }
  44507. m.SetOrganizationID(v)
  44508. return nil
  44509. case whatsappchannel.FieldVerifyAccount:
  44510. v, ok := value.(string)
  44511. if !ok {
  44512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44513. }
  44514. m.SetVerifyAccount(v)
  44515. return nil
  44516. }
  44517. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44518. }
  44519. // AddedFields returns all numeric fields that were incremented/decremented during
  44520. // this mutation.
  44521. func (m *WhatsappChannelMutation) AddedFields() []string {
  44522. var fields []string
  44523. if m.addstatus != nil {
  44524. fields = append(fields, whatsappchannel.FieldStatus)
  44525. }
  44526. if m.addwaba_id != nil {
  44527. fields = append(fields, whatsappchannel.FieldWabaID)
  44528. }
  44529. if m.addbusiness_id != nil {
  44530. fields = append(fields, whatsappchannel.FieldBusinessID)
  44531. }
  44532. if m.addorganization_id != nil {
  44533. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44534. }
  44535. return fields
  44536. }
  44537. // AddedField returns the numeric value that was incremented/decremented on a field
  44538. // with the given name. The second boolean return value indicates that this field
  44539. // was not set, or was not defined in the schema.
  44540. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  44541. switch name {
  44542. case whatsappchannel.FieldStatus:
  44543. return m.AddedStatus()
  44544. case whatsappchannel.FieldWabaID:
  44545. return m.AddedWabaID()
  44546. case whatsappchannel.FieldBusinessID:
  44547. return m.AddedBusinessID()
  44548. case whatsappchannel.FieldOrganizationID:
  44549. return m.AddedOrganizationID()
  44550. }
  44551. return nil, false
  44552. }
  44553. // AddField adds the value to the field with the given name. It returns an error if
  44554. // the field is not defined in the schema, or if the type mismatched the field
  44555. // type.
  44556. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  44557. switch name {
  44558. case whatsappchannel.FieldStatus:
  44559. v, ok := value.(int8)
  44560. if !ok {
  44561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44562. }
  44563. m.AddStatus(v)
  44564. return nil
  44565. case whatsappchannel.FieldWabaID:
  44566. v, ok := value.(int64)
  44567. if !ok {
  44568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44569. }
  44570. m.AddWabaID(v)
  44571. return nil
  44572. case whatsappchannel.FieldBusinessID:
  44573. v, ok := value.(int64)
  44574. if !ok {
  44575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44576. }
  44577. m.AddBusinessID(v)
  44578. return nil
  44579. case whatsappchannel.FieldOrganizationID:
  44580. v, ok := value.(int64)
  44581. if !ok {
  44582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44583. }
  44584. m.AddOrganizationID(v)
  44585. return nil
  44586. }
  44587. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  44588. }
  44589. // ClearedFields returns all nullable fields that were cleared during this
  44590. // mutation.
  44591. func (m *WhatsappChannelMutation) ClearedFields() []string {
  44592. var fields []string
  44593. if m.FieldCleared(whatsappchannel.FieldStatus) {
  44594. fields = append(fields, whatsappchannel.FieldStatus)
  44595. }
  44596. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  44597. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44598. }
  44599. if m.FieldCleared(whatsappchannel.FieldAk) {
  44600. fields = append(fields, whatsappchannel.FieldAk)
  44601. }
  44602. if m.FieldCleared(whatsappchannel.FieldWaID) {
  44603. fields = append(fields, whatsappchannel.FieldWaID)
  44604. }
  44605. if m.FieldCleared(whatsappchannel.FieldWaName) {
  44606. fields = append(fields, whatsappchannel.FieldWaName)
  44607. }
  44608. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  44609. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44610. }
  44611. return fields
  44612. }
  44613. // FieldCleared returns a boolean indicating if a field with the given name was
  44614. // cleared in this mutation.
  44615. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  44616. _, ok := m.clearedFields[name]
  44617. return ok
  44618. }
  44619. // ClearField clears the value of the field with the given name. It returns an
  44620. // error if the field is not defined in the schema.
  44621. func (m *WhatsappChannelMutation) ClearField(name string) error {
  44622. switch name {
  44623. case whatsappchannel.FieldStatus:
  44624. m.ClearStatus()
  44625. return nil
  44626. case whatsappchannel.FieldDeletedAt:
  44627. m.ClearDeletedAt()
  44628. return nil
  44629. case whatsappchannel.FieldAk:
  44630. m.ClearAk()
  44631. return nil
  44632. case whatsappchannel.FieldWaID:
  44633. m.ClearWaID()
  44634. return nil
  44635. case whatsappchannel.FieldWaName:
  44636. m.ClearWaName()
  44637. return nil
  44638. case whatsappchannel.FieldOrganizationID:
  44639. m.ClearOrganizationID()
  44640. return nil
  44641. }
  44642. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  44643. }
  44644. // ResetField resets all changes in the mutation for the field with the given name.
  44645. // It returns an error if the field is not defined in the schema.
  44646. func (m *WhatsappChannelMutation) ResetField(name string) error {
  44647. switch name {
  44648. case whatsappchannel.FieldCreatedAt:
  44649. m.ResetCreatedAt()
  44650. return nil
  44651. case whatsappchannel.FieldUpdatedAt:
  44652. m.ResetUpdatedAt()
  44653. return nil
  44654. case whatsappchannel.FieldStatus:
  44655. m.ResetStatus()
  44656. return nil
  44657. case whatsappchannel.FieldDeletedAt:
  44658. m.ResetDeletedAt()
  44659. return nil
  44660. case whatsappchannel.FieldAk:
  44661. m.ResetAk()
  44662. return nil
  44663. case whatsappchannel.FieldSk:
  44664. m.ResetSk()
  44665. return nil
  44666. case whatsappchannel.FieldWaID:
  44667. m.ResetWaID()
  44668. return nil
  44669. case whatsappchannel.FieldWaName:
  44670. m.ResetWaName()
  44671. return nil
  44672. case whatsappchannel.FieldWabaID:
  44673. m.ResetWabaID()
  44674. return nil
  44675. case whatsappchannel.FieldBusinessID:
  44676. m.ResetBusinessID()
  44677. return nil
  44678. case whatsappchannel.FieldOrganizationID:
  44679. m.ResetOrganizationID()
  44680. return nil
  44681. case whatsappchannel.FieldVerifyAccount:
  44682. m.ResetVerifyAccount()
  44683. return nil
  44684. }
  44685. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44686. }
  44687. // AddedEdges returns all edge names that were set/added in this mutation.
  44688. func (m *WhatsappChannelMutation) AddedEdges() []string {
  44689. edges := make([]string, 0, 0)
  44690. return edges
  44691. }
  44692. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44693. // name in this mutation.
  44694. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  44695. return nil
  44696. }
  44697. // RemovedEdges returns all edge names that were removed in this mutation.
  44698. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  44699. edges := make([]string, 0, 0)
  44700. return edges
  44701. }
  44702. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44703. // the given name in this mutation.
  44704. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  44705. return nil
  44706. }
  44707. // ClearedEdges returns all edge names that were cleared in this mutation.
  44708. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  44709. edges := make([]string, 0, 0)
  44710. return edges
  44711. }
  44712. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44713. // was cleared in this mutation.
  44714. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  44715. return false
  44716. }
  44717. // ClearEdge clears the value of the edge with the given name. It returns an error
  44718. // if that edge is not defined in the schema.
  44719. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  44720. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  44721. }
  44722. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44723. // It returns an error if the edge is not defined in the schema.
  44724. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  44725. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  44726. }
  44727. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  44728. type WorkExperienceMutation struct {
  44729. config
  44730. op Op
  44731. typ string
  44732. id *uint64
  44733. created_at *time.Time
  44734. updated_at *time.Time
  44735. deleted_at *time.Time
  44736. start_date *time.Time
  44737. end_date *time.Time
  44738. company *string
  44739. experience *string
  44740. organization_id *uint64
  44741. addorganization_id *int64
  44742. clearedFields map[string]struct{}
  44743. employee *uint64
  44744. clearedemployee bool
  44745. done bool
  44746. oldValue func(context.Context) (*WorkExperience, error)
  44747. predicates []predicate.WorkExperience
  44748. }
  44749. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  44750. // workexperienceOption allows management of the mutation configuration using functional options.
  44751. type workexperienceOption func(*WorkExperienceMutation)
  44752. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  44753. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  44754. m := &WorkExperienceMutation{
  44755. config: c,
  44756. op: op,
  44757. typ: TypeWorkExperience,
  44758. clearedFields: make(map[string]struct{}),
  44759. }
  44760. for _, opt := range opts {
  44761. opt(m)
  44762. }
  44763. return m
  44764. }
  44765. // withWorkExperienceID sets the ID field of the mutation.
  44766. func withWorkExperienceID(id uint64) workexperienceOption {
  44767. return func(m *WorkExperienceMutation) {
  44768. var (
  44769. err error
  44770. once sync.Once
  44771. value *WorkExperience
  44772. )
  44773. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  44774. once.Do(func() {
  44775. if m.done {
  44776. err = errors.New("querying old values post mutation is not allowed")
  44777. } else {
  44778. value, err = m.Client().WorkExperience.Get(ctx, id)
  44779. }
  44780. })
  44781. return value, err
  44782. }
  44783. m.id = &id
  44784. }
  44785. }
  44786. // withWorkExperience sets the old WorkExperience of the mutation.
  44787. func withWorkExperience(node *WorkExperience) workexperienceOption {
  44788. return func(m *WorkExperienceMutation) {
  44789. m.oldValue = func(context.Context) (*WorkExperience, error) {
  44790. return node, nil
  44791. }
  44792. m.id = &node.ID
  44793. }
  44794. }
  44795. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44796. // executed in a transaction (ent.Tx), a transactional client is returned.
  44797. func (m WorkExperienceMutation) Client() *Client {
  44798. client := &Client{config: m.config}
  44799. client.init()
  44800. return client
  44801. }
  44802. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44803. // it returns an error otherwise.
  44804. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  44805. if _, ok := m.driver.(*txDriver); !ok {
  44806. return nil, errors.New("ent: mutation is not running in a transaction")
  44807. }
  44808. tx := &Tx{config: m.config}
  44809. tx.init()
  44810. return tx, nil
  44811. }
  44812. // SetID sets the value of the id field. Note that this
  44813. // operation is only accepted on creation of WorkExperience entities.
  44814. func (m *WorkExperienceMutation) SetID(id uint64) {
  44815. m.id = &id
  44816. }
  44817. // ID returns the ID value in the mutation. Note that the ID is only available
  44818. // if it was provided to the builder or after it was returned from the database.
  44819. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  44820. if m.id == nil {
  44821. return
  44822. }
  44823. return *m.id, true
  44824. }
  44825. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44826. // That means, if the mutation is applied within a transaction with an isolation level such
  44827. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44828. // or updated by the mutation.
  44829. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  44830. switch {
  44831. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44832. id, exists := m.ID()
  44833. if exists {
  44834. return []uint64{id}, nil
  44835. }
  44836. fallthrough
  44837. case m.op.Is(OpUpdate | OpDelete):
  44838. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  44839. default:
  44840. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44841. }
  44842. }
  44843. // SetCreatedAt sets the "created_at" field.
  44844. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  44845. m.created_at = &t
  44846. }
  44847. // CreatedAt returns the value of the "created_at" field in the mutation.
  44848. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  44849. v := m.created_at
  44850. if v == nil {
  44851. return
  44852. }
  44853. return *v, true
  44854. }
  44855. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  44856. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44858. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44859. if !m.op.Is(OpUpdateOne) {
  44860. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44861. }
  44862. if m.id == nil || m.oldValue == nil {
  44863. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44864. }
  44865. oldValue, err := m.oldValue(ctx)
  44866. if err != nil {
  44867. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44868. }
  44869. return oldValue.CreatedAt, nil
  44870. }
  44871. // ResetCreatedAt resets all changes to the "created_at" field.
  44872. func (m *WorkExperienceMutation) ResetCreatedAt() {
  44873. m.created_at = nil
  44874. }
  44875. // SetUpdatedAt sets the "updated_at" field.
  44876. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  44877. m.updated_at = &t
  44878. }
  44879. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44880. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  44881. v := m.updated_at
  44882. if v == nil {
  44883. return
  44884. }
  44885. return *v, true
  44886. }
  44887. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  44888. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44890. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44891. if !m.op.Is(OpUpdateOne) {
  44892. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44893. }
  44894. if m.id == nil || m.oldValue == nil {
  44895. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44896. }
  44897. oldValue, err := m.oldValue(ctx)
  44898. if err != nil {
  44899. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44900. }
  44901. return oldValue.UpdatedAt, nil
  44902. }
  44903. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44904. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  44905. m.updated_at = nil
  44906. }
  44907. // SetDeletedAt sets the "deleted_at" field.
  44908. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  44909. m.deleted_at = &t
  44910. }
  44911. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44912. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  44913. v := m.deleted_at
  44914. if v == nil {
  44915. return
  44916. }
  44917. return *v, true
  44918. }
  44919. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  44920. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44922. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44923. if !m.op.Is(OpUpdateOne) {
  44924. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44925. }
  44926. if m.id == nil || m.oldValue == nil {
  44927. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44928. }
  44929. oldValue, err := m.oldValue(ctx)
  44930. if err != nil {
  44931. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44932. }
  44933. return oldValue.DeletedAt, nil
  44934. }
  44935. // ClearDeletedAt clears the value of the "deleted_at" field.
  44936. func (m *WorkExperienceMutation) ClearDeletedAt() {
  44937. m.deleted_at = nil
  44938. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  44939. }
  44940. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44941. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  44942. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  44943. return ok
  44944. }
  44945. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44946. func (m *WorkExperienceMutation) ResetDeletedAt() {
  44947. m.deleted_at = nil
  44948. delete(m.clearedFields, workexperience.FieldDeletedAt)
  44949. }
  44950. // SetEmployeeID sets the "employee_id" field.
  44951. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  44952. m.employee = &u
  44953. }
  44954. // EmployeeID returns the value of the "employee_id" field in the mutation.
  44955. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  44956. v := m.employee
  44957. if v == nil {
  44958. return
  44959. }
  44960. return *v, true
  44961. }
  44962. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  44963. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44965. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  44966. if !m.op.Is(OpUpdateOne) {
  44967. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  44968. }
  44969. if m.id == nil || m.oldValue == nil {
  44970. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  44971. }
  44972. oldValue, err := m.oldValue(ctx)
  44973. if err != nil {
  44974. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  44975. }
  44976. return oldValue.EmployeeID, nil
  44977. }
  44978. // ResetEmployeeID resets all changes to the "employee_id" field.
  44979. func (m *WorkExperienceMutation) ResetEmployeeID() {
  44980. m.employee = nil
  44981. }
  44982. // SetStartDate sets the "start_date" field.
  44983. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  44984. m.start_date = &t
  44985. }
  44986. // StartDate returns the value of the "start_date" field in the mutation.
  44987. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  44988. v := m.start_date
  44989. if v == nil {
  44990. return
  44991. }
  44992. return *v, true
  44993. }
  44994. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  44995. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44997. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  44998. if !m.op.Is(OpUpdateOne) {
  44999. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  45000. }
  45001. if m.id == nil || m.oldValue == nil {
  45002. return v, errors.New("OldStartDate requires an ID field in the mutation")
  45003. }
  45004. oldValue, err := m.oldValue(ctx)
  45005. if err != nil {
  45006. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  45007. }
  45008. return oldValue.StartDate, nil
  45009. }
  45010. // ResetStartDate resets all changes to the "start_date" field.
  45011. func (m *WorkExperienceMutation) ResetStartDate() {
  45012. m.start_date = nil
  45013. }
  45014. // SetEndDate sets the "end_date" field.
  45015. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  45016. m.end_date = &t
  45017. }
  45018. // EndDate returns the value of the "end_date" field in the mutation.
  45019. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  45020. v := m.end_date
  45021. if v == nil {
  45022. return
  45023. }
  45024. return *v, true
  45025. }
  45026. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  45027. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45029. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  45030. if !m.op.Is(OpUpdateOne) {
  45031. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  45032. }
  45033. if m.id == nil || m.oldValue == nil {
  45034. return v, errors.New("OldEndDate requires an ID field in the mutation")
  45035. }
  45036. oldValue, err := m.oldValue(ctx)
  45037. if err != nil {
  45038. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  45039. }
  45040. return oldValue.EndDate, nil
  45041. }
  45042. // ResetEndDate resets all changes to the "end_date" field.
  45043. func (m *WorkExperienceMutation) ResetEndDate() {
  45044. m.end_date = nil
  45045. }
  45046. // SetCompany sets the "company" field.
  45047. func (m *WorkExperienceMutation) SetCompany(s string) {
  45048. m.company = &s
  45049. }
  45050. // Company returns the value of the "company" field in the mutation.
  45051. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  45052. v := m.company
  45053. if v == nil {
  45054. return
  45055. }
  45056. return *v, true
  45057. }
  45058. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  45059. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45061. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  45062. if !m.op.Is(OpUpdateOne) {
  45063. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  45064. }
  45065. if m.id == nil || m.oldValue == nil {
  45066. return v, errors.New("OldCompany requires an ID field in the mutation")
  45067. }
  45068. oldValue, err := m.oldValue(ctx)
  45069. if err != nil {
  45070. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  45071. }
  45072. return oldValue.Company, nil
  45073. }
  45074. // ResetCompany resets all changes to the "company" field.
  45075. func (m *WorkExperienceMutation) ResetCompany() {
  45076. m.company = nil
  45077. }
  45078. // SetExperience sets the "experience" field.
  45079. func (m *WorkExperienceMutation) SetExperience(s string) {
  45080. m.experience = &s
  45081. }
  45082. // Experience returns the value of the "experience" field in the mutation.
  45083. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  45084. v := m.experience
  45085. if v == nil {
  45086. return
  45087. }
  45088. return *v, true
  45089. }
  45090. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  45091. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45093. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  45094. if !m.op.Is(OpUpdateOne) {
  45095. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  45096. }
  45097. if m.id == nil || m.oldValue == nil {
  45098. return v, errors.New("OldExperience requires an ID field in the mutation")
  45099. }
  45100. oldValue, err := m.oldValue(ctx)
  45101. if err != nil {
  45102. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  45103. }
  45104. return oldValue.Experience, nil
  45105. }
  45106. // ResetExperience resets all changes to the "experience" field.
  45107. func (m *WorkExperienceMutation) ResetExperience() {
  45108. m.experience = nil
  45109. }
  45110. // SetOrganizationID sets the "organization_id" field.
  45111. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  45112. m.organization_id = &u
  45113. m.addorganization_id = nil
  45114. }
  45115. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45116. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  45117. v := m.organization_id
  45118. if v == nil {
  45119. return
  45120. }
  45121. return *v, true
  45122. }
  45123. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  45124. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45126. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45127. if !m.op.Is(OpUpdateOne) {
  45128. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45129. }
  45130. if m.id == nil || m.oldValue == nil {
  45131. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45132. }
  45133. oldValue, err := m.oldValue(ctx)
  45134. if err != nil {
  45135. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45136. }
  45137. return oldValue.OrganizationID, nil
  45138. }
  45139. // AddOrganizationID adds u to the "organization_id" field.
  45140. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  45141. if m.addorganization_id != nil {
  45142. *m.addorganization_id += u
  45143. } else {
  45144. m.addorganization_id = &u
  45145. }
  45146. }
  45147. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45148. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  45149. v := m.addorganization_id
  45150. if v == nil {
  45151. return
  45152. }
  45153. return *v, true
  45154. }
  45155. // ResetOrganizationID resets all changes to the "organization_id" field.
  45156. func (m *WorkExperienceMutation) ResetOrganizationID() {
  45157. m.organization_id = nil
  45158. m.addorganization_id = nil
  45159. }
  45160. // ClearEmployee clears the "employee" edge to the Employee entity.
  45161. func (m *WorkExperienceMutation) ClearEmployee() {
  45162. m.clearedemployee = true
  45163. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  45164. }
  45165. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  45166. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  45167. return m.clearedemployee
  45168. }
  45169. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  45170. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45171. // EmployeeID instead. It exists only for internal usage by the builders.
  45172. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  45173. if id := m.employee; id != nil {
  45174. ids = append(ids, *id)
  45175. }
  45176. return
  45177. }
  45178. // ResetEmployee resets all changes to the "employee" edge.
  45179. func (m *WorkExperienceMutation) ResetEmployee() {
  45180. m.employee = nil
  45181. m.clearedemployee = false
  45182. }
  45183. // Where appends a list predicates to the WorkExperienceMutation builder.
  45184. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  45185. m.predicates = append(m.predicates, ps...)
  45186. }
  45187. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  45188. // users can use type-assertion to append predicates that do not depend on any generated package.
  45189. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  45190. p := make([]predicate.WorkExperience, len(ps))
  45191. for i := range ps {
  45192. p[i] = ps[i]
  45193. }
  45194. m.Where(p...)
  45195. }
  45196. // Op returns the operation name.
  45197. func (m *WorkExperienceMutation) Op() Op {
  45198. return m.op
  45199. }
  45200. // SetOp allows setting the mutation operation.
  45201. func (m *WorkExperienceMutation) SetOp(op Op) {
  45202. m.op = op
  45203. }
  45204. // Type returns the node type of this mutation (WorkExperience).
  45205. func (m *WorkExperienceMutation) Type() string {
  45206. return m.typ
  45207. }
  45208. // Fields returns all fields that were changed during this mutation. Note that in
  45209. // order to get all numeric fields that were incremented/decremented, call
  45210. // AddedFields().
  45211. func (m *WorkExperienceMutation) Fields() []string {
  45212. fields := make([]string, 0, 9)
  45213. if m.created_at != nil {
  45214. fields = append(fields, workexperience.FieldCreatedAt)
  45215. }
  45216. if m.updated_at != nil {
  45217. fields = append(fields, workexperience.FieldUpdatedAt)
  45218. }
  45219. if m.deleted_at != nil {
  45220. fields = append(fields, workexperience.FieldDeletedAt)
  45221. }
  45222. if m.employee != nil {
  45223. fields = append(fields, workexperience.FieldEmployeeID)
  45224. }
  45225. if m.start_date != nil {
  45226. fields = append(fields, workexperience.FieldStartDate)
  45227. }
  45228. if m.end_date != nil {
  45229. fields = append(fields, workexperience.FieldEndDate)
  45230. }
  45231. if m.company != nil {
  45232. fields = append(fields, workexperience.FieldCompany)
  45233. }
  45234. if m.experience != nil {
  45235. fields = append(fields, workexperience.FieldExperience)
  45236. }
  45237. if m.organization_id != nil {
  45238. fields = append(fields, workexperience.FieldOrganizationID)
  45239. }
  45240. return fields
  45241. }
  45242. // Field returns the value of a field with the given name. The second boolean
  45243. // return value indicates that this field was not set, or was not defined in the
  45244. // schema.
  45245. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  45246. switch name {
  45247. case workexperience.FieldCreatedAt:
  45248. return m.CreatedAt()
  45249. case workexperience.FieldUpdatedAt:
  45250. return m.UpdatedAt()
  45251. case workexperience.FieldDeletedAt:
  45252. return m.DeletedAt()
  45253. case workexperience.FieldEmployeeID:
  45254. return m.EmployeeID()
  45255. case workexperience.FieldStartDate:
  45256. return m.StartDate()
  45257. case workexperience.FieldEndDate:
  45258. return m.EndDate()
  45259. case workexperience.FieldCompany:
  45260. return m.Company()
  45261. case workexperience.FieldExperience:
  45262. return m.Experience()
  45263. case workexperience.FieldOrganizationID:
  45264. return m.OrganizationID()
  45265. }
  45266. return nil, false
  45267. }
  45268. // OldField returns the old value of the field from the database. An error is
  45269. // returned if the mutation operation is not UpdateOne, or the query to the
  45270. // database failed.
  45271. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45272. switch name {
  45273. case workexperience.FieldCreatedAt:
  45274. return m.OldCreatedAt(ctx)
  45275. case workexperience.FieldUpdatedAt:
  45276. return m.OldUpdatedAt(ctx)
  45277. case workexperience.FieldDeletedAt:
  45278. return m.OldDeletedAt(ctx)
  45279. case workexperience.FieldEmployeeID:
  45280. return m.OldEmployeeID(ctx)
  45281. case workexperience.FieldStartDate:
  45282. return m.OldStartDate(ctx)
  45283. case workexperience.FieldEndDate:
  45284. return m.OldEndDate(ctx)
  45285. case workexperience.FieldCompany:
  45286. return m.OldCompany(ctx)
  45287. case workexperience.FieldExperience:
  45288. return m.OldExperience(ctx)
  45289. case workexperience.FieldOrganizationID:
  45290. return m.OldOrganizationID(ctx)
  45291. }
  45292. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  45293. }
  45294. // SetField sets the value of a field with the given name. It returns an error if
  45295. // the field is not defined in the schema, or if the type mismatched the field
  45296. // type.
  45297. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  45298. switch name {
  45299. case workexperience.FieldCreatedAt:
  45300. v, ok := value.(time.Time)
  45301. if !ok {
  45302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45303. }
  45304. m.SetCreatedAt(v)
  45305. return nil
  45306. case workexperience.FieldUpdatedAt:
  45307. v, ok := value.(time.Time)
  45308. if !ok {
  45309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45310. }
  45311. m.SetUpdatedAt(v)
  45312. return nil
  45313. case workexperience.FieldDeletedAt:
  45314. v, ok := value.(time.Time)
  45315. if !ok {
  45316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45317. }
  45318. m.SetDeletedAt(v)
  45319. return nil
  45320. case workexperience.FieldEmployeeID:
  45321. v, ok := value.(uint64)
  45322. if !ok {
  45323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45324. }
  45325. m.SetEmployeeID(v)
  45326. return nil
  45327. case workexperience.FieldStartDate:
  45328. v, ok := value.(time.Time)
  45329. if !ok {
  45330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45331. }
  45332. m.SetStartDate(v)
  45333. return nil
  45334. case workexperience.FieldEndDate:
  45335. v, ok := value.(time.Time)
  45336. if !ok {
  45337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45338. }
  45339. m.SetEndDate(v)
  45340. return nil
  45341. case workexperience.FieldCompany:
  45342. v, ok := value.(string)
  45343. if !ok {
  45344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45345. }
  45346. m.SetCompany(v)
  45347. return nil
  45348. case workexperience.FieldExperience:
  45349. v, ok := value.(string)
  45350. if !ok {
  45351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45352. }
  45353. m.SetExperience(v)
  45354. return nil
  45355. case workexperience.FieldOrganizationID:
  45356. v, ok := value.(uint64)
  45357. if !ok {
  45358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45359. }
  45360. m.SetOrganizationID(v)
  45361. return nil
  45362. }
  45363. return fmt.Errorf("unknown WorkExperience field %s", name)
  45364. }
  45365. // AddedFields returns all numeric fields that were incremented/decremented during
  45366. // this mutation.
  45367. func (m *WorkExperienceMutation) AddedFields() []string {
  45368. var fields []string
  45369. if m.addorganization_id != nil {
  45370. fields = append(fields, workexperience.FieldOrganizationID)
  45371. }
  45372. return fields
  45373. }
  45374. // AddedField returns the numeric value that was incremented/decremented on a field
  45375. // with the given name. The second boolean return value indicates that this field
  45376. // was not set, or was not defined in the schema.
  45377. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  45378. switch name {
  45379. case workexperience.FieldOrganizationID:
  45380. return m.AddedOrganizationID()
  45381. }
  45382. return nil, false
  45383. }
  45384. // AddField adds the value to the field with the given name. It returns an error if
  45385. // the field is not defined in the schema, or if the type mismatched the field
  45386. // type.
  45387. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  45388. switch name {
  45389. case workexperience.FieldOrganizationID:
  45390. v, ok := value.(int64)
  45391. if !ok {
  45392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45393. }
  45394. m.AddOrganizationID(v)
  45395. return nil
  45396. }
  45397. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  45398. }
  45399. // ClearedFields returns all nullable fields that were cleared during this
  45400. // mutation.
  45401. func (m *WorkExperienceMutation) ClearedFields() []string {
  45402. var fields []string
  45403. if m.FieldCleared(workexperience.FieldDeletedAt) {
  45404. fields = append(fields, workexperience.FieldDeletedAt)
  45405. }
  45406. return fields
  45407. }
  45408. // FieldCleared returns a boolean indicating if a field with the given name was
  45409. // cleared in this mutation.
  45410. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  45411. _, ok := m.clearedFields[name]
  45412. return ok
  45413. }
  45414. // ClearField clears the value of the field with the given name. It returns an
  45415. // error if the field is not defined in the schema.
  45416. func (m *WorkExperienceMutation) ClearField(name string) error {
  45417. switch name {
  45418. case workexperience.FieldDeletedAt:
  45419. m.ClearDeletedAt()
  45420. return nil
  45421. }
  45422. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  45423. }
  45424. // ResetField resets all changes in the mutation for the field with the given name.
  45425. // It returns an error if the field is not defined in the schema.
  45426. func (m *WorkExperienceMutation) ResetField(name string) error {
  45427. switch name {
  45428. case workexperience.FieldCreatedAt:
  45429. m.ResetCreatedAt()
  45430. return nil
  45431. case workexperience.FieldUpdatedAt:
  45432. m.ResetUpdatedAt()
  45433. return nil
  45434. case workexperience.FieldDeletedAt:
  45435. m.ResetDeletedAt()
  45436. return nil
  45437. case workexperience.FieldEmployeeID:
  45438. m.ResetEmployeeID()
  45439. return nil
  45440. case workexperience.FieldStartDate:
  45441. m.ResetStartDate()
  45442. return nil
  45443. case workexperience.FieldEndDate:
  45444. m.ResetEndDate()
  45445. return nil
  45446. case workexperience.FieldCompany:
  45447. m.ResetCompany()
  45448. return nil
  45449. case workexperience.FieldExperience:
  45450. m.ResetExperience()
  45451. return nil
  45452. case workexperience.FieldOrganizationID:
  45453. m.ResetOrganizationID()
  45454. return nil
  45455. }
  45456. return fmt.Errorf("unknown WorkExperience field %s", name)
  45457. }
  45458. // AddedEdges returns all edge names that were set/added in this mutation.
  45459. func (m *WorkExperienceMutation) AddedEdges() []string {
  45460. edges := make([]string, 0, 1)
  45461. if m.employee != nil {
  45462. edges = append(edges, workexperience.EdgeEmployee)
  45463. }
  45464. return edges
  45465. }
  45466. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45467. // name in this mutation.
  45468. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  45469. switch name {
  45470. case workexperience.EdgeEmployee:
  45471. if id := m.employee; id != nil {
  45472. return []ent.Value{*id}
  45473. }
  45474. }
  45475. return nil
  45476. }
  45477. // RemovedEdges returns all edge names that were removed in this mutation.
  45478. func (m *WorkExperienceMutation) RemovedEdges() []string {
  45479. edges := make([]string, 0, 1)
  45480. return edges
  45481. }
  45482. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45483. // the given name in this mutation.
  45484. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  45485. return nil
  45486. }
  45487. // ClearedEdges returns all edge names that were cleared in this mutation.
  45488. func (m *WorkExperienceMutation) ClearedEdges() []string {
  45489. edges := make([]string, 0, 1)
  45490. if m.clearedemployee {
  45491. edges = append(edges, workexperience.EdgeEmployee)
  45492. }
  45493. return edges
  45494. }
  45495. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45496. // was cleared in this mutation.
  45497. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  45498. switch name {
  45499. case workexperience.EdgeEmployee:
  45500. return m.clearedemployee
  45501. }
  45502. return false
  45503. }
  45504. // ClearEdge clears the value of the edge with the given name. It returns an error
  45505. // if that edge is not defined in the schema.
  45506. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  45507. switch name {
  45508. case workexperience.EdgeEmployee:
  45509. m.ClearEmployee()
  45510. return nil
  45511. }
  45512. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  45513. }
  45514. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45515. // It returns an error if the edge is not defined in the schema.
  45516. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  45517. switch name {
  45518. case workexperience.EdgeEmployee:
  45519. m.ResetEmployee()
  45520. return nil
  45521. }
  45522. return fmt.Errorf("unknown WorkExperience edge %s", name)
  45523. }
  45524. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  45525. type WpChatroomMutation struct {
  45526. config
  45527. op Op
  45528. typ string
  45529. id *uint64
  45530. created_at *time.Time
  45531. updated_at *time.Time
  45532. status *uint8
  45533. addstatus *int8
  45534. wx_wxid *string
  45535. chatroom_id *string
  45536. nickname *string
  45537. owner *string
  45538. avatar *string
  45539. member_list *[]string
  45540. appendmember_list []string
  45541. clearedFields map[string]struct{}
  45542. done bool
  45543. oldValue func(context.Context) (*WpChatroom, error)
  45544. predicates []predicate.WpChatroom
  45545. }
  45546. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  45547. // wpchatroomOption allows management of the mutation configuration using functional options.
  45548. type wpchatroomOption func(*WpChatroomMutation)
  45549. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  45550. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  45551. m := &WpChatroomMutation{
  45552. config: c,
  45553. op: op,
  45554. typ: TypeWpChatroom,
  45555. clearedFields: make(map[string]struct{}),
  45556. }
  45557. for _, opt := range opts {
  45558. opt(m)
  45559. }
  45560. return m
  45561. }
  45562. // withWpChatroomID sets the ID field of the mutation.
  45563. func withWpChatroomID(id uint64) wpchatroomOption {
  45564. return func(m *WpChatroomMutation) {
  45565. var (
  45566. err error
  45567. once sync.Once
  45568. value *WpChatroom
  45569. )
  45570. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  45571. once.Do(func() {
  45572. if m.done {
  45573. err = errors.New("querying old values post mutation is not allowed")
  45574. } else {
  45575. value, err = m.Client().WpChatroom.Get(ctx, id)
  45576. }
  45577. })
  45578. return value, err
  45579. }
  45580. m.id = &id
  45581. }
  45582. }
  45583. // withWpChatroom sets the old WpChatroom of the mutation.
  45584. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  45585. return func(m *WpChatroomMutation) {
  45586. m.oldValue = func(context.Context) (*WpChatroom, error) {
  45587. return node, nil
  45588. }
  45589. m.id = &node.ID
  45590. }
  45591. }
  45592. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45593. // executed in a transaction (ent.Tx), a transactional client is returned.
  45594. func (m WpChatroomMutation) Client() *Client {
  45595. client := &Client{config: m.config}
  45596. client.init()
  45597. return client
  45598. }
  45599. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45600. // it returns an error otherwise.
  45601. func (m WpChatroomMutation) Tx() (*Tx, error) {
  45602. if _, ok := m.driver.(*txDriver); !ok {
  45603. return nil, errors.New("ent: mutation is not running in a transaction")
  45604. }
  45605. tx := &Tx{config: m.config}
  45606. tx.init()
  45607. return tx, nil
  45608. }
  45609. // SetID sets the value of the id field. Note that this
  45610. // operation is only accepted on creation of WpChatroom entities.
  45611. func (m *WpChatroomMutation) SetID(id uint64) {
  45612. m.id = &id
  45613. }
  45614. // ID returns the ID value in the mutation. Note that the ID is only available
  45615. // if it was provided to the builder or after it was returned from the database.
  45616. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  45617. if m.id == nil {
  45618. return
  45619. }
  45620. return *m.id, true
  45621. }
  45622. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45623. // That means, if the mutation is applied within a transaction with an isolation level such
  45624. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45625. // or updated by the mutation.
  45626. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  45627. switch {
  45628. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45629. id, exists := m.ID()
  45630. if exists {
  45631. return []uint64{id}, nil
  45632. }
  45633. fallthrough
  45634. case m.op.Is(OpUpdate | OpDelete):
  45635. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  45636. default:
  45637. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45638. }
  45639. }
  45640. // SetCreatedAt sets the "created_at" field.
  45641. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  45642. m.created_at = &t
  45643. }
  45644. // CreatedAt returns the value of the "created_at" field in the mutation.
  45645. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  45646. v := m.created_at
  45647. if v == nil {
  45648. return
  45649. }
  45650. return *v, true
  45651. }
  45652. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  45653. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45655. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45656. if !m.op.Is(OpUpdateOne) {
  45657. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45658. }
  45659. if m.id == nil || m.oldValue == nil {
  45660. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45661. }
  45662. oldValue, err := m.oldValue(ctx)
  45663. if err != nil {
  45664. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45665. }
  45666. return oldValue.CreatedAt, nil
  45667. }
  45668. // ResetCreatedAt resets all changes to the "created_at" field.
  45669. func (m *WpChatroomMutation) ResetCreatedAt() {
  45670. m.created_at = nil
  45671. }
  45672. // SetUpdatedAt sets the "updated_at" field.
  45673. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  45674. m.updated_at = &t
  45675. }
  45676. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45677. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  45678. v := m.updated_at
  45679. if v == nil {
  45680. return
  45681. }
  45682. return *v, true
  45683. }
  45684. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  45685. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45687. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45688. if !m.op.Is(OpUpdateOne) {
  45689. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45690. }
  45691. if m.id == nil || m.oldValue == nil {
  45692. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45693. }
  45694. oldValue, err := m.oldValue(ctx)
  45695. if err != nil {
  45696. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45697. }
  45698. return oldValue.UpdatedAt, nil
  45699. }
  45700. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45701. func (m *WpChatroomMutation) ResetUpdatedAt() {
  45702. m.updated_at = nil
  45703. }
  45704. // SetStatus sets the "status" field.
  45705. func (m *WpChatroomMutation) SetStatus(u uint8) {
  45706. m.status = &u
  45707. m.addstatus = nil
  45708. }
  45709. // Status returns the value of the "status" field in the mutation.
  45710. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  45711. v := m.status
  45712. if v == nil {
  45713. return
  45714. }
  45715. return *v, true
  45716. }
  45717. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  45718. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45720. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45721. if !m.op.Is(OpUpdateOne) {
  45722. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45723. }
  45724. if m.id == nil || m.oldValue == nil {
  45725. return v, errors.New("OldStatus requires an ID field in the mutation")
  45726. }
  45727. oldValue, err := m.oldValue(ctx)
  45728. if err != nil {
  45729. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45730. }
  45731. return oldValue.Status, nil
  45732. }
  45733. // AddStatus adds u to the "status" field.
  45734. func (m *WpChatroomMutation) AddStatus(u int8) {
  45735. if m.addstatus != nil {
  45736. *m.addstatus += u
  45737. } else {
  45738. m.addstatus = &u
  45739. }
  45740. }
  45741. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45742. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  45743. v := m.addstatus
  45744. if v == nil {
  45745. return
  45746. }
  45747. return *v, true
  45748. }
  45749. // ClearStatus clears the value of the "status" field.
  45750. func (m *WpChatroomMutation) ClearStatus() {
  45751. m.status = nil
  45752. m.addstatus = nil
  45753. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  45754. }
  45755. // StatusCleared returns if the "status" field was cleared in this mutation.
  45756. func (m *WpChatroomMutation) StatusCleared() bool {
  45757. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  45758. return ok
  45759. }
  45760. // ResetStatus resets all changes to the "status" field.
  45761. func (m *WpChatroomMutation) ResetStatus() {
  45762. m.status = nil
  45763. m.addstatus = nil
  45764. delete(m.clearedFields, wpchatroom.FieldStatus)
  45765. }
  45766. // SetWxWxid sets the "wx_wxid" field.
  45767. func (m *WpChatroomMutation) SetWxWxid(s string) {
  45768. m.wx_wxid = &s
  45769. }
  45770. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45771. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  45772. v := m.wx_wxid
  45773. if v == nil {
  45774. return
  45775. }
  45776. return *v, true
  45777. }
  45778. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  45779. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45781. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45782. if !m.op.Is(OpUpdateOne) {
  45783. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45784. }
  45785. if m.id == nil || m.oldValue == nil {
  45786. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45787. }
  45788. oldValue, err := m.oldValue(ctx)
  45789. if err != nil {
  45790. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45791. }
  45792. return oldValue.WxWxid, nil
  45793. }
  45794. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45795. func (m *WpChatroomMutation) ResetWxWxid() {
  45796. m.wx_wxid = nil
  45797. }
  45798. // SetChatroomID sets the "chatroom_id" field.
  45799. func (m *WpChatroomMutation) SetChatroomID(s string) {
  45800. m.chatroom_id = &s
  45801. }
  45802. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  45803. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  45804. v := m.chatroom_id
  45805. if v == nil {
  45806. return
  45807. }
  45808. return *v, true
  45809. }
  45810. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  45811. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45813. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  45814. if !m.op.Is(OpUpdateOne) {
  45815. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  45816. }
  45817. if m.id == nil || m.oldValue == nil {
  45818. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  45819. }
  45820. oldValue, err := m.oldValue(ctx)
  45821. if err != nil {
  45822. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  45823. }
  45824. return oldValue.ChatroomID, nil
  45825. }
  45826. // ResetChatroomID resets all changes to the "chatroom_id" field.
  45827. func (m *WpChatroomMutation) ResetChatroomID() {
  45828. m.chatroom_id = nil
  45829. }
  45830. // SetNickname sets the "nickname" field.
  45831. func (m *WpChatroomMutation) SetNickname(s string) {
  45832. m.nickname = &s
  45833. }
  45834. // Nickname returns the value of the "nickname" field in the mutation.
  45835. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  45836. v := m.nickname
  45837. if v == nil {
  45838. return
  45839. }
  45840. return *v, true
  45841. }
  45842. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  45843. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45845. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  45846. if !m.op.Is(OpUpdateOne) {
  45847. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45848. }
  45849. if m.id == nil || m.oldValue == nil {
  45850. return v, errors.New("OldNickname requires an ID field in the mutation")
  45851. }
  45852. oldValue, err := m.oldValue(ctx)
  45853. if err != nil {
  45854. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45855. }
  45856. return oldValue.Nickname, nil
  45857. }
  45858. // ResetNickname resets all changes to the "nickname" field.
  45859. func (m *WpChatroomMutation) ResetNickname() {
  45860. m.nickname = nil
  45861. }
  45862. // SetOwner sets the "owner" field.
  45863. func (m *WpChatroomMutation) SetOwner(s string) {
  45864. m.owner = &s
  45865. }
  45866. // Owner returns the value of the "owner" field in the mutation.
  45867. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  45868. v := m.owner
  45869. if v == nil {
  45870. return
  45871. }
  45872. return *v, true
  45873. }
  45874. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  45875. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45877. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  45878. if !m.op.Is(OpUpdateOne) {
  45879. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  45880. }
  45881. if m.id == nil || m.oldValue == nil {
  45882. return v, errors.New("OldOwner requires an ID field in the mutation")
  45883. }
  45884. oldValue, err := m.oldValue(ctx)
  45885. if err != nil {
  45886. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  45887. }
  45888. return oldValue.Owner, nil
  45889. }
  45890. // ResetOwner resets all changes to the "owner" field.
  45891. func (m *WpChatroomMutation) ResetOwner() {
  45892. m.owner = nil
  45893. }
  45894. // SetAvatar sets the "avatar" field.
  45895. func (m *WpChatroomMutation) SetAvatar(s string) {
  45896. m.avatar = &s
  45897. }
  45898. // Avatar returns the value of the "avatar" field in the mutation.
  45899. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  45900. v := m.avatar
  45901. if v == nil {
  45902. return
  45903. }
  45904. return *v, true
  45905. }
  45906. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  45907. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45909. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45910. if !m.op.Is(OpUpdateOne) {
  45911. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45912. }
  45913. if m.id == nil || m.oldValue == nil {
  45914. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45915. }
  45916. oldValue, err := m.oldValue(ctx)
  45917. if err != nil {
  45918. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45919. }
  45920. return oldValue.Avatar, nil
  45921. }
  45922. // ResetAvatar resets all changes to the "avatar" field.
  45923. func (m *WpChatroomMutation) ResetAvatar() {
  45924. m.avatar = nil
  45925. }
  45926. // SetMemberList sets the "member_list" field.
  45927. func (m *WpChatroomMutation) SetMemberList(s []string) {
  45928. m.member_list = &s
  45929. m.appendmember_list = nil
  45930. }
  45931. // MemberList returns the value of the "member_list" field in the mutation.
  45932. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  45933. v := m.member_list
  45934. if v == nil {
  45935. return
  45936. }
  45937. return *v, true
  45938. }
  45939. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  45940. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45942. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  45943. if !m.op.Is(OpUpdateOne) {
  45944. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  45945. }
  45946. if m.id == nil || m.oldValue == nil {
  45947. return v, errors.New("OldMemberList requires an ID field in the mutation")
  45948. }
  45949. oldValue, err := m.oldValue(ctx)
  45950. if err != nil {
  45951. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  45952. }
  45953. return oldValue.MemberList, nil
  45954. }
  45955. // AppendMemberList adds s to the "member_list" field.
  45956. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  45957. m.appendmember_list = append(m.appendmember_list, s...)
  45958. }
  45959. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  45960. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  45961. if len(m.appendmember_list) == 0 {
  45962. return nil, false
  45963. }
  45964. return m.appendmember_list, true
  45965. }
  45966. // ResetMemberList resets all changes to the "member_list" field.
  45967. func (m *WpChatroomMutation) ResetMemberList() {
  45968. m.member_list = nil
  45969. m.appendmember_list = nil
  45970. }
  45971. // Where appends a list predicates to the WpChatroomMutation builder.
  45972. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  45973. m.predicates = append(m.predicates, ps...)
  45974. }
  45975. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  45976. // users can use type-assertion to append predicates that do not depend on any generated package.
  45977. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  45978. p := make([]predicate.WpChatroom, len(ps))
  45979. for i := range ps {
  45980. p[i] = ps[i]
  45981. }
  45982. m.Where(p...)
  45983. }
  45984. // Op returns the operation name.
  45985. func (m *WpChatroomMutation) Op() Op {
  45986. return m.op
  45987. }
  45988. // SetOp allows setting the mutation operation.
  45989. func (m *WpChatroomMutation) SetOp(op Op) {
  45990. m.op = op
  45991. }
  45992. // Type returns the node type of this mutation (WpChatroom).
  45993. func (m *WpChatroomMutation) Type() string {
  45994. return m.typ
  45995. }
  45996. // Fields returns all fields that were changed during this mutation. Note that in
  45997. // order to get all numeric fields that were incremented/decremented, call
  45998. // AddedFields().
  45999. func (m *WpChatroomMutation) Fields() []string {
  46000. fields := make([]string, 0, 9)
  46001. if m.created_at != nil {
  46002. fields = append(fields, wpchatroom.FieldCreatedAt)
  46003. }
  46004. if m.updated_at != nil {
  46005. fields = append(fields, wpchatroom.FieldUpdatedAt)
  46006. }
  46007. if m.status != nil {
  46008. fields = append(fields, wpchatroom.FieldStatus)
  46009. }
  46010. if m.wx_wxid != nil {
  46011. fields = append(fields, wpchatroom.FieldWxWxid)
  46012. }
  46013. if m.chatroom_id != nil {
  46014. fields = append(fields, wpchatroom.FieldChatroomID)
  46015. }
  46016. if m.nickname != nil {
  46017. fields = append(fields, wpchatroom.FieldNickname)
  46018. }
  46019. if m.owner != nil {
  46020. fields = append(fields, wpchatroom.FieldOwner)
  46021. }
  46022. if m.avatar != nil {
  46023. fields = append(fields, wpchatroom.FieldAvatar)
  46024. }
  46025. if m.member_list != nil {
  46026. fields = append(fields, wpchatroom.FieldMemberList)
  46027. }
  46028. return fields
  46029. }
  46030. // Field returns the value of a field with the given name. The second boolean
  46031. // return value indicates that this field was not set, or was not defined in the
  46032. // schema.
  46033. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  46034. switch name {
  46035. case wpchatroom.FieldCreatedAt:
  46036. return m.CreatedAt()
  46037. case wpchatroom.FieldUpdatedAt:
  46038. return m.UpdatedAt()
  46039. case wpchatroom.FieldStatus:
  46040. return m.Status()
  46041. case wpchatroom.FieldWxWxid:
  46042. return m.WxWxid()
  46043. case wpchatroom.FieldChatroomID:
  46044. return m.ChatroomID()
  46045. case wpchatroom.FieldNickname:
  46046. return m.Nickname()
  46047. case wpchatroom.FieldOwner:
  46048. return m.Owner()
  46049. case wpchatroom.FieldAvatar:
  46050. return m.Avatar()
  46051. case wpchatroom.FieldMemberList:
  46052. return m.MemberList()
  46053. }
  46054. return nil, false
  46055. }
  46056. // OldField returns the old value of the field from the database. An error is
  46057. // returned if the mutation operation is not UpdateOne, or the query to the
  46058. // database failed.
  46059. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46060. switch name {
  46061. case wpchatroom.FieldCreatedAt:
  46062. return m.OldCreatedAt(ctx)
  46063. case wpchatroom.FieldUpdatedAt:
  46064. return m.OldUpdatedAt(ctx)
  46065. case wpchatroom.FieldStatus:
  46066. return m.OldStatus(ctx)
  46067. case wpchatroom.FieldWxWxid:
  46068. return m.OldWxWxid(ctx)
  46069. case wpchatroom.FieldChatroomID:
  46070. return m.OldChatroomID(ctx)
  46071. case wpchatroom.FieldNickname:
  46072. return m.OldNickname(ctx)
  46073. case wpchatroom.FieldOwner:
  46074. return m.OldOwner(ctx)
  46075. case wpchatroom.FieldAvatar:
  46076. return m.OldAvatar(ctx)
  46077. case wpchatroom.FieldMemberList:
  46078. return m.OldMemberList(ctx)
  46079. }
  46080. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  46081. }
  46082. // SetField sets the value of a field with the given name. It returns an error if
  46083. // the field is not defined in the schema, or if the type mismatched the field
  46084. // type.
  46085. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  46086. switch name {
  46087. case wpchatroom.FieldCreatedAt:
  46088. v, ok := value.(time.Time)
  46089. if !ok {
  46090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46091. }
  46092. m.SetCreatedAt(v)
  46093. return nil
  46094. case wpchatroom.FieldUpdatedAt:
  46095. v, ok := value.(time.Time)
  46096. if !ok {
  46097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46098. }
  46099. m.SetUpdatedAt(v)
  46100. return nil
  46101. case wpchatroom.FieldStatus:
  46102. v, ok := value.(uint8)
  46103. if !ok {
  46104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46105. }
  46106. m.SetStatus(v)
  46107. return nil
  46108. case wpchatroom.FieldWxWxid:
  46109. v, ok := value.(string)
  46110. if !ok {
  46111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46112. }
  46113. m.SetWxWxid(v)
  46114. return nil
  46115. case wpchatroom.FieldChatroomID:
  46116. v, ok := value.(string)
  46117. if !ok {
  46118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46119. }
  46120. m.SetChatroomID(v)
  46121. return nil
  46122. case wpchatroom.FieldNickname:
  46123. v, ok := value.(string)
  46124. if !ok {
  46125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46126. }
  46127. m.SetNickname(v)
  46128. return nil
  46129. case wpchatroom.FieldOwner:
  46130. v, ok := value.(string)
  46131. if !ok {
  46132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46133. }
  46134. m.SetOwner(v)
  46135. return nil
  46136. case wpchatroom.FieldAvatar:
  46137. v, ok := value.(string)
  46138. if !ok {
  46139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46140. }
  46141. m.SetAvatar(v)
  46142. return nil
  46143. case wpchatroom.FieldMemberList:
  46144. v, ok := value.([]string)
  46145. if !ok {
  46146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46147. }
  46148. m.SetMemberList(v)
  46149. return nil
  46150. }
  46151. return fmt.Errorf("unknown WpChatroom field %s", name)
  46152. }
  46153. // AddedFields returns all numeric fields that were incremented/decremented during
  46154. // this mutation.
  46155. func (m *WpChatroomMutation) AddedFields() []string {
  46156. var fields []string
  46157. if m.addstatus != nil {
  46158. fields = append(fields, wpchatroom.FieldStatus)
  46159. }
  46160. return fields
  46161. }
  46162. // AddedField returns the numeric value that was incremented/decremented on a field
  46163. // with the given name. The second boolean return value indicates that this field
  46164. // was not set, or was not defined in the schema.
  46165. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  46166. switch name {
  46167. case wpchatroom.FieldStatus:
  46168. return m.AddedStatus()
  46169. }
  46170. return nil, false
  46171. }
  46172. // AddField adds the value to the field with the given name. It returns an error if
  46173. // the field is not defined in the schema, or if the type mismatched the field
  46174. // type.
  46175. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  46176. switch name {
  46177. case wpchatroom.FieldStatus:
  46178. v, ok := value.(int8)
  46179. if !ok {
  46180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46181. }
  46182. m.AddStatus(v)
  46183. return nil
  46184. }
  46185. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  46186. }
  46187. // ClearedFields returns all nullable fields that were cleared during this
  46188. // mutation.
  46189. func (m *WpChatroomMutation) ClearedFields() []string {
  46190. var fields []string
  46191. if m.FieldCleared(wpchatroom.FieldStatus) {
  46192. fields = append(fields, wpchatroom.FieldStatus)
  46193. }
  46194. return fields
  46195. }
  46196. // FieldCleared returns a boolean indicating if a field with the given name was
  46197. // cleared in this mutation.
  46198. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  46199. _, ok := m.clearedFields[name]
  46200. return ok
  46201. }
  46202. // ClearField clears the value of the field with the given name. It returns an
  46203. // error if the field is not defined in the schema.
  46204. func (m *WpChatroomMutation) ClearField(name string) error {
  46205. switch name {
  46206. case wpchatroom.FieldStatus:
  46207. m.ClearStatus()
  46208. return nil
  46209. }
  46210. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  46211. }
  46212. // ResetField resets all changes in the mutation for the field with the given name.
  46213. // It returns an error if the field is not defined in the schema.
  46214. func (m *WpChatroomMutation) ResetField(name string) error {
  46215. switch name {
  46216. case wpchatroom.FieldCreatedAt:
  46217. m.ResetCreatedAt()
  46218. return nil
  46219. case wpchatroom.FieldUpdatedAt:
  46220. m.ResetUpdatedAt()
  46221. return nil
  46222. case wpchatroom.FieldStatus:
  46223. m.ResetStatus()
  46224. return nil
  46225. case wpchatroom.FieldWxWxid:
  46226. m.ResetWxWxid()
  46227. return nil
  46228. case wpchatroom.FieldChatroomID:
  46229. m.ResetChatroomID()
  46230. return nil
  46231. case wpchatroom.FieldNickname:
  46232. m.ResetNickname()
  46233. return nil
  46234. case wpchatroom.FieldOwner:
  46235. m.ResetOwner()
  46236. return nil
  46237. case wpchatroom.FieldAvatar:
  46238. m.ResetAvatar()
  46239. return nil
  46240. case wpchatroom.FieldMemberList:
  46241. m.ResetMemberList()
  46242. return nil
  46243. }
  46244. return fmt.Errorf("unknown WpChatroom field %s", name)
  46245. }
  46246. // AddedEdges returns all edge names that were set/added in this mutation.
  46247. func (m *WpChatroomMutation) AddedEdges() []string {
  46248. edges := make([]string, 0, 0)
  46249. return edges
  46250. }
  46251. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46252. // name in this mutation.
  46253. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  46254. return nil
  46255. }
  46256. // RemovedEdges returns all edge names that were removed in this mutation.
  46257. func (m *WpChatroomMutation) RemovedEdges() []string {
  46258. edges := make([]string, 0, 0)
  46259. return edges
  46260. }
  46261. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46262. // the given name in this mutation.
  46263. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  46264. return nil
  46265. }
  46266. // ClearedEdges returns all edge names that were cleared in this mutation.
  46267. func (m *WpChatroomMutation) ClearedEdges() []string {
  46268. edges := make([]string, 0, 0)
  46269. return edges
  46270. }
  46271. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46272. // was cleared in this mutation.
  46273. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  46274. return false
  46275. }
  46276. // ClearEdge clears the value of the edge with the given name. It returns an error
  46277. // if that edge is not defined in the schema.
  46278. func (m *WpChatroomMutation) ClearEdge(name string) error {
  46279. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  46280. }
  46281. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46282. // It returns an error if the edge is not defined in the schema.
  46283. func (m *WpChatroomMutation) ResetEdge(name string) error {
  46284. return fmt.Errorf("unknown WpChatroom edge %s", name)
  46285. }
  46286. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  46287. type WpChatroomMemberMutation struct {
  46288. config
  46289. op Op
  46290. typ string
  46291. id *uint64
  46292. created_at *time.Time
  46293. updated_at *time.Time
  46294. status *uint8
  46295. addstatus *int8
  46296. wx_wxid *string
  46297. wxid *string
  46298. nickname *string
  46299. avatar *string
  46300. clearedFields map[string]struct{}
  46301. done bool
  46302. oldValue func(context.Context) (*WpChatroomMember, error)
  46303. predicates []predicate.WpChatroomMember
  46304. }
  46305. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  46306. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  46307. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  46308. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  46309. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  46310. m := &WpChatroomMemberMutation{
  46311. config: c,
  46312. op: op,
  46313. typ: TypeWpChatroomMember,
  46314. clearedFields: make(map[string]struct{}),
  46315. }
  46316. for _, opt := range opts {
  46317. opt(m)
  46318. }
  46319. return m
  46320. }
  46321. // withWpChatroomMemberID sets the ID field of the mutation.
  46322. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  46323. return func(m *WpChatroomMemberMutation) {
  46324. var (
  46325. err error
  46326. once sync.Once
  46327. value *WpChatroomMember
  46328. )
  46329. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  46330. once.Do(func() {
  46331. if m.done {
  46332. err = errors.New("querying old values post mutation is not allowed")
  46333. } else {
  46334. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  46335. }
  46336. })
  46337. return value, err
  46338. }
  46339. m.id = &id
  46340. }
  46341. }
  46342. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  46343. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  46344. return func(m *WpChatroomMemberMutation) {
  46345. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  46346. return node, nil
  46347. }
  46348. m.id = &node.ID
  46349. }
  46350. }
  46351. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46352. // executed in a transaction (ent.Tx), a transactional client is returned.
  46353. func (m WpChatroomMemberMutation) Client() *Client {
  46354. client := &Client{config: m.config}
  46355. client.init()
  46356. return client
  46357. }
  46358. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46359. // it returns an error otherwise.
  46360. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  46361. if _, ok := m.driver.(*txDriver); !ok {
  46362. return nil, errors.New("ent: mutation is not running in a transaction")
  46363. }
  46364. tx := &Tx{config: m.config}
  46365. tx.init()
  46366. return tx, nil
  46367. }
  46368. // SetID sets the value of the id field. Note that this
  46369. // operation is only accepted on creation of WpChatroomMember entities.
  46370. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  46371. m.id = &id
  46372. }
  46373. // ID returns the ID value in the mutation. Note that the ID is only available
  46374. // if it was provided to the builder or after it was returned from the database.
  46375. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  46376. if m.id == nil {
  46377. return
  46378. }
  46379. return *m.id, true
  46380. }
  46381. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46382. // That means, if the mutation is applied within a transaction with an isolation level such
  46383. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46384. // or updated by the mutation.
  46385. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  46386. switch {
  46387. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46388. id, exists := m.ID()
  46389. if exists {
  46390. return []uint64{id}, nil
  46391. }
  46392. fallthrough
  46393. case m.op.Is(OpUpdate | OpDelete):
  46394. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  46395. default:
  46396. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46397. }
  46398. }
  46399. // SetCreatedAt sets the "created_at" field.
  46400. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  46401. m.created_at = &t
  46402. }
  46403. // CreatedAt returns the value of the "created_at" field in the mutation.
  46404. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  46405. v := m.created_at
  46406. if v == nil {
  46407. return
  46408. }
  46409. return *v, true
  46410. }
  46411. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  46412. // If the WpChatroomMember 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 *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46415. if !m.op.Is(OpUpdateOne) {
  46416. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46417. }
  46418. if m.id == nil || m.oldValue == nil {
  46419. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  46424. }
  46425. return oldValue.CreatedAt, nil
  46426. }
  46427. // ResetCreatedAt resets all changes to the "created_at" field.
  46428. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  46429. m.created_at = nil
  46430. }
  46431. // SetUpdatedAt sets the "updated_at" field.
  46432. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  46433. m.updated_at = &t
  46434. }
  46435. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46436. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  46437. v := m.updated_at
  46438. if v == nil {
  46439. return
  46440. }
  46441. return *v, true
  46442. }
  46443. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  46444. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46446. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46447. if !m.op.Is(OpUpdateOne) {
  46448. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46449. }
  46450. if m.id == nil || m.oldValue == nil {
  46451. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46452. }
  46453. oldValue, err := m.oldValue(ctx)
  46454. if err != nil {
  46455. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46456. }
  46457. return oldValue.UpdatedAt, nil
  46458. }
  46459. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46460. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  46461. m.updated_at = nil
  46462. }
  46463. // SetStatus sets the "status" field.
  46464. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  46465. m.status = &u
  46466. m.addstatus = nil
  46467. }
  46468. // Status returns the value of the "status" field in the mutation.
  46469. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  46470. v := m.status
  46471. if v == nil {
  46472. return
  46473. }
  46474. return *v, true
  46475. }
  46476. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  46477. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46479. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46480. if !m.op.Is(OpUpdateOne) {
  46481. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46482. }
  46483. if m.id == nil || m.oldValue == nil {
  46484. return v, errors.New("OldStatus requires an ID field in the mutation")
  46485. }
  46486. oldValue, err := m.oldValue(ctx)
  46487. if err != nil {
  46488. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46489. }
  46490. return oldValue.Status, nil
  46491. }
  46492. // AddStatus adds u to the "status" field.
  46493. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  46494. if m.addstatus != nil {
  46495. *m.addstatus += u
  46496. } else {
  46497. m.addstatus = &u
  46498. }
  46499. }
  46500. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46501. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  46502. v := m.addstatus
  46503. if v == nil {
  46504. return
  46505. }
  46506. return *v, true
  46507. }
  46508. // ClearStatus clears the value of the "status" field.
  46509. func (m *WpChatroomMemberMutation) ClearStatus() {
  46510. m.status = nil
  46511. m.addstatus = nil
  46512. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  46513. }
  46514. // StatusCleared returns if the "status" field was cleared in this mutation.
  46515. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  46516. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  46517. return ok
  46518. }
  46519. // ResetStatus resets all changes to the "status" field.
  46520. func (m *WpChatroomMemberMutation) ResetStatus() {
  46521. m.status = nil
  46522. m.addstatus = nil
  46523. delete(m.clearedFields, wpchatroommember.FieldStatus)
  46524. }
  46525. // SetWxWxid sets the "wx_wxid" field.
  46526. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  46527. m.wx_wxid = &s
  46528. }
  46529. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  46530. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  46531. v := m.wx_wxid
  46532. if v == nil {
  46533. return
  46534. }
  46535. return *v, true
  46536. }
  46537. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  46538. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46540. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  46541. if !m.op.Is(OpUpdateOne) {
  46542. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  46543. }
  46544. if m.id == nil || m.oldValue == nil {
  46545. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  46546. }
  46547. oldValue, err := m.oldValue(ctx)
  46548. if err != nil {
  46549. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  46550. }
  46551. return oldValue.WxWxid, nil
  46552. }
  46553. // ResetWxWxid resets all changes to the "wx_wxid" field.
  46554. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  46555. m.wx_wxid = nil
  46556. }
  46557. // SetWxid sets the "wxid" field.
  46558. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  46559. m.wxid = &s
  46560. }
  46561. // Wxid returns the value of the "wxid" field in the mutation.
  46562. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  46563. v := m.wxid
  46564. if v == nil {
  46565. return
  46566. }
  46567. return *v, true
  46568. }
  46569. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  46570. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46572. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  46573. if !m.op.Is(OpUpdateOne) {
  46574. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46575. }
  46576. if m.id == nil || m.oldValue == nil {
  46577. return v, errors.New("OldWxid requires an ID field in the mutation")
  46578. }
  46579. oldValue, err := m.oldValue(ctx)
  46580. if err != nil {
  46581. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46582. }
  46583. return oldValue.Wxid, nil
  46584. }
  46585. // ResetWxid resets all changes to the "wxid" field.
  46586. func (m *WpChatroomMemberMutation) ResetWxid() {
  46587. m.wxid = nil
  46588. }
  46589. // SetNickname sets the "nickname" field.
  46590. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  46591. m.nickname = &s
  46592. }
  46593. // Nickname returns the value of the "nickname" field in the mutation.
  46594. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  46595. v := m.nickname
  46596. if v == nil {
  46597. return
  46598. }
  46599. return *v, true
  46600. }
  46601. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  46602. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46604. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  46605. if !m.op.Is(OpUpdateOne) {
  46606. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46607. }
  46608. if m.id == nil || m.oldValue == nil {
  46609. return v, errors.New("OldNickname requires an ID field in the mutation")
  46610. }
  46611. oldValue, err := m.oldValue(ctx)
  46612. if err != nil {
  46613. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46614. }
  46615. return oldValue.Nickname, nil
  46616. }
  46617. // ResetNickname resets all changes to the "nickname" field.
  46618. func (m *WpChatroomMemberMutation) ResetNickname() {
  46619. m.nickname = nil
  46620. }
  46621. // SetAvatar sets the "avatar" field.
  46622. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  46623. m.avatar = &s
  46624. }
  46625. // Avatar returns the value of the "avatar" field in the mutation.
  46626. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  46627. v := m.avatar
  46628. if v == nil {
  46629. return
  46630. }
  46631. return *v, true
  46632. }
  46633. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  46634. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46636. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46637. if !m.op.Is(OpUpdateOne) {
  46638. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46639. }
  46640. if m.id == nil || m.oldValue == nil {
  46641. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46642. }
  46643. oldValue, err := m.oldValue(ctx)
  46644. if err != nil {
  46645. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46646. }
  46647. return oldValue.Avatar, nil
  46648. }
  46649. // ResetAvatar resets all changes to the "avatar" field.
  46650. func (m *WpChatroomMemberMutation) ResetAvatar() {
  46651. m.avatar = nil
  46652. }
  46653. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  46654. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  46655. m.predicates = append(m.predicates, ps...)
  46656. }
  46657. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  46658. // users can use type-assertion to append predicates that do not depend on any generated package.
  46659. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  46660. p := make([]predicate.WpChatroomMember, len(ps))
  46661. for i := range ps {
  46662. p[i] = ps[i]
  46663. }
  46664. m.Where(p...)
  46665. }
  46666. // Op returns the operation name.
  46667. func (m *WpChatroomMemberMutation) Op() Op {
  46668. return m.op
  46669. }
  46670. // SetOp allows setting the mutation operation.
  46671. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  46672. m.op = op
  46673. }
  46674. // Type returns the node type of this mutation (WpChatroomMember).
  46675. func (m *WpChatroomMemberMutation) Type() string {
  46676. return m.typ
  46677. }
  46678. // Fields returns all fields that were changed during this mutation. Note that in
  46679. // order to get all numeric fields that were incremented/decremented, call
  46680. // AddedFields().
  46681. func (m *WpChatroomMemberMutation) Fields() []string {
  46682. fields := make([]string, 0, 7)
  46683. if m.created_at != nil {
  46684. fields = append(fields, wpchatroommember.FieldCreatedAt)
  46685. }
  46686. if m.updated_at != nil {
  46687. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  46688. }
  46689. if m.status != nil {
  46690. fields = append(fields, wpchatroommember.FieldStatus)
  46691. }
  46692. if m.wx_wxid != nil {
  46693. fields = append(fields, wpchatroommember.FieldWxWxid)
  46694. }
  46695. if m.wxid != nil {
  46696. fields = append(fields, wpchatroommember.FieldWxid)
  46697. }
  46698. if m.nickname != nil {
  46699. fields = append(fields, wpchatroommember.FieldNickname)
  46700. }
  46701. if m.avatar != nil {
  46702. fields = append(fields, wpchatroommember.FieldAvatar)
  46703. }
  46704. return fields
  46705. }
  46706. // Field returns the value of a field with the given name. The second boolean
  46707. // return value indicates that this field was not set, or was not defined in the
  46708. // schema.
  46709. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  46710. switch name {
  46711. case wpchatroommember.FieldCreatedAt:
  46712. return m.CreatedAt()
  46713. case wpchatroommember.FieldUpdatedAt:
  46714. return m.UpdatedAt()
  46715. case wpchatroommember.FieldStatus:
  46716. return m.Status()
  46717. case wpchatroommember.FieldWxWxid:
  46718. return m.WxWxid()
  46719. case wpchatroommember.FieldWxid:
  46720. return m.Wxid()
  46721. case wpchatroommember.FieldNickname:
  46722. return m.Nickname()
  46723. case wpchatroommember.FieldAvatar:
  46724. return m.Avatar()
  46725. }
  46726. return nil, false
  46727. }
  46728. // OldField returns the old value of the field from the database. An error is
  46729. // returned if the mutation operation is not UpdateOne, or the query to the
  46730. // database failed.
  46731. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46732. switch name {
  46733. case wpchatroommember.FieldCreatedAt:
  46734. return m.OldCreatedAt(ctx)
  46735. case wpchatroommember.FieldUpdatedAt:
  46736. return m.OldUpdatedAt(ctx)
  46737. case wpchatroommember.FieldStatus:
  46738. return m.OldStatus(ctx)
  46739. case wpchatroommember.FieldWxWxid:
  46740. return m.OldWxWxid(ctx)
  46741. case wpchatroommember.FieldWxid:
  46742. return m.OldWxid(ctx)
  46743. case wpchatroommember.FieldNickname:
  46744. return m.OldNickname(ctx)
  46745. case wpchatroommember.FieldAvatar:
  46746. return m.OldAvatar(ctx)
  46747. }
  46748. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  46749. }
  46750. // SetField sets the value of a field with the given name. It returns an error if
  46751. // the field is not defined in the schema, or if the type mismatched the field
  46752. // type.
  46753. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  46754. switch name {
  46755. case wpchatroommember.FieldCreatedAt:
  46756. v, ok := value.(time.Time)
  46757. if !ok {
  46758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46759. }
  46760. m.SetCreatedAt(v)
  46761. return nil
  46762. case wpchatroommember.FieldUpdatedAt:
  46763. v, ok := value.(time.Time)
  46764. if !ok {
  46765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46766. }
  46767. m.SetUpdatedAt(v)
  46768. return nil
  46769. case wpchatroommember.FieldStatus:
  46770. v, ok := value.(uint8)
  46771. if !ok {
  46772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46773. }
  46774. m.SetStatus(v)
  46775. return nil
  46776. case wpchatroommember.FieldWxWxid:
  46777. v, ok := value.(string)
  46778. if !ok {
  46779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46780. }
  46781. m.SetWxWxid(v)
  46782. return nil
  46783. case wpchatroommember.FieldWxid:
  46784. v, ok := value.(string)
  46785. if !ok {
  46786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46787. }
  46788. m.SetWxid(v)
  46789. return nil
  46790. case wpchatroommember.FieldNickname:
  46791. v, ok := value.(string)
  46792. if !ok {
  46793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46794. }
  46795. m.SetNickname(v)
  46796. return nil
  46797. case wpchatroommember.FieldAvatar:
  46798. v, ok := value.(string)
  46799. if !ok {
  46800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46801. }
  46802. m.SetAvatar(v)
  46803. return nil
  46804. }
  46805. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46806. }
  46807. // AddedFields returns all numeric fields that were incremented/decremented during
  46808. // this mutation.
  46809. func (m *WpChatroomMemberMutation) AddedFields() []string {
  46810. var fields []string
  46811. if m.addstatus != nil {
  46812. fields = append(fields, wpchatroommember.FieldStatus)
  46813. }
  46814. return fields
  46815. }
  46816. // AddedField returns the numeric value that was incremented/decremented on a field
  46817. // with the given name. The second boolean return value indicates that this field
  46818. // was not set, or was not defined in the schema.
  46819. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  46820. switch name {
  46821. case wpchatroommember.FieldStatus:
  46822. return m.AddedStatus()
  46823. }
  46824. return nil, false
  46825. }
  46826. // AddField adds the value to the field with the given name. It returns an error if
  46827. // the field is not defined in the schema, or if the type mismatched the field
  46828. // type.
  46829. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  46830. switch name {
  46831. case wpchatroommember.FieldStatus:
  46832. v, ok := value.(int8)
  46833. if !ok {
  46834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46835. }
  46836. m.AddStatus(v)
  46837. return nil
  46838. }
  46839. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  46840. }
  46841. // ClearedFields returns all nullable fields that were cleared during this
  46842. // mutation.
  46843. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  46844. var fields []string
  46845. if m.FieldCleared(wpchatroommember.FieldStatus) {
  46846. fields = append(fields, wpchatroommember.FieldStatus)
  46847. }
  46848. return fields
  46849. }
  46850. // FieldCleared returns a boolean indicating if a field with the given name was
  46851. // cleared in this mutation.
  46852. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  46853. _, ok := m.clearedFields[name]
  46854. return ok
  46855. }
  46856. // ClearField clears the value of the field with the given name. It returns an
  46857. // error if the field is not defined in the schema.
  46858. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  46859. switch name {
  46860. case wpchatroommember.FieldStatus:
  46861. m.ClearStatus()
  46862. return nil
  46863. }
  46864. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  46865. }
  46866. // ResetField resets all changes in the mutation for the field with the given name.
  46867. // It returns an error if the field is not defined in the schema.
  46868. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  46869. switch name {
  46870. case wpchatroommember.FieldCreatedAt:
  46871. m.ResetCreatedAt()
  46872. return nil
  46873. case wpchatroommember.FieldUpdatedAt:
  46874. m.ResetUpdatedAt()
  46875. return nil
  46876. case wpchatroommember.FieldStatus:
  46877. m.ResetStatus()
  46878. return nil
  46879. case wpchatroommember.FieldWxWxid:
  46880. m.ResetWxWxid()
  46881. return nil
  46882. case wpchatroommember.FieldWxid:
  46883. m.ResetWxid()
  46884. return nil
  46885. case wpchatroommember.FieldNickname:
  46886. m.ResetNickname()
  46887. return nil
  46888. case wpchatroommember.FieldAvatar:
  46889. m.ResetAvatar()
  46890. return nil
  46891. }
  46892. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46893. }
  46894. // AddedEdges returns all edge names that were set/added in this mutation.
  46895. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  46896. edges := make([]string, 0, 0)
  46897. return edges
  46898. }
  46899. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46900. // name in this mutation.
  46901. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  46902. return nil
  46903. }
  46904. // RemovedEdges returns all edge names that were removed in this mutation.
  46905. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  46906. edges := make([]string, 0, 0)
  46907. return edges
  46908. }
  46909. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46910. // the given name in this mutation.
  46911. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  46912. return nil
  46913. }
  46914. // ClearedEdges returns all edge names that were cleared in this mutation.
  46915. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  46916. edges := make([]string, 0, 0)
  46917. return edges
  46918. }
  46919. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46920. // was cleared in this mutation.
  46921. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  46922. return false
  46923. }
  46924. // ClearEdge clears the value of the edge with the given name. It returns an error
  46925. // if that edge is not defined in the schema.
  46926. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  46927. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  46928. }
  46929. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46930. // It returns an error if the edge is not defined in the schema.
  46931. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  46932. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  46933. }
  46934. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  46935. type WxMutation struct {
  46936. config
  46937. op Op
  46938. typ string
  46939. id *uint64
  46940. created_at *time.Time
  46941. updated_at *time.Time
  46942. status *uint8
  46943. addstatus *int8
  46944. deleted_at *time.Time
  46945. port *string
  46946. process_id *string
  46947. callback *string
  46948. wxid *string
  46949. account *string
  46950. nickname *string
  46951. tel *string
  46952. head_big *string
  46953. organization_id *uint64
  46954. addorganization_id *int64
  46955. api_base *string
  46956. api_key *string
  46957. allow_list *[]string
  46958. appendallow_list []string
  46959. group_allow_list *[]string
  46960. appendgroup_allow_list []string
  46961. block_list *[]string
  46962. appendblock_list []string
  46963. group_block_list *[]string
  46964. appendgroup_block_list []string
  46965. ctype *uint64
  46966. addctype *int64
  46967. clearedFields map[string]struct{}
  46968. server *uint64
  46969. clearedserver bool
  46970. agent *uint64
  46971. clearedagent bool
  46972. done bool
  46973. oldValue func(context.Context) (*Wx, error)
  46974. predicates []predicate.Wx
  46975. }
  46976. var _ ent.Mutation = (*WxMutation)(nil)
  46977. // wxOption allows management of the mutation configuration using functional options.
  46978. type wxOption func(*WxMutation)
  46979. // newWxMutation creates new mutation for the Wx entity.
  46980. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  46981. m := &WxMutation{
  46982. config: c,
  46983. op: op,
  46984. typ: TypeWx,
  46985. clearedFields: make(map[string]struct{}),
  46986. }
  46987. for _, opt := range opts {
  46988. opt(m)
  46989. }
  46990. return m
  46991. }
  46992. // withWxID sets the ID field of the mutation.
  46993. func withWxID(id uint64) wxOption {
  46994. return func(m *WxMutation) {
  46995. var (
  46996. err error
  46997. once sync.Once
  46998. value *Wx
  46999. )
  47000. m.oldValue = func(ctx context.Context) (*Wx, error) {
  47001. once.Do(func() {
  47002. if m.done {
  47003. err = errors.New("querying old values post mutation is not allowed")
  47004. } else {
  47005. value, err = m.Client().Wx.Get(ctx, id)
  47006. }
  47007. })
  47008. return value, err
  47009. }
  47010. m.id = &id
  47011. }
  47012. }
  47013. // withWx sets the old Wx of the mutation.
  47014. func withWx(node *Wx) wxOption {
  47015. return func(m *WxMutation) {
  47016. m.oldValue = func(context.Context) (*Wx, error) {
  47017. return node, nil
  47018. }
  47019. m.id = &node.ID
  47020. }
  47021. }
  47022. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47023. // executed in a transaction (ent.Tx), a transactional client is returned.
  47024. func (m WxMutation) Client() *Client {
  47025. client := &Client{config: m.config}
  47026. client.init()
  47027. return client
  47028. }
  47029. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47030. // it returns an error otherwise.
  47031. func (m WxMutation) Tx() (*Tx, error) {
  47032. if _, ok := m.driver.(*txDriver); !ok {
  47033. return nil, errors.New("ent: mutation is not running in a transaction")
  47034. }
  47035. tx := &Tx{config: m.config}
  47036. tx.init()
  47037. return tx, nil
  47038. }
  47039. // SetID sets the value of the id field. Note that this
  47040. // operation is only accepted on creation of Wx entities.
  47041. func (m *WxMutation) SetID(id uint64) {
  47042. m.id = &id
  47043. }
  47044. // ID returns the ID value in the mutation. Note that the ID is only available
  47045. // if it was provided to the builder or after it was returned from the database.
  47046. func (m *WxMutation) ID() (id uint64, exists bool) {
  47047. if m.id == nil {
  47048. return
  47049. }
  47050. return *m.id, true
  47051. }
  47052. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47053. // That means, if the mutation is applied within a transaction with an isolation level such
  47054. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47055. // or updated by the mutation.
  47056. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  47057. switch {
  47058. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47059. id, exists := m.ID()
  47060. if exists {
  47061. return []uint64{id}, nil
  47062. }
  47063. fallthrough
  47064. case m.op.Is(OpUpdate | OpDelete):
  47065. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  47066. default:
  47067. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47068. }
  47069. }
  47070. // SetCreatedAt sets the "created_at" field.
  47071. func (m *WxMutation) SetCreatedAt(t time.Time) {
  47072. m.created_at = &t
  47073. }
  47074. // CreatedAt returns the value of the "created_at" field in the mutation.
  47075. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  47076. v := m.created_at
  47077. if v == nil {
  47078. return
  47079. }
  47080. return *v, true
  47081. }
  47082. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  47083. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47085. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47086. if !m.op.Is(OpUpdateOne) {
  47087. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47088. }
  47089. if m.id == nil || m.oldValue == nil {
  47090. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47091. }
  47092. oldValue, err := m.oldValue(ctx)
  47093. if err != nil {
  47094. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47095. }
  47096. return oldValue.CreatedAt, nil
  47097. }
  47098. // ResetCreatedAt resets all changes to the "created_at" field.
  47099. func (m *WxMutation) ResetCreatedAt() {
  47100. m.created_at = nil
  47101. }
  47102. // SetUpdatedAt sets the "updated_at" field.
  47103. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  47104. m.updated_at = &t
  47105. }
  47106. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47107. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  47108. v := m.updated_at
  47109. if v == nil {
  47110. return
  47111. }
  47112. return *v, true
  47113. }
  47114. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  47115. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47117. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47118. if !m.op.Is(OpUpdateOne) {
  47119. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47120. }
  47121. if m.id == nil || m.oldValue == nil {
  47122. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47123. }
  47124. oldValue, err := m.oldValue(ctx)
  47125. if err != nil {
  47126. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47127. }
  47128. return oldValue.UpdatedAt, nil
  47129. }
  47130. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47131. func (m *WxMutation) ResetUpdatedAt() {
  47132. m.updated_at = nil
  47133. }
  47134. // SetStatus sets the "status" field.
  47135. func (m *WxMutation) SetStatus(u uint8) {
  47136. m.status = &u
  47137. m.addstatus = nil
  47138. }
  47139. // Status returns the value of the "status" field in the mutation.
  47140. func (m *WxMutation) Status() (r uint8, exists bool) {
  47141. v := m.status
  47142. if v == nil {
  47143. return
  47144. }
  47145. return *v, true
  47146. }
  47147. // OldStatus returns the old "status" field's value of the Wx entity.
  47148. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47150. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  47151. if !m.op.Is(OpUpdateOne) {
  47152. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  47153. }
  47154. if m.id == nil || m.oldValue == nil {
  47155. return v, errors.New("OldStatus requires an ID field in the mutation")
  47156. }
  47157. oldValue, err := m.oldValue(ctx)
  47158. if err != nil {
  47159. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  47160. }
  47161. return oldValue.Status, nil
  47162. }
  47163. // AddStatus adds u to the "status" field.
  47164. func (m *WxMutation) AddStatus(u int8) {
  47165. if m.addstatus != nil {
  47166. *m.addstatus += u
  47167. } else {
  47168. m.addstatus = &u
  47169. }
  47170. }
  47171. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47172. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  47173. v := m.addstatus
  47174. if v == nil {
  47175. return
  47176. }
  47177. return *v, true
  47178. }
  47179. // ClearStatus clears the value of the "status" field.
  47180. func (m *WxMutation) ClearStatus() {
  47181. m.status = nil
  47182. m.addstatus = nil
  47183. m.clearedFields[wx.FieldStatus] = struct{}{}
  47184. }
  47185. // StatusCleared returns if the "status" field was cleared in this mutation.
  47186. func (m *WxMutation) StatusCleared() bool {
  47187. _, ok := m.clearedFields[wx.FieldStatus]
  47188. return ok
  47189. }
  47190. // ResetStatus resets all changes to the "status" field.
  47191. func (m *WxMutation) ResetStatus() {
  47192. m.status = nil
  47193. m.addstatus = nil
  47194. delete(m.clearedFields, wx.FieldStatus)
  47195. }
  47196. // SetDeletedAt sets the "deleted_at" field.
  47197. func (m *WxMutation) SetDeletedAt(t time.Time) {
  47198. m.deleted_at = &t
  47199. }
  47200. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47201. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  47202. v := m.deleted_at
  47203. if v == nil {
  47204. return
  47205. }
  47206. return *v, true
  47207. }
  47208. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  47209. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47211. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47212. if !m.op.Is(OpUpdateOne) {
  47213. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47214. }
  47215. if m.id == nil || m.oldValue == nil {
  47216. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47217. }
  47218. oldValue, err := m.oldValue(ctx)
  47219. if err != nil {
  47220. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47221. }
  47222. return oldValue.DeletedAt, nil
  47223. }
  47224. // ClearDeletedAt clears the value of the "deleted_at" field.
  47225. func (m *WxMutation) ClearDeletedAt() {
  47226. m.deleted_at = nil
  47227. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  47228. }
  47229. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47230. func (m *WxMutation) DeletedAtCleared() bool {
  47231. _, ok := m.clearedFields[wx.FieldDeletedAt]
  47232. return ok
  47233. }
  47234. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47235. func (m *WxMutation) ResetDeletedAt() {
  47236. m.deleted_at = nil
  47237. delete(m.clearedFields, wx.FieldDeletedAt)
  47238. }
  47239. // SetServerID sets the "server_id" field.
  47240. func (m *WxMutation) SetServerID(u uint64) {
  47241. m.server = &u
  47242. }
  47243. // ServerID returns the value of the "server_id" field in the mutation.
  47244. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  47245. v := m.server
  47246. if v == nil {
  47247. return
  47248. }
  47249. return *v, true
  47250. }
  47251. // OldServerID returns the old "server_id" field's value of the Wx entity.
  47252. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47254. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  47255. if !m.op.Is(OpUpdateOne) {
  47256. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  47257. }
  47258. if m.id == nil || m.oldValue == nil {
  47259. return v, errors.New("OldServerID requires an ID field in the mutation")
  47260. }
  47261. oldValue, err := m.oldValue(ctx)
  47262. if err != nil {
  47263. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  47264. }
  47265. return oldValue.ServerID, nil
  47266. }
  47267. // ClearServerID clears the value of the "server_id" field.
  47268. func (m *WxMutation) ClearServerID() {
  47269. m.server = nil
  47270. m.clearedFields[wx.FieldServerID] = struct{}{}
  47271. }
  47272. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  47273. func (m *WxMutation) ServerIDCleared() bool {
  47274. _, ok := m.clearedFields[wx.FieldServerID]
  47275. return ok
  47276. }
  47277. // ResetServerID resets all changes to the "server_id" field.
  47278. func (m *WxMutation) ResetServerID() {
  47279. m.server = nil
  47280. delete(m.clearedFields, wx.FieldServerID)
  47281. }
  47282. // SetPort sets the "port" field.
  47283. func (m *WxMutation) SetPort(s string) {
  47284. m.port = &s
  47285. }
  47286. // Port returns the value of the "port" field in the mutation.
  47287. func (m *WxMutation) Port() (r string, exists bool) {
  47288. v := m.port
  47289. if v == nil {
  47290. return
  47291. }
  47292. return *v, true
  47293. }
  47294. // OldPort returns the old "port" field's value of the Wx entity.
  47295. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47297. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  47298. if !m.op.Is(OpUpdateOne) {
  47299. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  47300. }
  47301. if m.id == nil || m.oldValue == nil {
  47302. return v, errors.New("OldPort requires an ID field in the mutation")
  47303. }
  47304. oldValue, err := m.oldValue(ctx)
  47305. if err != nil {
  47306. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  47307. }
  47308. return oldValue.Port, nil
  47309. }
  47310. // ResetPort resets all changes to the "port" field.
  47311. func (m *WxMutation) ResetPort() {
  47312. m.port = nil
  47313. }
  47314. // SetProcessID sets the "process_id" field.
  47315. func (m *WxMutation) SetProcessID(s string) {
  47316. m.process_id = &s
  47317. }
  47318. // ProcessID returns the value of the "process_id" field in the mutation.
  47319. func (m *WxMutation) ProcessID() (r string, exists bool) {
  47320. v := m.process_id
  47321. if v == nil {
  47322. return
  47323. }
  47324. return *v, true
  47325. }
  47326. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  47327. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47329. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  47330. if !m.op.Is(OpUpdateOne) {
  47331. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  47332. }
  47333. if m.id == nil || m.oldValue == nil {
  47334. return v, errors.New("OldProcessID requires an ID field in the mutation")
  47335. }
  47336. oldValue, err := m.oldValue(ctx)
  47337. if err != nil {
  47338. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  47339. }
  47340. return oldValue.ProcessID, nil
  47341. }
  47342. // ResetProcessID resets all changes to the "process_id" field.
  47343. func (m *WxMutation) ResetProcessID() {
  47344. m.process_id = nil
  47345. }
  47346. // SetCallback sets the "callback" field.
  47347. func (m *WxMutation) SetCallback(s string) {
  47348. m.callback = &s
  47349. }
  47350. // Callback returns the value of the "callback" field in the mutation.
  47351. func (m *WxMutation) Callback() (r string, exists bool) {
  47352. v := m.callback
  47353. if v == nil {
  47354. return
  47355. }
  47356. return *v, true
  47357. }
  47358. // OldCallback returns the old "callback" field's value of the Wx entity.
  47359. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47361. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  47362. if !m.op.Is(OpUpdateOne) {
  47363. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  47364. }
  47365. if m.id == nil || m.oldValue == nil {
  47366. return v, errors.New("OldCallback requires an ID field in the mutation")
  47367. }
  47368. oldValue, err := m.oldValue(ctx)
  47369. if err != nil {
  47370. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  47371. }
  47372. return oldValue.Callback, nil
  47373. }
  47374. // ResetCallback resets all changes to the "callback" field.
  47375. func (m *WxMutation) ResetCallback() {
  47376. m.callback = nil
  47377. }
  47378. // SetWxid sets the "wxid" field.
  47379. func (m *WxMutation) SetWxid(s string) {
  47380. m.wxid = &s
  47381. }
  47382. // Wxid returns the value of the "wxid" field in the mutation.
  47383. func (m *WxMutation) Wxid() (r string, exists bool) {
  47384. v := m.wxid
  47385. if v == nil {
  47386. return
  47387. }
  47388. return *v, true
  47389. }
  47390. // OldWxid returns the old "wxid" field's value of the Wx entity.
  47391. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47393. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  47394. if !m.op.Is(OpUpdateOne) {
  47395. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47396. }
  47397. if m.id == nil || m.oldValue == nil {
  47398. return v, errors.New("OldWxid requires an ID field in the mutation")
  47399. }
  47400. oldValue, err := m.oldValue(ctx)
  47401. if err != nil {
  47402. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47403. }
  47404. return oldValue.Wxid, nil
  47405. }
  47406. // ResetWxid resets all changes to the "wxid" field.
  47407. func (m *WxMutation) ResetWxid() {
  47408. m.wxid = nil
  47409. }
  47410. // SetAccount sets the "account" field.
  47411. func (m *WxMutation) SetAccount(s string) {
  47412. m.account = &s
  47413. }
  47414. // Account returns the value of the "account" field in the mutation.
  47415. func (m *WxMutation) Account() (r string, exists bool) {
  47416. v := m.account
  47417. if v == nil {
  47418. return
  47419. }
  47420. return *v, true
  47421. }
  47422. // OldAccount returns the old "account" field's value of the Wx entity.
  47423. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47425. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  47426. if !m.op.Is(OpUpdateOne) {
  47427. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47428. }
  47429. if m.id == nil || m.oldValue == nil {
  47430. return v, errors.New("OldAccount requires an ID field in the mutation")
  47431. }
  47432. oldValue, err := m.oldValue(ctx)
  47433. if err != nil {
  47434. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47435. }
  47436. return oldValue.Account, nil
  47437. }
  47438. // ResetAccount resets all changes to the "account" field.
  47439. func (m *WxMutation) ResetAccount() {
  47440. m.account = nil
  47441. }
  47442. // SetNickname sets the "nickname" field.
  47443. func (m *WxMutation) SetNickname(s string) {
  47444. m.nickname = &s
  47445. }
  47446. // Nickname returns the value of the "nickname" field in the mutation.
  47447. func (m *WxMutation) Nickname() (r string, exists bool) {
  47448. v := m.nickname
  47449. if v == nil {
  47450. return
  47451. }
  47452. return *v, true
  47453. }
  47454. // OldNickname returns the old "nickname" field's value of the Wx entity.
  47455. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47457. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  47458. if !m.op.Is(OpUpdateOne) {
  47459. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47460. }
  47461. if m.id == nil || m.oldValue == nil {
  47462. return v, errors.New("OldNickname requires an ID field in the mutation")
  47463. }
  47464. oldValue, err := m.oldValue(ctx)
  47465. if err != nil {
  47466. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47467. }
  47468. return oldValue.Nickname, nil
  47469. }
  47470. // ResetNickname resets all changes to the "nickname" field.
  47471. func (m *WxMutation) ResetNickname() {
  47472. m.nickname = nil
  47473. }
  47474. // SetTel sets the "tel" field.
  47475. func (m *WxMutation) SetTel(s string) {
  47476. m.tel = &s
  47477. }
  47478. // Tel returns the value of the "tel" field in the mutation.
  47479. func (m *WxMutation) Tel() (r string, exists bool) {
  47480. v := m.tel
  47481. if v == nil {
  47482. return
  47483. }
  47484. return *v, true
  47485. }
  47486. // OldTel returns the old "tel" field's value of the Wx entity.
  47487. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47489. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  47490. if !m.op.Is(OpUpdateOne) {
  47491. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  47492. }
  47493. if m.id == nil || m.oldValue == nil {
  47494. return v, errors.New("OldTel requires an ID field in the mutation")
  47495. }
  47496. oldValue, err := m.oldValue(ctx)
  47497. if err != nil {
  47498. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  47499. }
  47500. return oldValue.Tel, nil
  47501. }
  47502. // ResetTel resets all changes to the "tel" field.
  47503. func (m *WxMutation) ResetTel() {
  47504. m.tel = nil
  47505. }
  47506. // SetHeadBig sets the "head_big" field.
  47507. func (m *WxMutation) SetHeadBig(s string) {
  47508. m.head_big = &s
  47509. }
  47510. // HeadBig returns the value of the "head_big" field in the mutation.
  47511. func (m *WxMutation) HeadBig() (r string, exists bool) {
  47512. v := m.head_big
  47513. if v == nil {
  47514. return
  47515. }
  47516. return *v, true
  47517. }
  47518. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  47519. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47521. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  47522. if !m.op.Is(OpUpdateOne) {
  47523. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  47524. }
  47525. if m.id == nil || m.oldValue == nil {
  47526. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  47527. }
  47528. oldValue, err := m.oldValue(ctx)
  47529. if err != nil {
  47530. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  47531. }
  47532. return oldValue.HeadBig, nil
  47533. }
  47534. // ResetHeadBig resets all changes to the "head_big" field.
  47535. func (m *WxMutation) ResetHeadBig() {
  47536. m.head_big = nil
  47537. }
  47538. // SetOrganizationID sets the "organization_id" field.
  47539. func (m *WxMutation) SetOrganizationID(u uint64) {
  47540. m.organization_id = &u
  47541. m.addorganization_id = nil
  47542. }
  47543. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47544. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  47545. v := m.organization_id
  47546. if v == nil {
  47547. return
  47548. }
  47549. return *v, true
  47550. }
  47551. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  47552. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47554. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47555. if !m.op.Is(OpUpdateOne) {
  47556. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47557. }
  47558. if m.id == nil || m.oldValue == nil {
  47559. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47560. }
  47561. oldValue, err := m.oldValue(ctx)
  47562. if err != nil {
  47563. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47564. }
  47565. return oldValue.OrganizationID, nil
  47566. }
  47567. // AddOrganizationID adds u to the "organization_id" field.
  47568. func (m *WxMutation) AddOrganizationID(u int64) {
  47569. if m.addorganization_id != nil {
  47570. *m.addorganization_id += u
  47571. } else {
  47572. m.addorganization_id = &u
  47573. }
  47574. }
  47575. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47576. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  47577. v := m.addorganization_id
  47578. if v == nil {
  47579. return
  47580. }
  47581. return *v, true
  47582. }
  47583. // ClearOrganizationID clears the value of the "organization_id" field.
  47584. func (m *WxMutation) ClearOrganizationID() {
  47585. m.organization_id = nil
  47586. m.addorganization_id = nil
  47587. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  47588. }
  47589. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  47590. func (m *WxMutation) OrganizationIDCleared() bool {
  47591. _, ok := m.clearedFields[wx.FieldOrganizationID]
  47592. return ok
  47593. }
  47594. // ResetOrganizationID resets all changes to the "organization_id" field.
  47595. func (m *WxMutation) ResetOrganizationID() {
  47596. m.organization_id = nil
  47597. m.addorganization_id = nil
  47598. delete(m.clearedFields, wx.FieldOrganizationID)
  47599. }
  47600. // SetAgentID sets the "agent_id" field.
  47601. func (m *WxMutation) SetAgentID(u uint64) {
  47602. m.agent = &u
  47603. }
  47604. // AgentID returns the value of the "agent_id" field in the mutation.
  47605. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  47606. v := m.agent
  47607. if v == nil {
  47608. return
  47609. }
  47610. return *v, true
  47611. }
  47612. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  47613. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47615. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47616. if !m.op.Is(OpUpdateOne) {
  47617. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47618. }
  47619. if m.id == nil || m.oldValue == nil {
  47620. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47621. }
  47622. oldValue, err := m.oldValue(ctx)
  47623. if err != nil {
  47624. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47625. }
  47626. return oldValue.AgentID, nil
  47627. }
  47628. // ResetAgentID resets all changes to the "agent_id" field.
  47629. func (m *WxMutation) ResetAgentID() {
  47630. m.agent = nil
  47631. }
  47632. // SetAPIBase sets the "api_base" field.
  47633. func (m *WxMutation) SetAPIBase(s string) {
  47634. m.api_base = &s
  47635. }
  47636. // APIBase returns the value of the "api_base" field in the mutation.
  47637. func (m *WxMutation) APIBase() (r string, exists bool) {
  47638. v := m.api_base
  47639. if v == nil {
  47640. return
  47641. }
  47642. return *v, true
  47643. }
  47644. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  47645. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47647. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47648. if !m.op.Is(OpUpdateOne) {
  47649. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47650. }
  47651. if m.id == nil || m.oldValue == nil {
  47652. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47653. }
  47654. oldValue, err := m.oldValue(ctx)
  47655. if err != nil {
  47656. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47657. }
  47658. return oldValue.APIBase, nil
  47659. }
  47660. // ClearAPIBase clears the value of the "api_base" field.
  47661. func (m *WxMutation) ClearAPIBase() {
  47662. m.api_base = nil
  47663. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  47664. }
  47665. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47666. func (m *WxMutation) APIBaseCleared() bool {
  47667. _, ok := m.clearedFields[wx.FieldAPIBase]
  47668. return ok
  47669. }
  47670. // ResetAPIBase resets all changes to the "api_base" field.
  47671. func (m *WxMutation) ResetAPIBase() {
  47672. m.api_base = nil
  47673. delete(m.clearedFields, wx.FieldAPIBase)
  47674. }
  47675. // SetAPIKey sets the "api_key" field.
  47676. func (m *WxMutation) SetAPIKey(s string) {
  47677. m.api_key = &s
  47678. }
  47679. // APIKey returns the value of the "api_key" field in the mutation.
  47680. func (m *WxMutation) APIKey() (r string, exists bool) {
  47681. v := m.api_key
  47682. if v == nil {
  47683. return
  47684. }
  47685. return *v, true
  47686. }
  47687. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  47688. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47690. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47691. if !m.op.Is(OpUpdateOne) {
  47692. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47693. }
  47694. if m.id == nil || m.oldValue == nil {
  47695. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47696. }
  47697. oldValue, err := m.oldValue(ctx)
  47698. if err != nil {
  47699. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47700. }
  47701. return oldValue.APIKey, nil
  47702. }
  47703. // ClearAPIKey clears the value of the "api_key" field.
  47704. func (m *WxMutation) ClearAPIKey() {
  47705. m.api_key = nil
  47706. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  47707. }
  47708. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47709. func (m *WxMutation) APIKeyCleared() bool {
  47710. _, ok := m.clearedFields[wx.FieldAPIKey]
  47711. return ok
  47712. }
  47713. // ResetAPIKey resets all changes to the "api_key" field.
  47714. func (m *WxMutation) ResetAPIKey() {
  47715. m.api_key = nil
  47716. delete(m.clearedFields, wx.FieldAPIKey)
  47717. }
  47718. // SetAllowList sets the "allow_list" field.
  47719. func (m *WxMutation) SetAllowList(s []string) {
  47720. m.allow_list = &s
  47721. m.appendallow_list = nil
  47722. }
  47723. // AllowList returns the value of the "allow_list" field in the mutation.
  47724. func (m *WxMutation) AllowList() (r []string, exists bool) {
  47725. v := m.allow_list
  47726. if v == nil {
  47727. return
  47728. }
  47729. return *v, true
  47730. }
  47731. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  47732. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47734. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  47735. if !m.op.Is(OpUpdateOne) {
  47736. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  47737. }
  47738. if m.id == nil || m.oldValue == nil {
  47739. return v, errors.New("OldAllowList requires an ID field in the mutation")
  47740. }
  47741. oldValue, err := m.oldValue(ctx)
  47742. if err != nil {
  47743. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  47744. }
  47745. return oldValue.AllowList, nil
  47746. }
  47747. // AppendAllowList adds s to the "allow_list" field.
  47748. func (m *WxMutation) AppendAllowList(s []string) {
  47749. m.appendallow_list = append(m.appendallow_list, s...)
  47750. }
  47751. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  47752. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  47753. if len(m.appendallow_list) == 0 {
  47754. return nil, false
  47755. }
  47756. return m.appendallow_list, true
  47757. }
  47758. // ResetAllowList resets all changes to the "allow_list" field.
  47759. func (m *WxMutation) ResetAllowList() {
  47760. m.allow_list = nil
  47761. m.appendallow_list = nil
  47762. }
  47763. // SetGroupAllowList sets the "group_allow_list" field.
  47764. func (m *WxMutation) SetGroupAllowList(s []string) {
  47765. m.group_allow_list = &s
  47766. m.appendgroup_allow_list = nil
  47767. }
  47768. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  47769. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  47770. v := m.group_allow_list
  47771. if v == nil {
  47772. return
  47773. }
  47774. return *v, true
  47775. }
  47776. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  47777. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47779. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  47780. if !m.op.Is(OpUpdateOne) {
  47781. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  47782. }
  47783. if m.id == nil || m.oldValue == nil {
  47784. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  47785. }
  47786. oldValue, err := m.oldValue(ctx)
  47787. if err != nil {
  47788. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  47789. }
  47790. return oldValue.GroupAllowList, nil
  47791. }
  47792. // AppendGroupAllowList adds s to the "group_allow_list" field.
  47793. func (m *WxMutation) AppendGroupAllowList(s []string) {
  47794. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  47795. }
  47796. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  47797. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  47798. if len(m.appendgroup_allow_list) == 0 {
  47799. return nil, false
  47800. }
  47801. return m.appendgroup_allow_list, true
  47802. }
  47803. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  47804. func (m *WxMutation) ResetGroupAllowList() {
  47805. m.group_allow_list = nil
  47806. m.appendgroup_allow_list = nil
  47807. }
  47808. // SetBlockList sets the "block_list" field.
  47809. func (m *WxMutation) SetBlockList(s []string) {
  47810. m.block_list = &s
  47811. m.appendblock_list = nil
  47812. }
  47813. // BlockList returns the value of the "block_list" field in the mutation.
  47814. func (m *WxMutation) BlockList() (r []string, exists bool) {
  47815. v := m.block_list
  47816. if v == nil {
  47817. return
  47818. }
  47819. return *v, true
  47820. }
  47821. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  47822. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47824. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  47825. if !m.op.Is(OpUpdateOne) {
  47826. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  47827. }
  47828. if m.id == nil || m.oldValue == nil {
  47829. return v, errors.New("OldBlockList requires an ID field in the mutation")
  47830. }
  47831. oldValue, err := m.oldValue(ctx)
  47832. if err != nil {
  47833. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  47834. }
  47835. return oldValue.BlockList, nil
  47836. }
  47837. // AppendBlockList adds s to the "block_list" field.
  47838. func (m *WxMutation) AppendBlockList(s []string) {
  47839. m.appendblock_list = append(m.appendblock_list, s...)
  47840. }
  47841. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  47842. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  47843. if len(m.appendblock_list) == 0 {
  47844. return nil, false
  47845. }
  47846. return m.appendblock_list, true
  47847. }
  47848. // ResetBlockList resets all changes to the "block_list" field.
  47849. func (m *WxMutation) ResetBlockList() {
  47850. m.block_list = nil
  47851. m.appendblock_list = nil
  47852. }
  47853. // SetGroupBlockList sets the "group_block_list" field.
  47854. func (m *WxMutation) SetGroupBlockList(s []string) {
  47855. m.group_block_list = &s
  47856. m.appendgroup_block_list = nil
  47857. }
  47858. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  47859. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  47860. v := m.group_block_list
  47861. if v == nil {
  47862. return
  47863. }
  47864. return *v, true
  47865. }
  47866. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  47867. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47869. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  47870. if !m.op.Is(OpUpdateOne) {
  47871. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  47872. }
  47873. if m.id == nil || m.oldValue == nil {
  47874. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  47875. }
  47876. oldValue, err := m.oldValue(ctx)
  47877. if err != nil {
  47878. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  47879. }
  47880. return oldValue.GroupBlockList, nil
  47881. }
  47882. // AppendGroupBlockList adds s to the "group_block_list" field.
  47883. func (m *WxMutation) AppendGroupBlockList(s []string) {
  47884. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  47885. }
  47886. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  47887. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  47888. if len(m.appendgroup_block_list) == 0 {
  47889. return nil, false
  47890. }
  47891. return m.appendgroup_block_list, true
  47892. }
  47893. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  47894. func (m *WxMutation) ResetGroupBlockList() {
  47895. m.group_block_list = nil
  47896. m.appendgroup_block_list = nil
  47897. }
  47898. // SetCtype sets the "ctype" field.
  47899. func (m *WxMutation) SetCtype(u uint64) {
  47900. m.ctype = &u
  47901. m.addctype = nil
  47902. }
  47903. // Ctype returns the value of the "ctype" field in the mutation.
  47904. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  47905. v := m.ctype
  47906. if v == nil {
  47907. return
  47908. }
  47909. return *v, true
  47910. }
  47911. // OldCtype returns the old "ctype" field's value of the Wx entity.
  47912. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47914. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  47915. if !m.op.Is(OpUpdateOne) {
  47916. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  47917. }
  47918. if m.id == nil || m.oldValue == nil {
  47919. return v, errors.New("OldCtype requires an ID field in the mutation")
  47920. }
  47921. oldValue, err := m.oldValue(ctx)
  47922. if err != nil {
  47923. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  47924. }
  47925. return oldValue.Ctype, nil
  47926. }
  47927. // AddCtype adds u to the "ctype" field.
  47928. func (m *WxMutation) AddCtype(u int64) {
  47929. if m.addctype != nil {
  47930. *m.addctype += u
  47931. } else {
  47932. m.addctype = &u
  47933. }
  47934. }
  47935. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  47936. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  47937. v := m.addctype
  47938. if v == nil {
  47939. return
  47940. }
  47941. return *v, true
  47942. }
  47943. // ClearCtype clears the value of the "ctype" field.
  47944. func (m *WxMutation) ClearCtype() {
  47945. m.ctype = nil
  47946. m.addctype = nil
  47947. m.clearedFields[wx.FieldCtype] = struct{}{}
  47948. }
  47949. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  47950. func (m *WxMutation) CtypeCleared() bool {
  47951. _, ok := m.clearedFields[wx.FieldCtype]
  47952. return ok
  47953. }
  47954. // ResetCtype resets all changes to the "ctype" field.
  47955. func (m *WxMutation) ResetCtype() {
  47956. m.ctype = nil
  47957. m.addctype = nil
  47958. delete(m.clearedFields, wx.FieldCtype)
  47959. }
  47960. // ClearServer clears the "server" edge to the Server entity.
  47961. func (m *WxMutation) ClearServer() {
  47962. m.clearedserver = true
  47963. m.clearedFields[wx.FieldServerID] = struct{}{}
  47964. }
  47965. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  47966. func (m *WxMutation) ServerCleared() bool {
  47967. return m.ServerIDCleared() || m.clearedserver
  47968. }
  47969. // ServerIDs returns the "server" edge IDs in the mutation.
  47970. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47971. // ServerID instead. It exists only for internal usage by the builders.
  47972. func (m *WxMutation) ServerIDs() (ids []uint64) {
  47973. if id := m.server; id != nil {
  47974. ids = append(ids, *id)
  47975. }
  47976. return
  47977. }
  47978. // ResetServer resets all changes to the "server" edge.
  47979. func (m *WxMutation) ResetServer() {
  47980. m.server = nil
  47981. m.clearedserver = false
  47982. }
  47983. // ClearAgent clears the "agent" edge to the Agent entity.
  47984. func (m *WxMutation) ClearAgent() {
  47985. m.clearedagent = true
  47986. m.clearedFields[wx.FieldAgentID] = struct{}{}
  47987. }
  47988. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47989. func (m *WxMutation) AgentCleared() bool {
  47990. return m.clearedagent
  47991. }
  47992. // AgentIDs returns the "agent" edge IDs in the mutation.
  47993. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47994. // AgentID instead. It exists only for internal usage by the builders.
  47995. func (m *WxMutation) AgentIDs() (ids []uint64) {
  47996. if id := m.agent; id != nil {
  47997. ids = append(ids, *id)
  47998. }
  47999. return
  48000. }
  48001. // ResetAgent resets all changes to the "agent" edge.
  48002. func (m *WxMutation) ResetAgent() {
  48003. m.agent = nil
  48004. m.clearedagent = false
  48005. }
  48006. // Where appends a list predicates to the WxMutation builder.
  48007. func (m *WxMutation) Where(ps ...predicate.Wx) {
  48008. m.predicates = append(m.predicates, ps...)
  48009. }
  48010. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  48011. // users can use type-assertion to append predicates that do not depend on any generated package.
  48012. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  48013. p := make([]predicate.Wx, len(ps))
  48014. for i := range ps {
  48015. p[i] = ps[i]
  48016. }
  48017. m.Where(p...)
  48018. }
  48019. // Op returns the operation name.
  48020. func (m *WxMutation) Op() Op {
  48021. return m.op
  48022. }
  48023. // SetOp allows setting the mutation operation.
  48024. func (m *WxMutation) SetOp(op Op) {
  48025. m.op = op
  48026. }
  48027. // Type returns the node type of this mutation (Wx).
  48028. func (m *WxMutation) Type() string {
  48029. return m.typ
  48030. }
  48031. // Fields returns all fields that were changed during this mutation. Note that in
  48032. // order to get all numeric fields that were incremented/decremented, call
  48033. // AddedFields().
  48034. func (m *WxMutation) Fields() []string {
  48035. fields := make([]string, 0, 22)
  48036. if m.created_at != nil {
  48037. fields = append(fields, wx.FieldCreatedAt)
  48038. }
  48039. if m.updated_at != nil {
  48040. fields = append(fields, wx.FieldUpdatedAt)
  48041. }
  48042. if m.status != nil {
  48043. fields = append(fields, wx.FieldStatus)
  48044. }
  48045. if m.deleted_at != nil {
  48046. fields = append(fields, wx.FieldDeletedAt)
  48047. }
  48048. if m.server != nil {
  48049. fields = append(fields, wx.FieldServerID)
  48050. }
  48051. if m.port != nil {
  48052. fields = append(fields, wx.FieldPort)
  48053. }
  48054. if m.process_id != nil {
  48055. fields = append(fields, wx.FieldProcessID)
  48056. }
  48057. if m.callback != nil {
  48058. fields = append(fields, wx.FieldCallback)
  48059. }
  48060. if m.wxid != nil {
  48061. fields = append(fields, wx.FieldWxid)
  48062. }
  48063. if m.account != nil {
  48064. fields = append(fields, wx.FieldAccount)
  48065. }
  48066. if m.nickname != nil {
  48067. fields = append(fields, wx.FieldNickname)
  48068. }
  48069. if m.tel != nil {
  48070. fields = append(fields, wx.FieldTel)
  48071. }
  48072. if m.head_big != nil {
  48073. fields = append(fields, wx.FieldHeadBig)
  48074. }
  48075. if m.organization_id != nil {
  48076. fields = append(fields, wx.FieldOrganizationID)
  48077. }
  48078. if m.agent != nil {
  48079. fields = append(fields, wx.FieldAgentID)
  48080. }
  48081. if m.api_base != nil {
  48082. fields = append(fields, wx.FieldAPIBase)
  48083. }
  48084. if m.api_key != nil {
  48085. fields = append(fields, wx.FieldAPIKey)
  48086. }
  48087. if m.allow_list != nil {
  48088. fields = append(fields, wx.FieldAllowList)
  48089. }
  48090. if m.group_allow_list != nil {
  48091. fields = append(fields, wx.FieldGroupAllowList)
  48092. }
  48093. if m.block_list != nil {
  48094. fields = append(fields, wx.FieldBlockList)
  48095. }
  48096. if m.group_block_list != nil {
  48097. fields = append(fields, wx.FieldGroupBlockList)
  48098. }
  48099. if m.ctype != nil {
  48100. fields = append(fields, wx.FieldCtype)
  48101. }
  48102. return fields
  48103. }
  48104. // Field returns the value of a field with the given name. The second boolean
  48105. // return value indicates that this field was not set, or was not defined in the
  48106. // schema.
  48107. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  48108. switch name {
  48109. case wx.FieldCreatedAt:
  48110. return m.CreatedAt()
  48111. case wx.FieldUpdatedAt:
  48112. return m.UpdatedAt()
  48113. case wx.FieldStatus:
  48114. return m.Status()
  48115. case wx.FieldDeletedAt:
  48116. return m.DeletedAt()
  48117. case wx.FieldServerID:
  48118. return m.ServerID()
  48119. case wx.FieldPort:
  48120. return m.Port()
  48121. case wx.FieldProcessID:
  48122. return m.ProcessID()
  48123. case wx.FieldCallback:
  48124. return m.Callback()
  48125. case wx.FieldWxid:
  48126. return m.Wxid()
  48127. case wx.FieldAccount:
  48128. return m.Account()
  48129. case wx.FieldNickname:
  48130. return m.Nickname()
  48131. case wx.FieldTel:
  48132. return m.Tel()
  48133. case wx.FieldHeadBig:
  48134. return m.HeadBig()
  48135. case wx.FieldOrganizationID:
  48136. return m.OrganizationID()
  48137. case wx.FieldAgentID:
  48138. return m.AgentID()
  48139. case wx.FieldAPIBase:
  48140. return m.APIBase()
  48141. case wx.FieldAPIKey:
  48142. return m.APIKey()
  48143. case wx.FieldAllowList:
  48144. return m.AllowList()
  48145. case wx.FieldGroupAllowList:
  48146. return m.GroupAllowList()
  48147. case wx.FieldBlockList:
  48148. return m.BlockList()
  48149. case wx.FieldGroupBlockList:
  48150. return m.GroupBlockList()
  48151. case wx.FieldCtype:
  48152. return m.Ctype()
  48153. }
  48154. return nil, false
  48155. }
  48156. // OldField returns the old value of the field from the database. An error is
  48157. // returned if the mutation operation is not UpdateOne, or the query to the
  48158. // database failed.
  48159. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48160. switch name {
  48161. case wx.FieldCreatedAt:
  48162. return m.OldCreatedAt(ctx)
  48163. case wx.FieldUpdatedAt:
  48164. return m.OldUpdatedAt(ctx)
  48165. case wx.FieldStatus:
  48166. return m.OldStatus(ctx)
  48167. case wx.FieldDeletedAt:
  48168. return m.OldDeletedAt(ctx)
  48169. case wx.FieldServerID:
  48170. return m.OldServerID(ctx)
  48171. case wx.FieldPort:
  48172. return m.OldPort(ctx)
  48173. case wx.FieldProcessID:
  48174. return m.OldProcessID(ctx)
  48175. case wx.FieldCallback:
  48176. return m.OldCallback(ctx)
  48177. case wx.FieldWxid:
  48178. return m.OldWxid(ctx)
  48179. case wx.FieldAccount:
  48180. return m.OldAccount(ctx)
  48181. case wx.FieldNickname:
  48182. return m.OldNickname(ctx)
  48183. case wx.FieldTel:
  48184. return m.OldTel(ctx)
  48185. case wx.FieldHeadBig:
  48186. return m.OldHeadBig(ctx)
  48187. case wx.FieldOrganizationID:
  48188. return m.OldOrganizationID(ctx)
  48189. case wx.FieldAgentID:
  48190. return m.OldAgentID(ctx)
  48191. case wx.FieldAPIBase:
  48192. return m.OldAPIBase(ctx)
  48193. case wx.FieldAPIKey:
  48194. return m.OldAPIKey(ctx)
  48195. case wx.FieldAllowList:
  48196. return m.OldAllowList(ctx)
  48197. case wx.FieldGroupAllowList:
  48198. return m.OldGroupAllowList(ctx)
  48199. case wx.FieldBlockList:
  48200. return m.OldBlockList(ctx)
  48201. case wx.FieldGroupBlockList:
  48202. return m.OldGroupBlockList(ctx)
  48203. case wx.FieldCtype:
  48204. return m.OldCtype(ctx)
  48205. }
  48206. return nil, fmt.Errorf("unknown Wx field %s", name)
  48207. }
  48208. // SetField sets the value of a field with the given name. It returns an error if
  48209. // the field is not defined in the schema, or if the type mismatched the field
  48210. // type.
  48211. func (m *WxMutation) SetField(name string, value ent.Value) error {
  48212. switch name {
  48213. case wx.FieldCreatedAt:
  48214. v, ok := value.(time.Time)
  48215. if !ok {
  48216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48217. }
  48218. m.SetCreatedAt(v)
  48219. return nil
  48220. case wx.FieldUpdatedAt:
  48221. v, ok := value.(time.Time)
  48222. if !ok {
  48223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48224. }
  48225. m.SetUpdatedAt(v)
  48226. return nil
  48227. case wx.FieldStatus:
  48228. v, ok := value.(uint8)
  48229. if !ok {
  48230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48231. }
  48232. m.SetStatus(v)
  48233. return nil
  48234. case wx.FieldDeletedAt:
  48235. v, ok := value.(time.Time)
  48236. if !ok {
  48237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48238. }
  48239. m.SetDeletedAt(v)
  48240. return nil
  48241. case wx.FieldServerID:
  48242. v, ok := value.(uint64)
  48243. if !ok {
  48244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48245. }
  48246. m.SetServerID(v)
  48247. return nil
  48248. case wx.FieldPort:
  48249. v, ok := value.(string)
  48250. if !ok {
  48251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48252. }
  48253. m.SetPort(v)
  48254. return nil
  48255. case wx.FieldProcessID:
  48256. v, ok := value.(string)
  48257. if !ok {
  48258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48259. }
  48260. m.SetProcessID(v)
  48261. return nil
  48262. case wx.FieldCallback:
  48263. v, ok := value.(string)
  48264. if !ok {
  48265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48266. }
  48267. m.SetCallback(v)
  48268. return nil
  48269. case wx.FieldWxid:
  48270. v, ok := value.(string)
  48271. if !ok {
  48272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48273. }
  48274. m.SetWxid(v)
  48275. return nil
  48276. case wx.FieldAccount:
  48277. v, ok := value.(string)
  48278. if !ok {
  48279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48280. }
  48281. m.SetAccount(v)
  48282. return nil
  48283. case wx.FieldNickname:
  48284. v, ok := value.(string)
  48285. if !ok {
  48286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48287. }
  48288. m.SetNickname(v)
  48289. return nil
  48290. case wx.FieldTel:
  48291. v, ok := value.(string)
  48292. if !ok {
  48293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48294. }
  48295. m.SetTel(v)
  48296. return nil
  48297. case wx.FieldHeadBig:
  48298. v, ok := value.(string)
  48299. if !ok {
  48300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48301. }
  48302. m.SetHeadBig(v)
  48303. return nil
  48304. case wx.FieldOrganizationID:
  48305. v, ok := value.(uint64)
  48306. if !ok {
  48307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48308. }
  48309. m.SetOrganizationID(v)
  48310. return nil
  48311. case wx.FieldAgentID:
  48312. v, ok := value.(uint64)
  48313. if !ok {
  48314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48315. }
  48316. m.SetAgentID(v)
  48317. return nil
  48318. case wx.FieldAPIBase:
  48319. v, ok := value.(string)
  48320. if !ok {
  48321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48322. }
  48323. m.SetAPIBase(v)
  48324. return nil
  48325. case wx.FieldAPIKey:
  48326. v, ok := value.(string)
  48327. if !ok {
  48328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48329. }
  48330. m.SetAPIKey(v)
  48331. return nil
  48332. case wx.FieldAllowList:
  48333. v, ok := value.([]string)
  48334. if !ok {
  48335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48336. }
  48337. m.SetAllowList(v)
  48338. return nil
  48339. case wx.FieldGroupAllowList:
  48340. v, ok := value.([]string)
  48341. if !ok {
  48342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48343. }
  48344. m.SetGroupAllowList(v)
  48345. return nil
  48346. case wx.FieldBlockList:
  48347. v, ok := value.([]string)
  48348. if !ok {
  48349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48350. }
  48351. m.SetBlockList(v)
  48352. return nil
  48353. case wx.FieldGroupBlockList:
  48354. v, ok := value.([]string)
  48355. if !ok {
  48356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48357. }
  48358. m.SetGroupBlockList(v)
  48359. return nil
  48360. case wx.FieldCtype:
  48361. v, ok := value.(uint64)
  48362. if !ok {
  48363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48364. }
  48365. m.SetCtype(v)
  48366. return nil
  48367. }
  48368. return fmt.Errorf("unknown Wx field %s", name)
  48369. }
  48370. // AddedFields returns all numeric fields that were incremented/decremented during
  48371. // this mutation.
  48372. func (m *WxMutation) AddedFields() []string {
  48373. var fields []string
  48374. if m.addstatus != nil {
  48375. fields = append(fields, wx.FieldStatus)
  48376. }
  48377. if m.addorganization_id != nil {
  48378. fields = append(fields, wx.FieldOrganizationID)
  48379. }
  48380. if m.addctype != nil {
  48381. fields = append(fields, wx.FieldCtype)
  48382. }
  48383. return fields
  48384. }
  48385. // AddedField returns the numeric value that was incremented/decremented on a field
  48386. // with the given name. The second boolean return value indicates that this field
  48387. // was not set, or was not defined in the schema.
  48388. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  48389. switch name {
  48390. case wx.FieldStatus:
  48391. return m.AddedStatus()
  48392. case wx.FieldOrganizationID:
  48393. return m.AddedOrganizationID()
  48394. case wx.FieldCtype:
  48395. return m.AddedCtype()
  48396. }
  48397. return nil, false
  48398. }
  48399. // AddField adds the value to the field with the given name. It returns an error if
  48400. // the field is not defined in the schema, or if the type mismatched the field
  48401. // type.
  48402. func (m *WxMutation) AddField(name string, value ent.Value) error {
  48403. switch name {
  48404. case wx.FieldStatus:
  48405. v, ok := value.(int8)
  48406. if !ok {
  48407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48408. }
  48409. m.AddStatus(v)
  48410. return nil
  48411. case wx.FieldOrganizationID:
  48412. v, ok := value.(int64)
  48413. if !ok {
  48414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48415. }
  48416. m.AddOrganizationID(v)
  48417. return nil
  48418. case wx.FieldCtype:
  48419. v, ok := value.(int64)
  48420. if !ok {
  48421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48422. }
  48423. m.AddCtype(v)
  48424. return nil
  48425. }
  48426. return fmt.Errorf("unknown Wx numeric field %s", name)
  48427. }
  48428. // ClearedFields returns all nullable fields that were cleared during this
  48429. // mutation.
  48430. func (m *WxMutation) ClearedFields() []string {
  48431. var fields []string
  48432. if m.FieldCleared(wx.FieldStatus) {
  48433. fields = append(fields, wx.FieldStatus)
  48434. }
  48435. if m.FieldCleared(wx.FieldDeletedAt) {
  48436. fields = append(fields, wx.FieldDeletedAt)
  48437. }
  48438. if m.FieldCleared(wx.FieldServerID) {
  48439. fields = append(fields, wx.FieldServerID)
  48440. }
  48441. if m.FieldCleared(wx.FieldOrganizationID) {
  48442. fields = append(fields, wx.FieldOrganizationID)
  48443. }
  48444. if m.FieldCleared(wx.FieldAPIBase) {
  48445. fields = append(fields, wx.FieldAPIBase)
  48446. }
  48447. if m.FieldCleared(wx.FieldAPIKey) {
  48448. fields = append(fields, wx.FieldAPIKey)
  48449. }
  48450. if m.FieldCleared(wx.FieldCtype) {
  48451. fields = append(fields, wx.FieldCtype)
  48452. }
  48453. return fields
  48454. }
  48455. // FieldCleared returns a boolean indicating if a field with the given name was
  48456. // cleared in this mutation.
  48457. func (m *WxMutation) FieldCleared(name string) bool {
  48458. _, ok := m.clearedFields[name]
  48459. return ok
  48460. }
  48461. // ClearField clears the value of the field with the given name. It returns an
  48462. // error if the field is not defined in the schema.
  48463. func (m *WxMutation) ClearField(name string) error {
  48464. switch name {
  48465. case wx.FieldStatus:
  48466. m.ClearStatus()
  48467. return nil
  48468. case wx.FieldDeletedAt:
  48469. m.ClearDeletedAt()
  48470. return nil
  48471. case wx.FieldServerID:
  48472. m.ClearServerID()
  48473. return nil
  48474. case wx.FieldOrganizationID:
  48475. m.ClearOrganizationID()
  48476. return nil
  48477. case wx.FieldAPIBase:
  48478. m.ClearAPIBase()
  48479. return nil
  48480. case wx.FieldAPIKey:
  48481. m.ClearAPIKey()
  48482. return nil
  48483. case wx.FieldCtype:
  48484. m.ClearCtype()
  48485. return nil
  48486. }
  48487. return fmt.Errorf("unknown Wx nullable field %s", name)
  48488. }
  48489. // ResetField resets all changes in the mutation for the field with the given name.
  48490. // It returns an error if the field is not defined in the schema.
  48491. func (m *WxMutation) ResetField(name string) error {
  48492. switch name {
  48493. case wx.FieldCreatedAt:
  48494. m.ResetCreatedAt()
  48495. return nil
  48496. case wx.FieldUpdatedAt:
  48497. m.ResetUpdatedAt()
  48498. return nil
  48499. case wx.FieldStatus:
  48500. m.ResetStatus()
  48501. return nil
  48502. case wx.FieldDeletedAt:
  48503. m.ResetDeletedAt()
  48504. return nil
  48505. case wx.FieldServerID:
  48506. m.ResetServerID()
  48507. return nil
  48508. case wx.FieldPort:
  48509. m.ResetPort()
  48510. return nil
  48511. case wx.FieldProcessID:
  48512. m.ResetProcessID()
  48513. return nil
  48514. case wx.FieldCallback:
  48515. m.ResetCallback()
  48516. return nil
  48517. case wx.FieldWxid:
  48518. m.ResetWxid()
  48519. return nil
  48520. case wx.FieldAccount:
  48521. m.ResetAccount()
  48522. return nil
  48523. case wx.FieldNickname:
  48524. m.ResetNickname()
  48525. return nil
  48526. case wx.FieldTel:
  48527. m.ResetTel()
  48528. return nil
  48529. case wx.FieldHeadBig:
  48530. m.ResetHeadBig()
  48531. return nil
  48532. case wx.FieldOrganizationID:
  48533. m.ResetOrganizationID()
  48534. return nil
  48535. case wx.FieldAgentID:
  48536. m.ResetAgentID()
  48537. return nil
  48538. case wx.FieldAPIBase:
  48539. m.ResetAPIBase()
  48540. return nil
  48541. case wx.FieldAPIKey:
  48542. m.ResetAPIKey()
  48543. return nil
  48544. case wx.FieldAllowList:
  48545. m.ResetAllowList()
  48546. return nil
  48547. case wx.FieldGroupAllowList:
  48548. m.ResetGroupAllowList()
  48549. return nil
  48550. case wx.FieldBlockList:
  48551. m.ResetBlockList()
  48552. return nil
  48553. case wx.FieldGroupBlockList:
  48554. m.ResetGroupBlockList()
  48555. return nil
  48556. case wx.FieldCtype:
  48557. m.ResetCtype()
  48558. return nil
  48559. }
  48560. return fmt.Errorf("unknown Wx field %s", name)
  48561. }
  48562. // AddedEdges returns all edge names that were set/added in this mutation.
  48563. func (m *WxMutation) AddedEdges() []string {
  48564. edges := make([]string, 0, 2)
  48565. if m.server != nil {
  48566. edges = append(edges, wx.EdgeServer)
  48567. }
  48568. if m.agent != nil {
  48569. edges = append(edges, wx.EdgeAgent)
  48570. }
  48571. return edges
  48572. }
  48573. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48574. // name in this mutation.
  48575. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  48576. switch name {
  48577. case wx.EdgeServer:
  48578. if id := m.server; id != nil {
  48579. return []ent.Value{*id}
  48580. }
  48581. case wx.EdgeAgent:
  48582. if id := m.agent; id != nil {
  48583. return []ent.Value{*id}
  48584. }
  48585. }
  48586. return nil
  48587. }
  48588. // RemovedEdges returns all edge names that were removed in this mutation.
  48589. func (m *WxMutation) RemovedEdges() []string {
  48590. edges := make([]string, 0, 2)
  48591. return edges
  48592. }
  48593. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48594. // the given name in this mutation.
  48595. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  48596. return nil
  48597. }
  48598. // ClearedEdges returns all edge names that were cleared in this mutation.
  48599. func (m *WxMutation) ClearedEdges() []string {
  48600. edges := make([]string, 0, 2)
  48601. if m.clearedserver {
  48602. edges = append(edges, wx.EdgeServer)
  48603. }
  48604. if m.clearedagent {
  48605. edges = append(edges, wx.EdgeAgent)
  48606. }
  48607. return edges
  48608. }
  48609. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48610. // was cleared in this mutation.
  48611. func (m *WxMutation) EdgeCleared(name string) bool {
  48612. switch name {
  48613. case wx.EdgeServer:
  48614. return m.clearedserver
  48615. case wx.EdgeAgent:
  48616. return m.clearedagent
  48617. }
  48618. return false
  48619. }
  48620. // ClearEdge clears the value of the edge with the given name. It returns an error
  48621. // if that edge is not defined in the schema.
  48622. func (m *WxMutation) ClearEdge(name string) error {
  48623. switch name {
  48624. case wx.EdgeServer:
  48625. m.ClearServer()
  48626. return nil
  48627. case wx.EdgeAgent:
  48628. m.ClearAgent()
  48629. return nil
  48630. }
  48631. return fmt.Errorf("unknown Wx unique edge %s", name)
  48632. }
  48633. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48634. // It returns an error if the edge is not defined in the schema.
  48635. func (m *WxMutation) ResetEdge(name string) error {
  48636. switch name {
  48637. case wx.EdgeServer:
  48638. m.ResetServer()
  48639. return nil
  48640. case wx.EdgeAgent:
  48641. m.ResetAgent()
  48642. return nil
  48643. }
  48644. return fmt.Errorf("unknown Wx edge %s", name)
  48645. }
  48646. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  48647. type WxCardMutation struct {
  48648. config
  48649. op Op
  48650. typ string
  48651. id *uint64
  48652. created_at *time.Time
  48653. updated_at *time.Time
  48654. deleted_at *time.Time
  48655. user_id *uint64
  48656. adduser_id *int64
  48657. wx_user_id *uint64
  48658. addwx_user_id *int64
  48659. avatar *string
  48660. logo *string
  48661. name *string
  48662. company *string
  48663. address *string
  48664. phone *string
  48665. official_account *string
  48666. wechat_account *string
  48667. email *string
  48668. api_base *string
  48669. api_key *string
  48670. ai_info *string
  48671. intro *string
  48672. clearedFields map[string]struct{}
  48673. done bool
  48674. oldValue func(context.Context) (*WxCard, error)
  48675. predicates []predicate.WxCard
  48676. }
  48677. var _ ent.Mutation = (*WxCardMutation)(nil)
  48678. // wxcardOption allows management of the mutation configuration using functional options.
  48679. type wxcardOption func(*WxCardMutation)
  48680. // newWxCardMutation creates new mutation for the WxCard entity.
  48681. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  48682. m := &WxCardMutation{
  48683. config: c,
  48684. op: op,
  48685. typ: TypeWxCard,
  48686. clearedFields: make(map[string]struct{}),
  48687. }
  48688. for _, opt := range opts {
  48689. opt(m)
  48690. }
  48691. return m
  48692. }
  48693. // withWxCardID sets the ID field of the mutation.
  48694. func withWxCardID(id uint64) wxcardOption {
  48695. return func(m *WxCardMutation) {
  48696. var (
  48697. err error
  48698. once sync.Once
  48699. value *WxCard
  48700. )
  48701. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  48702. once.Do(func() {
  48703. if m.done {
  48704. err = errors.New("querying old values post mutation is not allowed")
  48705. } else {
  48706. value, err = m.Client().WxCard.Get(ctx, id)
  48707. }
  48708. })
  48709. return value, err
  48710. }
  48711. m.id = &id
  48712. }
  48713. }
  48714. // withWxCard sets the old WxCard of the mutation.
  48715. func withWxCard(node *WxCard) wxcardOption {
  48716. return func(m *WxCardMutation) {
  48717. m.oldValue = func(context.Context) (*WxCard, error) {
  48718. return node, nil
  48719. }
  48720. m.id = &node.ID
  48721. }
  48722. }
  48723. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48724. // executed in a transaction (ent.Tx), a transactional client is returned.
  48725. func (m WxCardMutation) Client() *Client {
  48726. client := &Client{config: m.config}
  48727. client.init()
  48728. return client
  48729. }
  48730. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48731. // it returns an error otherwise.
  48732. func (m WxCardMutation) Tx() (*Tx, error) {
  48733. if _, ok := m.driver.(*txDriver); !ok {
  48734. return nil, errors.New("ent: mutation is not running in a transaction")
  48735. }
  48736. tx := &Tx{config: m.config}
  48737. tx.init()
  48738. return tx, nil
  48739. }
  48740. // SetID sets the value of the id field. Note that this
  48741. // operation is only accepted on creation of WxCard entities.
  48742. func (m *WxCardMutation) SetID(id uint64) {
  48743. m.id = &id
  48744. }
  48745. // ID returns the ID value in the mutation. Note that the ID is only available
  48746. // if it was provided to the builder or after it was returned from the database.
  48747. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  48748. if m.id == nil {
  48749. return
  48750. }
  48751. return *m.id, true
  48752. }
  48753. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48754. // That means, if the mutation is applied within a transaction with an isolation level such
  48755. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48756. // or updated by the mutation.
  48757. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  48758. switch {
  48759. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48760. id, exists := m.ID()
  48761. if exists {
  48762. return []uint64{id}, nil
  48763. }
  48764. fallthrough
  48765. case m.op.Is(OpUpdate | OpDelete):
  48766. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  48767. default:
  48768. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48769. }
  48770. }
  48771. // SetCreatedAt sets the "created_at" field.
  48772. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  48773. m.created_at = &t
  48774. }
  48775. // CreatedAt returns the value of the "created_at" field in the mutation.
  48776. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  48777. v := m.created_at
  48778. if v == nil {
  48779. return
  48780. }
  48781. return *v, true
  48782. }
  48783. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  48784. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48786. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48787. if !m.op.Is(OpUpdateOne) {
  48788. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48789. }
  48790. if m.id == nil || m.oldValue == nil {
  48791. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48792. }
  48793. oldValue, err := m.oldValue(ctx)
  48794. if err != nil {
  48795. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48796. }
  48797. return oldValue.CreatedAt, nil
  48798. }
  48799. // ResetCreatedAt resets all changes to the "created_at" field.
  48800. func (m *WxCardMutation) ResetCreatedAt() {
  48801. m.created_at = nil
  48802. }
  48803. // SetUpdatedAt sets the "updated_at" field.
  48804. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  48805. m.updated_at = &t
  48806. }
  48807. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48808. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  48809. v := m.updated_at
  48810. if v == nil {
  48811. return
  48812. }
  48813. return *v, true
  48814. }
  48815. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  48816. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48818. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48819. if !m.op.Is(OpUpdateOne) {
  48820. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48821. }
  48822. if m.id == nil || m.oldValue == nil {
  48823. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48824. }
  48825. oldValue, err := m.oldValue(ctx)
  48826. if err != nil {
  48827. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48828. }
  48829. return oldValue.UpdatedAt, nil
  48830. }
  48831. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48832. func (m *WxCardMutation) ResetUpdatedAt() {
  48833. m.updated_at = nil
  48834. }
  48835. // SetDeletedAt sets the "deleted_at" field.
  48836. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  48837. m.deleted_at = &t
  48838. }
  48839. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48840. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  48841. v := m.deleted_at
  48842. if v == nil {
  48843. return
  48844. }
  48845. return *v, true
  48846. }
  48847. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  48848. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48850. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48851. if !m.op.Is(OpUpdateOne) {
  48852. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48853. }
  48854. if m.id == nil || m.oldValue == nil {
  48855. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48856. }
  48857. oldValue, err := m.oldValue(ctx)
  48858. if err != nil {
  48859. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48860. }
  48861. return oldValue.DeletedAt, nil
  48862. }
  48863. // ClearDeletedAt clears the value of the "deleted_at" field.
  48864. func (m *WxCardMutation) ClearDeletedAt() {
  48865. m.deleted_at = nil
  48866. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  48867. }
  48868. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48869. func (m *WxCardMutation) DeletedAtCleared() bool {
  48870. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  48871. return ok
  48872. }
  48873. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48874. func (m *WxCardMutation) ResetDeletedAt() {
  48875. m.deleted_at = nil
  48876. delete(m.clearedFields, wxcard.FieldDeletedAt)
  48877. }
  48878. // SetUserID sets the "user_id" field.
  48879. func (m *WxCardMutation) SetUserID(u uint64) {
  48880. m.user_id = &u
  48881. m.adduser_id = nil
  48882. }
  48883. // UserID returns the value of the "user_id" field in the mutation.
  48884. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  48885. v := m.user_id
  48886. if v == nil {
  48887. return
  48888. }
  48889. return *v, true
  48890. }
  48891. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  48892. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48894. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48895. if !m.op.Is(OpUpdateOne) {
  48896. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48897. }
  48898. if m.id == nil || m.oldValue == nil {
  48899. return v, errors.New("OldUserID requires an ID field in the mutation")
  48900. }
  48901. oldValue, err := m.oldValue(ctx)
  48902. if err != nil {
  48903. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48904. }
  48905. return oldValue.UserID, nil
  48906. }
  48907. // AddUserID adds u to the "user_id" field.
  48908. func (m *WxCardMutation) AddUserID(u int64) {
  48909. if m.adduser_id != nil {
  48910. *m.adduser_id += u
  48911. } else {
  48912. m.adduser_id = &u
  48913. }
  48914. }
  48915. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48916. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  48917. v := m.adduser_id
  48918. if v == nil {
  48919. return
  48920. }
  48921. return *v, true
  48922. }
  48923. // ClearUserID clears the value of the "user_id" field.
  48924. func (m *WxCardMutation) ClearUserID() {
  48925. m.user_id = nil
  48926. m.adduser_id = nil
  48927. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  48928. }
  48929. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48930. func (m *WxCardMutation) UserIDCleared() bool {
  48931. _, ok := m.clearedFields[wxcard.FieldUserID]
  48932. return ok
  48933. }
  48934. // ResetUserID resets all changes to the "user_id" field.
  48935. func (m *WxCardMutation) ResetUserID() {
  48936. m.user_id = nil
  48937. m.adduser_id = nil
  48938. delete(m.clearedFields, wxcard.FieldUserID)
  48939. }
  48940. // SetWxUserID sets the "wx_user_id" field.
  48941. func (m *WxCardMutation) SetWxUserID(u uint64) {
  48942. m.wx_user_id = &u
  48943. m.addwx_user_id = nil
  48944. }
  48945. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  48946. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  48947. v := m.wx_user_id
  48948. if v == nil {
  48949. return
  48950. }
  48951. return *v, true
  48952. }
  48953. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  48954. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48956. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  48957. if !m.op.Is(OpUpdateOne) {
  48958. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  48959. }
  48960. if m.id == nil || m.oldValue == nil {
  48961. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  48962. }
  48963. oldValue, err := m.oldValue(ctx)
  48964. if err != nil {
  48965. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  48966. }
  48967. return oldValue.WxUserID, nil
  48968. }
  48969. // AddWxUserID adds u to the "wx_user_id" field.
  48970. func (m *WxCardMutation) AddWxUserID(u int64) {
  48971. if m.addwx_user_id != nil {
  48972. *m.addwx_user_id += u
  48973. } else {
  48974. m.addwx_user_id = &u
  48975. }
  48976. }
  48977. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  48978. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  48979. v := m.addwx_user_id
  48980. if v == nil {
  48981. return
  48982. }
  48983. return *v, true
  48984. }
  48985. // ClearWxUserID clears the value of the "wx_user_id" field.
  48986. func (m *WxCardMutation) ClearWxUserID() {
  48987. m.wx_user_id = nil
  48988. m.addwx_user_id = nil
  48989. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  48990. }
  48991. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  48992. func (m *WxCardMutation) WxUserIDCleared() bool {
  48993. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  48994. return ok
  48995. }
  48996. // ResetWxUserID resets all changes to the "wx_user_id" field.
  48997. func (m *WxCardMutation) ResetWxUserID() {
  48998. m.wx_user_id = nil
  48999. m.addwx_user_id = nil
  49000. delete(m.clearedFields, wxcard.FieldWxUserID)
  49001. }
  49002. // SetAvatar sets the "avatar" field.
  49003. func (m *WxCardMutation) SetAvatar(s string) {
  49004. m.avatar = &s
  49005. }
  49006. // Avatar returns the value of the "avatar" field in the mutation.
  49007. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  49008. v := m.avatar
  49009. if v == nil {
  49010. return
  49011. }
  49012. return *v, true
  49013. }
  49014. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  49015. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49017. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  49018. if !m.op.Is(OpUpdateOne) {
  49019. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  49020. }
  49021. if m.id == nil || m.oldValue == nil {
  49022. return v, errors.New("OldAvatar requires an ID field in the mutation")
  49023. }
  49024. oldValue, err := m.oldValue(ctx)
  49025. if err != nil {
  49026. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  49027. }
  49028. return oldValue.Avatar, nil
  49029. }
  49030. // ResetAvatar resets all changes to the "avatar" field.
  49031. func (m *WxCardMutation) ResetAvatar() {
  49032. m.avatar = nil
  49033. }
  49034. // SetLogo sets the "logo" field.
  49035. func (m *WxCardMutation) SetLogo(s string) {
  49036. m.logo = &s
  49037. }
  49038. // Logo returns the value of the "logo" field in the mutation.
  49039. func (m *WxCardMutation) Logo() (r string, exists bool) {
  49040. v := m.logo
  49041. if v == nil {
  49042. return
  49043. }
  49044. return *v, true
  49045. }
  49046. // OldLogo returns the old "logo" field's value of the WxCard entity.
  49047. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49049. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  49050. if !m.op.Is(OpUpdateOne) {
  49051. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  49052. }
  49053. if m.id == nil || m.oldValue == nil {
  49054. return v, errors.New("OldLogo requires an ID field in the mutation")
  49055. }
  49056. oldValue, err := m.oldValue(ctx)
  49057. if err != nil {
  49058. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  49059. }
  49060. return oldValue.Logo, nil
  49061. }
  49062. // ResetLogo resets all changes to the "logo" field.
  49063. func (m *WxCardMutation) ResetLogo() {
  49064. m.logo = nil
  49065. }
  49066. // SetName sets the "name" field.
  49067. func (m *WxCardMutation) SetName(s string) {
  49068. m.name = &s
  49069. }
  49070. // Name returns the value of the "name" field in the mutation.
  49071. func (m *WxCardMutation) Name() (r string, exists bool) {
  49072. v := m.name
  49073. if v == nil {
  49074. return
  49075. }
  49076. return *v, true
  49077. }
  49078. // OldName returns the old "name" field's value of the WxCard entity.
  49079. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49081. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  49082. if !m.op.Is(OpUpdateOne) {
  49083. return v, errors.New("OldName is only allowed on UpdateOne operations")
  49084. }
  49085. if m.id == nil || m.oldValue == nil {
  49086. return v, errors.New("OldName requires an ID field in the mutation")
  49087. }
  49088. oldValue, err := m.oldValue(ctx)
  49089. if err != nil {
  49090. return v, fmt.Errorf("querying old value for OldName: %w", err)
  49091. }
  49092. return oldValue.Name, nil
  49093. }
  49094. // ResetName resets all changes to the "name" field.
  49095. func (m *WxCardMutation) ResetName() {
  49096. m.name = nil
  49097. }
  49098. // SetCompany sets the "company" field.
  49099. func (m *WxCardMutation) SetCompany(s string) {
  49100. m.company = &s
  49101. }
  49102. // Company returns the value of the "company" field in the mutation.
  49103. func (m *WxCardMutation) Company() (r string, exists bool) {
  49104. v := m.company
  49105. if v == nil {
  49106. return
  49107. }
  49108. return *v, true
  49109. }
  49110. // OldCompany returns the old "company" field's value of the WxCard entity.
  49111. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49113. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  49114. if !m.op.Is(OpUpdateOne) {
  49115. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  49116. }
  49117. if m.id == nil || m.oldValue == nil {
  49118. return v, errors.New("OldCompany requires an ID field in the mutation")
  49119. }
  49120. oldValue, err := m.oldValue(ctx)
  49121. if err != nil {
  49122. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  49123. }
  49124. return oldValue.Company, nil
  49125. }
  49126. // ResetCompany resets all changes to the "company" field.
  49127. func (m *WxCardMutation) ResetCompany() {
  49128. m.company = nil
  49129. }
  49130. // SetAddress sets the "address" field.
  49131. func (m *WxCardMutation) SetAddress(s string) {
  49132. m.address = &s
  49133. }
  49134. // Address returns the value of the "address" field in the mutation.
  49135. func (m *WxCardMutation) Address() (r string, exists bool) {
  49136. v := m.address
  49137. if v == nil {
  49138. return
  49139. }
  49140. return *v, true
  49141. }
  49142. // OldAddress returns the old "address" field's value of the WxCard entity.
  49143. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49145. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  49146. if !m.op.Is(OpUpdateOne) {
  49147. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  49148. }
  49149. if m.id == nil || m.oldValue == nil {
  49150. return v, errors.New("OldAddress requires an ID field in the mutation")
  49151. }
  49152. oldValue, err := m.oldValue(ctx)
  49153. if err != nil {
  49154. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  49155. }
  49156. return oldValue.Address, nil
  49157. }
  49158. // ResetAddress resets all changes to the "address" field.
  49159. func (m *WxCardMutation) ResetAddress() {
  49160. m.address = nil
  49161. }
  49162. // SetPhone sets the "phone" field.
  49163. func (m *WxCardMutation) SetPhone(s string) {
  49164. m.phone = &s
  49165. }
  49166. // Phone returns the value of the "phone" field in the mutation.
  49167. func (m *WxCardMutation) Phone() (r string, exists bool) {
  49168. v := m.phone
  49169. if v == nil {
  49170. return
  49171. }
  49172. return *v, true
  49173. }
  49174. // OldPhone returns the old "phone" field's value of the WxCard entity.
  49175. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49177. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  49178. if !m.op.Is(OpUpdateOne) {
  49179. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  49180. }
  49181. if m.id == nil || m.oldValue == nil {
  49182. return v, errors.New("OldPhone requires an ID field in the mutation")
  49183. }
  49184. oldValue, err := m.oldValue(ctx)
  49185. if err != nil {
  49186. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  49187. }
  49188. return oldValue.Phone, nil
  49189. }
  49190. // ResetPhone resets all changes to the "phone" field.
  49191. func (m *WxCardMutation) ResetPhone() {
  49192. m.phone = nil
  49193. }
  49194. // SetOfficialAccount sets the "official_account" field.
  49195. func (m *WxCardMutation) SetOfficialAccount(s string) {
  49196. m.official_account = &s
  49197. }
  49198. // OfficialAccount returns the value of the "official_account" field in the mutation.
  49199. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  49200. v := m.official_account
  49201. if v == nil {
  49202. return
  49203. }
  49204. return *v, true
  49205. }
  49206. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  49207. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49209. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  49210. if !m.op.Is(OpUpdateOne) {
  49211. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  49212. }
  49213. if m.id == nil || m.oldValue == nil {
  49214. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  49215. }
  49216. oldValue, err := m.oldValue(ctx)
  49217. if err != nil {
  49218. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  49219. }
  49220. return oldValue.OfficialAccount, nil
  49221. }
  49222. // ResetOfficialAccount resets all changes to the "official_account" field.
  49223. func (m *WxCardMutation) ResetOfficialAccount() {
  49224. m.official_account = nil
  49225. }
  49226. // SetWechatAccount sets the "wechat_account" field.
  49227. func (m *WxCardMutation) SetWechatAccount(s string) {
  49228. m.wechat_account = &s
  49229. }
  49230. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  49231. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  49232. v := m.wechat_account
  49233. if v == nil {
  49234. return
  49235. }
  49236. return *v, true
  49237. }
  49238. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  49239. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49241. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  49242. if !m.op.Is(OpUpdateOne) {
  49243. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  49244. }
  49245. if m.id == nil || m.oldValue == nil {
  49246. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  49247. }
  49248. oldValue, err := m.oldValue(ctx)
  49249. if err != nil {
  49250. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  49251. }
  49252. return oldValue.WechatAccount, nil
  49253. }
  49254. // ResetWechatAccount resets all changes to the "wechat_account" field.
  49255. func (m *WxCardMutation) ResetWechatAccount() {
  49256. m.wechat_account = nil
  49257. }
  49258. // SetEmail sets the "email" field.
  49259. func (m *WxCardMutation) SetEmail(s string) {
  49260. m.email = &s
  49261. }
  49262. // Email returns the value of the "email" field in the mutation.
  49263. func (m *WxCardMutation) Email() (r string, exists bool) {
  49264. v := m.email
  49265. if v == nil {
  49266. return
  49267. }
  49268. return *v, true
  49269. }
  49270. // OldEmail returns the old "email" field's value of the WxCard entity.
  49271. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49273. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  49274. if !m.op.Is(OpUpdateOne) {
  49275. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  49276. }
  49277. if m.id == nil || m.oldValue == nil {
  49278. return v, errors.New("OldEmail requires an ID field in the mutation")
  49279. }
  49280. oldValue, err := m.oldValue(ctx)
  49281. if err != nil {
  49282. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  49283. }
  49284. return oldValue.Email, nil
  49285. }
  49286. // ClearEmail clears the value of the "email" field.
  49287. func (m *WxCardMutation) ClearEmail() {
  49288. m.email = nil
  49289. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  49290. }
  49291. // EmailCleared returns if the "email" field was cleared in this mutation.
  49292. func (m *WxCardMutation) EmailCleared() bool {
  49293. _, ok := m.clearedFields[wxcard.FieldEmail]
  49294. return ok
  49295. }
  49296. // ResetEmail resets all changes to the "email" field.
  49297. func (m *WxCardMutation) ResetEmail() {
  49298. m.email = nil
  49299. delete(m.clearedFields, wxcard.FieldEmail)
  49300. }
  49301. // SetAPIBase sets the "api_base" field.
  49302. func (m *WxCardMutation) SetAPIBase(s string) {
  49303. m.api_base = &s
  49304. }
  49305. // APIBase returns the value of the "api_base" field in the mutation.
  49306. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  49307. v := m.api_base
  49308. if v == nil {
  49309. return
  49310. }
  49311. return *v, true
  49312. }
  49313. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  49314. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49316. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49317. if !m.op.Is(OpUpdateOne) {
  49318. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49319. }
  49320. if m.id == nil || m.oldValue == nil {
  49321. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49322. }
  49323. oldValue, err := m.oldValue(ctx)
  49324. if err != nil {
  49325. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49326. }
  49327. return oldValue.APIBase, nil
  49328. }
  49329. // ClearAPIBase clears the value of the "api_base" field.
  49330. func (m *WxCardMutation) ClearAPIBase() {
  49331. m.api_base = nil
  49332. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  49333. }
  49334. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49335. func (m *WxCardMutation) APIBaseCleared() bool {
  49336. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  49337. return ok
  49338. }
  49339. // ResetAPIBase resets all changes to the "api_base" field.
  49340. func (m *WxCardMutation) ResetAPIBase() {
  49341. m.api_base = nil
  49342. delete(m.clearedFields, wxcard.FieldAPIBase)
  49343. }
  49344. // SetAPIKey sets the "api_key" field.
  49345. func (m *WxCardMutation) SetAPIKey(s string) {
  49346. m.api_key = &s
  49347. }
  49348. // APIKey returns the value of the "api_key" field in the mutation.
  49349. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  49350. v := m.api_key
  49351. if v == nil {
  49352. return
  49353. }
  49354. return *v, true
  49355. }
  49356. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  49357. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49359. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49360. if !m.op.Is(OpUpdateOne) {
  49361. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49362. }
  49363. if m.id == nil || m.oldValue == nil {
  49364. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49365. }
  49366. oldValue, err := m.oldValue(ctx)
  49367. if err != nil {
  49368. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49369. }
  49370. return oldValue.APIKey, nil
  49371. }
  49372. // ClearAPIKey clears the value of the "api_key" field.
  49373. func (m *WxCardMutation) ClearAPIKey() {
  49374. m.api_key = nil
  49375. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  49376. }
  49377. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49378. func (m *WxCardMutation) APIKeyCleared() bool {
  49379. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  49380. return ok
  49381. }
  49382. // ResetAPIKey resets all changes to the "api_key" field.
  49383. func (m *WxCardMutation) ResetAPIKey() {
  49384. m.api_key = nil
  49385. delete(m.clearedFields, wxcard.FieldAPIKey)
  49386. }
  49387. // SetAiInfo sets the "ai_info" field.
  49388. func (m *WxCardMutation) SetAiInfo(s string) {
  49389. m.ai_info = &s
  49390. }
  49391. // AiInfo returns the value of the "ai_info" field in the mutation.
  49392. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  49393. v := m.ai_info
  49394. if v == nil {
  49395. return
  49396. }
  49397. return *v, true
  49398. }
  49399. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  49400. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49402. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  49403. if !m.op.Is(OpUpdateOne) {
  49404. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  49405. }
  49406. if m.id == nil || m.oldValue == nil {
  49407. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  49408. }
  49409. oldValue, err := m.oldValue(ctx)
  49410. if err != nil {
  49411. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  49412. }
  49413. return oldValue.AiInfo, nil
  49414. }
  49415. // ClearAiInfo clears the value of the "ai_info" field.
  49416. func (m *WxCardMutation) ClearAiInfo() {
  49417. m.ai_info = nil
  49418. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  49419. }
  49420. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  49421. func (m *WxCardMutation) AiInfoCleared() bool {
  49422. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  49423. return ok
  49424. }
  49425. // ResetAiInfo resets all changes to the "ai_info" field.
  49426. func (m *WxCardMutation) ResetAiInfo() {
  49427. m.ai_info = nil
  49428. delete(m.clearedFields, wxcard.FieldAiInfo)
  49429. }
  49430. // SetIntro sets the "intro" field.
  49431. func (m *WxCardMutation) SetIntro(s string) {
  49432. m.intro = &s
  49433. }
  49434. // Intro returns the value of the "intro" field in the mutation.
  49435. func (m *WxCardMutation) Intro() (r string, exists bool) {
  49436. v := m.intro
  49437. if v == nil {
  49438. return
  49439. }
  49440. return *v, true
  49441. }
  49442. // OldIntro returns the old "intro" field's value of the WxCard entity.
  49443. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49445. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  49446. if !m.op.Is(OpUpdateOne) {
  49447. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  49448. }
  49449. if m.id == nil || m.oldValue == nil {
  49450. return v, errors.New("OldIntro requires an ID field in the mutation")
  49451. }
  49452. oldValue, err := m.oldValue(ctx)
  49453. if err != nil {
  49454. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  49455. }
  49456. return oldValue.Intro, nil
  49457. }
  49458. // ClearIntro clears the value of the "intro" field.
  49459. func (m *WxCardMutation) ClearIntro() {
  49460. m.intro = nil
  49461. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  49462. }
  49463. // IntroCleared returns if the "intro" field was cleared in this mutation.
  49464. func (m *WxCardMutation) IntroCleared() bool {
  49465. _, ok := m.clearedFields[wxcard.FieldIntro]
  49466. return ok
  49467. }
  49468. // ResetIntro resets all changes to the "intro" field.
  49469. func (m *WxCardMutation) ResetIntro() {
  49470. m.intro = nil
  49471. delete(m.clearedFields, wxcard.FieldIntro)
  49472. }
  49473. // Where appends a list predicates to the WxCardMutation builder.
  49474. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  49475. m.predicates = append(m.predicates, ps...)
  49476. }
  49477. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  49478. // users can use type-assertion to append predicates that do not depend on any generated package.
  49479. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  49480. p := make([]predicate.WxCard, len(ps))
  49481. for i := range ps {
  49482. p[i] = ps[i]
  49483. }
  49484. m.Where(p...)
  49485. }
  49486. // Op returns the operation name.
  49487. func (m *WxCardMutation) Op() Op {
  49488. return m.op
  49489. }
  49490. // SetOp allows setting the mutation operation.
  49491. func (m *WxCardMutation) SetOp(op Op) {
  49492. m.op = op
  49493. }
  49494. // Type returns the node type of this mutation (WxCard).
  49495. func (m *WxCardMutation) Type() string {
  49496. return m.typ
  49497. }
  49498. // Fields returns all fields that were changed during this mutation. Note that in
  49499. // order to get all numeric fields that were incremented/decremented, call
  49500. // AddedFields().
  49501. func (m *WxCardMutation) Fields() []string {
  49502. fields := make([]string, 0, 18)
  49503. if m.created_at != nil {
  49504. fields = append(fields, wxcard.FieldCreatedAt)
  49505. }
  49506. if m.updated_at != nil {
  49507. fields = append(fields, wxcard.FieldUpdatedAt)
  49508. }
  49509. if m.deleted_at != nil {
  49510. fields = append(fields, wxcard.FieldDeletedAt)
  49511. }
  49512. if m.user_id != nil {
  49513. fields = append(fields, wxcard.FieldUserID)
  49514. }
  49515. if m.wx_user_id != nil {
  49516. fields = append(fields, wxcard.FieldWxUserID)
  49517. }
  49518. if m.avatar != nil {
  49519. fields = append(fields, wxcard.FieldAvatar)
  49520. }
  49521. if m.logo != nil {
  49522. fields = append(fields, wxcard.FieldLogo)
  49523. }
  49524. if m.name != nil {
  49525. fields = append(fields, wxcard.FieldName)
  49526. }
  49527. if m.company != nil {
  49528. fields = append(fields, wxcard.FieldCompany)
  49529. }
  49530. if m.address != nil {
  49531. fields = append(fields, wxcard.FieldAddress)
  49532. }
  49533. if m.phone != nil {
  49534. fields = append(fields, wxcard.FieldPhone)
  49535. }
  49536. if m.official_account != nil {
  49537. fields = append(fields, wxcard.FieldOfficialAccount)
  49538. }
  49539. if m.wechat_account != nil {
  49540. fields = append(fields, wxcard.FieldWechatAccount)
  49541. }
  49542. if m.email != nil {
  49543. fields = append(fields, wxcard.FieldEmail)
  49544. }
  49545. if m.api_base != nil {
  49546. fields = append(fields, wxcard.FieldAPIBase)
  49547. }
  49548. if m.api_key != nil {
  49549. fields = append(fields, wxcard.FieldAPIKey)
  49550. }
  49551. if m.ai_info != nil {
  49552. fields = append(fields, wxcard.FieldAiInfo)
  49553. }
  49554. if m.intro != nil {
  49555. fields = append(fields, wxcard.FieldIntro)
  49556. }
  49557. return fields
  49558. }
  49559. // Field returns the value of a field with the given name. The second boolean
  49560. // return value indicates that this field was not set, or was not defined in the
  49561. // schema.
  49562. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  49563. switch name {
  49564. case wxcard.FieldCreatedAt:
  49565. return m.CreatedAt()
  49566. case wxcard.FieldUpdatedAt:
  49567. return m.UpdatedAt()
  49568. case wxcard.FieldDeletedAt:
  49569. return m.DeletedAt()
  49570. case wxcard.FieldUserID:
  49571. return m.UserID()
  49572. case wxcard.FieldWxUserID:
  49573. return m.WxUserID()
  49574. case wxcard.FieldAvatar:
  49575. return m.Avatar()
  49576. case wxcard.FieldLogo:
  49577. return m.Logo()
  49578. case wxcard.FieldName:
  49579. return m.Name()
  49580. case wxcard.FieldCompany:
  49581. return m.Company()
  49582. case wxcard.FieldAddress:
  49583. return m.Address()
  49584. case wxcard.FieldPhone:
  49585. return m.Phone()
  49586. case wxcard.FieldOfficialAccount:
  49587. return m.OfficialAccount()
  49588. case wxcard.FieldWechatAccount:
  49589. return m.WechatAccount()
  49590. case wxcard.FieldEmail:
  49591. return m.Email()
  49592. case wxcard.FieldAPIBase:
  49593. return m.APIBase()
  49594. case wxcard.FieldAPIKey:
  49595. return m.APIKey()
  49596. case wxcard.FieldAiInfo:
  49597. return m.AiInfo()
  49598. case wxcard.FieldIntro:
  49599. return m.Intro()
  49600. }
  49601. return nil, false
  49602. }
  49603. // OldField returns the old value of the field from the database. An error is
  49604. // returned if the mutation operation is not UpdateOne, or the query to the
  49605. // database failed.
  49606. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49607. switch name {
  49608. case wxcard.FieldCreatedAt:
  49609. return m.OldCreatedAt(ctx)
  49610. case wxcard.FieldUpdatedAt:
  49611. return m.OldUpdatedAt(ctx)
  49612. case wxcard.FieldDeletedAt:
  49613. return m.OldDeletedAt(ctx)
  49614. case wxcard.FieldUserID:
  49615. return m.OldUserID(ctx)
  49616. case wxcard.FieldWxUserID:
  49617. return m.OldWxUserID(ctx)
  49618. case wxcard.FieldAvatar:
  49619. return m.OldAvatar(ctx)
  49620. case wxcard.FieldLogo:
  49621. return m.OldLogo(ctx)
  49622. case wxcard.FieldName:
  49623. return m.OldName(ctx)
  49624. case wxcard.FieldCompany:
  49625. return m.OldCompany(ctx)
  49626. case wxcard.FieldAddress:
  49627. return m.OldAddress(ctx)
  49628. case wxcard.FieldPhone:
  49629. return m.OldPhone(ctx)
  49630. case wxcard.FieldOfficialAccount:
  49631. return m.OldOfficialAccount(ctx)
  49632. case wxcard.FieldWechatAccount:
  49633. return m.OldWechatAccount(ctx)
  49634. case wxcard.FieldEmail:
  49635. return m.OldEmail(ctx)
  49636. case wxcard.FieldAPIBase:
  49637. return m.OldAPIBase(ctx)
  49638. case wxcard.FieldAPIKey:
  49639. return m.OldAPIKey(ctx)
  49640. case wxcard.FieldAiInfo:
  49641. return m.OldAiInfo(ctx)
  49642. case wxcard.FieldIntro:
  49643. return m.OldIntro(ctx)
  49644. }
  49645. return nil, fmt.Errorf("unknown WxCard field %s", name)
  49646. }
  49647. // SetField sets the value of a field with the given name. It returns an error if
  49648. // the field is not defined in the schema, or if the type mismatched the field
  49649. // type.
  49650. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  49651. switch name {
  49652. case wxcard.FieldCreatedAt:
  49653. v, ok := value.(time.Time)
  49654. if !ok {
  49655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49656. }
  49657. m.SetCreatedAt(v)
  49658. return nil
  49659. case wxcard.FieldUpdatedAt:
  49660. v, ok := value.(time.Time)
  49661. if !ok {
  49662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49663. }
  49664. m.SetUpdatedAt(v)
  49665. return nil
  49666. case wxcard.FieldDeletedAt:
  49667. v, ok := value.(time.Time)
  49668. if !ok {
  49669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49670. }
  49671. m.SetDeletedAt(v)
  49672. return nil
  49673. case wxcard.FieldUserID:
  49674. v, ok := value.(uint64)
  49675. if !ok {
  49676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49677. }
  49678. m.SetUserID(v)
  49679. return nil
  49680. case wxcard.FieldWxUserID:
  49681. v, ok := value.(uint64)
  49682. if !ok {
  49683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49684. }
  49685. m.SetWxUserID(v)
  49686. return nil
  49687. case wxcard.FieldAvatar:
  49688. v, ok := value.(string)
  49689. if !ok {
  49690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49691. }
  49692. m.SetAvatar(v)
  49693. return nil
  49694. case wxcard.FieldLogo:
  49695. v, ok := value.(string)
  49696. if !ok {
  49697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49698. }
  49699. m.SetLogo(v)
  49700. return nil
  49701. case wxcard.FieldName:
  49702. v, ok := value.(string)
  49703. if !ok {
  49704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49705. }
  49706. m.SetName(v)
  49707. return nil
  49708. case wxcard.FieldCompany:
  49709. v, ok := value.(string)
  49710. if !ok {
  49711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49712. }
  49713. m.SetCompany(v)
  49714. return nil
  49715. case wxcard.FieldAddress:
  49716. v, ok := value.(string)
  49717. if !ok {
  49718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49719. }
  49720. m.SetAddress(v)
  49721. return nil
  49722. case wxcard.FieldPhone:
  49723. v, ok := value.(string)
  49724. if !ok {
  49725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49726. }
  49727. m.SetPhone(v)
  49728. return nil
  49729. case wxcard.FieldOfficialAccount:
  49730. v, ok := value.(string)
  49731. if !ok {
  49732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49733. }
  49734. m.SetOfficialAccount(v)
  49735. return nil
  49736. case wxcard.FieldWechatAccount:
  49737. v, ok := value.(string)
  49738. if !ok {
  49739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49740. }
  49741. m.SetWechatAccount(v)
  49742. return nil
  49743. case wxcard.FieldEmail:
  49744. v, ok := value.(string)
  49745. if !ok {
  49746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49747. }
  49748. m.SetEmail(v)
  49749. return nil
  49750. case wxcard.FieldAPIBase:
  49751. v, ok := value.(string)
  49752. if !ok {
  49753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49754. }
  49755. m.SetAPIBase(v)
  49756. return nil
  49757. case wxcard.FieldAPIKey:
  49758. v, ok := value.(string)
  49759. if !ok {
  49760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49761. }
  49762. m.SetAPIKey(v)
  49763. return nil
  49764. case wxcard.FieldAiInfo:
  49765. v, ok := value.(string)
  49766. if !ok {
  49767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49768. }
  49769. m.SetAiInfo(v)
  49770. return nil
  49771. case wxcard.FieldIntro:
  49772. v, ok := value.(string)
  49773. if !ok {
  49774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49775. }
  49776. m.SetIntro(v)
  49777. return nil
  49778. }
  49779. return fmt.Errorf("unknown WxCard field %s", name)
  49780. }
  49781. // AddedFields returns all numeric fields that were incremented/decremented during
  49782. // this mutation.
  49783. func (m *WxCardMutation) AddedFields() []string {
  49784. var fields []string
  49785. if m.adduser_id != nil {
  49786. fields = append(fields, wxcard.FieldUserID)
  49787. }
  49788. if m.addwx_user_id != nil {
  49789. fields = append(fields, wxcard.FieldWxUserID)
  49790. }
  49791. return fields
  49792. }
  49793. // AddedField returns the numeric value that was incremented/decremented on a field
  49794. // with the given name. The second boolean return value indicates that this field
  49795. // was not set, or was not defined in the schema.
  49796. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  49797. switch name {
  49798. case wxcard.FieldUserID:
  49799. return m.AddedUserID()
  49800. case wxcard.FieldWxUserID:
  49801. return m.AddedWxUserID()
  49802. }
  49803. return nil, false
  49804. }
  49805. // AddField adds the value to the field with the given name. It returns an error if
  49806. // the field is not defined in the schema, or if the type mismatched the field
  49807. // type.
  49808. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  49809. switch name {
  49810. case wxcard.FieldUserID:
  49811. v, ok := value.(int64)
  49812. if !ok {
  49813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49814. }
  49815. m.AddUserID(v)
  49816. return nil
  49817. case wxcard.FieldWxUserID:
  49818. v, ok := value.(int64)
  49819. if !ok {
  49820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49821. }
  49822. m.AddWxUserID(v)
  49823. return nil
  49824. }
  49825. return fmt.Errorf("unknown WxCard numeric field %s", name)
  49826. }
  49827. // ClearedFields returns all nullable fields that were cleared during this
  49828. // mutation.
  49829. func (m *WxCardMutation) ClearedFields() []string {
  49830. var fields []string
  49831. if m.FieldCleared(wxcard.FieldDeletedAt) {
  49832. fields = append(fields, wxcard.FieldDeletedAt)
  49833. }
  49834. if m.FieldCleared(wxcard.FieldUserID) {
  49835. fields = append(fields, wxcard.FieldUserID)
  49836. }
  49837. if m.FieldCleared(wxcard.FieldWxUserID) {
  49838. fields = append(fields, wxcard.FieldWxUserID)
  49839. }
  49840. if m.FieldCleared(wxcard.FieldEmail) {
  49841. fields = append(fields, wxcard.FieldEmail)
  49842. }
  49843. if m.FieldCleared(wxcard.FieldAPIBase) {
  49844. fields = append(fields, wxcard.FieldAPIBase)
  49845. }
  49846. if m.FieldCleared(wxcard.FieldAPIKey) {
  49847. fields = append(fields, wxcard.FieldAPIKey)
  49848. }
  49849. if m.FieldCleared(wxcard.FieldAiInfo) {
  49850. fields = append(fields, wxcard.FieldAiInfo)
  49851. }
  49852. if m.FieldCleared(wxcard.FieldIntro) {
  49853. fields = append(fields, wxcard.FieldIntro)
  49854. }
  49855. return fields
  49856. }
  49857. // FieldCleared returns a boolean indicating if a field with the given name was
  49858. // cleared in this mutation.
  49859. func (m *WxCardMutation) FieldCleared(name string) bool {
  49860. _, ok := m.clearedFields[name]
  49861. return ok
  49862. }
  49863. // ClearField clears the value of the field with the given name. It returns an
  49864. // error if the field is not defined in the schema.
  49865. func (m *WxCardMutation) ClearField(name string) error {
  49866. switch name {
  49867. case wxcard.FieldDeletedAt:
  49868. m.ClearDeletedAt()
  49869. return nil
  49870. case wxcard.FieldUserID:
  49871. m.ClearUserID()
  49872. return nil
  49873. case wxcard.FieldWxUserID:
  49874. m.ClearWxUserID()
  49875. return nil
  49876. case wxcard.FieldEmail:
  49877. m.ClearEmail()
  49878. return nil
  49879. case wxcard.FieldAPIBase:
  49880. m.ClearAPIBase()
  49881. return nil
  49882. case wxcard.FieldAPIKey:
  49883. m.ClearAPIKey()
  49884. return nil
  49885. case wxcard.FieldAiInfo:
  49886. m.ClearAiInfo()
  49887. return nil
  49888. case wxcard.FieldIntro:
  49889. m.ClearIntro()
  49890. return nil
  49891. }
  49892. return fmt.Errorf("unknown WxCard nullable field %s", name)
  49893. }
  49894. // ResetField resets all changes in the mutation for the field with the given name.
  49895. // It returns an error if the field is not defined in the schema.
  49896. func (m *WxCardMutation) ResetField(name string) error {
  49897. switch name {
  49898. case wxcard.FieldCreatedAt:
  49899. m.ResetCreatedAt()
  49900. return nil
  49901. case wxcard.FieldUpdatedAt:
  49902. m.ResetUpdatedAt()
  49903. return nil
  49904. case wxcard.FieldDeletedAt:
  49905. m.ResetDeletedAt()
  49906. return nil
  49907. case wxcard.FieldUserID:
  49908. m.ResetUserID()
  49909. return nil
  49910. case wxcard.FieldWxUserID:
  49911. m.ResetWxUserID()
  49912. return nil
  49913. case wxcard.FieldAvatar:
  49914. m.ResetAvatar()
  49915. return nil
  49916. case wxcard.FieldLogo:
  49917. m.ResetLogo()
  49918. return nil
  49919. case wxcard.FieldName:
  49920. m.ResetName()
  49921. return nil
  49922. case wxcard.FieldCompany:
  49923. m.ResetCompany()
  49924. return nil
  49925. case wxcard.FieldAddress:
  49926. m.ResetAddress()
  49927. return nil
  49928. case wxcard.FieldPhone:
  49929. m.ResetPhone()
  49930. return nil
  49931. case wxcard.FieldOfficialAccount:
  49932. m.ResetOfficialAccount()
  49933. return nil
  49934. case wxcard.FieldWechatAccount:
  49935. m.ResetWechatAccount()
  49936. return nil
  49937. case wxcard.FieldEmail:
  49938. m.ResetEmail()
  49939. return nil
  49940. case wxcard.FieldAPIBase:
  49941. m.ResetAPIBase()
  49942. return nil
  49943. case wxcard.FieldAPIKey:
  49944. m.ResetAPIKey()
  49945. return nil
  49946. case wxcard.FieldAiInfo:
  49947. m.ResetAiInfo()
  49948. return nil
  49949. case wxcard.FieldIntro:
  49950. m.ResetIntro()
  49951. return nil
  49952. }
  49953. return fmt.Errorf("unknown WxCard field %s", name)
  49954. }
  49955. // AddedEdges returns all edge names that were set/added in this mutation.
  49956. func (m *WxCardMutation) AddedEdges() []string {
  49957. edges := make([]string, 0, 0)
  49958. return edges
  49959. }
  49960. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49961. // name in this mutation.
  49962. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  49963. return nil
  49964. }
  49965. // RemovedEdges returns all edge names that were removed in this mutation.
  49966. func (m *WxCardMutation) RemovedEdges() []string {
  49967. edges := make([]string, 0, 0)
  49968. return edges
  49969. }
  49970. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49971. // the given name in this mutation.
  49972. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  49973. return nil
  49974. }
  49975. // ClearedEdges returns all edge names that were cleared in this mutation.
  49976. func (m *WxCardMutation) ClearedEdges() []string {
  49977. edges := make([]string, 0, 0)
  49978. return edges
  49979. }
  49980. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49981. // was cleared in this mutation.
  49982. func (m *WxCardMutation) EdgeCleared(name string) bool {
  49983. return false
  49984. }
  49985. // ClearEdge clears the value of the edge with the given name. It returns an error
  49986. // if that edge is not defined in the schema.
  49987. func (m *WxCardMutation) ClearEdge(name string) error {
  49988. return fmt.Errorf("unknown WxCard unique edge %s", name)
  49989. }
  49990. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49991. // It returns an error if the edge is not defined in the schema.
  49992. func (m *WxCardMutation) ResetEdge(name string) error {
  49993. return fmt.Errorf("unknown WxCard edge %s", name)
  49994. }
  49995. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  49996. type WxCardUserMutation struct {
  49997. config
  49998. op Op
  49999. typ string
  50000. id *uint64
  50001. created_at *time.Time
  50002. updated_at *time.Time
  50003. deleted_at *time.Time
  50004. wxid *string
  50005. account *string
  50006. avatar *string
  50007. nickname *string
  50008. remark *string
  50009. phone *string
  50010. open_id *string
  50011. union_id *string
  50012. session_key *string
  50013. is_vip *int
  50014. addis_vip *int
  50015. clearedFields map[string]struct{}
  50016. done bool
  50017. oldValue func(context.Context) (*WxCardUser, error)
  50018. predicates []predicate.WxCardUser
  50019. }
  50020. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  50021. // wxcarduserOption allows management of the mutation configuration using functional options.
  50022. type wxcarduserOption func(*WxCardUserMutation)
  50023. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  50024. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  50025. m := &WxCardUserMutation{
  50026. config: c,
  50027. op: op,
  50028. typ: TypeWxCardUser,
  50029. clearedFields: make(map[string]struct{}),
  50030. }
  50031. for _, opt := range opts {
  50032. opt(m)
  50033. }
  50034. return m
  50035. }
  50036. // withWxCardUserID sets the ID field of the mutation.
  50037. func withWxCardUserID(id uint64) wxcarduserOption {
  50038. return func(m *WxCardUserMutation) {
  50039. var (
  50040. err error
  50041. once sync.Once
  50042. value *WxCardUser
  50043. )
  50044. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  50045. once.Do(func() {
  50046. if m.done {
  50047. err = errors.New("querying old values post mutation is not allowed")
  50048. } else {
  50049. value, err = m.Client().WxCardUser.Get(ctx, id)
  50050. }
  50051. })
  50052. return value, err
  50053. }
  50054. m.id = &id
  50055. }
  50056. }
  50057. // withWxCardUser sets the old WxCardUser of the mutation.
  50058. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  50059. return func(m *WxCardUserMutation) {
  50060. m.oldValue = func(context.Context) (*WxCardUser, error) {
  50061. return node, nil
  50062. }
  50063. m.id = &node.ID
  50064. }
  50065. }
  50066. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50067. // executed in a transaction (ent.Tx), a transactional client is returned.
  50068. func (m WxCardUserMutation) Client() *Client {
  50069. client := &Client{config: m.config}
  50070. client.init()
  50071. return client
  50072. }
  50073. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50074. // it returns an error otherwise.
  50075. func (m WxCardUserMutation) Tx() (*Tx, error) {
  50076. if _, ok := m.driver.(*txDriver); !ok {
  50077. return nil, errors.New("ent: mutation is not running in a transaction")
  50078. }
  50079. tx := &Tx{config: m.config}
  50080. tx.init()
  50081. return tx, nil
  50082. }
  50083. // SetID sets the value of the id field. Note that this
  50084. // operation is only accepted on creation of WxCardUser entities.
  50085. func (m *WxCardUserMutation) SetID(id uint64) {
  50086. m.id = &id
  50087. }
  50088. // ID returns the ID value in the mutation. Note that the ID is only available
  50089. // if it was provided to the builder or after it was returned from the database.
  50090. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  50091. if m.id == nil {
  50092. return
  50093. }
  50094. return *m.id, true
  50095. }
  50096. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50097. // That means, if the mutation is applied within a transaction with an isolation level such
  50098. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50099. // or updated by the mutation.
  50100. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  50101. switch {
  50102. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50103. id, exists := m.ID()
  50104. if exists {
  50105. return []uint64{id}, nil
  50106. }
  50107. fallthrough
  50108. case m.op.Is(OpUpdate | OpDelete):
  50109. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  50110. default:
  50111. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50112. }
  50113. }
  50114. // SetCreatedAt sets the "created_at" field.
  50115. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  50116. m.created_at = &t
  50117. }
  50118. // CreatedAt returns the value of the "created_at" field in the mutation.
  50119. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  50120. v := m.created_at
  50121. if v == nil {
  50122. return
  50123. }
  50124. return *v, true
  50125. }
  50126. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  50127. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50129. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50130. if !m.op.Is(OpUpdateOne) {
  50131. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50132. }
  50133. if m.id == nil || m.oldValue == nil {
  50134. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50135. }
  50136. oldValue, err := m.oldValue(ctx)
  50137. if err != nil {
  50138. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50139. }
  50140. return oldValue.CreatedAt, nil
  50141. }
  50142. // ResetCreatedAt resets all changes to the "created_at" field.
  50143. func (m *WxCardUserMutation) ResetCreatedAt() {
  50144. m.created_at = nil
  50145. }
  50146. // SetUpdatedAt sets the "updated_at" field.
  50147. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  50148. m.updated_at = &t
  50149. }
  50150. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50151. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  50152. v := m.updated_at
  50153. if v == nil {
  50154. return
  50155. }
  50156. return *v, true
  50157. }
  50158. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  50159. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50161. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50162. if !m.op.Is(OpUpdateOne) {
  50163. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50164. }
  50165. if m.id == nil || m.oldValue == nil {
  50166. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50167. }
  50168. oldValue, err := m.oldValue(ctx)
  50169. if err != nil {
  50170. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50171. }
  50172. return oldValue.UpdatedAt, nil
  50173. }
  50174. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50175. func (m *WxCardUserMutation) ResetUpdatedAt() {
  50176. m.updated_at = nil
  50177. }
  50178. // SetDeletedAt sets the "deleted_at" field.
  50179. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  50180. m.deleted_at = &t
  50181. }
  50182. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50183. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  50184. v := m.deleted_at
  50185. if v == nil {
  50186. return
  50187. }
  50188. return *v, true
  50189. }
  50190. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  50191. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50193. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50194. if !m.op.Is(OpUpdateOne) {
  50195. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50196. }
  50197. if m.id == nil || m.oldValue == nil {
  50198. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50199. }
  50200. oldValue, err := m.oldValue(ctx)
  50201. if err != nil {
  50202. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50203. }
  50204. return oldValue.DeletedAt, nil
  50205. }
  50206. // ClearDeletedAt clears the value of the "deleted_at" field.
  50207. func (m *WxCardUserMutation) ClearDeletedAt() {
  50208. m.deleted_at = nil
  50209. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  50210. }
  50211. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50212. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  50213. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  50214. return ok
  50215. }
  50216. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50217. func (m *WxCardUserMutation) ResetDeletedAt() {
  50218. m.deleted_at = nil
  50219. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  50220. }
  50221. // SetWxid sets the "wxid" field.
  50222. func (m *WxCardUserMutation) SetWxid(s string) {
  50223. m.wxid = &s
  50224. }
  50225. // Wxid returns the value of the "wxid" field in the mutation.
  50226. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  50227. v := m.wxid
  50228. if v == nil {
  50229. return
  50230. }
  50231. return *v, true
  50232. }
  50233. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  50234. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50236. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  50237. if !m.op.Is(OpUpdateOne) {
  50238. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  50239. }
  50240. if m.id == nil || m.oldValue == nil {
  50241. return v, errors.New("OldWxid requires an ID field in the mutation")
  50242. }
  50243. oldValue, err := m.oldValue(ctx)
  50244. if err != nil {
  50245. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  50246. }
  50247. return oldValue.Wxid, nil
  50248. }
  50249. // ResetWxid resets all changes to the "wxid" field.
  50250. func (m *WxCardUserMutation) ResetWxid() {
  50251. m.wxid = nil
  50252. }
  50253. // SetAccount sets the "account" field.
  50254. func (m *WxCardUserMutation) SetAccount(s string) {
  50255. m.account = &s
  50256. }
  50257. // Account returns the value of the "account" field in the mutation.
  50258. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  50259. v := m.account
  50260. if v == nil {
  50261. return
  50262. }
  50263. return *v, true
  50264. }
  50265. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  50266. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50268. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  50269. if !m.op.Is(OpUpdateOne) {
  50270. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  50271. }
  50272. if m.id == nil || m.oldValue == nil {
  50273. return v, errors.New("OldAccount requires an ID field in the mutation")
  50274. }
  50275. oldValue, err := m.oldValue(ctx)
  50276. if err != nil {
  50277. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  50278. }
  50279. return oldValue.Account, nil
  50280. }
  50281. // ResetAccount resets all changes to the "account" field.
  50282. func (m *WxCardUserMutation) ResetAccount() {
  50283. m.account = nil
  50284. }
  50285. // SetAvatar sets the "avatar" field.
  50286. func (m *WxCardUserMutation) SetAvatar(s string) {
  50287. m.avatar = &s
  50288. }
  50289. // Avatar returns the value of the "avatar" field in the mutation.
  50290. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  50291. v := m.avatar
  50292. if v == nil {
  50293. return
  50294. }
  50295. return *v, true
  50296. }
  50297. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  50298. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50300. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  50301. if !m.op.Is(OpUpdateOne) {
  50302. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  50303. }
  50304. if m.id == nil || m.oldValue == nil {
  50305. return v, errors.New("OldAvatar requires an ID field in the mutation")
  50306. }
  50307. oldValue, err := m.oldValue(ctx)
  50308. if err != nil {
  50309. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  50310. }
  50311. return oldValue.Avatar, nil
  50312. }
  50313. // ResetAvatar resets all changes to the "avatar" field.
  50314. func (m *WxCardUserMutation) ResetAvatar() {
  50315. m.avatar = nil
  50316. }
  50317. // SetNickname sets the "nickname" field.
  50318. func (m *WxCardUserMutation) SetNickname(s string) {
  50319. m.nickname = &s
  50320. }
  50321. // Nickname returns the value of the "nickname" field in the mutation.
  50322. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  50323. v := m.nickname
  50324. if v == nil {
  50325. return
  50326. }
  50327. return *v, true
  50328. }
  50329. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  50330. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50332. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  50333. if !m.op.Is(OpUpdateOne) {
  50334. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  50335. }
  50336. if m.id == nil || m.oldValue == nil {
  50337. return v, errors.New("OldNickname requires an ID field in the mutation")
  50338. }
  50339. oldValue, err := m.oldValue(ctx)
  50340. if err != nil {
  50341. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  50342. }
  50343. return oldValue.Nickname, nil
  50344. }
  50345. // ResetNickname resets all changes to the "nickname" field.
  50346. func (m *WxCardUserMutation) ResetNickname() {
  50347. m.nickname = nil
  50348. }
  50349. // SetRemark sets the "remark" field.
  50350. func (m *WxCardUserMutation) SetRemark(s string) {
  50351. m.remark = &s
  50352. }
  50353. // Remark returns the value of the "remark" field in the mutation.
  50354. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  50355. v := m.remark
  50356. if v == nil {
  50357. return
  50358. }
  50359. return *v, true
  50360. }
  50361. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  50362. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50364. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  50365. if !m.op.Is(OpUpdateOne) {
  50366. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  50367. }
  50368. if m.id == nil || m.oldValue == nil {
  50369. return v, errors.New("OldRemark requires an ID field in the mutation")
  50370. }
  50371. oldValue, err := m.oldValue(ctx)
  50372. if err != nil {
  50373. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  50374. }
  50375. return oldValue.Remark, nil
  50376. }
  50377. // ResetRemark resets all changes to the "remark" field.
  50378. func (m *WxCardUserMutation) ResetRemark() {
  50379. m.remark = nil
  50380. }
  50381. // SetPhone sets the "phone" field.
  50382. func (m *WxCardUserMutation) SetPhone(s string) {
  50383. m.phone = &s
  50384. }
  50385. // Phone returns the value of the "phone" field in the mutation.
  50386. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  50387. v := m.phone
  50388. if v == nil {
  50389. return
  50390. }
  50391. return *v, true
  50392. }
  50393. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  50394. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50396. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  50397. if !m.op.Is(OpUpdateOne) {
  50398. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  50399. }
  50400. if m.id == nil || m.oldValue == nil {
  50401. return v, errors.New("OldPhone requires an ID field in the mutation")
  50402. }
  50403. oldValue, err := m.oldValue(ctx)
  50404. if err != nil {
  50405. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  50406. }
  50407. return oldValue.Phone, nil
  50408. }
  50409. // ResetPhone resets all changes to the "phone" field.
  50410. func (m *WxCardUserMutation) ResetPhone() {
  50411. m.phone = nil
  50412. }
  50413. // SetOpenID sets the "open_id" field.
  50414. func (m *WxCardUserMutation) SetOpenID(s string) {
  50415. m.open_id = &s
  50416. }
  50417. // OpenID returns the value of the "open_id" field in the mutation.
  50418. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  50419. v := m.open_id
  50420. if v == nil {
  50421. return
  50422. }
  50423. return *v, true
  50424. }
  50425. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  50426. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50428. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  50429. if !m.op.Is(OpUpdateOne) {
  50430. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  50431. }
  50432. if m.id == nil || m.oldValue == nil {
  50433. return v, errors.New("OldOpenID requires an ID field in the mutation")
  50434. }
  50435. oldValue, err := m.oldValue(ctx)
  50436. if err != nil {
  50437. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  50438. }
  50439. return oldValue.OpenID, nil
  50440. }
  50441. // ResetOpenID resets all changes to the "open_id" field.
  50442. func (m *WxCardUserMutation) ResetOpenID() {
  50443. m.open_id = nil
  50444. }
  50445. // SetUnionID sets the "union_id" field.
  50446. func (m *WxCardUserMutation) SetUnionID(s string) {
  50447. m.union_id = &s
  50448. }
  50449. // UnionID returns the value of the "union_id" field in the mutation.
  50450. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  50451. v := m.union_id
  50452. if v == nil {
  50453. return
  50454. }
  50455. return *v, true
  50456. }
  50457. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  50458. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50460. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  50461. if !m.op.Is(OpUpdateOne) {
  50462. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  50463. }
  50464. if m.id == nil || m.oldValue == nil {
  50465. return v, errors.New("OldUnionID requires an ID field in the mutation")
  50466. }
  50467. oldValue, err := m.oldValue(ctx)
  50468. if err != nil {
  50469. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  50470. }
  50471. return oldValue.UnionID, nil
  50472. }
  50473. // ResetUnionID resets all changes to the "union_id" field.
  50474. func (m *WxCardUserMutation) ResetUnionID() {
  50475. m.union_id = nil
  50476. }
  50477. // SetSessionKey sets the "session_key" field.
  50478. func (m *WxCardUserMutation) SetSessionKey(s string) {
  50479. m.session_key = &s
  50480. }
  50481. // SessionKey returns the value of the "session_key" field in the mutation.
  50482. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  50483. v := m.session_key
  50484. if v == nil {
  50485. return
  50486. }
  50487. return *v, true
  50488. }
  50489. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  50490. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50492. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  50493. if !m.op.Is(OpUpdateOne) {
  50494. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  50495. }
  50496. if m.id == nil || m.oldValue == nil {
  50497. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  50498. }
  50499. oldValue, err := m.oldValue(ctx)
  50500. if err != nil {
  50501. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  50502. }
  50503. return oldValue.SessionKey, nil
  50504. }
  50505. // ResetSessionKey resets all changes to the "session_key" field.
  50506. func (m *WxCardUserMutation) ResetSessionKey() {
  50507. m.session_key = nil
  50508. }
  50509. // SetIsVip sets the "is_vip" field.
  50510. func (m *WxCardUserMutation) SetIsVip(i int) {
  50511. m.is_vip = &i
  50512. m.addis_vip = nil
  50513. }
  50514. // IsVip returns the value of the "is_vip" field in the mutation.
  50515. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  50516. v := m.is_vip
  50517. if v == nil {
  50518. return
  50519. }
  50520. return *v, true
  50521. }
  50522. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  50523. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50525. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  50526. if !m.op.Is(OpUpdateOne) {
  50527. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  50528. }
  50529. if m.id == nil || m.oldValue == nil {
  50530. return v, errors.New("OldIsVip requires an ID field in the mutation")
  50531. }
  50532. oldValue, err := m.oldValue(ctx)
  50533. if err != nil {
  50534. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  50535. }
  50536. return oldValue.IsVip, nil
  50537. }
  50538. // AddIsVip adds i to the "is_vip" field.
  50539. func (m *WxCardUserMutation) AddIsVip(i int) {
  50540. if m.addis_vip != nil {
  50541. *m.addis_vip += i
  50542. } else {
  50543. m.addis_vip = &i
  50544. }
  50545. }
  50546. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  50547. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  50548. v := m.addis_vip
  50549. if v == nil {
  50550. return
  50551. }
  50552. return *v, true
  50553. }
  50554. // ResetIsVip resets all changes to the "is_vip" field.
  50555. func (m *WxCardUserMutation) ResetIsVip() {
  50556. m.is_vip = nil
  50557. m.addis_vip = nil
  50558. }
  50559. // Where appends a list predicates to the WxCardUserMutation builder.
  50560. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  50561. m.predicates = append(m.predicates, ps...)
  50562. }
  50563. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  50564. // users can use type-assertion to append predicates that do not depend on any generated package.
  50565. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  50566. p := make([]predicate.WxCardUser, len(ps))
  50567. for i := range ps {
  50568. p[i] = ps[i]
  50569. }
  50570. m.Where(p...)
  50571. }
  50572. // Op returns the operation name.
  50573. func (m *WxCardUserMutation) Op() Op {
  50574. return m.op
  50575. }
  50576. // SetOp allows setting the mutation operation.
  50577. func (m *WxCardUserMutation) SetOp(op Op) {
  50578. m.op = op
  50579. }
  50580. // Type returns the node type of this mutation (WxCardUser).
  50581. func (m *WxCardUserMutation) Type() string {
  50582. return m.typ
  50583. }
  50584. // Fields returns all fields that were changed during this mutation. Note that in
  50585. // order to get all numeric fields that were incremented/decremented, call
  50586. // AddedFields().
  50587. func (m *WxCardUserMutation) Fields() []string {
  50588. fields := make([]string, 0, 13)
  50589. if m.created_at != nil {
  50590. fields = append(fields, wxcarduser.FieldCreatedAt)
  50591. }
  50592. if m.updated_at != nil {
  50593. fields = append(fields, wxcarduser.FieldUpdatedAt)
  50594. }
  50595. if m.deleted_at != nil {
  50596. fields = append(fields, wxcarduser.FieldDeletedAt)
  50597. }
  50598. if m.wxid != nil {
  50599. fields = append(fields, wxcarduser.FieldWxid)
  50600. }
  50601. if m.account != nil {
  50602. fields = append(fields, wxcarduser.FieldAccount)
  50603. }
  50604. if m.avatar != nil {
  50605. fields = append(fields, wxcarduser.FieldAvatar)
  50606. }
  50607. if m.nickname != nil {
  50608. fields = append(fields, wxcarduser.FieldNickname)
  50609. }
  50610. if m.remark != nil {
  50611. fields = append(fields, wxcarduser.FieldRemark)
  50612. }
  50613. if m.phone != nil {
  50614. fields = append(fields, wxcarduser.FieldPhone)
  50615. }
  50616. if m.open_id != nil {
  50617. fields = append(fields, wxcarduser.FieldOpenID)
  50618. }
  50619. if m.union_id != nil {
  50620. fields = append(fields, wxcarduser.FieldUnionID)
  50621. }
  50622. if m.session_key != nil {
  50623. fields = append(fields, wxcarduser.FieldSessionKey)
  50624. }
  50625. if m.is_vip != nil {
  50626. fields = append(fields, wxcarduser.FieldIsVip)
  50627. }
  50628. return fields
  50629. }
  50630. // Field returns the value of a field with the given name. The second boolean
  50631. // return value indicates that this field was not set, or was not defined in the
  50632. // schema.
  50633. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  50634. switch name {
  50635. case wxcarduser.FieldCreatedAt:
  50636. return m.CreatedAt()
  50637. case wxcarduser.FieldUpdatedAt:
  50638. return m.UpdatedAt()
  50639. case wxcarduser.FieldDeletedAt:
  50640. return m.DeletedAt()
  50641. case wxcarduser.FieldWxid:
  50642. return m.Wxid()
  50643. case wxcarduser.FieldAccount:
  50644. return m.Account()
  50645. case wxcarduser.FieldAvatar:
  50646. return m.Avatar()
  50647. case wxcarduser.FieldNickname:
  50648. return m.Nickname()
  50649. case wxcarduser.FieldRemark:
  50650. return m.Remark()
  50651. case wxcarduser.FieldPhone:
  50652. return m.Phone()
  50653. case wxcarduser.FieldOpenID:
  50654. return m.OpenID()
  50655. case wxcarduser.FieldUnionID:
  50656. return m.UnionID()
  50657. case wxcarduser.FieldSessionKey:
  50658. return m.SessionKey()
  50659. case wxcarduser.FieldIsVip:
  50660. return m.IsVip()
  50661. }
  50662. return nil, false
  50663. }
  50664. // OldField returns the old value of the field from the database. An error is
  50665. // returned if the mutation operation is not UpdateOne, or the query to the
  50666. // database failed.
  50667. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50668. switch name {
  50669. case wxcarduser.FieldCreatedAt:
  50670. return m.OldCreatedAt(ctx)
  50671. case wxcarduser.FieldUpdatedAt:
  50672. return m.OldUpdatedAt(ctx)
  50673. case wxcarduser.FieldDeletedAt:
  50674. return m.OldDeletedAt(ctx)
  50675. case wxcarduser.FieldWxid:
  50676. return m.OldWxid(ctx)
  50677. case wxcarduser.FieldAccount:
  50678. return m.OldAccount(ctx)
  50679. case wxcarduser.FieldAvatar:
  50680. return m.OldAvatar(ctx)
  50681. case wxcarduser.FieldNickname:
  50682. return m.OldNickname(ctx)
  50683. case wxcarduser.FieldRemark:
  50684. return m.OldRemark(ctx)
  50685. case wxcarduser.FieldPhone:
  50686. return m.OldPhone(ctx)
  50687. case wxcarduser.FieldOpenID:
  50688. return m.OldOpenID(ctx)
  50689. case wxcarduser.FieldUnionID:
  50690. return m.OldUnionID(ctx)
  50691. case wxcarduser.FieldSessionKey:
  50692. return m.OldSessionKey(ctx)
  50693. case wxcarduser.FieldIsVip:
  50694. return m.OldIsVip(ctx)
  50695. }
  50696. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  50697. }
  50698. // SetField sets the value of a field with the given name. It returns an error if
  50699. // the field is not defined in the schema, or if the type mismatched the field
  50700. // type.
  50701. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  50702. switch name {
  50703. case wxcarduser.FieldCreatedAt:
  50704. v, ok := value.(time.Time)
  50705. if !ok {
  50706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50707. }
  50708. m.SetCreatedAt(v)
  50709. return nil
  50710. case wxcarduser.FieldUpdatedAt:
  50711. v, ok := value.(time.Time)
  50712. if !ok {
  50713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50714. }
  50715. m.SetUpdatedAt(v)
  50716. return nil
  50717. case wxcarduser.FieldDeletedAt:
  50718. v, ok := value.(time.Time)
  50719. if !ok {
  50720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50721. }
  50722. m.SetDeletedAt(v)
  50723. return nil
  50724. case wxcarduser.FieldWxid:
  50725. v, ok := value.(string)
  50726. if !ok {
  50727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50728. }
  50729. m.SetWxid(v)
  50730. return nil
  50731. case wxcarduser.FieldAccount:
  50732. v, ok := value.(string)
  50733. if !ok {
  50734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50735. }
  50736. m.SetAccount(v)
  50737. return nil
  50738. case wxcarduser.FieldAvatar:
  50739. v, ok := value.(string)
  50740. if !ok {
  50741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50742. }
  50743. m.SetAvatar(v)
  50744. return nil
  50745. case wxcarduser.FieldNickname:
  50746. v, ok := value.(string)
  50747. if !ok {
  50748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50749. }
  50750. m.SetNickname(v)
  50751. return nil
  50752. case wxcarduser.FieldRemark:
  50753. v, ok := value.(string)
  50754. if !ok {
  50755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50756. }
  50757. m.SetRemark(v)
  50758. return nil
  50759. case wxcarduser.FieldPhone:
  50760. v, ok := value.(string)
  50761. if !ok {
  50762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50763. }
  50764. m.SetPhone(v)
  50765. return nil
  50766. case wxcarduser.FieldOpenID:
  50767. v, ok := value.(string)
  50768. if !ok {
  50769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50770. }
  50771. m.SetOpenID(v)
  50772. return nil
  50773. case wxcarduser.FieldUnionID:
  50774. v, ok := value.(string)
  50775. if !ok {
  50776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50777. }
  50778. m.SetUnionID(v)
  50779. return nil
  50780. case wxcarduser.FieldSessionKey:
  50781. v, ok := value.(string)
  50782. if !ok {
  50783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50784. }
  50785. m.SetSessionKey(v)
  50786. return nil
  50787. case wxcarduser.FieldIsVip:
  50788. v, ok := value.(int)
  50789. if !ok {
  50790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50791. }
  50792. m.SetIsVip(v)
  50793. return nil
  50794. }
  50795. return fmt.Errorf("unknown WxCardUser field %s", name)
  50796. }
  50797. // AddedFields returns all numeric fields that were incremented/decremented during
  50798. // this mutation.
  50799. func (m *WxCardUserMutation) AddedFields() []string {
  50800. var fields []string
  50801. if m.addis_vip != nil {
  50802. fields = append(fields, wxcarduser.FieldIsVip)
  50803. }
  50804. return fields
  50805. }
  50806. // AddedField returns the numeric value that was incremented/decremented on a field
  50807. // with the given name. The second boolean return value indicates that this field
  50808. // was not set, or was not defined in the schema.
  50809. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  50810. switch name {
  50811. case wxcarduser.FieldIsVip:
  50812. return m.AddedIsVip()
  50813. }
  50814. return nil, false
  50815. }
  50816. // AddField adds the value to the field with the given name. It returns an error if
  50817. // the field is not defined in the schema, or if the type mismatched the field
  50818. // type.
  50819. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  50820. switch name {
  50821. case wxcarduser.FieldIsVip:
  50822. v, ok := value.(int)
  50823. if !ok {
  50824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50825. }
  50826. m.AddIsVip(v)
  50827. return nil
  50828. }
  50829. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  50830. }
  50831. // ClearedFields returns all nullable fields that were cleared during this
  50832. // mutation.
  50833. func (m *WxCardUserMutation) ClearedFields() []string {
  50834. var fields []string
  50835. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  50836. fields = append(fields, wxcarduser.FieldDeletedAt)
  50837. }
  50838. return fields
  50839. }
  50840. // FieldCleared returns a boolean indicating if a field with the given name was
  50841. // cleared in this mutation.
  50842. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  50843. _, ok := m.clearedFields[name]
  50844. return ok
  50845. }
  50846. // ClearField clears the value of the field with the given name. It returns an
  50847. // error if the field is not defined in the schema.
  50848. func (m *WxCardUserMutation) ClearField(name string) error {
  50849. switch name {
  50850. case wxcarduser.FieldDeletedAt:
  50851. m.ClearDeletedAt()
  50852. return nil
  50853. }
  50854. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  50855. }
  50856. // ResetField resets all changes in the mutation for the field with the given name.
  50857. // It returns an error if the field is not defined in the schema.
  50858. func (m *WxCardUserMutation) ResetField(name string) error {
  50859. switch name {
  50860. case wxcarduser.FieldCreatedAt:
  50861. m.ResetCreatedAt()
  50862. return nil
  50863. case wxcarduser.FieldUpdatedAt:
  50864. m.ResetUpdatedAt()
  50865. return nil
  50866. case wxcarduser.FieldDeletedAt:
  50867. m.ResetDeletedAt()
  50868. return nil
  50869. case wxcarduser.FieldWxid:
  50870. m.ResetWxid()
  50871. return nil
  50872. case wxcarduser.FieldAccount:
  50873. m.ResetAccount()
  50874. return nil
  50875. case wxcarduser.FieldAvatar:
  50876. m.ResetAvatar()
  50877. return nil
  50878. case wxcarduser.FieldNickname:
  50879. m.ResetNickname()
  50880. return nil
  50881. case wxcarduser.FieldRemark:
  50882. m.ResetRemark()
  50883. return nil
  50884. case wxcarduser.FieldPhone:
  50885. m.ResetPhone()
  50886. return nil
  50887. case wxcarduser.FieldOpenID:
  50888. m.ResetOpenID()
  50889. return nil
  50890. case wxcarduser.FieldUnionID:
  50891. m.ResetUnionID()
  50892. return nil
  50893. case wxcarduser.FieldSessionKey:
  50894. m.ResetSessionKey()
  50895. return nil
  50896. case wxcarduser.FieldIsVip:
  50897. m.ResetIsVip()
  50898. return nil
  50899. }
  50900. return fmt.Errorf("unknown WxCardUser field %s", name)
  50901. }
  50902. // AddedEdges returns all edge names that were set/added in this mutation.
  50903. func (m *WxCardUserMutation) AddedEdges() []string {
  50904. edges := make([]string, 0, 0)
  50905. return edges
  50906. }
  50907. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50908. // name in this mutation.
  50909. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  50910. return nil
  50911. }
  50912. // RemovedEdges returns all edge names that were removed in this mutation.
  50913. func (m *WxCardUserMutation) RemovedEdges() []string {
  50914. edges := make([]string, 0, 0)
  50915. return edges
  50916. }
  50917. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50918. // the given name in this mutation.
  50919. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  50920. return nil
  50921. }
  50922. // ClearedEdges returns all edge names that were cleared in this mutation.
  50923. func (m *WxCardUserMutation) ClearedEdges() []string {
  50924. edges := make([]string, 0, 0)
  50925. return edges
  50926. }
  50927. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50928. // was cleared in this mutation.
  50929. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  50930. return false
  50931. }
  50932. // ClearEdge clears the value of the edge with the given name. It returns an error
  50933. // if that edge is not defined in the schema.
  50934. func (m *WxCardUserMutation) ClearEdge(name string) error {
  50935. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  50936. }
  50937. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50938. // It returns an error if the edge is not defined in the schema.
  50939. func (m *WxCardUserMutation) ResetEdge(name string) error {
  50940. return fmt.Errorf("unknown WxCardUser edge %s", name)
  50941. }
  50942. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  50943. type WxCardVisitMutation struct {
  50944. config
  50945. op Op
  50946. typ string
  50947. id *uint64
  50948. created_at *time.Time
  50949. updated_at *time.Time
  50950. deleted_at *time.Time
  50951. user_id *uint64
  50952. adduser_id *int64
  50953. bot_id *uint64
  50954. addbot_id *int64
  50955. bot_type *uint8
  50956. addbot_type *int8
  50957. clearedFields map[string]struct{}
  50958. done bool
  50959. oldValue func(context.Context) (*WxCardVisit, error)
  50960. predicates []predicate.WxCardVisit
  50961. }
  50962. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  50963. // wxcardvisitOption allows management of the mutation configuration using functional options.
  50964. type wxcardvisitOption func(*WxCardVisitMutation)
  50965. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  50966. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  50967. m := &WxCardVisitMutation{
  50968. config: c,
  50969. op: op,
  50970. typ: TypeWxCardVisit,
  50971. clearedFields: make(map[string]struct{}),
  50972. }
  50973. for _, opt := range opts {
  50974. opt(m)
  50975. }
  50976. return m
  50977. }
  50978. // withWxCardVisitID sets the ID field of the mutation.
  50979. func withWxCardVisitID(id uint64) wxcardvisitOption {
  50980. return func(m *WxCardVisitMutation) {
  50981. var (
  50982. err error
  50983. once sync.Once
  50984. value *WxCardVisit
  50985. )
  50986. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  50987. once.Do(func() {
  50988. if m.done {
  50989. err = errors.New("querying old values post mutation is not allowed")
  50990. } else {
  50991. value, err = m.Client().WxCardVisit.Get(ctx, id)
  50992. }
  50993. })
  50994. return value, err
  50995. }
  50996. m.id = &id
  50997. }
  50998. }
  50999. // withWxCardVisit sets the old WxCardVisit of the mutation.
  51000. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  51001. return func(m *WxCardVisitMutation) {
  51002. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  51003. return node, nil
  51004. }
  51005. m.id = &node.ID
  51006. }
  51007. }
  51008. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51009. // executed in a transaction (ent.Tx), a transactional client is returned.
  51010. func (m WxCardVisitMutation) Client() *Client {
  51011. client := &Client{config: m.config}
  51012. client.init()
  51013. return client
  51014. }
  51015. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51016. // it returns an error otherwise.
  51017. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  51018. if _, ok := m.driver.(*txDriver); !ok {
  51019. return nil, errors.New("ent: mutation is not running in a transaction")
  51020. }
  51021. tx := &Tx{config: m.config}
  51022. tx.init()
  51023. return tx, nil
  51024. }
  51025. // SetID sets the value of the id field. Note that this
  51026. // operation is only accepted on creation of WxCardVisit entities.
  51027. func (m *WxCardVisitMutation) SetID(id uint64) {
  51028. m.id = &id
  51029. }
  51030. // ID returns the ID value in the mutation. Note that the ID is only available
  51031. // if it was provided to the builder or after it was returned from the database.
  51032. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  51033. if m.id == nil {
  51034. return
  51035. }
  51036. return *m.id, true
  51037. }
  51038. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51039. // That means, if the mutation is applied within a transaction with an isolation level such
  51040. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51041. // or updated by the mutation.
  51042. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  51043. switch {
  51044. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51045. id, exists := m.ID()
  51046. if exists {
  51047. return []uint64{id}, nil
  51048. }
  51049. fallthrough
  51050. case m.op.Is(OpUpdate | OpDelete):
  51051. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  51052. default:
  51053. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51054. }
  51055. }
  51056. // SetCreatedAt sets the "created_at" field.
  51057. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  51058. m.created_at = &t
  51059. }
  51060. // CreatedAt returns the value of the "created_at" field in the mutation.
  51061. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  51062. v := m.created_at
  51063. if v == nil {
  51064. return
  51065. }
  51066. return *v, true
  51067. }
  51068. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  51069. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51071. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51072. if !m.op.Is(OpUpdateOne) {
  51073. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51074. }
  51075. if m.id == nil || m.oldValue == nil {
  51076. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51077. }
  51078. oldValue, err := m.oldValue(ctx)
  51079. if err != nil {
  51080. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51081. }
  51082. return oldValue.CreatedAt, nil
  51083. }
  51084. // ResetCreatedAt resets all changes to the "created_at" field.
  51085. func (m *WxCardVisitMutation) ResetCreatedAt() {
  51086. m.created_at = nil
  51087. }
  51088. // SetUpdatedAt sets the "updated_at" field.
  51089. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  51090. m.updated_at = &t
  51091. }
  51092. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51093. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  51094. v := m.updated_at
  51095. if v == nil {
  51096. return
  51097. }
  51098. return *v, true
  51099. }
  51100. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  51101. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51103. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51104. if !m.op.Is(OpUpdateOne) {
  51105. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51106. }
  51107. if m.id == nil || m.oldValue == nil {
  51108. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51109. }
  51110. oldValue, err := m.oldValue(ctx)
  51111. if err != nil {
  51112. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51113. }
  51114. return oldValue.UpdatedAt, nil
  51115. }
  51116. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51117. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  51118. m.updated_at = nil
  51119. }
  51120. // SetDeletedAt sets the "deleted_at" field.
  51121. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  51122. m.deleted_at = &t
  51123. }
  51124. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51125. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  51126. v := m.deleted_at
  51127. if v == nil {
  51128. return
  51129. }
  51130. return *v, true
  51131. }
  51132. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  51133. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51135. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51136. if !m.op.Is(OpUpdateOne) {
  51137. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51138. }
  51139. if m.id == nil || m.oldValue == nil {
  51140. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51141. }
  51142. oldValue, err := m.oldValue(ctx)
  51143. if err != nil {
  51144. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51145. }
  51146. return oldValue.DeletedAt, nil
  51147. }
  51148. // ClearDeletedAt clears the value of the "deleted_at" field.
  51149. func (m *WxCardVisitMutation) ClearDeletedAt() {
  51150. m.deleted_at = nil
  51151. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  51152. }
  51153. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51154. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  51155. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  51156. return ok
  51157. }
  51158. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51159. func (m *WxCardVisitMutation) ResetDeletedAt() {
  51160. m.deleted_at = nil
  51161. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  51162. }
  51163. // SetUserID sets the "user_id" field.
  51164. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  51165. m.user_id = &u
  51166. m.adduser_id = nil
  51167. }
  51168. // UserID returns the value of the "user_id" field in the mutation.
  51169. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  51170. v := m.user_id
  51171. if v == nil {
  51172. return
  51173. }
  51174. return *v, true
  51175. }
  51176. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  51177. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51179. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  51180. if !m.op.Is(OpUpdateOne) {
  51181. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  51182. }
  51183. if m.id == nil || m.oldValue == nil {
  51184. return v, errors.New("OldUserID requires an ID field in the mutation")
  51185. }
  51186. oldValue, err := m.oldValue(ctx)
  51187. if err != nil {
  51188. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  51189. }
  51190. return oldValue.UserID, nil
  51191. }
  51192. // AddUserID adds u to the "user_id" field.
  51193. func (m *WxCardVisitMutation) AddUserID(u int64) {
  51194. if m.adduser_id != nil {
  51195. *m.adduser_id += u
  51196. } else {
  51197. m.adduser_id = &u
  51198. }
  51199. }
  51200. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  51201. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  51202. v := m.adduser_id
  51203. if v == nil {
  51204. return
  51205. }
  51206. return *v, true
  51207. }
  51208. // ClearUserID clears the value of the "user_id" field.
  51209. func (m *WxCardVisitMutation) ClearUserID() {
  51210. m.user_id = nil
  51211. m.adduser_id = nil
  51212. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  51213. }
  51214. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  51215. func (m *WxCardVisitMutation) UserIDCleared() bool {
  51216. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  51217. return ok
  51218. }
  51219. // ResetUserID resets all changes to the "user_id" field.
  51220. func (m *WxCardVisitMutation) ResetUserID() {
  51221. m.user_id = nil
  51222. m.adduser_id = nil
  51223. delete(m.clearedFields, wxcardvisit.FieldUserID)
  51224. }
  51225. // SetBotID sets the "bot_id" field.
  51226. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  51227. m.bot_id = &u
  51228. m.addbot_id = nil
  51229. }
  51230. // BotID returns the value of the "bot_id" field in the mutation.
  51231. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  51232. v := m.bot_id
  51233. if v == nil {
  51234. return
  51235. }
  51236. return *v, true
  51237. }
  51238. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  51239. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51241. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  51242. if !m.op.Is(OpUpdateOne) {
  51243. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  51244. }
  51245. if m.id == nil || m.oldValue == nil {
  51246. return v, errors.New("OldBotID requires an ID field in the mutation")
  51247. }
  51248. oldValue, err := m.oldValue(ctx)
  51249. if err != nil {
  51250. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  51251. }
  51252. return oldValue.BotID, nil
  51253. }
  51254. // AddBotID adds u to the "bot_id" field.
  51255. func (m *WxCardVisitMutation) AddBotID(u int64) {
  51256. if m.addbot_id != nil {
  51257. *m.addbot_id += u
  51258. } else {
  51259. m.addbot_id = &u
  51260. }
  51261. }
  51262. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  51263. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  51264. v := m.addbot_id
  51265. if v == nil {
  51266. return
  51267. }
  51268. return *v, true
  51269. }
  51270. // ResetBotID resets all changes to the "bot_id" field.
  51271. func (m *WxCardVisitMutation) ResetBotID() {
  51272. m.bot_id = nil
  51273. m.addbot_id = nil
  51274. }
  51275. // SetBotType sets the "bot_type" field.
  51276. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  51277. m.bot_type = &u
  51278. m.addbot_type = nil
  51279. }
  51280. // BotType returns the value of the "bot_type" field in the mutation.
  51281. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  51282. v := m.bot_type
  51283. if v == nil {
  51284. return
  51285. }
  51286. return *v, true
  51287. }
  51288. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  51289. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51291. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  51292. if !m.op.Is(OpUpdateOne) {
  51293. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  51294. }
  51295. if m.id == nil || m.oldValue == nil {
  51296. return v, errors.New("OldBotType requires an ID field in the mutation")
  51297. }
  51298. oldValue, err := m.oldValue(ctx)
  51299. if err != nil {
  51300. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  51301. }
  51302. return oldValue.BotType, nil
  51303. }
  51304. // AddBotType adds u to the "bot_type" field.
  51305. func (m *WxCardVisitMutation) AddBotType(u int8) {
  51306. if m.addbot_type != nil {
  51307. *m.addbot_type += u
  51308. } else {
  51309. m.addbot_type = &u
  51310. }
  51311. }
  51312. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  51313. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  51314. v := m.addbot_type
  51315. if v == nil {
  51316. return
  51317. }
  51318. return *v, true
  51319. }
  51320. // ResetBotType resets all changes to the "bot_type" field.
  51321. func (m *WxCardVisitMutation) ResetBotType() {
  51322. m.bot_type = nil
  51323. m.addbot_type = nil
  51324. }
  51325. // Where appends a list predicates to the WxCardVisitMutation builder.
  51326. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  51327. m.predicates = append(m.predicates, ps...)
  51328. }
  51329. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  51330. // users can use type-assertion to append predicates that do not depend on any generated package.
  51331. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  51332. p := make([]predicate.WxCardVisit, len(ps))
  51333. for i := range ps {
  51334. p[i] = ps[i]
  51335. }
  51336. m.Where(p...)
  51337. }
  51338. // Op returns the operation name.
  51339. func (m *WxCardVisitMutation) Op() Op {
  51340. return m.op
  51341. }
  51342. // SetOp allows setting the mutation operation.
  51343. func (m *WxCardVisitMutation) SetOp(op Op) {
  51344. m.op = op
  51345. }
  51346. // Type returns the node type of this mutation (WxCardVisit).
  51347. func (m *WxCardVisitMutation) Type() string {
  51348. return m.typ
  51349. }
  51350. // Fields returns all fields that were changed during this mutation. Note that in
  51351. // order to get all numeric fields that were incremented/decremented, call
  51352. // AddedFields().
  51353. func (m *WxCardVisitMutation) Fields() []string {
  51354. fields := make([]string, 0, 6)
  51355. if m.created_at != nil {
  51356. fields = append(fields, wxcardvisit.FieldCreatedAt)
  51357. }
  51358. if m.updated_at != nil {
  51359. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  51360. }
  51361. if m.deleted_at != nil {
  51362. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51363. }
  51364. if m.user_id != nil {
  51365. fields = append(fields, wxcardvisit.FieldUserID)
  51366. }
  51367. if m.bot_id != nil {
  51368. fields = append(fields, wxcardvisit.FieldBotID)
  51369. }
  51370. if m.bot_type != nil {
  51371. fields = append(fields, wxcardvisit.FieldBotType)
  51372. }
  51373. return fields
  51374. }
  51375. // Field returns the value of a field with the given name. The second boolean
  51376. // return value indicates that this field was not set, or was not defined in the
  51377. // schema.
  51378. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  51379. switch name {
  51380. case wxcardvisit.FieldCreatedAt:
  51381. return m.CreatedAt()
  51382. case wxcardvisit.FieldUpdatedAt:
  51383. return m.UpdatedAt()
  51384. case wxcardvisit.FieldDeletedAt:
  51385. return m.DeletedAt()
  51386. case wxcardvisit.FieldUserID:
  51387. return m.UserID()
  51388. case wxcardvisit.FieldBotID:
  51389. return m.BotID()
  51390. case wxcardvisit.FieldBotType:
  51391. return m.BotType()
  51392. }
  51393. return nil, false
  51394. }
  51395. // OldField returns the old value of the field from the database. An error is
  51396. // returned if the mutation operation is not UpdateOne, or the query to the
  51397. // database failed.
  51398. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51399. switch name {
  51400. case wxcardvisit.FieldCreatedAt:
  51401. return m.OldCreatedAt(ctx)
  51402. case wxcardvisit.FieldUpdatedAt:
  51403. return m.OldUpdatedAt(ctx)
  51404. case wxcardvisit.FieldDeletedAt:
  51405. return m.OldDeletedAt(ctx)
  51406. case wxcardvisit.FieldUserID:
  51407. return m.OldUserID(ctx)
  51408. case wxcardvisit.FieldBotID:
  51409. return m.OldBotID(ctx)
  51410. case wxcardvisit.FieldBotType:
  51411. return m.OldBotType(ctx)
  51412. }
  51413. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  51414. }
  51415. // SetField sets the value of a field with the given name. It returns an error if
  51416. // the field is not defined in the schema, or if the type mismatched the field
  51417. // type.
  51418. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  51419. switch name {
  51420. case wxcardvisit.FieldCreatedAt:
  51421. v, ok := value.(time.Time)
  51422. if !ok {
  51423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51424. }
  51425. m.SetCreatedAt(v)
  51426. return nil
  51427. case wxcardvisit.FieldUpdatedAt:
  51428. v, ok := value.(time.Time)
  51429. if !ok {
  51430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51431. }
  51432. m.SetUpdatedAt(v)
  51433. return nil
  51434. case wxcardvisit.FieldDeletedAt:
  51435. v, ok := value.(time.Time)
  51436. if !ok {
  51437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51438. }
  51439. m.SetDeletedAt(v)
  51440. return nil
  51441. case wxcardvisit.FieldUserID:
  51442. v, ok := value.(uint64)
  51443. if !ok {
  51444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51445. }
  51446. m.SetUserID(v)
  51447. return nil
  51448. case wxcardvisit.FieldBotID:
  51449. v, ok := value.(uint64)
  51450. if !ok {
  51451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51452. }
  51453. m.SetBotID(v)
  51454. return nil
  51455. case wxcardvisit.FieldBotType:
  51456. v, ok := value.(uint8)
  51457. if !ok {
  51458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51459. }
  51460. m.SetBotType(v)
  51461. return nil
  51462. }
  51463. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51464. }
  51465. // AddedFields returns all numeric fields that were incremented/decremented during
  51466. // this mutation.
  51467. func (m *WxCardVisitMutation) AddedFields() []string {
  51468. var fields []string
  51469. if m.adduser_id != nil {
  51470. fields = append(fields, wxcardvisit.FieldUserID)
  51471. }
  51472. if m.addbot_id != nil {
  51473. fields = append(fields, wxcardvisit.FieldBotID)
  51474. }
  51475. if m.addbot_type != nil {
  51476. fields = append(fields, wxcardvisit.FieldBotType)
  51477. }
  51478. return fields
  51479. }
  51480. // AddedField returns the numeric value that was incremented/decremented on a field
  51481. // with the given name. The second boolean return value indicates that this field
  51482. // was not set, or was not defined in the schema.
  51483. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  51484. switch name {
  51485. case wxcardvisit.FieldUserID:
  51486. return m.AddedUserID()
  51487. case wxcardvisit.FieldBotID:
  51488. return m.AddedBotID()
  51489. case wxcardvisit.FieldBotType:
  51490. return m.AddedBotType()
  51491. }
  51492. return nil, false
  51493. }
  51494. // AddField adds the value to the field with the given name. It returns an error if
  51495. // the field is not defined in the schema, or if the type mismatched the field
  51496. // type.
  51497. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  51498. switch name {
  51499. case wxcardvisit.FieldUserID:
  51500. v, ok := value.(int64)
  51501. if !ok {
  51502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51503. }
  51504. m.AddUserID(v)
  51505. return nil
  51506. case wxcardvisit.FieldBotID:
  51507. v, ok := value.(int64)
  51508. if !ok {
  51509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51510. }
  51511. m.AddBotID(v)
  51512. return nil
  51513. case wxcardvisit.FieldBotType:
  51514. v, ok := value.(int8)
  51515. if !ok {
  51516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51517. }
  51518. m.AddBotType(v)
  51519. return nil
  51520. }
  51521. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  51522. }
  51523. // ClearedFields returns all nullable fields that were cleared during this
  51524. // mutation.
  51525. func (m *WxCardVisitMutation) ClearedFields() []string {
  51526. var fields []string
  51527. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  51528. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51529. }
  51530. if m.FieldCleared(wxcardvisit.FieldUserID) {
  51531. fields = append(fields, wxcardvisit.FieldUserID)
  51532. }
  51533. return fields
  51534. }
  51535. // FieldCleared returns a boolean indicating if a field with the given name was
  51536. // cleared in this mutation.
  51537. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  51538. _, ok := m.clearedFields[name]
  51539. return ok
  51540. }
  51541. // ClearField clears the value of the field with the given name. It returns an
  51542. // error if the field is not defined in the schema.
  51543. func (m *WxCardVisitMutation) ClearField(name string) error {
  51544. switch name {
  51545. case wxcardvisit.FieldDeletedAt:
  51546. m.ClearDeletedAt()
  51547. return nil
  51548. case wxcardvisit.FieldUserID:
  51549. m.ClearUserID()
  51550. return nil
  51551. }
  51552. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  51553. }
  51554. // ResetField resets all changes in the mutation for the field with the given name.
  51555. // It returns an error if the field is not defined in the schema.
  51556. func (m *WxCardVisitMutation) ResetField(name string) error {
  51557. switch name {
  51558. case wxcardvisit.FieldCreatedAt:
  51559. m.ResetCreatedAt()
  51560. return nil
  51561. case wxcardvisit.FieldUpdatedAt:
  51562. m.ResetUpdatedAt()
  51563. return nil
  51564. case wxcardvisit.FieldDeletedAt:
  51565. m.ResetDeletedAt()
  51566. return nil
  51567. case wxcardvisit.FieldUserID:
  51568. m.ResetUserID()
  51569. return nil
  51570. case wxcardvisit.FieldBotID:
  51571. m.ResetBotID()
  51572. return nil
  51573. case wxcardvisit.FieldBotType:
  51574. m.ResetBotType()
  51575. return nil
  51576. }
  51577. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51578. }
  51579. // AddedEdges returns all edge names that were set/added in this mutation.
  51580. func (m *WxCardVisitMutation) AddedEdges() []string {
  51581. edges := make([]string, 0, 0)
  51582. return edges
  51583. }
  51584. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51585. // name in this mutation.
  51586. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  51587. return nil
  51588. }
  51589. // RemovedEdges returns all edge names that were removed in this mutation.
  51590. func (m *WxCardVisitMutation) RemovedEdges() []string {
  51591. edges := make([]string, 0, 0)
  51592. return edges
  51593. }
  51594. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51595. // the given name in this mutation.
  51596. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  51597. return nil
  51598. }
  51599. // ClearedEdges returns all edge names that were cleared in this mutation.
  51600. func (m *WxCardVisitMutation) ClearedEdges() []string {
  51601. edges := make([]string, 0, 0)
  51602. return edges
  51603. }
  51604. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51605. // was cleared in this mutation.
  51606. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  51607. return false
  51608. }
  51609. // ClearEdge clears the value of the edge with the given name. It returns an error
  51610. // if that edge is not defined in the schema.
  51611. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  51612. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  51613. }
  51614. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51615. // It returns an error if the edge is not defined in the schema.
  51616. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  51617. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  51618. }
  51619. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  51620. type XunjiMutation struct {
  51621. config
  51622. op Op
  51623. typ string
  51624. id *uint64
  51625. created_at *time.Time
  51626. updated_at *time.Time
  51627. status *uint8
  51628. addstatus *int8
  51629. deleted_at *time.Time
  51630. app_key *string
  51631. app_secret *string
  51632. token *string
  51633. encoding_key *string
  51634. organization_id *uint64
  51635. addorganization_id *int64
  51636. clearedFields map[string]struct{}
  51637. done bool
  51638. oldValue func(context.Context) (*Xunji, error)
  51639. predicates []predicate.Xunji
  51640. }
  51641. var _ ent.Mutation = (*XunjiMutation)(nil)
  51642. // xunjiOption allows management of the mutation configuration using functional options.
  51643. type xunjiOption func(*XunjiMutation)
  51644. // newXunjiMutation creates new mutation for the Xunji entity.
  51645. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  51646. m := &XunjiMutation{
  51647. config: c,
  51648. op: op,
  51649. typ: TypeXunji,
  51650. clearedFields: make(map[string]struct{}),
  51651. }
  51652. for _, opt := range opts {
  51653. opt(m)
  51654. }
  51655. return m
  51656. }
  51657. // withXunjiID sets the ID field of the mutation.
  51658. func withXunjiID(id uint64) xunjiOption {
  51659. return func(m *XunjiMutation) {
  51660. var (
  51661. err error
  51662. once sync.Once
  51663. value *Xunji
  51664. )
  51665. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  51666. once.Do(func() {
  51667. if m.done {
  51668. err = errors.New("querying old values post mutation is not allowed")
  51669. } else {
  51670. value, err = m.Client().Xunji.Get(ctx, id)
  51671. }
  51672. })
  51673. return value, err
  51674. }
  51675. m.id = &id
  51676. }
  51677. }
  51678. // withXunji sets the old Xunji of the mutation.
  51679. func withXunji(node *Xunji) xunjiOption {
  51680. return func(m *XunjiMutation) {
  51681. m.oldValue = func(context.Context) (*Xunji, error) {
  51682. return node, nil
  51683. }
  51684. m.id = &node.ID
  51685. }
  51686. }
  51687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51688. // executed in a transaction (ent.Tx), a transactional client is returned.
  51689. func (m XunjiMutation) Client() *Client {
  51690. client := &Client{config: m.config}
  51691. client.init()
  51692. return client
  51693. }
  51694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51695. // it returns an error otherwise.
  51696. func (m XunjiMutation) Tx() (*Tx, error) {
  51697. if _, ok := m.driver.(*txDriver); !ok {
  51698. return nil, errors.New("ent: mutation is not running in a transaction")
  51699. }
  51700. tx := &Tx{config: m.config}
  51701. tx.init()
  51702. return tx, nil
  51703. }
  51704. // SetID sets the value of the id field. Note that this
  51705. // operation is only accepted on creation of Xunji entities.
  51706. func (m *XunjiMutation) SetID(id uint64) {
  51707. m.id = &id
  51708. }
  51709. // ID returns the ID value in the mutation. Note that the ID is only available
  51710. // if it was provided to the builder or after it was returned from the database.
  51711. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  51712. if m.id == nil {
  51713. return
  51714. }
  51715. return *m.id, true
  51716. }
  51717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51718. // That means, if the mutation is applied within a transaction with an isolation level such
  51719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51720. // or updated by the mutation.
  51721. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  51722. switch {
  51723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51724. id, exists := m.ID()
  51725. if exists {
  51726. return []uint64{id}, nil
  51727. }
  51728. fallthrough
  51729. case m.op.Is(OpUpdate | OpDelete):
  51730. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  51731. default:
  51732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51733. }
  51734. }
  51735. // SetCreatedAt sets the "created_at" field.
  51736. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  51737. m.created_at = &t
  51738. }
  51739. // CreatedAt returns the value of the "created_at" field in the mutation.
  51740. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  51741. v := m.created_at
  51742. if v == nil {
  51743. return
  51744. }
  51745. return *v, true
  51746. }
  51747. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  51748. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51750. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51751. if !m.op.Is(OpUpdateOne) {
  51752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51753. }
  51754. if m.id == nil || m.oldValue == nil {
  51755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51756. }
  51757. oldValue, err := m.oldValue(ctx)
  51758. if err != nil {
  51759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51760. }
  51761. return oldValue.CreatedAt, nil
  51762. }
  51763. // ResetCreatedAt resets all changes to the "created_at" field.
  51764. func (m *XunjiMutation) ResetCreatedAt() {
  51765. m.created_at = nil
  51766. }
  51767. // SetUpdatedAt sets the "updated_at" field.
  51768. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  51769. m.updated_at = &t
  51770. }
  51771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51772. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  51773. v := m.updated_at
  51774. if v == nil {
  51775. return
  51776. }
  51777. return *v, true
  51778. }
  51779. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  51780. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51782. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51783. if !m.op.Is(OpUpdateOne) {
  51784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51785. }
  51786. if m.id == nil || m.oldValue == nil {
  51787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51788. }
  51789. oldValue, err := m.oldValue(ctx)
  51790. if err != nil {
  51791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51792. }
  51793. return oldValue.UpdatedAt, nil
  51794. }
  51795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51796. func (m *XunjiMutation) ResetUpdatedAt() {
  51797. m.updated_at = nil
  51798. }
  51799. // SetStatus sets the "status" field.
  51800. func (m *XunjiMutation) SetStatus(u uint8) {
  51801. m.status = &u
  51802. m.addstatus = nil
  51803. }
  51804. // Status returns the value of the "status" field in the mutation.
  51805. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  51806. v := m.status
  51807. if v == nil {
  51808. return
  51809. }
  51810. return *v, true
  51811. }
  51812. // OldStatus returns the old "status" field's value of the Xunji entity.
  51813. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51815. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51816. if !m.op.Is(OpUpdateOne) {
  51817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51818. }
  51819. if m.id == nil || m.oldValue == nil {
  51820. return v, errors.New("OldStatus requires an ID field in the mutation")
  51821. }
  51822. oldValue, err := m.oldValue(ctx)
  51823. if err != nil {
  51824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51825. }
  51826. return oldValue.Status, nil
  51827. }
  51828. // AddStatus adds u to the "status" field.
  51829. func (m *XunjiMutation) AddStatus(u int8) {
  51830. if m.addstatus != nil {
  51831. *m.addstatus += u
  51832. } else {
  51833. m.addstatus = &u
  51834. }
  51835. }
  51836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51837. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  51838. v := m.addstatus
  51839. if v == nil {
  51840. return
  51841. }
  51842. return *v, true
  51843. }
  51844. // ClearStatus clears the value of the "status" field.
  51845. func (m *XunjiMutation) ClearStatus() {
  51846. m.status = nil
  51847. m.addstatus = nil
  51848. m.clearedFields[xunji.FieldStatus] = struct{}{}
  51849. }
  51850. // StatusCleared returns if the "status" field was cleared in this mutation.
  51851. func (m *XunjiMutation) StatusCleared() bool {
  51852. _, ok := m.clearedFields[xunji.FieldStatus]
  51853. return ok
  51854. }
  51855. // ResetStatus resets all changes to the "status" field.
  51856. func (m *XunjiMutation) ResetStatus() {
  51857. m.status = nil
  51858. m.addstatus = nil
  51859. delete(m.clearedFields, xunji.FieldStatus)
  51860. }
  51861. // SetDeletedAt sets the "deleted_at" field.
  51862. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  51863. m.deleted_at = &t
  51864. }
  51865. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51866. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  51867. v := m.deleted_at
  51868. if v == nil {
  51869. return
  51870. }
  51871. return *v, true
  51872. }
  51873. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  51874. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51876. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51877. if !m.op.Is(OpUpdateOne) {
  51878. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51879. }
  51880. if m.id == nil || m.oldValue == nil {
  51881. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51882. }
  51883. oldValue, err := m.oldValue(ctx)
  51884. if err != nil {
  51885. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51886. }
  51887. return oldValue.DeletedAt, nil
  51888. }
  51889. // ClearDeletedAt clears the value of the "deleted_at" field.
  51890. func (m *XunjiMutation) ClearDeletedAt() {
  51891. m.deleted_at = nil
  51892. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  51893. }
  51894. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51895. func (m *XunjiMutation) DeletedAtCleared() bool {
  51896. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  51897. return ok
  51898. }
  51899. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51900. func (m *XunjiMutation) ResetDeletedAt() {
  51901. m.deleted_at = nil
  51902. delete(m.clearedFields, xunji.FieldDeletedAt)
  51903. }
  51904. // SetAppKey sets the "app_key" field.
  51905. func (m *XunjiMutation) SetAppKey(s string) {
  51906. m.app_key = &s
  51907. }
  51908. // AppKey returns the value of the "app_key" field in the mutation.
  51909. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  51910. v := m.app_key
  51911. if v == nil {
  51912. return
  51913. }
  51914. return *v, true
  51915. }
  51916. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  51917. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51919. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  51920. if !m.op.Is(OpUpdateOne) {
  51921. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  51922. }
  51923. if m.id == nil || m.oldValue == nil {
  51924. return v, errors.New("OldAppKey requires an ID field in the mutation")
  51925. }
  51926. oldValue, err := m.oldValue(ctx)
  51927. if err != nil {
  51928. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  51929. }
  51930. return oldValue.AppKey, nil
  51931. }
  51932. // ClearAppKey clears the value of the "app_key" field.
  51933. func (m *XunjiMutation) ClearAppKey() {
  51934. m.app_key = nil
  51935. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  51936. }
  51937. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  51938. func (m *XunjiMutation) AppKeyCleared() bool {
  51939. _, ok := m.clearedFields[xunji.FieldAppKey]
  51940. return ok
  51941. }
  51942. // ResetAppKey resets all changes to the "app_key" field.
  51943. func (m *XunjiMutation) ResetAppKey() {
  51944. m.app_key = nil
  51945. delete(m.clearedFields, xunji.FieldAppKey)
  51946. }
  51947. // SetAppSecret sets the "app_secret" field.
  51948. func (m *XunjiMutation) SetAppSecret(s string) {
  51949. m.app_secret = &s
  51950. }
  51951. // AppSecret returns the value of the "app_secret" field in the mutation.
  51952. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  51953. v := m.app_secret
  51954. if v == nil {
  51955. return
  51956. }
  51957. return *v, true
  51958. }
  51959. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  51960. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51962. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  51963. if !m.op.Is(OpUpdateOne) {
  51964. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  51965. }
  51966. if m.id == nil || m.oldValue == nil {
  51967. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  51968. }
  51969. oldValue, err := m.oldValue(ctx)
  51970. if err != nil {
  51971. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  51972. }
  51973. return oldValue.AppSecret, nil
  51974. }
  51975. // ClearAppSecret clears the value of the "app_secret" field.
  51976. func (m *XunjiMutation) ClearAppSecret() {
  51977. m.app_secret = nil
  51978. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  51979. }
  51980. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  51981. func (m *XunjiMutation) AppSecretCleared() bool {
  51982. _, ok := m.clearedFields[xunji.FieldAppSecret]
  51983. return ok
  51984. }
  51985. // ResetAppSecret resets all changes to the "app_secret" field.
  51986. func (m *XunjiMutation) ResetAppSecret() {
  51987. m.app_secret = nil
  51988. delete(m.clearedFields, xunji.FieldAppSecret)
  51989. }
  51990. // SetToken sets the "token" field.
  51991. func (m *XunjiMutation) SetToken(s string) {
  51992. m.token = &s
  51993. }
  51994. // Token returns the value of the "token" field in the mutation.
  51995. func (m *XunjiMutation) Token() (r string, exists bool) {
  51996. v := m.token
  51997. if v == nil {
  51998. return
  51999. }
  52000. return *v, true
  52001. }
  52002. // OldToken returns the old "token" field's value of the Xunji entity.
  52003. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52005. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  52006. if !m.op.Is(OpUpdateOne) {
  52007. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  52008. }
  52009. if m.id == nil || m.oldValue == nil {
  52010. return v, errors.New("OldToken requires an ID field in the mutation")
  52011. }
  52012. oldValue, err := m.oldValue(ctx)
  52013. if err != nil {
  52014. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  52015. }
  52016. return oldValue.Token, nil
  52017. }
  52018. // ClearToken clears the value of the "token" field.
  52019. func (m *XunjiMutation) ClearToken() {
  52020. m.token = nil
  52021. m.clearedFields[xunji.FieldToken] = struct{}{}
  52022. }
  52023. // TokenCleared returns if the "token" field was cleared in this mutation.
  52024. func (m *XunjiMutation) TokenCleared() bool {
  52025. _, ok := m.clearedFields[xunji.FieldToken]
  52026. return ok
  52027. }
  52028. // ResetToken resets all changes to the "token" field.
  52029. func (m *XunjiMutation) ResetToken() {
  52030. m.token = nil
  52031. delete(m.clearedFields, xunji.FieldToken)
  52032. }
  52033. // SetEncodingKey sets the "encoding_key" field.
  52034. func (m *XunjiMutation) SetEncodingKey(s string) {
  52035. m.encoding_key = &s
  52036. }
  52037. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  52038. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  52039. v := m.encoding_key
  52040. if v == nil {
  52041. return
  52042. }
  52043. return *v, true
  52044. }
  52045. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  52046. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52048. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  52049. if !m.op.Is(OpUpdateOne) {
  52050. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  52051. }
  52052. if m.id == nil || m.oldValue == nil {
  52053. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  52054. }
  52055. oldValue, err := m.oldValue(ctx)
  52056. if err != nil {
  52057. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  52058. }
  52059. return oldValue.EncodingKey, nil
  52060. }
  52061. // ClearEncodingKey clears the value of the "encoding_key" field.
  52062. func (m *XunjiMutation) ClearEncodingKey() {
  52063. m.encoding_key = nil
  52064. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  52065. }
  52066. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  52067. func (m *XunjiMutation) EncodingKeyCleared() bool {
  52068. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  52069. return ok
  52070. }
  52071. // ResetEncodingKey resets all changes to the "encoding_key" field.
  52072. func (m *XunjiMutation) ResetEncodingKey() {
  52073. m.encoding_key = nil
  52074. delete(m.clearedFields, xunji.FieldEncodingKey)
  52075. }
  52076. // SetOrganizationID sets the "organization_id" field.
  52077. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  52078. m.organization_id = &u
  52079. m.addorganization_id = nil
  52080. }
  52081. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52082. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  52083. v := m.organization_id
  52084. if v == nil {
  52085. return
  52086. }
  52087. return *v, true
  52088. }
  52089. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  52090. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52092. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52093. if !m.op.Is(OpUpdateOne) {
  52094. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52095. }
  52096. if m.id == nil || m.oldValue == nil {
  52097. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52098. }
  52099. oldValue, err := m.oldValue(ctx)
  52100. if err != nil {
  52101. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52102. }
  52103. return oldValue.OrganizationID, nil
  52104. }
  52105. // AddOrganizationID adds u to the "organization_id" field.
  52106. func (m *XunjiMutation) AddOrganizationID(u int64) {
  52107. if m.addorganization_id != nil {
  52108. *m.addorganization_id += u
  52109. } else {
  52110. m.addorganization_id = &u
  52111. }
  52112. }
  52113. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52114. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  52115. v := m.addorganization_id
  52116. if v == nil {
  52117. return
  52118. }
  52119. return *v, true
  52120. }
  52121. // ResetOrganizationID resets all changes to the "organization_id" field.
  52122. func (m *XunjiMutation) ResetOrganizationID() {
  52123. m.organization_id = nil
  52124. m.addorganization_id = nil
  52125. }
  52126. // Where appends a list predicates to the XunjiMutation builder.
  52127. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  52128. m.predicates = append(m.predicates, ps...)
  52129. }
  52130. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  52131. // users can use type-assertion to append predicates that do not depend on any generated package.
  52132. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  52133. p := make([]predicate.Xunji, len(ps))
  52134. for i := range ps {
  52135. p[i] = ps[i]
  52136. }
  52137. m.Where(p...)
  52138. }
  52139. // Op returns the operation name.
  52140. func (m *XunjiMutation) Op() Op {
  52141. return m.op
  52142. }
  52143. // SetOp allows setting the mutation operation.
  52144. func (m *XunjiMutation) SetOp(op Op) {
  52145. m.op = op
  52146. }
  52147. // Type returns the node type of this mutation (Xunji).
  52148. func (m *XunjiMutation) Type() string {
  52149. return m.typ
  52150. }
  52151. // Fields returns all fields that were changed during this mutation. Note that in
  52152. // order to get all numeric fields that were incremented/decremented, call
  52153. // AddedFields().
  52154. func (m *XunjiMutation) Fields() []string {
  52155. fields := make([]string, 0, 9)
  52156. if m.created_at != nil {
  52157. fields = append(fields, xunji.FieldCreatedAt)
  52158. }
  52159. if m.updated_at != nil {
  52160. fields = append(fields, xunji.FieldUpdatedAt)
  52161. }
  52162. if m.status != nil {
  52163. fields = append(fields, xunji.FieldStatus)
  52164. }
  52165. if m.deleted_at != nil {
  52166. fields = append(fields, xunji.FieldDeletedAt)
  52167. }
  52168. if m.app_key != nil {
  52169. fields = append(fields, xunji.FieldAppKey)
  52170. }
  52171. if m.app_secret != nil {
  52172. fields = append(fields, xunji.FieldAppSecret)
  52173. }
  52174. if m.token != nil {
  52175. fields = append(fields, xunji.FieldToken)
  52176. }
  52177. if m.encoding_key != nil {
  52178. fields = append(fields, xunji.FieldEncodingKey)
  52179. }
  52180. if m.organization_id != nil {
  52181. fields = append(fields, xunji.FieldOrganizationID)
  52182. }
  52183. return fields
  52184. }
  52185. // Field returns the value of a field with the given name. The second boolean
  52186. // return value indicates that this field was not set, or was not defined in the
  52187. // schema.
  52188. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  52189. switch name {
  52190. case xunji.FieldCreatedAt:
  52191. return m.CreatedAt()
  52192. case xunji.FieldUpdatedAt:
  52193. return m.UpdatedAt()
  52194. case xunji.FieldStatus:
  52195. return m.Status()
  52196. case xunji.FieldDeletedAt:
  52197. return m.DeletedAt()
  52198. case xunji.FieldAppKey:
  52199. return m.AppKey()
  52200. case xunji.FieldAppSecret:
  52201. return m.AppSecret()
  52202. case xunji.FieldToken:
  52203. return m.Token()
  52204. case xunji.FieldEncodingKey:
  52205. return m.EncodingKey()
  52206. case xunji.FieldOrganizationID:
  52207. return m.OrganizationID()
  52208. }
  52209. return nil, false
  52210. }
  52211. // OldField returns the old value of the field from the database. An error is
  52212. // returned if the mutation operation is not UpdateOne, or the query to the
  52213. // database failed.
  52214. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52215. switch name {
  52216. case xunji.FieldCreatedAt:
  52217. return m.OldCreatedAt(ctx)
  52218. case xunji.FieldUpdatedAt:
  52219. return m.OldUpdatedAt(ctx)
  52220. case xunji.FieldStatus:
  52221. return m.OldStatus(ctx)
  52222. case xunji.FieldDeletedAt:
  52223. return m.OldDeletedAt(ctx)
  52224. case xunji.FieldAppKey:
  52225. return m.OldAppKey(ctx)
  52226. case xunji.FieldAppSecret:
  52227. return m.OldAppSecret(ctx)
  52228. case xunji.FieldToken:
  52229. return m.OldToken(ctx)
  52230. case xunji.FieldEncodingKey:
  52231. return m.OldEncodingKey(ctx)
  52232. case xunji.FieldOrganizationID:
  52233. return m.OldOrganizationID(ctx)
  52234. }
  52235. return nil, fmt.Errorf("unknown Xunji field %s", name)
  52236. }
  52237. // SetField sets the value of a field with the given name. It returns an error if
  52238. // the field is not defined in the schema, or if the type mismatched the field
  52239. // type.
  52240. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  52241. switch name {
  52242. case xunji.FieldCreatedAt:
  52243. v, ok := value.(time.Time)
  52244. if !ok {
  52245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52246. }
  52247. m.SetCreatedAt(v)
  52248. return nil
  52249. case xunji.FieldUpdatedAt:
  52250. v, ok := value.(time.Time)
  52251. if !ok {
  52252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52253. }
  52254. m.SetUpdatedAt(v)
  52255. return nil
  52256. case xunji.FieldStatus:
  52257. v, ok := value.(uint8)
  52258. if !ok {
  52259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52260. }
  52261. m.SetStatus(v)
  52262. return nil
  52263. case xunji.FieldDeletedAt:
  52264. v, ok := value.(time.Time)
  52265. if !ok {
  52266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52267. }
  52268. m.SetDeletedAt(v)
  52269. return nil
  52270. case xunji.FieldAppKey:
  52271. v, ok := value.(string)
  52272. if !ok {
  52273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52274. }
  52275. m.SetAppKey(v)
  52276. return nil
  52277. case xunji.FieldAppSecret:
  52278. v, ok := value.(string)
  52279. if !ok {
  52280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52281. }
  52282. m.SetAppSecret(v)
  52283. return nil
  52284. case xunji.FieldToken:
  52285. v, ok := value.(string)
  52286. if !ok {
  52287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52288. }
  52289. m.SetToken(v)
  52290. return nil
  52291. case xunji.FieldEncodingKey:
  52292. v, ok := value.(string)
  52293. if !ok {
  52294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52295. }
  52296. m.SetEncodingKey(v)
  52297. return nil
  52298. case xunji.FieldOrganizationID:
  52299. v, ok := value.(uint64)
  52300. if !ok {
  52301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52302. }
  52303. m.SetOrganizationID(v)
  52304. return nil
  52305. }
  52306. return fmt.Errorf("unknown Xunji field %s", name)
  52307. }
  52308. // AddedFields returns all numeric fields that were incremented/decremented during
  52309. // this mutation.
  52310. func (m *XunjiMutation) AddedFields() []string {
  52311. var fields []string
  52312. if m.addstatus != nil {
  52313. fields = append(fields, xunji.FieldStatus)
  52314. }
  52315. if m.addorganization_id != nil {
  52316. fields = append(fields, xunji.FieldOrganizationID)
  52317. }
  52318. return fields
  52319. }
  52320. // AddedField returns the numeric value that was incremented/decremented on a field
  52321. // with the given name. The second boolean return value indicates that this field
  52322. // was not set, or was not defined in the schema.
  52323. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  52324. switch name {
  52325. case xunji.FieldStatus:
  52326. return m.AddedStatus()
  52327. case xunji.FieldOrganizationID:
  52328. return m.AddedOrganizationID()
  52329. }
  52330. return nil, false
  52331. }
  52332. // AddField adds the value to the field with the given name. It returns an error if
  52333. // the field is not defined in the schema, or if the type mismatched the field
  52334. // type.
  52335. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  52336. switch name {
  52337. case xunji.FieldStatus:
  52338. v, ok := value.(int8)
  52339. if !ok {
  52340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52341. }
  52342. m.AddStatus(v)
  52343. return nil
  52344. case xunji.FieldOrganizationID:
  52345. v, ok := value.(int64)
  52346. if !ok {
  52347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52348. }
  52349. m.AddOrganizationID(v)
  52350. return nil
  52351. }
  52352. return fmt.Errorf("unknown Xunji numeric field %s", name)
  52353. }
  52354. // ClearedFields returns all nullable fields that were cleared during this
  52355. // mutation.
  52356. func (m *XunjiMutation) ClearedFields() []string {
  52357. var fields []string
  52358. if m.FieldCleared(xunji.FieldStatus) {
  52359. fields = append(fields, xunji.FieldStatus)
  52360. }
  52361. if m.FieldCleared(xunji.FieldDeletedAt) {
  52362. fields = append(fields, xunji.FieldDeletedAt)
  52363. }
  52364. if m.FieldCleared(xunji.FieldAppKey) {
  52365. fields = append(fields, xunji.FieldAppKey)
  52366. }
  52367. if m.FieldCleared(xunji.FieldAppSecret) {
  52368. fields = append(fields, xunji.FieldAppSecret)
  52369. }
  52370. if m.FieldCleared(xunji.FieldToken) {
  52371. fields = append(fields, xunji.FieldToken)
  52372. }
  52373. if m.FieldCleared(xunji.FieldEncodingKey) {
  52374. fields = append(fields, xunji.FieldEncodingKey)
  52375. }
  52376. return fields
  52377. }
  52378. // FieldCleared returns a boolean indicating if a field with the given name was
  52379. // cleared in this mutation.
  52380. func (m *XunjiMutation) FieldCleared(name string) bool {
  52381. _, ok := m.clearedFields[name]
  52382. return ok
  52383. }
  52384. // ClearField clears the value of the field with the given name. It returns an
  52385. // error if the field is not defined in the schema.
  52386. func (m *XunjiMutation) ClearField(name string) error {
  52387. switch name {
  52388. case xunji.FieldStatus:
  52389. m.ClearStatus()
  52390. return nil
  52391. case xunji.FieldDeletedAt:
  52392. m.ClearDeletedAt()
  52393. return nil
  52394. case xunji.FieldAppKey:
  52395. m.ClearAppKey()
  52396. return nil
  52397. case xunji.FieldAppSecret:
  52398. m.ClearAppSecret()
  52399. return nil
  52400. case xunji.FieldToken:
  52401. m.ClearToken()
  52402. return nil
  52403. case xunji.FieldEncodingKey:
  52404. m.ClearEncodingKey()
  52405. return nil
  52406. }
  52407. return fmt.Errorf("unknown Xunji nullable field %s", name)
  52408. }
  52409. // ResetField resets all changes in the mutation for the field with the given name.
  52410. // It returns an error if the field is not defined in the schema.
  52411. func (m *XunjiMutation) ResetField(name string) error {
  52412. switch name {
  52413. case xunji.FieldCreatedAt:
  52414. m.ResetCreatedAt()
  52415. return nil
  52416. case xunji.FieldUpdatedAt:
  52417. m.ResetUpdatedAt()
  52418. return nil
  52419. case xunji.FieldStatus:
  52420. m.ResetStatus()
  52421. return nil
  52422. case xunji.FieldDeletedAt:
  52423. m.ResetDeletedAt()
  52424. return nil
  52425. case xunji.FieldAppKey:
  52426. m.ResetAppKey()
  52427. return nil
  52428. case xunji.FieldAppSecret:
  52429. m.ResetAppSecret()
  52430. return nil
  52431. case xunji.FieldToken:
  52432. m.ResetToken()
  52433. return nil
  52434. case xunji.FieldEncodingKey:
  52435. m.ResetEncodingKey()
  52436. return nil
  52437. case xunji.FieldOrganizationID:
  52438. m.ResetOrganizationID()
  52439. return nil
  52440. }
  52441. return fmt.Errorf("unknown Xunji field %s", name)
  52442. }
  52443. // AddedEdges returns all edge names that were set/added in this mutation.
  52444. func (m *XunjiMutation) AddedEdges() []string {
  52445. edges := make([]string, 0, 0)
  52446. return edges
  52447. }
  52448. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52449. // name in this mutation.
  52450. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  52451. return nil
  52452. }
  52453. // RemovedEdges returns all edge names that were removed in this mutation.
  52454. func (m *XunjiMutation) RemovedEdges() []string {
  52455. edges := make([]string, 0, 0)
  52456. return edges
  52457. }
  52458. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52459. // the given name in this mutation.
  52460. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  52461. return nil
  52462. }
  52463. // ClearedEdges returns all edge names that were cleared in this mutation.
  52464. func (m *XunjiMutation) ClearedEdges() []string {
  52465. edges := make([]string, 0, 0)
  52466. return edges
  52467. }
  52468. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52469. // was cleared in this mutation.
  52470. func (m *XunjiMutation) EdgeCleared(name string) bool {
  52471. return false
  52472. }
  52473. // ClearEdge clears the value of the edge with the given name. It returns an error
  52474. // if that edge is not defined in the schema.
  52475. func (m *XunjiMutation) ClearEdge(name string) error {
  52476. return fmt.Errorf("unknown Xunji unique edge %s", name)
  52477. }
  52478. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52479. // It returns an error if the edge is not defined in the schema.
  52480. func (m *XunjiMutation) ResetEdge(name string) error {
  52481. return fmt.Errorf("unknown Xunji edge %s", name)
  52482. }
  52483. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  52484. type XunjiServiceMutation struct {
  52485. config
  52486. op Op
  52487. typ string
  52488. id *uint64
  52489. created_at *time.Time
  52490. updated_at *time.Time
  52491. status *uint8
  52492. addstatus *int8
  52493. deleted_at *time.Time
  52494. xunji_id *uint64
  52495. addxunji_id *int64
  52496. organization_id *uint64
  52497. addorganization_id *int64
  52498. wxid *string
  52499. api_base *string
  52500. api_key *string
  52501. clearedFields map[string]struct{}
  52502. agent *uint64
  52503. clearedagent bool
  52504. done bool
  52505. oldValue func(context.Context) (*XunjiService, error)
  52506. predicates []predicate.XunjiService
  52507. }
  52508. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  52509. // xunjiserviceOption allows management of the mutation configuration using functional options.
  52510. type xunjiserviceOption func(*XunjiServiceMutation)
  52511. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  52512. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  52513. m := &XunjiServiceMutation{
  52514. config: c,
  52515. op: op,
  52516. typ: TypeXunjiService,
  52517. clearedFields: make(map[string]struct{}),
  52518. }
  52519. for _, opt := range opts {
  52520. opt(m)
  52521. }
  52522. return m
  52523. }
  52524. // withXunjiServiceID sets the ID field of the mutation.
  52525. func withXunjiServiceID(id uint64) xunjiserviceOption {
  52526. return func(m *XunjiServiceMutation) {
  52527. var (
  52528. err error
  52529. once sync.Once
  52530. value *XunjiService
  52531. )
  52532. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  52533. once.Do(func() {
  52534. if m.done {
  52535. err = errors.New("querying old values post mutation is not allowed")
  52536. } else {
  52537. value, err = m.Client().XunjiService.Get(ctx, id)
  52538. }
  52539. })
  52540. return value, err
  52541. }
  52542. m.id = &id
  52543. }
  52544. }
  52545. // withXunjiService sets the old XunjiService of the mutation.
  52546. func withXunjiService(node *XunjiService) xunjiserviceOption {
  52547. return func(m *XunjiServiceMutation) {
  52548. m.oldValue = func(context.Context) (*XunjiService, error) {
  52549. return node, nil
  52550. }
  52551. m.id = &node.ID
  52552. }
  52553. }
  52554. // Client returns a new `ent.Client` from the mutation. If the mutation was
  52555. // executed in a transaction (ent.Tx), a transactional client is returned.
  52556. func (m XunjiServiceMutation) Client() *Client {
  52557. client := &Client{config: m.config}
  52558. client.init()
  52559. return client
  52560. }
  52561. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  52562. // it returns an error otherwise.
  52563. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  52564. if _, ok := m.driver.(*txDriver); !ok {
  52565. return nil, errors.New("ent: mutation is not running in a transaction")
  52566. }
  52567. tx := &Tx{config: m.config}
  52568. tx.init()
  52569. return tx, nil
  52570. }
  52571. // SetID sets the value of the id field. Note that this
  52572. // operation is only accepted on creation of XunjiService entities.
  52573. func (m *XunjiServiceMutation) SetID(id uint64) {
  52574. m.id = &id
  52575. }
  52576. // ID returns the ID value in the mutation. Note that the ID is only available
  52577. // if it was provided to the builder or after it was returned from the database.
  52578. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  52579. if m.id == nil {
  52580. return
  52581. }
  52582. return *m.id, true
  52583. }
  52584. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  52585. // That means, if the mutation is applied within a transaction with an isolation level such
  52586. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  52587. // or updated by the mutation.
  52588. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  52589. switch {
  52590. case m.op.Is(OpUpdateOne | OpDeleteOne):
  52591. id, exists := m.ID()
  52592. if exists {
  52593. return []uint64{id}, nil
  52594. }
  52595. fallthrough
  52596. case m.op.Is(OpUpdate | OpDelete):
  52597. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  52598. default:
  52599. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  52600. }
  52601. }
  52602. // SetCreatedAt sets the "created_at" field.
  52603. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  52604. m.created_at = &t
  52605. }
  52606. // CreatedAt returns the value of the "created_at" field in the mutation.
  52607. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  52608. v := m.created_at
  52609. if v == nil {
  52610. return
  52611. }
  52612. return *v, true
  52613. }
  52614. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  52615. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52617. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  52618. if !m.op.Is(OpUpdateOne) {
  52619. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  52620. }
  52621. if m.id == nil || m.oldValue == nil {
  52622. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  52623. }
  52624. oldValue, err := m.oldValue(ctx)
  52625. if err != nil {
  52626. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  52627. }
  52628. return oldValue.CreatedAt, nil
  52629. }
  52630. // ResetCreatedAt resets all changes to the "created_at" field.
  52631. func (m *XunjiServiceMutation) ResetCreatedAt() {
  52632. m.created_at = nil
  52633. }
  52634. // SetUpdatedAt sets the "updated_at" field.
  52635. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  52636. m.updated_at = &t
  52637. }
  52638. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  52639. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  52640. v := m.updated_at
  52641. if v == nil {
  52642. return
  52643. }
  52644. return *v, true
  52645. }
  52646. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  52647. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52649. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  52650. if !m.op.Is(OpUpdateOne) {
  52651. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  52652. }
  52653. if m.id == nil || m.oldValue == nil {
  52654. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  52655. }
  52656. oldValue, err := m.oldValue(ctx)
  52657. if err != nil {
  52658. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  52659. }
  52660. return oldValue.UpdatedAt, nil
  52661. }
  52662. // ResetUpdatedAt resets all changes to the "updated_at" field.
  52663. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  52664. m.updated_at = nil
  52665. }
  52666. // SetStatus sets the "status" field.
  52667. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  52668. m.status = &u
  52669. m.addstatus = nil
  52670. }
  52671. // Status returns the value of the "status" field in the mutation.
  52672. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  52673. v := m.status
  52674. if v == nil {
  52675. return
  52676. }
  52677. return *v, true
  52678. }
  52679. // OldStatus returns the old "status" field's value of the XunjiService entity.
  52680. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52682. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  52683. if !m.op.Is(OpUpdateOne) {
  52684. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  52685. }
  52686. if m.id == nil || m.oldValue == nil {
  52687. return v, errors.New("OldStatus requires an ID field in the mutation")
  52688. }
  52689. oldValue, err := m.oldValue(ctx)
  52690. if err != nil {
  52691. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  52692. }
  52693. return oldValue.Status, nil
  52694. }
  52695. // AddStatus adds u to the "status" field.
  52696. func (m *XunjiServiceMutation) AddStatus(u int8) {
  52697. if m.addstatus != nil {
  52698. *m.addstatus += u
  52699. } else {
  52700. m.addstatus = &u
  52701. }
  52702. }
  52703. // AddedStatus returns the value that was added to the "status" field in this mutation.
  52704. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  52705. v := m.addstatus
  52706. if v == nil {
  52707. return
  52708. }
  52709. return *v, true
  52710. }
  52711. // ClearStatus clears the value of the "status" field.
  52712. func (m *XunjiServiceMutation) ClearStatus() {
  52713. m.status = nil
  52714. m.addstatus = nil
  52715. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  52716. }
  52717. // StatusCleared returns if the "status" field was cleared in this mutation.
  52718. func (m *XunjiServiceMutation) StatusCleared() bool {
  52719. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  52720. return ok
  52721. }
  52722. // ResetStatus resets all changes to the "status" field.
  52723. func (m *XunjiServiceMutation) ResetStatus() {
  52724. m.status = nil
  52725. m.addstatus = nil
  52726. delete(m.clearedFields, xunjiservice.FieldStatus)
  52727. }
  52728. // SetDeletedAt sets the "deleted_at" field.
  52729. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  52730. m.deleted_at = &t
  52731. }
  52732. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  52733. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  52734. v := m.deleted_at
  52735. if v == nil {
  52736. return
  52737. }
  52738. return *v, true
  52739. }
  52740. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  52741. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52743. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  52744. if !m.op.Is(OpUpdateOne) {
  52745. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  52746. }
  52747. if m.id == nil || m.oldValue == nil {
  52748. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  52749. }
  52750. oldValue, err := m.oldValue(ctx)
  52751. if err != nil {
  52752. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  52753. }
  52754. return oldValue.DeletedAt, nil
  52755. }
  52756. // ClearDeletedAt clears the value of the "deleted_at" field.
  52757. func (m *XunjiServiceMutation) ClearDeletedAt() {
  52758. m.deleted_at = nil
  52759. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  52760. }
  52761. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  52762. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  52763. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  52764. return ok
  52765. }
  52766. // ResetDeletedAt resets all changes to the "deleted_at" field.
  52767. func (m *XunjiServiceMutation) ResetDeletedAt() {
  52768. m.deleted_at = nil
  52769. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  52770. }
  52771. // SetXunjiID sets the "xunji_id" field.
  52772. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  52773. m.xunji_id = &u
  52774. m.addxunji_id = nil
  52775. }
  52776. // XunjiID returns the value of the "xunji_id" field in the mutation.
  52777. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  52778. v := m.xunji_id
  52779. if v == nil {
  52780. return
  52781. }
  52782. return *v, true
  52783. }
  52784. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  52785. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52787. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  52788. if !m.op.Is(OpUpdateOne) {
  52789. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  52790. }
  52791. if m.id == nil || m.oldValue == nil {
  52792. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  52793. }
  52794. oldValue, err := m.oldValue(ctx)
  52795. if err != nil {
  52796. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  52797. }
  52798. return oldValue.XunjiID, nil
  52799. }
  52800. // AddXunjiID adds u to the "xunji_id" field.
  52801. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  52802. if m.addxunji_id != nil {
  52803. *m.addxunji_id += u
  52804. } else {
  52805. m.addxunji_id = &u
  52806. }
  52807. }
  52808. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  52809. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  52810. v := m.addxunji_id
  52811. if v == nil {
  52812. return
  52813. }
  52814. return *v, true
  52815. }
  52816. // ResetXunjiID resets all changes to the "xunji_id" field.
  52817. func (m *XunjiServiceMutation) ResetXunjiID() {
  52818. m.xunji_id = nil
  52819. m.addxunji_id = nil
  52820. }
  52821. // SetAgentID sets the "agent_id" field.
  52822. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  52823. m.agent = &u
  52824. }
  52825. // AgentID returns the value of the "agent_id" field in the mutation.
  52826. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  52827. v := m.agent
  52828. if v == nil {
  52829. return
  52830. }
  52831. return *v, true
  52832. }
  52833. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  52834. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52836. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  52837. if !m.op.Is(OpUpdateOne) {
  52838. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  52839. }
  52840. if m.id == nil || m.oldValue == nil {
  52841. return v, errors.New("OldAgentID requires an ID field in the mutation")
  52842. }
  52843. oldValue, err := m.oldValue(ctx)
  52844. if err != nil {
  52845. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  52846. }
  52847. return oldValue.AgentID, nil
  52848. }
  52849. // ResetAgentID resets all changes to the "agent_id" field.
  52850. func (m *XunjiServiceMutation) ResetAgentID() {
  52851. m.agent = nil
  52852. }
  52853. // SetOrganizationID sets the "organization_id" field.
  52854. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  52855. m.organization_id = &u
  52856. m.addorganization_id = nil
  52857. }
  52858. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52859. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  52860. v := m.organization_id
  52861. if v == nil {
  52862. return
  52863. }
  52864. return *v, true
  52865. }
  52866. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  52867. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52869. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52870. if !m.op.Is(OpUpdateOne) {
  52871. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52872. }
  52873. if m.id == nil || m.oldValue == nil {
  52874. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52875. }
  52876. oldValue, err := m.oldValue(ctx)
  52877. if err != nil {
  52878. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52879. }
  52880. return oldValue.OrganizationID, nil
  52881. }
  52882. // AddOrganizationID adds u to the "organization_id" field.
  52883. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  52884. if m.addorganization_id != nil {
  52885. *m.addorganization_id += u
  52886. } else {
  52887. m.addorganization_id = &u
  52888. }
  52889. }
  52890. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52891. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  52892. v := m.addorganization_id
  52893. if v == nil {
  52894. return
  52895. }
  52896. return *v, true
  52897. }
  52898. // ResetOrganizationID resets all changes to the "organization_id" field.
  52899. func (m *XunjiServiceMutation) ResetOrganizationID() {
  52900. m.organization_id = nil
  52901. m.addorganization_id = nil
  52902. }
  52903. // SetWxid sets the "wxid" field.
  52904. func (m *XunjiServiceMutation) SetWxid(s string) {
  52905. m.wxid = &s
  52906. }
  52907. // Wxid returns the value of the "wxid" field in the mutation.
  52908. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  52909. v := m.wxid
  52910. if v == nil {
  52911. return
  52912. }
  52913. return *v, true
  52914. }
  52915. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  52916. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52918. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  52919. if !m.op.Is(OpUpdateOne) {
  52920. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  52921. }
  52922. if m.id == nil || m.oldValue == nil {
  52923. return v, errors.New("OldWxid requires an ID field in the mutation")
  52924. }
  52925. oldValue, err := m.oldValue(ctx)
  52926. if err != nil {
  52927. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  52928. }
  52929. return oldValue.Wxid, nil
  52930. }
  52931. // ResetWxid resets all changes to the "wxid" field.
  52932. func (m *XunjiServiceMutation) ResetWxid() {
  52933. m.wxid = nil
  52934. }
  52935. // SetAPIBase sets the "api_base" field.
  52936. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  52937. m.api_base = &s
  52938. }
  52939. // APIBase returns the value of the "api_base" field in the mutation.
  52940. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  52941. v := m.api_base
  52942. if v == nil {
  52943. return
  52944. }
  52945. return *v, true
  52946. }
  52947. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  52948. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52950. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  52951. if !m.op.Is(OpUpdateOne) {
  52952. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  52953. }
  52954. if m.id == nil || m.oldValue == nil {
  52955. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  52956. }
  52957. oldValue, err := m.oldValue(ctx)
  52958. if err != nil {
  52959. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  52960. }
  52961. return oldValue.APIBase, nil
  52962. }
  52963. // ClearAPIBase clears the value of the "api_base" field.
  52964. func (m *XunjiServiceMutation) ClearAPIBase() {
  52965. m.api_base = nil
  52966. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  52967. }
  52968. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  52969. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  52970. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  52971. return ok
  52972. }
  52973. // ResetAPIBase resets all changes to the "api_base" field.
  52974. func (m *XunjiServiceMutation) ResetAPIBase() {
  52975. m.api_base = nil
  52976. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  52977. }
  52978. // SetAPIKey sets the "api_key" field.
  52979. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  52980. m.api_key = &s
  52981. }
  52982. // APIKey returns the value of the "api_key" field in the mutation.
  52983. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  52984. v := m.api_key
  52985. if v == nil {
  52986. return
  52987. }
  52988. return *v, true
  52989. }
  52990. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  52991. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52993. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  52994. if !m.op.Is(OpUpdateOne) {
  52995. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  52996. }
  52997. if m.id == nil || m.oldValue == nil {
  52998. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  52999. }
  53000. oldValue, err := m.oldValue(ctx)
  53001. if err != nil {
  53002. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  53003. }
  53004. return oldValue.APIKey, nil
  53005. }
  53006. // ClearAPIKey clears the value of the "api_key" field.
  53007. func (m *XunjiServiceMutation) ClearAPIKey() {
  53008. m.api_key = nil
  53009. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  53010. }
  53011. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  53012. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  53013. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  53014. return ok
  53015. }
  53016. // ResetAPIKey resets all changes to the "api_key" field.
  53017. func (m *XunjiServiceMutation) ResetAPIKey() {
  53018. m.api_key = nil
  53019. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  53020. }
  53021. // ClearAgent clears the "agent" edge to the Agent entity.
  53022. func (m *XunjiServiceMutation) ClearAgent() {
  53023. m.clearedagent = true
  53024. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  53025. }
  53026. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  53027. func (m *XunjiServiceMutation) AgentCleared() bool {
  53028. return m.clearedagent
  53029. }
  53030. // AgentIDs returns the "agent" edge IDs in the mutation.
  53031. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  53032. // AgentID instead. It exists only for internal usage by the builders.
  53033. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  53034. if id := m.agent; id != nil {
  53035. ids = append(ids, *id)
  53036. }
  53037. return
  53038. }
  53039. // ResetAgent resets all changes to the "agent" edge.
  53040. func (m *XunjiServiceMutation) ResetAgent() {
  53041. m.agent = nil
  53042. m.clearedagent = false
  53043. }
  53044. // Where appends a list predicates to the XunjiServiceMutation builder.
  53045. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  53046. m.predicates = append(m.predicates, ps...)
  53047. }
  53048. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  53049. // users can use type-assertion to append predicates that do not depend on any generated package.
  53050. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  53051. p := make([]predicate.XunjiService, len(ps))
  53052. for i := range ps {
  53053. p[i] = ps[i]
  53054. }
  53055. m.Where(p...)
  53056. }
  53057. // Op returns the operation name.
  53058. func (m *XunjiServiceMutation) Op() Op {
  53059. return m.op
  53060. }
  53061. // SetOp allows setting the mutation operation.
  53062. func (m *XunjiServiceMutation) SetOp(op Op) {
  53063. m.op = op
  53064. }
  53065. // Type returns the node type of this mutation (XunjiService).
  53066. func (m *XunjiServiceMutation) Type() string {
  53067. return m.typ
  53068. }
  53069. // Fields returns all fields that were changed during this mutation. Note that in
  53070. // order to get all numeric fields that were incremented/decremented, call
  53071. // AddedFields().
  53072. func (m *XunjiServiceMutation) Fields() []string {
  53073. fields := make([]string, 0, 10)
  53074. if m.created_at != nil {
  53075. fields = append(fields, xunjiservice.FieldCreatedAt)
  53076. }
  53077. if m.updated_at != nil {
  53078. fields = append(fields, xunjiservice.FieldUpdatedAt)
  53079. }
  53080. if m.status != nil {
  53081. fields = append(fields, xunjiservice.FieldStatus)
  53082. }
  53083. if m.deleted_at != nil {
  53084. fields = append(fields, xunjiservice.FieldDeletedAt)
  53085. }
  53086. if m.xunji_id != nil {
  53087. fields = append(fields, xunjiservice.FieldXunjiID)
  53088. }
  53089. if m.agent != nil {
  53090. fields = append(fields, xunjiservice.FieldAgentID)
  53091. }
  53092. if m.organization_id != nil {
  53093. fields = append(fields, xunjiservice.FieldOrganizationID)
  53094. }
  53095. if m.wxid != nil {
  53096. fields = append(fields, xunjiservice.FieldWxid)
  53097. }
  53098. if m.api_base != nil {
  53099. fields = append(fields, xunjiservice.FieldAPIBase)
  53100. }
  53101. if m.api_key != nil {
  53102. fields = append(fields, xunjiservice.FieldAPIKey)
  53103. }
  53104. return fields
  53105. }
  53106. // Field returns the value of a field with the given name. The second boolean
  53107. // return value indicates that this field was not set, or was not defined in the
  53108. // schema.
  53109. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  53110. switch name {
  53111. case xunjiservice.FieldCreatedAt:
  53112. return m.CreatedAt()
  53113. case xunjiservice.FieldUpdatedAt:
  53114. return m.UpdatedAt()
  53115. case xunjiservice.FieldStatus:
  53116. return m.Status()
  53117. case xunjiservice.FieldDeletedAt:
  53118. return m.DeletedAt()
  53119. case xunjiservice.FieldXunjiID:
  53120. return m.XunjiID()
  53121. case xunjiservice.FieldAgentID:
  53122. return m.AgentID()
  53123. case xunjiservice.FieldOrganizationID:
  53124. return m.OrganizationID()
  53125. case xunjiservice.FieldWxid:
  53126. return m.Wxid()
  53127. case xunjiservice.FieldAPIBase:
  53128. return m.APIBase()
  53129. case xunjiservice.FieldAPIKey:
  53130. return m.APIKey()
  53131. }
  53132. return nil, false
  53133. }
  53134. // OldField returns the old value of the field from the database. An error is
  53135. // returned if the mutation operation is not UpdateOne, or the query to the
  53136. // database failed.
  53137. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  53138. switch name {
  53139. case xunjiservice.FieldCreatedAt:
  53140. return m.OldCreatedAt(ctx)
  53141. case xunjiservice.FieldUpdatedAt:
  53142. return m.OldUpdatedAt(ctx)
  53143. case xunjiservice.FieldStatus:
  53144. return m.OldStatus(ctx)
  53145. case xunjiservice.FieldDeletedAt:
  53146. return m.OldDeletedAt(ctx)
  53147. case xunjiservice.FieldXunjiID:
  53148. return m.OldXunjiID(ctx)
  53149. case xunjiservice.FieldAgentID:
  53150. return m.OldAgentID(ctx)
  53151. case xunjiservice.FieldOrganizationID:
  53152. return m.OldOrganizationID(ctx)
  53153. case xunjiservice.FieldWxid:
  53154. return m.OldWxid(ctx)
  53155. case xunjiservice.FieldAPIBase:
  53156. return m.OldAPIBase(ctx)
  53157. case xunjiservice.FieldAPIKey:
  53158. return m.OldAPIKey(ctx)
  53159. }
  53160. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  53161. }
  53162. // SetField sets the value of a field with the given name. It returns an error if
  53163. // the field is not defined in the schema, or if the type mismatched the field
  53164. // type.
  53165. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  53166. switch name {
  53167. case xunjiservice.FieldCreatedAt:
  53168. v, ok := value.(time.Time)
  53169. if !ok {
  53170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53171. }
  53172. m.SetCreatedAt(v)
  53173. return nil
  53174. case xunjiservice.FieldUpdatedAt:
  53175. v, ok := value.(time.Time)
  53176. if !ok {
  53177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53178. }
  53179. m.SetUpdatedAt(v)
  53180. return nil
  53181. case xunjiservice.FieldStatus:
  53182. v, ok := value.(uint8)
  53183. if !ok {
  53184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53185. }
  53186. m.SetStatus(v)
  53187. return nil
  53188. case xunjiservice.FieldDeletedAt:
  53189. v, ok := value.(time.Time)
  53190. if !ok {
  53191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53192. }
  53193. m.SetDeletedAt(v)
  53194. return nil
  53195. case xunjiservice.FieldXunjiID:
  53196. v, ok := value.(uint64)
  53197. if !ok {
  53198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53199. }
  53200. m.SetXunjiID(v)
  53201. return nil
  53202. case xunjiservice.FieldAgentID:
  53203. v, ok := value.(uint64)
  53204. if !ok {
  53205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53206. }
  53207. m.SetAgentID(v)
  53208. return nil
  53209. case xunjiservice.FieldOrganizationID:
  53210. v, ok := value.(uint64)
  53211. if !ok {
  53212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53213. }
  53214. m.SetOrganizationID(v)
  53215. return nil
  53216. case xunjiservice.FieldWxid:
  53217. v, ok := value.(string)
  53218. if !ok {
  53219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53220. }
  53221. m.SetWxid(v)
  53222. return nil
  53223. case xunjiservice.FieldAPIBase:
  53224. v, ok := value.(string)
  53225. if !ok {
  53226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53227. }
  53228. m.SetAPIBase(v)
  53229. return nil
  53230. case xunjiservice.FieldAPIKey:
  53231. v, ok := value.(string)
  53232. if !ok {
  53233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53234. }
  53235. m.SetAPIKey(v)
  53236. return nil
  53237. }
  53238. return fmt.Errorf("unknown XunjiService field %s", name)
  53239. }
  53240. // AddedFields returns all numeric fields that were incremented/decremented during
  53241. // this mutation.
  53242. func (m *XunjiServiceMutation) AddedFields() []string {
  53243. var fields []string
  53244. if m.addstatus != nil {
  53245. fields = append(fields, xunjiservice.FieldStatus)
  53246. }
  53247. if m.addxunji_id != nil {
  53248. fields = append(fields, xunjiservice.FieldXunjiID)
  53249. }
  53250. if m.addorganization_id != nil {
  53251. fields = append(fields, xunjiservice.FieldOrganizationID)
  53252. }
  53253. return fields
  53254. }
  53255. // AddedField returns the numeric value that was incremented/decremented on a field
  53256. // with the given name. The second boolean return value indicates that this field
  53257. // was not set, or was not defined in the schema.
  53258. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  53259. switch name {
  53260. case xunjiservice.FieldStatus:
  53261. return m.AddedStatus()
  53262. case xunjiservice.FieldXunjiID:
  53263. return m.AddedXunjiID()
  53264. case xunjiservice.FieldOrganizationID:
  53265. return m.AddedOrganizationID()
  53266. }
  53267. return nil, false
  53268. }
  53269. // AddField adds the value to the field with the given name. It returns an error if
  53270. // the field is not defined in the schema, or if the type mismatched the field
  53271. // type.
  53272. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  53273. switch name {
  53274. case xunjiservice.FieldStatus:
  53275. v, ok := value.(int8)
  53276. if !ok {
  53277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53278. }
  53279. m.AddStatus(v)
  53280. return nil
  53281. case xunjiservice.FieldXunjiID:
  53282. v, ok := value.(int64)
  53283. if !ok {
  53284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53285. }
  53286. m.AddXunjiID(v)
  53287. return nil
  53288. case xunjiservice.FieldOrganizationID:
  53289. v, ok := value.(int64)
  53290. if !ok {
  53291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53292. }
  53293. m.AddOrganizationID(v)
  53294. return nil
  53295. }
  53296. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  53297. }
  53298. // ClearedFields returns all nullable fields that were cleared during this
  53299. // mutation.
  53300. func (m *XunjiServiceMutation) ClearedFields() []string {
  53301. var fields []string
  53302. if m.FieldCleared(xunjiservice.FieldStatus) {
  53303. fields = append(fields, xunjiservice.FieldStatus)
  53304. }
  53305. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  53306. fields = append(fields, xunjiservice.FieldDeletedAt)
  53307. }
  53308. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  53309. fields = append(fields, xunjiservice.FieldAPIBase)
  53310. }
  53311. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  53312. fields = append(fields, xunjiservice.FieldAPIKey)
  53313. }
  53314. return fields
  53315. }
  53316. // FieldCleared returns a boolean indicating if a field with the given name was
  53317. // cleared in this mutation.
  53318. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  53319. _, ok := m.clearedFields[name]
  53320. return ok
  53321. }
  53322. // ClearField clears the value of the field with the given name. It returns an
  53323. // error if the field is not defined in the schema.
  53324. func (m *XunjiServiceMutation) ClearField(name string) error {
  53325. switch name {
  53326. case xunjiservice.FieldStatus:
  53327. m.ClearStatus()
  53328. return nil
  53329. case xunjiservice.FieldDeletedAt:
  53330. m.ClearDeletedAt()
  53331. return nil
  53332. case xunjiservice.FieldAPIBase:
  53333. m.ClearAPIBase()
  53334. return nil
  53335. case xunjiservice.FieldAPIKey:
  53336. m.ClearAPIKey()
  53337. return nil
  53338. }
  53339. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  53340. }
  53341. // ResetField resets all changes in the mutation for the field with the given name.
  53342. // It returns an error if the field is not defined in the schema.
  53343. func (m *XunjiServiceMutation) ResetField(name string) error {
  53344. switch name {
  53345. case xunjiservice.FieldCreatedAt:
  53346. m.ResetCreatedAt()
  53347. return nil
  53348. case xunjiservice.FieldUpdatedAt:
  53349. m.ResetUpdatedAt()
  53350. return nil
  53351. case xunjiservice.FieldStatus:
  53352. m.ResetStatus()
  53353. return nil
  53354. case xunjiservice.FieldDeletedAt:
  53355. m.ResetDeletedAt()
  53356. return nil
  53357. case xunjiservice.FieldXunjiID:
  53358. m.ResetXunjiID()
  53359. return nil
  53360. case xunjiservice.FieldAgentID:
  53361. m.ResetAgentID()
  53362. return nil
  53363. case xunjiservice.FieldOrganizationID:
  53364. m.ResetOrganizationID()
  53365. return nil
  53366. case xunjiservice.FieldWxid:
  53367. m.ResetWxid()
  53368. return nil
  53369. case xunjiservice.FieldAPIBase:
  53370. m.ResetAPIBase()
  53371. return nil
  53372. case xunjiservice.FieldAPIKey:
  53373. m.ResetAPIKey()
  53374. return nil
  53375. }
  53376. return fmt.Errorf("unknown XunjiService field %s", name)
  53377. }
  53378. // AddedEdges returns all edge names that were set/added in this mutation.
  53379. func (m *XunjiServiceMutation) AddedEdges() []string {
  53380. edges := make([]string, 0, 1)
  53381. if m.agent != nil {
  53382. edges = append(edges, xunjiservice.EdgeAgent)
  53383. }
  53384. return edges
  53385. }
  53386. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  53387. // name in this mutation.
  53388. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  53389. switch name {
  53390. case xunjiservice.EdgeAgent:
  53391. if id := m.agent; id != nil {
  53392. return []ent.Value{*id}
  53393. }
  53394. }
  53395. return nil
  53396. }
  53397. // RemovedEdges returns all edge names that were removed in this mutation.
  53398. func (m *XunjiServiceMutation) RemovedEdges() []string {
  53399. edges := make([]string, 0, 1)
  53400. return edges
  53401. }
  53402. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  53403. // the given name in this mutation.
  53404. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  53405. return nil
  53406. }
  53407. // ClearedEdges returns all edge names that were cleared in this mutation.
  53408. func (m *XunjiServiceMutation) ClearedEdges() []string {
  53409. edges := make([]string, 0, 1)
  53410. if m.clearedagent {
  53411. edges = append(edges, xunjiservice.EdgeAgent)
  53412. }
  53413. return edges
  53414. }
  53415. // EdgeCleared returns a boolean which indicates if the edge with the given name
  53416. // was cleared in this mutation.
  53417. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  53418. switch name {
  53419. case xunjiservice.EdgeAgent:
  53420. return m.clearedagent
  53421. }
  53422. return false
  53423. }
  53424. // ClearEdge clears the value of the edge with the given name. It returns an error
  53425. // if that edge is not defined in the schema.
  53426. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  53427. switch name {
  53428. case xunjiservice.EdgeAgent:
  53429. m.ClearAgent()
  53430. return nil
  53431. }
  53432. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  53433. }
  53434. // ResetEdge resets all changes to the edge with the given name in this mutation.
  53435. // It returns an error if the edge is not defined in the schema.
  53436. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  53437. switch name {
  53438. case xunjiservice.EdgeAgent:
  53439. m.ResetAgent()
  53440. return nil
  53441. }
  53442. return fmt.Errorf("unknown XunjiService edge %s", name)
  53443. }