mutation.go 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/compapiasynctask"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/contactfield"
  21. "wechat-api/ent/contactfieldtemplate"
  22. "wechat-api/ent/creditbalance"
  23. "wechat-api/ent/creditusage"
  24. "wechat-api/ent/custom_types"
  25. "wechat-api/ent/employee"
  26. "wechat-api/ent/employeeconfig"
  27. "wechat-api/ent/label"
  28. "wechat-api/ent/labellog"
  29. "wechat-api/ent/labelrelationship"
  30. "wechat-api/ent/labeltagging"
  31. "wechat-api/ent/message"
  32. "wechat-api/ent/messagerecords"
  33. "wechat-api/ent/msg"
  34. "wechat-api/ent/payrecharge"
  35. "wechat-api/ent/predicate"
  36. "wechat-api/ent/server"
  37. "wechat-api/ent/sopnode"
  38. "wechat-api/ent/sopstage"
  39. "wechat-api/ent/soptask"
  40. "wechat-api/ent/token"
  41. "wechat-api/ent/tutorial"
  42. "wechat-api/ent/usagedetail"
  43. "wechat-api/ent/usagestatisticday"
  44. "wechat-api/ent/usagestatistichour"
  45. "wechat-api/ent/usagestatisticmonth"
  46. "wechat-api/ent/usagetotal"
  47. "wechat-api/ent/whatsapp"
  48. "wechat-api/ent/whatsappchannel"
  49. "wechat-api/ent/workexperience"
  50. "wechat-api/ent/wpchatroom"
  51. "wechat-api/ent/wpchatroommember"
  52. "wechat-api/ent/wx"
  53. "wechat-api/ent/wxcard"
  54. "wechat-api/ent/wxcarduser"
  55. "wechat-api/ent/wxcardvisit"
  56. "entgo.io/ent"
  57. "entgo.io/ent/dialect/sql"
  58. )
  59. const (
  60. // Operation types.
  61. OpCreate = ent.OpCreate
  62. OpDelete = ent.OpDelete
  63. OpDeleteOne = ent.OpDeleteOne
  64. OpUpdate = ent.OpUpdate
  65. OpUpdateOne = ent.OpUpdateOne
  66. // Node types.
  67. TypeAgent = "Agent"
  68. TypeAgentBase = "AgentBase"
  69. TypeAliyunAvatar = "AliyunAvatar"
  70. TypeAllocAgent = "AllocAgent"
  71. TypeApiKey = "ApiKey"
  72. TypeBatchMsg = "BatchMsg"
  73. TypeCategory = "Category"
  74. TypeChatRecords = "ChatRecords"
  75. TypeChatSession = "ChatSession"
  76. TypeCompapiAsynctask = "CompapiAsynctask"
  77. TypeContact = "Contact"
  78. TypeContactField = "ContactField"
  79. TypeContactFieldTemplate = "ContactFieldTemplate"
  80. TypeCreditBalance = "CreditBalance"
  81. TypeCreditUsage = "CreditUsage"
  82. TypeEmployee = "Employee"
  83. TypeEmployeeConfig = "EmployeeConfig"
  84. TypeLabel = "Label"
  85. TypeLabelLog = "LabelLog"
  86. TypeLabelRelationship = "LabelRelationship"
  87. TypeLabelTagging = "LabelTagging"
  88. TypeMessage = "Message"
  89. TypeMessageRecords = "MessageRecords"
  90. TypeMsg = "Msg"
  91. TypePayRecharge = "PayRecharge"
  92. TypeServer = "Server"
  93. TypeSopNode = "SopNode"
  94. TypeSopStage = "SopStage"
  95. TypeSopTask = "SopTask"
  96. TypeToken = "Token"
  97. TypeTutorial = "Tutorial"
  98. TypeUsageDetail = "UsageDetail"
  99. TypeUsageStatisticDay = "UsageStatisticDay"
  100. TypeUsageStatisticHour = "UsageStatisticHour"
  101. TypeUsageStatisticMonth = "UsageStatisticMonth"
  102. TypeUsageTotal = "UsageTotal"
  103. TypeWhatsapp = "Whatsapp"
  104. TypeWhatsappChannel = "WhatsappChannel"
  105. TypeWorkExperience = "WorkExperience"
  106. TypeWpChatroom = "WpChatroom"
  107. TypeWpChatroomMember = "WpChatroomMember"
  108. TypeWx = "Wx"
  109. TypeWxCard = "WxCard"
  110. TypeWxCardUser = "WxCardUser"
  111. TypeWxCardVisit = "WxCardVisit"
  112. )
  113. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  114. type AgentMutation struct {
  115. config
  116. op Op
  117. typ string
  118. id *uint64
  119. created_at *time.Time
  120. updated_at *time.Time
  121. deleted_at *time.Time
  122. name *string
  123. role *string
  124. status *int
  125. addstatus *int
  126. background *string
  127. examples *string
  128. organization_id *uint64
  129. addorganization_id *int64
  130. dataset_id *string
  131. collection_id *string
  132. model *string
  133. api_base *string
  134. api_key *string
  135. _type *int
  136. add_type *int
  137. clearedFields map[string]struct{}
  138. wx_agent map[uint64]struct{}
  139. removedwx_agent map[uint64]struct{}
  140. clearedwx_agent bool
  141. token_agent map[uint64]struct{}
  142. removedtoken_agent map[uint64]struct{}
  143. clearedtoken_agent bool
  144. wa_agent map[uint64]struct{}
  145. removedwa_agent map[uint64]struct{}
  146. clearedwa_agent bool
  147. key_agent map[uint64]struct{}
  148. removedkey_agent map[uint64]struct{}
  149. clearedkey_agent bool
  150. done bool
  151. oldValue func(context.Context) (*Agent, error)
  152. predicates []predicate.Agent
  153. }
  154. var _ ent.Mutation = (*AgentMutation)(nil)
  155. // agentOption allows management of the mutation configuration using functional options.
  156. type agentOption func(*AgentMutation)
  157. // newAgentMutation creates new mutation for the Agent entity.
  158. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  159. m := &AgentMutation{
  160. config: c,
  161. op: op,
  162. typ: TypeAgent,
  163. clearedFields: make(map[string]struct{}),
  164. }
  165. for _, opt := range opts {
  166. opt(m)
  167. }
  168. return m
  169. }
  170. // withAgentID sets the ID field of the mutation.
  171. func withAgentID(id uint64) agentOption {
  172. return func(m *AgentMutation) {
  173. var (
  174. err error
  175. once sync.Once
  176. value *Agent
  177. )
  178. m.oldValue = func(ctx context.Context) (*Agent, error) {
  179. once.Do(func() {
  180. if m.done {
  181. err = errors.New("querying old values post mutation is not allowed")
  182. } else {
  183. value, err = m.Client().Agent.Get(ctx, id)
  184. }
  185. })
  186. return value, err
  187. }
  188. m.id = &id
  189. }
  190. }
  191. // withAgent sets the old Agent of the mutation.
  192. func withAgent(node *Agent) agentOption {
  193. return func(m *AgentMutation) {
  194. m.oldValue = func(context.Context) (*Agent, error) {
  195. return node, nil
  196. }
  197. m.id = &node.ID
  198. }
  199. }
  200. // Client returns a new `ent.Client` from the mutation. If the mutation was
  201. // executed in a transaction (ent.Tx), a transactional client is returned.
  202. func (m AgentMutation) Client() *Client {
  203. client := &Client{config: m.config}
  204. client.init()
  205. return client
  206. }
  207. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  208. // it returns an error otherwise.
  209. func (m AgentMutation) Tx() (*Tx, error) {
  210. if _, ok := m.driver.(*txDriver); !ok {
  211. return nil, errors.New("ent: mutation is not running in a transaction")
  212. }
  213. tx := &Tx{config: m.config}
  214. tx.init()
  215. return tx, nil
  216. }
  217. // SetID sets the value of the id field. Note that this
  218. // operation is only accepted on creation of Agent entities.
  219. func (m *AgentMutation) SetID(id uint64) {
  220. m.id = &id
  221. }
  222. // ID returns the ID value in the mutation. Note that the ID is only available
  223. // if it was provided to the builder or after it was returned from the database.
  224. func (m *AgentMutation) ID() (id uint64, exists bool) {
  225. if m.id == nil {
  226. return
  227. }
  228. return *m.id, true
  229. }
  230. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  231. // That means, if the mutation is applied within a transaction with an isolation level such
  232. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  233. // or updated by the mutation.
  234. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  235. switch {
  236. case m.op.Is(OpUpdateOne | OpDeleteOne):
  237. id, exists := m.ID()
  238. if exists {
  239. return []uint64{id}, nil
  240. }
  241. fallthrough
  242. case m.op.Is(OpUpdate | OpDelete):
  243. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  244. default:
  245. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  246. }
  247. }
  248. // SetCreatedAt sets the "created_at" field.
  249. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  250. m.created_at = &t
  251. }
  252. // CreatedAt returns the value of the "created_at" field in the mutation.
  253. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  254. v := m.created_at
  255. if v == nil {
  256. return
  257. }
  258. return *v, true
  259. }
  260. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  261. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  263. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  264. if !m.op.Is(OpUpdateOne) {
  265. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  266. }
  267. if m.id == nil || m.oldValue == nil {
  268. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  269. }
  270. oldValue, err := m.oldValue(ctx)
  271. if err != nil {
  272. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  273. }
  274. return oldValue.CreatedAt, nil
  275. }
  276. // ResetCreatedAt resets all changes to the "created_at" field.
  277. func (m *AgentMutation) ResetCreatedAt() {
  278. m.created_at = nil
  279. }
  280. // SetUpdatedAt sets the "updated_at" field.
  281. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  282. m.updated_at = &t
  283. }
  284. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  285. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  286. v := m.updated_at
  287. if v == nil {
  288. return
  289. }
  290. return *v, true
  291. }
  292. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  293. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  295. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  296. if !m.op.Is(OpUpdateOne) {
  297. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  298. }
  299. if m.id == nil || m.oldValue == nil {
  300. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  301. }
  302. oldValue, err := m.oldValue(ctx)
  303. if err != nil {
  304. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  305. }
  306. return oldValue.UpdatedAt, nil
  307. }
  308. // ResetUpdatedAt resets all changes to the "updated_at" field.
  309. func (m *AgentMutation) ResetUpdatedAt() {
  310. m.updated_at = nil
  311. }
  312. // SetDeletedAt sets the "deleted_at" field.
  313. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  314. m.deleted_at = &t
  315. }
  316. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  317. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  318. v := m.deleted_at
  319. if v == nil {
  320. return
  321. }
  322. return *v, true
  323. }
  324. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  325. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  327. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  328. if !m.op.Is(OpUpdateOne) {
  329. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  330. }
  331. if m.id == nil || m.oldValue == nil {
  332. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  333. }
  334. oldValue, err := m.oldValue(ctx)
  335. if err != nil {
  336. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  337. }
  338. return oldValue.DeletedAt, nil
  339. }
  340. // ClearDeletedAt clears the value of the "deleted_at" field.
  341. func (m *AgentMutation) ClearDeletedAt() {
  342. m.deleted_at = nil
  343. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  344. }
  345. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  346. func (m *AgentMutation) DeletedAtCleared() bool {
  347. _, ok := m.clearedFields[agent.FieldDeletedAt]
  348. return ok
  349. }
  350. // ResetDeletedAt resets all changes to the "deleted_at" field.
  351. func (m *AgentMutation) ResetDeletedAt() {
  352. m.deleted_at = nil
  353. delete(m.clearedFields, agent.FieldDeletedAt)
  354. }
  355. // SetName sets the "name" field.
  356. func (m *AgentMutation) SetName(s string) {
  357. m.name = &s
  358. }
  359. // Name returns the value of the "name" field in the mutation.
  360. func (m *AgentMutation) Name() (r string, exists bool) {
  361. v := m.name
  362. if v == nil {
  363. return
  364. }
  365. return *v, true
  366. }
  367. // OldName returns the old "name" field's value of the Agent entity.
  368. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  370. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  371. if !m.op.Is(OpUpdateOne) {
  372. return v, errors.New("OldName is only allowed on UpdateOne operations")
  373. }
  374. if m.id == nil || m.oldValue == nil {
  375. return v, errors.New("OldName requires an ID field in the mutation")
  376. }
  377. oldValue, err := m.oldValue(ctx)
  378. if err != nil {
  379. return v, fmt.Errorf("querying old value for OldName: %w", err)
  380. }
  381. return oldValue.Name, nil
  382. }
  383. // ResetName resets all changes to the "name" field.
  384. func (m *AgentMutation) ResetName() {
  385. m.name = nil
  386. }
  387. // SetRole sets the "role" field.
  388. func (m *AgentMutation) SetRole(s string) {
  389. m.role = &s
  390. }
  391. // Role returns the value of the "role" field in the mutation.
  392. func (m *AgentMutation) Role() (r string, exists bool) {
  393. v := m.role
  394. if v == nil {
  395. return
  396. }
  397. return *v, true
  398. }
  399. // OldRole returns the old "role" field's value of the Agent entity.
  400. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  402. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  403. if !m.op.Is(OpUpdateOne) {
  404. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  405. }
  406. if m.id == nil || m.oldValue == nil {
  407. return v, errors.New("OldRole requires an ID field in the mutation")
  408. }
  409. oldValue, err := m.oldValue(ctx)
  410. if err != nil {
  411. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  412. }
  413. return oldValue.Role, nil
  414. }
  415. // ClearRole clears the value of the "role" field.
  416. func (m *AgentMutation) ClearRole() {
  417. m.role = nil
  418. m.clearedFields[agent.FieldRole] = struct{}{}
  419. }
  420. // RoleCleared returns if the "role" field was cleared in this mutation.
  421. func (m *AgentMutation) RoleCleared() bool {
  422. _, ok := m.clearedFields[agent.FieldRole]
  423. return ok
  424. }
  425. // ResetRole resets all changes to the "role" field.
  426. func (m *AgentMutation) ResetRole() {
  427. m.role = nil
  428. delete(m.clearedFields, agent.FieldRole)
  429. }
  430. // SetStatus sets the "status" field.
  431. func (m *AgentMutation) SetStatus(i int) {
  432. m.status = &i
  433. m.addstatus = nil
  434. }
  435. // Status returns the value of the "status" field in the mutation.
  436. func (m *AgentMutation) Status() (r int, exists bool) {
  437. v := m.status
  438. if v == nil {
  439. return
  440. }
  441. return *v, true
  442. }
  443. // OldStatus returns the old "status" field's value of the Agent entity.
  444. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  446. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  447. if !m.op.Is(OpUpdateOne) {
  448. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  449. }
  450. if m.id == nil || m.oldValue == nil {
  451. return v, errors.New("OldStatus requires an ID field in the mutation")
  452. }
  453. oldValue, err := m.oldValue(ctx)
  454. if err != nil {
  455. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  456. }
  457. return oldValue.Status, nil
  458. }
  459. // AddStatus adds i to the "status" field.
  460. func (m *AgentMutation) AddStatus(i int) {
  461. if m.addstatus != nil {
  462. *m.addstatus += i
  463. } else {
  464. m.addstatus = &i
  465. }
  466. }
  467. // AddedStatus returns the value that was added to the "status" field in this mutation.
  468. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  469. v := m.addstatus
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // ClearStatus clears the value of the "status" field.
  476. func (m *AgentMutation) ClearStatus() {
  477. m.status = nil
  478. m.addstatus = nil
  479. m.clearedFields[agent.FieldStatus] = struct{}{}
  480. }
  481. // StatusCleared returns if the "status" field was cleared in this mutation.
  482. func (m *AgentMutation) StatusCleared() bool {
  483. _, ok := m.clearedFields[agent.FieldStatus]
  484. return ok
  485. }
  486. // ResetStatus resets all changes to the "status" field.
  487. func (m *AgentMutation) ResetStatus() {
  488. m.status = nil
  489. m.addstatus = nil
  490. delete(m.clearedFields, agent.FieldStatus)
  491. }
  492. // SetBackground sets the "background" field.
  493. func (m *AgentMutation) SetBackground(s string) {
  494. m.background = &s
  495. }
  496. // Background returns the value of the "background" field in the mutation.
  497. func (m *AgentMutation) Background() (r string, exists bool) {
  498. v := m.background
  499. if v == nil {
  500. return
  501. }
  502. return *v, true
  503. }
  504. // OldBackground returns the old "background" field's value of the Agent entity.
  505. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  507. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  508. if !m.op.Is(OpUpdateOne) {
  509. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  510. }
  511. if m.id == nil || m.oldValue == nil {
  512. return v, errors.New("OldBackground requires an ID field in the mutation")
  513. }
  514. oldValue, err := m.oldValue(ctx)
  515. if err != nil {
  516. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  517. }
  518. return oldValue.Background, nil
  519. }
  520. // ClearBackground clears the value of the "background" field.
  521. func (m *AgentMutation) ClearBackground() {
  522. m.background = nil
  523. m.clearedFields[agent.FieldBackground] = struct{}{}
  524. }
  525. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  526. func (m *AgentMutation) BackgroundCleared() bool {
  527. _, ok := m.clearedFields[agent.FieldBackground]
  528. return ok
  529. }
  530. // ResetBackground resets all changes to the "background" field.
  531. func (m *AgentMutation) ResetBackground() {
  532. m.background = nil
  533. delete(m.clearedFields, agent.FieldBackground)
  534. }
  535. // SetExamples sets the "examples" field.
  536. func (m *AgentMutation) SetExamples(s string) {
  537. m.examples = &s
  538. }
  539. // Examples returns the value of the "examples" field in the mutation.
  540. func (m *AgentMutation) Examples() (r string, exists bool) {
  541. v := m.examples
  542. if v == nil {
  543. return
  544. }
  545. return *v, true
  546. }
  547. // OldExamples returns the old "examples" field's value of the Agent entity.
  548. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  550. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  551. if !m.op.Is(OpUpdateOne) {
  552. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  553. }
  554. if m.id == nil || m.oldValue == nil {
  555. return v, errors.New("OldExamples requires an ID field in the mutation")
  556. }
  557. oldValue, err := m.oldValue(ctx)
  558. if err != nil {
  559. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  560. }
  561. return oldValue.Examples, nil
  562. }
  563. // ClearExamples clears the value of the "examples" field.
  564. func (m *AgentMutation) ClearExamples() {
  565. m.examples = nil
  566. m.clearedFields[agent.FieldExamples] = struct{}{}
  567. }
  568. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  569. func (m *AgentMutation) ExamplesCleared() bool {
  570. _, ok := m.clearedFields[agent.FieldExamples]
  571. return ok
  572. }
  573. // ResetExamples resets all changes to the "examples" field.
  574. func (m *AgentMutation) ResetExamples() {
  575. m.examples = nil
  576. delete(m.clearedFields, agent.FieldExamples)
  577. }
  578. // SetOrganizationID sets the "organization_id" field.
  579. func (m *AgentMutation) SetOrganizationID(u uint64) {
  580. m.organization_id = &u
  581. m.addorganization_id = nil
  582. }
  583. // OrganizationID returns the value of the "organization_id" field in the mutation.
  584. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  585. v := m.organization_id
  586. if v == nil {
  587. return
  588. }
  589. return *v, true
  590. }
  591. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  592. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  594. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  595. if !m.op.Is(OpUpdateOne) {
  596. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  597. }
  598. if m.id == nil || m.oldValue == nil {
  599. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  600. }
  601. oldValue, err := m.oldValue(ctx)
  602. if err != nil {
  603. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  604. }
  605. return oldValue.OrganizationID, nil
  606. }
  607. // AddOrganizationID adds u to the "organization_id" field.
  608. func (m *AgentMutation) AddOrganizationID(u int64) {
  609. if m.addorganization_id != nil {
  610. *m.addorganization_id += u
  611. } else {
  612. m.addorganization_id = &u
  613. }
  614. }
  615. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  616. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  617. v := m.addorganization_id
  618. if v == nil {
  619. return
  620. }
  621. return *v, true
  622. }
  623. // ResetOrganizationID resets all changes to the "organization_id" field.
  624. func (m *AgentMutation) ResetOrganizationID() {
  625. m.organization_id = nil
  626. m.addorganization_id = nil
  627. }
  628. // SetDatasetID sets the "dataset_id" field.
  629. func (m *AgentMutation) SetDatasetID(s string) {
  630. m.dataset_id = &s
  631. }
  632. // DatasetID returns the value of the "dataset_id" field in the mutation.
  633. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  634. v := m.dataset_id
  635. if v == nil {
  636. return
  637. }
  638. return *v, true
  639. }
  640. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  641. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  643. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  644. if !m.op.Is(OpUpdateOne) {
  645. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  646. }
  647. if m.id == nil || m.oldValue == nil {
  648. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  649. }
  650. oldValue, err := m.oldValue(ctx)
  651. if err != nil {
  652. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  653. }
  654. return oldValue.DatasetID, nil
  655. }
  656. // ResetDatasetID resets all changes to the "dataset_id" field.
  657. func (m *AgentMutation) ResetDatasetID() {
  658. m.dataset_id = nil
  659. }
  660. // SetCollectionID sets the "collection_id" field.
  661. func (m *AgentMutation) SetCollectionID(s string) {
  662. m.collection_id = &s
  663. }
  664. // CollectionID returns the value of the "collection_id" field in the mutation.
  665. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  666. v := m.collection_id
  667. if v == nil {
  668. return
  669. }
  670. return *v, true
  671. }
  672. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  673. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  675. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  676. if !m.op.Is(OpUpdateOne) {
  677. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  678. }
  679. if m.id == nil || m.oldValue == nil {
  680. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  681. }
  682. oldValue, err := m.oldValue(ctx)
  683. if err != nil {
  684. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  685. }
  686. return oldValue.CollectionID, nil
  687. }
  688. // ResetCollectionID resets all changes to the "collection_id" field.
  689. func (m *AgentMutation) ResetCollectionID() {
  690. m.collection_id = nil
  691. }
  692. // SetModel sets the "model" field.
  693. func (m *AgentMutation) SetModel(s string) {
  694. m.model = &s
  695. }
  696. // Model returns the value of the "model" field in the mutation.
  697. func (m *AgentMutation) Model() (r string, exists bool) {
  698. v := m.model
  699. if v == nil {
  700. return
  701. }
  702. return *v, true
  703. }
  704. // OldModel returns the old "model" field's value of the Agent entity.
  705. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  707. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  708. if !m.op.Is(OpUpdateOne) {
  709. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  710. }
  711. if m.id == nil || m.oldValue == nil {
  712. return v, errors.New("OldModel requires an ID field in the mutation")
  713. }
  714. oldValue, err := m.oldValue(ctx)
  715. if err != nil {
  716. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  717. }
  718. return oldValue.Model, nil
  719. }
  720. // ClearModel clears the value of the "model" field.
  721. func (m *AgentMutation) ClearModel() {
  722. m.model = nil
  723. m.clearedFields[agent.FieldModel] = struct{}{}
  724. }
  725. // ModelCleared returns if the "model" field was cleared in this mutation.
  726. func (m *AgentMutation) ModelCleared() bool {
  727. _, ok := m.clearedFields[agent.FieldModel]
  728. return ok
  729. }
  730. // ResetModel resets all changes to the "model" field.
  731. func (m *AgentMutation) ResetModel() {
  732. m.model = nil
  733. delete(m.clearedFields, agent.FieldModel)
  734. }
  735. // SetAPIBase sets the "api_base" field.
  736. func (m *AgentMutation) SetAPIBase(s string) {
  737. m.api_base = &s
  738. }
  739. // APIBase returns the value of the "api_base" field in the mutation.
  740. func (m *AgentMutation) APIBase() (r string, exists bool) {
  741. v := m.api_base
  742. if v == nil {
  743. return
  744. }
  745. return *v, true
  746. }
  747. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  748. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  750. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  751. if !m.op.Is(OpUpdateOne) {
  752. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  753. }
  754. if m.id == nil || m.oldValue == nil {
  755. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  756. }
  757. oldValue, err := m.oldValue(ctx)
  758. if err != nil {
  759. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  760. }
  761. return oldValue.APIBase, nil
  762. }
  763. // ClearAPIBase clears the value of the "api_base" field.
  764. func (m *AgentMutation) ClearAPIBase() {
  765. m.api_base = nil
  766. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  767. }
  768. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  769. func (m *AgentMutation) APIBaseCleared() bool {
  770. _, ok := m.clearedFields[agent.FieldAPIBase]
  771. return ok
  772. }
  773. // ResetAPIBase resets all changes to the "api_base" field.
  774. func (m *AgentMutation) ResetAPIBase() {
  775. m.api_base = nil
  776. delete(m.clearedFields, agent.FieldAPIBase)
  777. }
  778. // SetAPIKey sets the "api_key" field.
  779. func (m *AgentMutation) SetAPIKey(s string) {
  780. m.api_key = &s
  781. }
  782. // APIKey returns the value of the "api_key" field in the mutation.
  783. func (m *AgentMutation) APIKey() (r string, exists bool) {
  784. v := m.api_key
  785. if v == nil {
  786. return
  787. }
  788. return *v, true
  789. }
  790. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  791. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  793. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  794. if !m.op.Is(OpUpdateOne) {
  795. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  796. }
  797. if m.id == nil || m.oldValue == nil {
  798. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  799. }
  800. oldValue, err := m.oldValue(ctx)
  801. if err != nil {
  802. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  803. }
  804. return oldValue.APIKey, nil
  805. }
  806. // ClearAPIKey clears the value of the "api_key" field.
  807. func (m *AgentMutation) ClearAPIKey() {
  808. m.api_key = nil
  809. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  810. }
  811. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  812. func (m *AgentMutation) APIKeyCleared() bool {
  813. _, ok := m.clearedFields[agent.FieldAPIKey]
  814. return ok
  815. }
  816. // ResetAPIKey resets all changes to the "api_key" field.
  817. func (m *AgentMutation) ResetAPIKey() {
  818. m.api_key = nil
  819. delete(m.clearedFields, agent.FieldAPIKey)
  820. }
  821. // SetType sets the "type" field.
  822. func (m *AgentMutation) SetType(i int) {
  823. m._type = &i
  824. m.add_type = nil
  825. }
  826. // GetType returns the value of the "type" field in the mutation.
  827. func (m *AgentMutation) GetType() (r int, exists bool) {
  828. v := m._type
  829. if v == nil {
  830. return
  831. }
  832. return *v, true
  833. }
  834. // OldType returns the old "type" field's value of the Agent entity.
  835. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  837. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  838. if !m.op.Is(OpUpdateOne) {
  839. return v, errors.New("OldType is only allowed on UpdateOne operations")
  840. }
  841. if m.id == nil || m.oldValue == nil {
  842. return v, errors.New("OldType requires an ID field in the mutation")
  843. }
  844. oldValue, err := m.oldValue(ctx)
  845. if err != nil {
  846. return v, fmt.Errorf("querying old value for OldType: %w", err)
  847. }
  848. return oldValue.Type, nil
  849. }
  850. // AddType adds i to the "type" field.
  851. func (m *AgentMutation) AddType(i int) {
  852. if m.add_type != nil {
  853. *m.add_type += i
  854. } else {
  855. m.add_type = &i
  856. }
  857. }
  858. // AddedType returns the value that was added to the "type" field in this mutation.
  859. func (m *AgentMutation) AddedType() (r int, exists bool) {
  860. v := m.add_type
  861. if v == nil {
  862. return
  863. }
  864. return *v, true
  865. }
  866. // ClearType clears the value of the "type" field.
  867. func (m *AgentMutation) ClearType() {
  868. m._type = nil
  869. m.add_type = nil
  870. m.clearedFields[agent.FieldType] = struct{}{}
  871. }
  872. // TypeCleared returns if the "type" field was cleared in this mutation.
  873. func (m *AgentMutation) TypeCleared() bool {
  874. _, ok := m.clearedFields[agent.FieldType]
  875. return ok
  876. }
  877. // ResetType resets all changes to the "type" field.
  878. func (m *AgentMutation) ResetType() {
  879. m._type = nil
  880. m.add_type = nil
  881. delete(m.clearedFields, agent.FieldType)
  882. }
  883. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  884. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  885. if m.wx_agent == nil {
  886. m.wx_agent = make(map[uint64]struct{})
  887. }
  888. for i := range ids {
  889. m.wx_agent[ids[i]] = struct{}{}
  890. }
  891. }
  892. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  893. func (m *AgentMutation) ClearWxAgent() {
  894. m.clearedwx_agent = true
  895. }
  896. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  897. func (m *AgentMutation) WxAgentCleared() bool {
  898. return m.clearedwx_agent
  899. }
  900. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  901. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  902. if m.removedwx_agent == nil {
  903. m.removedwx_agent = make(map[uint64]struct{})
  904. }
  905. for i := range ids {
  906. delete(m.wx_agent, ids[i])
  907. m.removedwx_agent[ids[i]] = struct{}{}
  908. }
  909. }
  910. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  911. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  912. for id := range m.removedwx_agent {
  913. ids = append(ids, id)
  914. }
  915. return
  916. }
  917. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  918. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  919. for id := range m.wx_agent {
  920. ids = append(ids, id)
  921. }
  922. return
  923. }
  924. // ResetWxAgent resets all changes to the "wx_agent" edge.
  925. func (m *AgentMutation) ResetWxAgent() {
  926. m.wx_agent = nil
  927. m.clearedwx_agent = false
  928. m.removedwx_agent = nil
  929. }
  930. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  931. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  932. if m.token_agent == nil {
  933. m.token_agent = make(map[uint64]struct{})
  934. }
  935. for i := range ids {
  936. m.token_agent[ids[i]] = struct{}{}
  937. }
  938. }
  939. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  940. func (m *AgentMutation) ClearTokenAgent() {
  941. m.clearedtoken_agent = true
  942. }
  943. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  944. func (m *AgentMutation) TokenAgentCleared() bool {
  945. return m.clearedtoken_agent
  946. }
  947. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  948. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  949. if m.removedtoken_agent == nil {
  950. m.removedtoken_agent = make(map[uint64]struct{})
  951. }
  952. for i := range ids {
  953. delete(m.token_agent, ids[i])
  954. m.removedtoken_agent[ids[i]] = struct{}{}
  955. }
  956. }
  957. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  958. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  959. for id := range m.removedtoken_agent {
  960. ids = append(ids, id)
  961. }
  962. return
  963. }
  964. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  965. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  966. for id := range m.token_agent {
  967. ids = append(ids, id)
  968. }
  969. return
  970. }
  971. // ResetTokenAgent resets all changes to the "token_agent" edge.
  972. func (m *AgentMutation) ResetTokenAgent() {
  973. m.token_agent = nil
  974. m.clearedtoken_agent = false
  975. m.removedtoken_agent = nil
  976. }
  977. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  978. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  979. if m.wa_agent == nil {
  980. m.wa_agent = make(map[uint64]struct{})
  981. }
  982. for i := range ids {
  983. m.wa_agent[ids[i]] = struct{}{}
  984. }
  985. }
  986. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  987. func (m *AgentMutation) ClearWaAgent() {
  988. m.clearedwa_agent = true
  989. }
  990. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  991. func (m *AgentMutation) WaAgentCleared() bool {
  992. return m.clearedwa_agent
  993. }
  994. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  995. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  996. if m.removedwa_agent == nil {
  997. m.removedwa_agent = make(map[uint64]struct{})
  998. }
  999. for i := range ids {
  1000. delete(m.wa_agent, ids[i])
  1001. m.removedwa_agent[ids[i]] = struct{}{}
  1002. }
  1003. }
  1004. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1005. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1006. for id := range m.removedwa_agent {
  1007. ids = append(ids, id)
  1008. }
  1009. return
  1010. }
  1011. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1012. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1013. for id := range m.wa_agent {
  1014. ids = append(ids, id)
  1015. }
  1016. return
  1017. }
  1018. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1019. func (m *AgentMutation) ResetWaAgent() {
  1020. m.wa_agent = nil
  1021. m.clearedwa_agent = false
  1022. m.removedwa_agent = nil
  1023. }
  1024. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1025. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1026. if m.key_agent == nil {
  1027. m.key_agent = make(map[uint64]struct{})
  1028. }
  1029. for i := range ids {
  1030. m.key_agent[ids[i]] = struct{}{}
  1031. }
  1032. }
  1033. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1034. func (m *AgentMutation) ClearKeyAgent() {
  1035. m.clearedkey_agent = true
  1036. }
  1037. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1038. func (m *AgentMutation) KeyAgentCleared() bool {
  1039. return m.clearedkey_agent
  1040. }
  1041. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1042. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1043. if m.removedkey_agent == nil {
  1044. m.removedkey_agent = make(map[uint64]struct{})
  1045. }
  1046. for i := range ids {
  1047. delete(m.key_agent, ids[i])
  1048. m.removedkey_agent[ids[i]] = struct{}{}
  1049. }
  1050. }
  1051. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1052. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1053. for id := range m.removedkey_agent {
  1054. ids = append(ids, id)
  1055. }
  1056. return
  1057. }
  1058. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1059. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1060. for id := range m.key_agent {
  1061. ids = append(ids, id)
  1062. }
  1063. return
  1064. }
  1065. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1066. func (m *AgentMutation) ResetKeyAgent() {
  1067. m.key_agent = nil
  1068. m.clearedkey_agent = false
  1069. m.removedkey_agent = nil
  1070. }
  1071. // Where appends a list predicates to the AgentMutation builder.
  1072. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1073. m.predicates = append(m.predicates, ps...)
  1074. }
  1075. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1076. // users can use type-assertion to append predicates that do not depend on any generated package.
  1077. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1078. p := make([]predicate.Agent, len(ps))
  1079. for i := range ps {
  1080. p[i] = ps[i]
  1081. }
  1082. m.Where(p...)
  1083. }
  1084. // Op returns the operation name.
  1085. func (m *AgentMutation) Op() Op {
  1086. return m.op
  1087. }
  1088. // SetOp allows setting the mutation operation.
  1089. func (m *AgentMutation) SetOp(op Op) {
  1090. m.op = op
  1091. }
  1092. // Type returns the node type of this mutation (Agent).
  1093. func (m *AgentMutation) Type() string {
  1094. return m.typ
  1095. }
  1096. // Fields returns all fields that were changed during this mutation. Note that in
  1097. // order to get all numeric fields that were incremented/decremented, call
  1098. // AddedFields().
  1099. func (m *AgentMutation) Fields() []string {
  1100. fields := make([]string, 0, 15)
  1101. if m.created_at != nil {
  1102. fields = append(fields, agent.FieldCreatedAt)
  1103. }
  1104. if m.updated_at != nil {
  1105. fields = append(fields, agent.FieldUpdatedAt)
  1106. }
  1107. if m.deleted_at != nil {
  1108. fields = append(fields, agent.FieldDeletedAt)
  1109. }
  1110. if m.name != nil {
  1111. fields = append(fields, agent.FieldName)
  1112. }
  1113. if m.role != nil {
  1114. fields = append(fields, agent.FieldRole)
  1115. }
  1116. if m.status != nil {
  1117. fields = append(fields, agent.FieldStatus)
  1118. }
  1119. if m.background != nil {
  1120. fields = append(fields, agent.FieldBackground)
  1121. }
  1122. if m.examples != nil {
  1123. fields = append(fields, agent.FieldExamples)
  1124. }
  1125. if m.organization_id != nil {
  1126. fields = append(fields, agent.FieldOrganizationID)
  1127. }
  1128. if m.dataset_id != nil {
  1129. fields = append(fields, agent.FieldDatasetID)
  1130. }
  1131. if m.collection_id != nil {
  1132. fields = append(fields, agent.FieldCollectionID)
  1133. }
  1134. if m.model != nil {
  1135. fields = append(fields, agent.FieldModel)
  1136. }
  1137. if m.api_base != nil {
  1138. fields = append(fields, agent.FieldAPIBase)
  1139. }
  1140. if m.api_key != nil {
  1141. fields = append(fields, agent.FieldAPIKey)
  1142. }
  1143. if m._type != nil {
  1144. fields = append(fields, agent.FieldType)
  1145. }
  1146. return fields
  1147. }
  1148. // Field returns the value of a field with the given name. The second boolean
  1149. // return value indicates that this field was not set, or was not defined in the
  1150. // schema.
  1151. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1152. switch name {
  1153. case agent.FieldCreatedAt:
  1154. return m.CreatedAt()
  1155. case agent.FieldUpdatedAt:
  1156. return m.UpdatedAt()
  1157. case agent.FieldDeletedAt:
  1158. return m.DeletedAt()
  1159. case agent.FieldName:
  1160. return m.Name()
  1161. case agent.FieldRole:
  1162. return m.Role()
  1163. case agent.FieldStatus:
  1164. return m.Status()
  1165. case agent.FieldBackground:
  1166. return m.Background()
  1167. case agent.FieldExamples:
  1168. return m.Examples()
  1169. case agent.FieldOrganizationID:
  1170. return m.OrganizationID()
  1171. case agent.FieldDatasetID:
  1172. return m.DatasetID()
  1173. case agent.FieldCollectionID:
  1174. return m.CollectionID()
  1175. case agent.FieldModel:
  1176. return m.Model()
  1177. case agent.FieldAPIBase:
  1178. return m.APIBase()
  1179. case agent.FieldAPIKey:
  1180. return m.APIKey()
  1181. case agent.FieldType:
  1182. return m.GetType()
  1183. }
  1184. return nil, false
  1185. }
  1186. // OldField returns the old value of the field from the database. An error is
  1187. // returned if the mutation operation is not UpdateOne, or the query to the
  1188. // database failed.
  1189. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1190. switch name {
  1191. case agent.FieldCreatedAt:
  1192. return m.OldCreatedAt(ctx)
  1193. case agent.FieldUpdatedAt:
  1194. return m.OldUpdatedAt(ctx)
  1195. case agent.FieldDeletedAt:
  1196. return m.OldDeletedAt(ctx)
  1197. case agent.FieldName:
  1198. return m.OldName(ctx)
  1199. case agent.FieldRole:
  1200. return m.OldRole(ctx)
  1201. case agent.FieldStatus:
  1202. return m.OldStatus(ctx)
  1203. case agent.FieldBackground:
  1204. return m.OldBackground(ctx)
  1205. case agent.FieldExamples:
  1206. return m.OldExamples(ctx)
  1207. case agent.FieldOrganizationID:
  1208. return m.OldOrganizationID(ctx)
  1209. case agent.FieldDatasetID:
  1210. return m.OldDatasetID(ctx)
  1211. case agent.FieldCollectionID:
  1212. return m.OldCollectionID(ctx)
  1213. case agent.FieldModel:
  1214. return m.OldModel(ctx)
  1215. case agent.FieldAPIBase:
  1216. return m.OldAPIBase(ctx)
  1217. case agent.FieldAPIKey:
  1218. return m.OldAPIKey(ctx)
  1219. case agent.FieldType:
  1220. return m.OldType(ctx)
  1221. }
  1222. return nil, fmt.Errorf("unknown Agent field %s", name)
  1223. }
  1224. // SetField sets the value of a field with the given name. It returns an error if
  1225. // the field is not defined in the schema, or if the type mismatched the field
  1226. // type.
  1227. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1228. switch name {
  1229. case agent.FieldCreatedAt:
  1230. v, ok := value.(time.Time)
  1231. if !ok {
  1232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1233. }
  1234. m.SetCreatedAt(v)
  1235. return nil
  1236. case agent.FieldUpdatedAt:
  1237. v, ok := value.(time.Time)
  1238. if !ok {
  1239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1240. }
  1241. m.SetUpdatedAt(v)
  1242. return nil
  1243. case agent.FieldDeletedAt:
  1244. v, ok := value.(time.Time)
  1245. if !ok {
  1246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1247. }
  1248. m.SetDeletedAt(v)
  1249. return nil
  1250. case agent.FieldName:
  1251. v, ok := value.(string)
  1252. if !ok {
  1253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1254. }
  1255. m.SetName(v)
  1256. return nil
  1257. case agent.FieldRole:
  1258. v, ok := value.(string)
  1259. if !ok {
  1260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1261. }
  1262. m.SetRole(v)
  1263. return nil
  1264. case agent.FieldStatus:
  1265. v, ok := value.(int)
  1266. if !ok {
  1267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1268. }
  1269. m.SetStatus(v)
  1270. return nil
  1271. case agent.FieldBackground:
  1272. v, ok := value.(string)
  1273. if !ok {
  1274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1275. }
  1276. m.SetBackground(v)
  1277. return nil
  1278. case agent.FieldExamples:
  1279. v, ok := value.(string)
  1280. if !ok {
  1281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1282. }
  1283. m.SetExamples(v)
  1284. return nil
  1285. case agent.FieldOrganizationID:
  1286. v, ok := value.(uint64)
  1287. if !ok {
  1288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1289. }
  1290. m.SetOrganizationID(v)
  1291. return nil
  1292. case agent.FieldDatasetID:
  1293. v, ok := value.(string)
  1294. if !ok {
  1295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1296. }
  1297. m.SetDatasetID(v)
  1298. return nil
  1299. case agent.FieldCollectionID:
  1300. v, ok := value.(string)
  1301. if !ok {
  1302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1303. }
  1304. m.SetCollectionID(v)
  1305. return nil
  1306. case agent.FieldModel:
  1307. v, ok := value.(string)
  1308. if !ok {
  1309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1310. }
  1311. m.SetModel(v)
  1312. return nil
  1313. case agent.FieldAPIBase:
  1314. v, ok := value.(string)
  1315. if !ok {
  1316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1317. }
  1318. m.SetAPIBase(v)
  1319. return nil
  1320. case agent.FieldAPIKey:
  1321. v, ok := value.(string)
  1322. if !ok {
  1323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1324. }
  1325. m.SetAPIKey(v)
  1326. return nil
  1327. case agent.FieldType:
  1328. v, ok := value.(int)
  1329. if !ok {
  1330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1331. }
  1332. m.SetType(v)
  1333. return nil
  1334. }
  1335. return fmt.Errorf("unknown Agent field %s", name)
  1336. }
  1337. // AddedFields returns all numeric fields that were incremented/decremented during
  1338. // this mutation.
  1339. func (m *AgentMutation) AddedFields() []string {
  1340. var fields []string
  1341. if m.addstatus != nil {
  1342. fields = append(fields, agent.FieldStatus)
  1343. }
  1344. if m.addorganization_id != nil {
  1345. fields = append(fields, agent.FieldOrganizationID)
  1346. }
  1347. if m.add_type != nil {
  1348. fields = append(fields, agent.FieldType)
  1349. }
  1350. return fields
  1351. }
  1352. // AddedField returns the numeric value that was incremented/decremented on a field
  1353. // with the given name. The second boolean return value indicates that this field
  1354. // was not set, or was not defined in the schema.
  1355. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1356. switch name {
  1357. case agent.FieldStatus:
  1358. return m.AddedStatus()
  1359. case agent.FieldOrganizationID:
  1360. return m.AddedOrganizationID()
  1361. case agent.FieldType:
  1362. return m.AddedType()
  1363. }
  1364. return nil, false
  1365. }
  1366. // AddField adds the value to the field with the given name. It returns an error if
  1367. // the field is not defined in the schema, or if the type mismatched the field
  1368. // type.
  1369. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1370. switch name {
  1371. case agent.FieldStatus:
  1372. v, ok := value.(int)
  1373. if !ok {
  1374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1375. }
  1376. m.AddStatus(v)
  1377. return nil
  1378. case agent.FieldOrganizationID:
  1379. v, ok := value.(int64)
  1380. if !ok {
  1381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1382. }
  1383. m.AddOrganizationID(v)
  1384. return nil
  1385. case agent.FieldType:
  1386. v, ok := value.(int)
  1387. if !ok {
  1388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1389. }
  1390. m.AddType(v)
  1391. return nil
  1392. }
  1393. return fmt.Errorf("unknown Agent numeric field %s", name)
  1394. }
  1395. // ClearedFields returns all nullable fields that were cleared during this
  1396. // mutation.
  1397. func (m *AgentMutation) ClearedFields() []string {
  1398. var fields []string
  1399. if m.FieldCleared(agent.FieldDeletedAt) {
  1400. fields = append(fields, agent.FieldDeletedAt)
  1401. }
  1402. if m.FieldCleared(agent.FieldRole) {
  1403. fields = append(fields, agent.FieldRole)
  1404. }
  1405. if m.FieldCleared(agent.FieldStatus) {
  1406. fields = append(fields, agent.FieldStatus)
  1407. }
  1408. if m.FieldCleared(agent.FieldBackground) {
  1409. fields = append(fields, agent.FieldBackground)
  1410. }
  1411. if m.FieldCleared(agent.FieldExamples) {
  1412. fields = append(fields, agent.FieldExamples)
  1413. }
  1414. if m.FieldCleared(agent.FieldModel) {
  1415. fields = append(fields, agent.FieldModel)
  1416. }
  1417. if m.FieldCleared(agent.FieldAPIBase) {
  1418. fields = append(fields, agent.FieldAPIBase)
  1419. }
  1420. if m.FieldCleared(agent.FieldAPIKey) {
  1421. fields = append(fields, agent.FieldAPIKey)
  1422. }
  1423. if m.FieldCleared(agent.FieldType) {
  1424. fields = append(fields, agent.FieldType)
  1425. }
  1426. return fields
  1427. }
  1428. // FieldCleared returns a boolean indicating if a field with the given name was
  1429. // cleared in this mutation.
  1430. func (m *AgentMutation) FieldCleared(name string) bool {
  1431. _, ok := m.clearedFields[name]
  1432. return ok
  1433. }
  1434. // ClearField clears the value of the field with the given name. It returns an
  1435. // error if the field is not defined in the schema.
  1436. func (m *AgentMutation) ClearField(name string) error {
  1437. switch name {
  1438. case agent.FieldDeletedAt:
  1439. m.ClearDeletedAt()
  1440. return nil
  1441. case agent.FieldRole:
  1442. m.ClearRole()
  1443. return nil
  1444. case agent.FieldStatus:
  1445. m.ClearStatus()
  1446. return nil
  1447. case agent.FieldBackground:
  1448. m.ClearBackground()
  1449. return nil
  1450. case agent.FieldExamples:
  1451. m.ClearExamples()
  1452. return nil
  1453. case agent.FieldModel:
  1454. m.ClearModel()
  1455. return nil
  1456. case agent.FieldAPIBase:
  1457. m.ClearAPIBase()
  1458. return nil
  1459. case agent.FieldAPIKey:
  1460. m.ClearAPIKey()
  1461. return nil
  1462. case agent.FieldType:
  1463. m.ClearType()
  1464. return nil
  1465. }
  1466. return fmt.Errorf("unknown Agent nullable field %s", name)
  1467. }
  1468. // ResetField resets all changes in the mutation for the field with the given name.
  1469. // It returns an error if the field is not defined in the schema.
  1470. func (m *AgentMutation) ResetField(name string) error {
  1471. switch name {
  1472. case agent.FieldCreatedAt:
  1473. m.ResetCreatedAt()
  1474. return nil
  1475. case agent.FieldUpdatedAt:
  1476. m.ResetUpdatedAt()
  1477. return nil
  1478. case agent.FieldDeletedAt:
  1479. m.ResetDeletedAt()
  1480. return nil
  1481. case agent.FieldName:
  1482. m.ResetName()
  1483. return nil
  1484. case agent.FieldRole:
  1485. m.ResetRole()
  1486. return nil
  1487. case agent.FieldStatus:
  1488. m.ResetStatus()
  1489. return nil
  1490. case agent.FieldBackground:
  1491. m.ResetBackground()
  1492. return nil
  1493. case agent.FieldExamples:
  1494. m.ResetExamples()
  1495. return nil
  1496. case agent.FieldOrganizationID:
  1497. m.ResetOrganizationID()
  1498. return nil
  1499. case agent.FieldDatasetID:
  1500. m.ResetDatasetID()
  1501. return nil
  1502. case agent.FieldCollectionID:
  1503. m.ResetCollectionID()
  1504. return nil
  1505. case agent.FieldModel:
  1506. m.ResetModel()
  1507. return nil
  1508. case agent.FieldAPIBase:
  1509. m.ResetAPIBase()
  1510. return nil
  1511. case agent.FieldAPIKey:
  1512. m.ResetAPIKey()
  1513. return nil
  1514. case agent.FieldType:
  1515. m.ResetType()
  1516. return nil
  1517. }
  1518. return fmt.Errorf("unknown Agent field %s", name)
  1519. }
  1520. // AddedEdges returns all edge names that were set/added in this mutation.
  1521. func (m *AgentMutation) AddedEdges() []string {
  1522. edges := make([]string, 0, 4)
  1523. if m.wx_agent != nil {
  1524. edges = append(edges, agent.EdgeWxAgent)
  1525. }
  1526. if m.token_agent != nil {
  1527. edges = append(edges, agent.EdgeTokenAgent)
  1528. }
  1529. if m.wa_agent != nil {
  1530. edges = append(edges, agent.EdgeWaAgent)
  1531. }
  1532. if m.key_agent != nil {
  1533. edges = append(edges, agent.EdgeKeyAgent)
  1534. }
  1535. return edges
  1536. }
  1537. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1538. // name in this mutation.
  1539. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1540. switch name {
  1541. case agent.EdgeWxAgent:
  1542. ids := make([]ent.Value, 0, len(m.wx_agent))
  1543. for id := range m.wx_agent {
  1544. ids = append(ids, id)
  1545. }
  1546. return ids
  1547. case agent.EdgeTokenAgent:
  1548. ids := make([]ent.Value, 0, len(m.token_agent))
  1549. for id := range m.token_agent {
  1550. ids = append(ids, id)
  1551. }
  1552. return ids
  1553. case agent.EdgeWaAgent:
  1554. ids := make([]ent.Value, 0, len(m.wa_agent))
  1555. for id := range m.wa_agent {
  1556. ids = append(ids, id)
  1557. }
  1558. return ids
  1559. case agent.EdgeKeyAgent:
  1560. ids := make([]ent.Value, 0, len(m.key_agent))
  1561. for id := range m.key_agent {
  1562. ids = append(ids, id)
  1563. }
  1564. return ids
  1565. }
  1566. return nil
  1567. }
  1568. // RemovedEdges returns all edge names that were removed in this mutation.
  1569. func (m *AgentMutation) RemovedEdges() []string {
  1570. edges := make([]string, 0, 4)
  1571. if m.removedwx_agent != nil {
  1572. edges = append(edges, agent.EdgeWxAgent)
  1573. }
  1574. if m.removedtoken_agent != nil {
  1575. edges = append(edges, agent.EdgeTokenAgent)
  1576. }
  1577. if m.removedwa_agent != nil {
  1578. edges = append(edges, agent.EdgeWaAgent)
  1579. }
  1580. if m.removedkey_agent != nil {
  1581. edges = append(edges, agent.EdgeKeyAgent)
  1582. }
  1583. return edges
  1584. }
  1585. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1586. // the given name in this mutation.
  1587. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1588. switch name {
  1589. case agent.EdgeWxAgent:
  1590. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1591. for id := range m.removedwx_agent {
  1592. ids = append(ids, id)
  1593. }
  1594. return ids
  1595. case agent.EdgeTokenAgent:
  1596. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1597. for id := range m.removedtoken_agent {
  1598. ids = append(ids, id)
  1599. }
  1600. return ids
  1601. case agent.EdgeWaAgent:
  1602. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1603. for id := range m.removedwa_agent {
  1604. ids = append(ids, id)
  1605. }
  1606. return ids
  1607. case agent.EdgeKeyAgent:
  1608. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1609. for id := range m.removedkey_agent {
  1610. ids = append(ids, id)
  1611. }
  1612. return ids
  1613. }
  1614. return nil
  1615. }
  1616. // ClearedEdges returns all edge names that were cleared in this mutation.
  1617. func (m *AgentMutation) ClearedEdges() []string {
  1618. edges := make([]string, 0, 4)
  1619. if m.clearedwx_agent {
  1620. edges = append(edges, agent.EdgeWxAgent)
  1621. }
  1622. if m.clearedtoken_agent {
  1623. edges = append(edges, agent.EdgeTokenAgent)
  1624. }
  1625. if m.clearedwa_agent {
  1626. edges = append(edges, agent.EdgeWaAgent)
  1627. }
  1628. if m.clearedkey_agent {
  1629. edges = append(edges, agent.EdgeKeyAgent)
  1630. }
  1631. return edges
  1632. }
  1633. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1634. // was cleared in this mutation.
  1635. func (m *AgentMutation) EdgeCleared(name string) bool {
  1636. switch name {
  1637. case agent.EdgeWxAgent:
  1638. return m.clearedwx_agent
  1639. case agent.EdgeTokenAgent:
  1640. return m.clearedtoken_agent
  1641. case agent.EdgeWaAgent:
  1642. return m.clearedwa_agent
  1643. case agent.EdgeKeyAgent:
  1644. return m.clearedkey_agent
  1645. }
  1646. return false
  1647. }
  1648. // ClearEdge clears the value of the edge with the given name. It returns an error
  1649. // if that edge is not defined in the schema.
  1650. func (m *AgentMutation) ClearEdge(name string) error {
  1651. switch name {
  1652. }
  1653. return fmt.Errorf("unknown Agent unique edge %s", name)
  1654. }
  1655. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1656. // It returns an error if the edge is not defined in the schema.
  1657. func (m *AgentMutation) ResetEdge(name string) error {
  1658. switch name {
  1659. case agent.EdgeWxAgent:
  1660. m.ResetWxAgent()
  1661. return nil
  1662. case agent.EdgeTokenAgent:
  1663. m.ResetTokenAgent()
  1664. return nil
  1665. case agent.EdgeWaAgent:
  1666. m.ResetWaAgent()
  1667. return nil
  1668. case agent.EdgeKeyAgent:
  1669. m.ResetKeyAgent()
  1670. return nil
  1671. }
  1672. return fmt.Errorf("unknown Agent edge %s", name)
  1673. }
  1674. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1675. type AgentBaseMutation struct {
  1676. config
  1677. op Op
  1678. typ string
  1679. id *string
  1680. q *string
  1681. a *string
  1682. chunk_index *uint64
  1683. addchunk_index *int64
  1684. indexes *[]string
  1685. appendindexes []string
  1686. dataset_id *string
  1687. collection_id *string
  1688. source_name *string
  1689. can_write *[]bool
  1690. appendcan_write []bool
  1691. is_owner *[]bool
  1692. appendis_owner []bool
  1693. clearedFields map[string]struct{}
  1694. wx_agent map[uint64]struct{}
  1695. removedwx_agent map[uint64]struct{}
  1696. clearedwx_agent bool
  1697. done bool
  1698. oldValue func(context.Context) (*AgentBase, error)
  1699. predicates []predicate.AgentBase
  1700. }
  1701. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1702. // agentbaseOption allows management of the mutation configuration using functional options.
  1703. type agentbaseOption func(*AgentBaseMutation)
  1704. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1705. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1706. m := &AgentBaseMutation{
  1707. config: c,
  1708. op: op,
  1709. typ: TypeAgentBase,
  1710. clearedFields: make(map[string]struct{}),
  1711. }
  1712. for _, opt := range opts {
  1713. opt(m)
  1714. }
  1715. return m
  1716. }
  1717. // withAgentBaseID sets the ID field of the mutation.
  1718. func withAgentBaseID(id string) agentbaseOption {
  1719. return func(m *AgentBaseMutation) {
  1720. var (
  1721. err error
  1722. once sync.Once
  1723. value *AgentBase
  1724. )
  1725. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1726. once.Do(func() {
  1727. if m.done {
  1728. err = errors.New("querying old values post mutation is not allowed")
  1729. } else {
  1730. value, err = m.Client().AgentBase.Get(ctx, id)
  1731. }
  1732. })
  1733. return value, err
  1734. }
  1735. m.id = &id
  1736. }
  1737. }
  1738. // withAgentBase sets the old AgentBase of the mutation.
  1739. func withAgentBase(node *AgentBase) agentbaseOption {
  1740. return func(m *AgentBaseMutation) {
  1741. m.oldValue = func(context.Context) (*AgentBase, error) {
  1742. return node, nil
  1743. }
  1744. m.id = &node.ID
  1745. }
  1746. }
  1747. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1748. // executed in a transaction (ent.Tx), a transactional client is returned.
  1749. func (m AgentBaseMutation) Client() *Client {
  1750. client := &Client{config: m.config}
  1751. client.init()
  1752. return client
  1753. }
  1754. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1755. // it returns an error otherwise.
  1756. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1757. if _, ok := m.driver.(*txDriver); !ok {
  1758. return nil, errors.New("ent: mutation is not running in a transaction")
  1759. }
  1760. tx := &Tx{config: m.config}
  1761. tx.init()
  1762. return tx, nil
  1763. }
  1764. // SetID sets the value of the id field. Note that this
  1765. // operation is only accepted on creation of AgentBase entities.
  1766. func (m *AgentBaseMutation) SetID(id string) {
  1767. m.id = &id
  1768. }
  1769. // ID returns the ID value in the mutation. Note that the ID is only available
  1770. // if it was provided to the builder or after it was returned from the database.
  1771. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1772. if m.id == nil {
  1773. return
  1774. }
  1775. return *m.id, true
  1776. }
  1777. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1778. // That means, if the mutation is applied within a transaction with an isolation level such
  1779. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1780. // or updated by the mutation.
  1781. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1782. switch {
  1783. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1784. id, exists := m.ID()
  1785. if exists {
  1786. return []string{id}, nil
  1787. }
  1788. fallthrough
  1789. case m.op.Is(OpUpdate | OpDelete):
  1790. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1791. default:
  1792. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1793. }
  1794. }
  1795. // SetQ sets the "q" field.
  1796. func (m *AgentBaseMutation) SetQ(s string) {
  1797. m.q = &s
  1798. }
  1799. // Q returns the value of the "q" field in the mutation.
  1800. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1801. v := m.q
  1802. if v == nil {
  1803. return
  1804. }
  1805. return *v, true
  1806. }
  1807. // OldQ returns the old "q" field's value of the AgentBase entity.
  1808. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1810. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1811. if !m.op.Is(OpUpdateOne) {
  1812. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1813. }
  1814. if m.id == nil || m.oldValue == nil {
  1815. return v, errors.New("OldQ requires an ID field in the mutation")
  1816. }
  1817. oldValue, err := m.oldValue(ctx)
  1818. if err != nil {
  1819. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1820. }
  1821. return oldValue.Q, nil
  1822. }
  1823. // ClearQ clears the value of the "q" field.
  1824. func (m *AgentBaseMutation) ClearQ() {
  1825. m.q = nil
  1826. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1827. }
  1828. // QCleared returns if the "q" field was cleared in this mutation.
  1829. func (m *AgentBaseMutation) QCleared() bool {
  1830. _, ok := m.clearedFields[agentbase.FieldQ]
  1831. return ok
  1832. }
  1833. // ResetQ resets all changes to the "q" field.
  1834. func (m *AgentBaseMutation) ResetQ() {
  1835. m.q = nil
  1836. delete(m.clearedFields, agentbase.FieldQ)
  1837. }
  1838. // SetA sets the "a" field.
  1839. func (m *AgentBaseMutation) SetA(s string) {
  1840. m.a = &s
  1841. }
  1842. // A returns the value of the "a" field in the mutation.
  1843. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1844. v := m.a
  1845. if v == nil {
  1846. return
  1847. }
  1848. return *v, true
  1849. }
  1850. // OldA returns the old "a" field's value of the AgentBase entity.
  1851. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1853. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1854. if !m.op.Is(OpUpdateOne) {
  1855. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1856. }
  1857. if m.id == nil || m.oldValue == nil {
  1858. return v, errors.New("OldA requires an ID field in the mutation")
  1859. }
  1860. oldValue, err := m.oldValue(ctx)
  1861. if err != nil {
  1862. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1863. }
  1864. return oldValue.A, nil
  1865. }
  1866. // ClearA clears the value of the "a" field.
  1867. func (m *AgentBaseMutation) ClearA() {
  1868. m.a = nil
  1869. m.clearedFields[agentbase.FieldA] = struct{}{}
  1870. }
  1871. // ACleared returns if the "a" field was cleared in this mutation.
  1872. func (m *AgentBaseMutation) ACleared() bool {
  1873. _, ok := m.clearedFields[agentbase.FieldA]
  1874. return ok
  1875. }
  1876. // ResetA resets all changes to the "a" field.
  1877. func (m *AgentBaseMutation) ResetA() {
  1878. m.a = nil
  1879. delete(m.clearedFields, agentbase.FieldA)
  1880. }
  1881. // SetChunkIndex sets the "chunk_index" field.
  1882. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1883. m.chunk_index = &u
  1884. m.addchunk_index = nil
  1885. }
  1886. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1887. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1888. v := m.chunk_index
  1889. if v == nil {
  1890. return
  1891. }
  1892. return *v, true
  1893. }
  1894. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1895. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1897. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1898. if !m.op.Is(OpUpdateOne) {
  1899. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1900. }
  1901. if m.id == nil || m.oldValue == nil {
  1902. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1903. }
  1904. oldValue, err := m.oldValue(ctx)
  1905. if err != nil {
  1906. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1907. }
  1908. return oldValue.ChunkIndex, nil
  1909. }
  1910. // AddChunkIndex adds u to the "chunk_index" field.
  1911. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1912. if m.addchunk_index != nil {
  1913. *m.addchunk_index += u
  1914. } else {
  1915. m.addchunk_index = &u
  1916. }
  1917. }
  1918. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1919. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1920. v := m.addchunk_index
  1921. if v == nil {
  1922. return
  1923. }
  1924. return *v, true
  1925. }
  1926. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1927. func (m *AgentBaseMutation) ResetChunkIndex() {
  1928. m.chunk_index = nil
  1929. m.addchunk_index = nil
  1930. }
  1931. // SetIndexes sets the "indexes" field.
  1932. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1933. m.indexes = &s
  1934. m.appendindexes = nil
  1935. }
  1936. // Indexes returns the value of the "indexes" field in the mutation.
  1937. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1938. v := m.indexes
  1939. if v == nil {
  1940. return
  1941. }
  1942. return *v, true
  1943. }
  1944. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1945. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1947. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1948. if !m.op.Is(OpUpdateOne) {
  1949. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1950. }
  1951. if m.id == nil || m.oldValue == nil {
  1952. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1953. }
  1954. oldValue, err := m.oldValue(ctx)
  1955. if err != nil {
  1956. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1957. }
  1958. return oldValue.Indexes, nil
  1959. }
  1960. // AppendIndexes adds s to the "indexes" field.
  1961. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1962. m.appendindexes = append(m.appendindexes, s...)
  1963. }
  1964. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1965. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1966. if len(m.appendindexes) == 0 {
  1967. return nil, false
  1968. }
  1969. return m.appendindexes, true
  1970. }
  1971. // ClearIndexes clears the value of the "indexes" field.
  1972. func (m *AgentBaseMutation) ClearIndexes() {
  1973. m.indexes = nil
  1974. m.appendindexes = nil
  1975. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1976. }
  1977. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1978. func (m *AgentBaseMutation) IndexesCleared() bool {
  1979. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1980. return ok
  1981. }
  1982. // ResetIndexes resets all changes to the "indexes" field.
  1983. func (m *AgentBaseMutation) ResetIndexes() {
  1984. m.indexes = nil
  1985. m.appendindexes = nil
  1986. delete(m.clearedFields, agentbase.FieldIndexes)
  1987. }
  1988. // SetDatasetID sets the "dataset_id" field.
  1989. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1990. m.dataset_id = &s
  1991. }
  1992. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1993. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1994. v := m.dataset_id
  1995. if v == nil {
  1996. return
  1997. }
  1998. return *v, true
  1999. }
  2000. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  2001. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2003. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2004. if !m.op.Is(OpUpdateOne) {
  2005. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2006. }
  2007. if m.id == nil || m.oldValue == nil {
  2008. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2009. }
  2010. oldValue, err := m.oldValue(ctx)
  2011. if err != nil {
  2012. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2013. }
  2014. return oldValue.DatasetID, nil
  2015. }
  2016. // ClearDatasetID clears the value of the "dataset_id" field.
  2017. func (m *AgentBaseMutation) ClearDatasetID() {
  2018. m.dataset_id = nil
  2019. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2020. }
  2021. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2022. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2023. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2024. return ok
  2025. }
  2026. // ResetDatasetID resets all changes to the "dataset_id" field.
  2027. func (m *AgentBaseMutation) ResetDatasetID() {
  2028. m.dataset_id = nil
  2029. delete(m.clearedFields, agentbase.FieldDatasetID)
  2030. }
  2031. // SetCollectionID sets the "collection_id" field.
  2032. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2033. m.collection_id = &s
  2034. }
  2035. // CollectionID returns the value of the "collection_id" field in the mutation.
  2036. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2037. v := m.collection_id
  2038. if v == nil {
  2039. return
  2040. }
  2041. return *v, true
  2042. }
  2043. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2044. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2046. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2047. if !m.op.Is(OpUpdateOne) {
  2048. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2049. }
  2050. if m.id == nil || m.oldValue == nil {
  2051. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2052. }
  2053. oldValue, err := m.oldValue(ctx)
  2054. if err != nil {
  2055. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2056. }
  2057. return oldValue.CollectionID, nil
  2058. }
  2059. // ClearCollectionID clears the value of the "collection_id" field.
  2060. func (m *AgentBaseMutation) ClearCollectionID() {
  2061. m.collection_id = nil
  2062. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2063. }
  2064. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2065. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2066. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2067. return ok
  2068. }
  2069. // ResetCollectionID resets all changes to the "collection_id" field.
  2070. func (m *AgentBaseMutation) ResetCollectionID() {
  2071. m.collection_id = nil
  2072. delete(m.clearedFields, agentbase.FieldCollectionID)
  2073. }
  2074. // SetSourceName sets the "source_name" field.
  2075. func (m *AgentBaseMutation) SetSourceName(s string) {
  2076. m.source_name = &s
  2077. }
  2078. // SourceName returns the value of the "source_name" field in the mutation.
  2079. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2080. v := m.source_name
  2081. if v == nil {
  2082. return
  2083. }
  2084. return *v, true
  2085. }
  2086. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2087. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2089. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2090. if !m.op.Is(OpUpdateOne) {
  2091. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2092. }
  2093. if m.id == nil || m.oldValue == nil {
  2094. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2095. }
  2096. oldValue, err := m.oldValue(ctx)
  2097. if err != nil {
  2098. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2099. }
  2100. return oldValue.SourceName, nil
  2101. }
  2102. // ClearSourceName clears the value of the "source_name" field.
  2103. func (m *AgentBaseMutation) ClearSourceName() {
  2104. m.source_name = nil
  2105. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2106. }
  2107. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2108. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2109. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2110. return ok
  2111. }
  2112. // ResetSourceName resets all changes to the "source_name" field.
  2113. func (m *AgentBaseMutation) ResetSourceName() {
  2114. m.source_name = nil
  2115. delete(m.clearedFields, agentbase.FieldSourceName)
  2116. }
  2117. // SetCanWrite sets the "can_write" field.
  2118. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2119. m.can_write = &b
  2120. m.appendcan_write = nil
  2121. }
  2122. // CanWrite returns the value of the "can_write" field in the mutation.
  2123. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2124. v := m.can_write
  2125. if v == nil {
  2126. return
  2127. }
  2128. return *v, true
  2129. }
  2130. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2131. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2133. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2134. if !m.op.Is(OpUpdateOne) {
  2135. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2136. }
  2137. if m.id == nil || m.oldValue == nil {
  2138. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2139. }
  2140. oldValue, err := m.oldValue(ctx)
  2141. if err != nil {
  2142. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2143. }
  2144. return oldValue.CanWrite, nil
  2145. }
  2146. // AppendCanWrite adds b to the "can_write" field.
  2147. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2148. m.appendcan_write = append(m.appendcan_write, b...)
  2149. }
  2150. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2151. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2152. if len(m.appendcan_write) == 0 {
  2153. return nil, false
  2154. }
  2155. return m.appendcan_write, true
  2156. }
  2157. // ClearCanWrite clears the value of the "can_write" field.
  2158. func (m *AgentBaseMutation) ClearCanWrite() {
  2159. m.can_write = nil
  2160. m.appendcan_write = nil
  2161. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2162. }
  2163. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2164. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2165. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2166. return ok
  2167. }
  2168. // ResetCanWrite resets all changes to the "can_write" field.
  2169. func (m *AgentBaseMutation) ResetCanWrite() {
  2170. m.can_write = nil
  2171. m.appendcan_write = nil
  2172. delete(m.clearedFields, agentbase.FieldCanWrite)
  2173. }
  2174. // SetIsOwner sets the "is_owner" field.
  2175. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2176. m.is_owner = &b
  2177. m.appendis_owner = nil
  2178. }
  2179. // IsOwner returns the value of the "is_owner" field in the mutation.
  2180. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2181. v := m.is_owner
  2182. if v == nil {
  2183. return
  2184. }
  2185. return *v, true
  2186. }
  2187. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2188. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2190. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2191. if !m.op.Is(OpUpdateOne) {
  2192. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2193. }
  2194. if m.id == nil || m.oldValue == nil {
  2195. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2196. }
  2197. oldValue, err := m.oldValue(ctx)
  2198. if err != nil {
  2199. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2200. }
  2201. return oldValue.IsOwner, nil
  2202. }
  2203. // AppendIsOwner adds b to the "is_owner" field.
  2204. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2205. m.appendis_owner = append(m.appendis_owner, b...)
  2206. }
  2207. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2208. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2209. if len(m.appendis_owner) == 0 {
  2210. return nil, false
  2211. }
  2212. return m.appendis_owner, true
  2213. }
  2214. // ClearIsOwner clears the value of the "is_owner" field.
  2215. func (m *AgentBaseMutation) ClearIsOwner() {
  2216. m.is_owner = nil
  2217. m.appendis_owner = nil
  2218. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2219. }
  2220. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2221. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2222. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2223. return ok
  2224. }
  2225. // ResetIsOwner resets all changes to the "is_owner" field.
  2226. func (m *AgentBaseMutation) ResetIsOwner() {
  2227. m.is_owner = nil
  2228. m.appendis_owner = nil
  2229. delete(m.clearedFields, agentbase.FieldIsOwner)
  2230. }
  2231. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2232. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2233. if m.wx_agent == nil {
  2234. m.wx_agent = make(map[uint64]struct{})
  2235. }
  2236. for i := range ids {
  2237. m.wx_agent[ids[i]] = struct{}{}
  2238. }
  2239. }
  2240. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2241. func (m *AgentBaseMutation) ClearWxAgent() {
  2242. m.clearedwx_agent = true
  2243. }
  2244. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2245. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2246. return m.clearedwx_agent
  2247. }
  2248. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2249. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2250. if m.removedwx_agent == nil {
  2251. m.removedwx_agent = make(map[uint64]struct{})
  2252. }
  2253. for i := range ids {
  2254. delete(m.wx_agent, ids[i])
  2255. m.removedwx_agent[ids[i]] = struct{}{}
  2256. }
  2257. }
  2258. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2259. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2260. for id := range m.removedwx_agent {
  2261. ids = append(ids, id)
  2262. }
  2263. return
  2264. }
  2265. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2266. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2267. for id := range m.wx_agent {
  2268. ids = append(ids, id)
  2269. }
  2270. return
  2271. }
  2272. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2273. func (m *AgentBaseMutation) ResetWxAgent() {
  2274. m.wx_agent = nil
  2275. m.clearedwx_agent = false
  2276. m.removedwx_agent = nil
  2277. }
  2278. // Where appends a list predicates to the AgentBaseMutation builder.
  2279. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2280. m.predicates = append(m.predicates, ps...)
  2281. }
  2282. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2283. // users can use type-assertion to append predicates that do not depend on any generated package.
  2284. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2285. p := make([]predicate.AgentBase, len(ps))
  2286. for i := range ps {
  2287. p[i] = ps[i]
  2288. }
  2289. m.Where(p...)
  2290. }
  2291. // Op returns the operation name.
  2292. func (m *AgentBaseMutation) Op() Op {
  2293. return m.op
  2294. }
  2295. // SetOp allows setting the mutation operation.
  2296. func (m *AgentBaseMutation) SetOp(op Op) {
  2297. m.op = op
  2298. }
  2299. // Type returns the node type of this mutation (AgentBase).
  2300. func (m *AgentBaseMutation) Type() string {
  2301. return m.typ
  2302. }
  2303. // Fields returns all fields that were changed during this mutation. Note that in
  2304. // order to get all numeric fields that were incremented/decremented, call
  2305. // AddedFields().
  2306. func (m *AgentBaseMutation) Fields() []string {
  2307. fields := make([]string, 0, 9)
  2308. if m.q != nil {
  2309. fields = append(fields, agentbase.FieldQ)
  2310. }
  2311. if m.a != nil {
  2312. fields = append(fields, agentbase.FieldA)
  2313. }
  2314. if m.chunk_index != nil {
  2315. fields = append(fields, agentbase.FieldChunkIndex)
  2316. }
  2317. if m.indexes != nil {
  2318. fields = append(fields, agentbase.FieldIndexes)
  2319. }
  2320. if m.dataset_id != nil {
  2321. fields = append(fields, agentbase.FieldDatasetID)
  2322. }
  2323. if m.collection_id != nil {
  2324. fields = append(fields, agentbase.FieldCollectionID)
  2325. }
  2326. if m.source_name != nil {
  2327. fields = append(fields, agentbase.FieldSourceName)
  2328. }
  2329. if m.can_write != nil {
  2330. fields = append(fields, agentbase.FieldCanWrite)
  2331. }
  2332. if m.is_owner != nil {
  2333. fields = append(fields, agentbase.FieldIsOwner)
  2334. }
  2335. return fields
  2336. }
  2337. // Field returns the value of a field with the given name. The second boolean
  2338. // return value indicates that this field was not set, or was not defined in the
  2339. // schema.
  2340. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2341. switch name {
  2342. case agentbase.FieldQ:
  2343. return m.Q()
  2344. case agentbase.FieldA:
  2345. return m.A()
  2346. case agentbase.FieldChunkIndex:
  2347. return m.ChunkIndex()
  2348. case agentbase.FieldIndexes:
  2349. return m.Indexes()
  2350. case agentbase.FieldDatasetID:
  2351. return m.DatasetID()
  2352. case agentbase.FieldCollectionID:
  2353. return m.CollectionID()
  2354. case agentbase.FieldSourceName:
  2355. return m.SourceName()
  2356. case agentbase.FieldCanWrite:
  2357. return m.CanWrite()
  2358. case agentbase.FieldIsOwner:
  2359. return m.IsOwner()
  2360. }
  2361. return nil, false
  2362. }
  2363. // OldField returns the old value of the field from the database. An error is
  2364. // returned if the mutation operation is not UpdateOne, or the query to the
  2365. // database failed.
  2366. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2367. switch name {
  2368. case agentbase.FieldQ:
  2369. return m.OldQ(ctx)
  2370. case agentbase.FieldA:
  2371. return m.OldA(ctx)
  2372. case agentbase.FieldChunkIndex:
  2373. return m.OldChunkIndex(ctx)
  2374. case agentbase.FieldIndexes:
  2375. return m.OldIndexes(ctx)
  2376. case agentbase.FieldDatasetID:
  2377. return m.OldDatasetID(ctx)
  2378. case agentbase.FieldCollectionID:
  2379. return m.OldCollectionID(ctx)
  2380. case agentbase.FieldSourceName:
  2381. return m.OldSourceName(ctx)
  2382. case agentbase.FieldCanWrite:
  2383. return m.OldCanWrite(ctx)
  2384. case agentbase.FieldIsOwner:
  2385. return m.OldIsOwner(ctx)
  2386. }
  2387. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2388. }
  2389. // SetField sets the value of a field with the given name. It returns an error if
  2390. // the field is not defined in the schema, or if the type mismatched the field
  2391. // type.
  2392. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2393. switch name {
  2394. case agentbase.FieldQ:
  2395. v, ok := value.(string)
  2396. if !ok {
  2397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2398. }
  2399. m.SetQ(v)
  2400. return nil
  2401. case agentbase.FieldA:
  2402. v, ok := value.(string)
  2403. if !ok {
  2404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2405. }
  2406. m.SetA(v)
  2407. return nil
  2408. case agentbase.FieldChunkIndex:
  2409. v, ok := value.(uint64)
  2410. if !ok {
  2411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2412. }
  2413. m.SetChunkIndex(v)
  2414. return nil
  2415. case agentbase.FieldIndexes:
  2416. v, ok := value.([]string)
  2417. if !ok {
  2418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2419. }
  2420. m.SetIndexes(v)
  2421. return nil
  2422. case agentbase.FieldDatasetID:
  2423. v, ok := value.(string)
  2424. if !ok {
  2425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2426. }
  2427. m.SetDatasetID(v)
  2428. return nil
  2429. case agentbase.FieldCollectionID:
  2430. v, ok := value.(string)
  2431. if !ok {
  2432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2433. }
  2434. m.SetCollectionID(v)
  2435. return nil
  2436. case agentbase.FieldSourceName:
  2437. v, ok := value.(string)
  2438. if !ok {
  2439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2440. }
  2441. m.SetSourceName(v)
  2442. return nil
  2443. case agentbase.FieldCanWrite:
  2444. v, ok := value.([]bool)
  2445. if !ok {
  2446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2447. }
  2448. m.SetCanWrite(v)
  2449. return nil
  2450. case agentbase.FieldIsOwner:
  2451. v, ok := value.([]bool)
  2452. if !ok {
  2453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2454. }
  2455. m.SetIsOwner(v)
  2456. return nil
  2457. }
  2458. return fmt.Errorf("unknown AgentBase field %s", name)
  2459. }
  2460. // AddedFields returns all numeric fields that were incremented/decremented during
  2461. // this mutation.
  2462. func (m *AgentBaseMutation) AddedFields() []string {
  2463. var fields []string
  2464. if m.addchunk_index != nil {
  2465. fields = append(fields, agentbase.FieldChunkIndex)
  2466. }
  2467. return fields
  2468. }
  2469. // AddedField returns the numeric value that was incremented/decremented on a field
  2470. // with the given name. The second boolean return value indicates that this field
  2471. // was not set, or was not defined in the schema.
  2472. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2473. switch name {
  2474. case agentbase.FieldChunkIndex:
  2475. return m.AddedChunkIndex()
  2476. }
  2477. return nil, false
  2478. }
  2479. // AddField adds the value to the field with the given name. It returns an error if
  2480. // the field is not defined in the schema, or if the type mismatched the field
  2481. // type.
  2482. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2483. switch name {
  2484. case agentbase.FieldChunkIndex:
  2485. v, ok := value.(int64)
  2486. if !ok {
  2487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2488. }
  2489. m.AddChunkIndex(v)
  2490. return nil
  2491. }
  2492. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2493. }
  2494. // ClearedFields returns all nullable fields that were cleared during this
  2495. // mutation.
  2496. func (m *AgentBaseMutation) ClearedFields() []string {
  2497. var fields []string
  2498. if m.FieldCleared(agentbase.FieldQ) {
  2499. fields = append(fields, agentbase.FieldQ)
  2500. }
  2501. if m.FieldCleared(agentbase.FieldA) {
  2502. fields = append(fields, agentbase.FieldA)
  2503. }
  2504. if m.FieldCleared(agentbase.FieldIndexes) {
  2505. fields = append(fields, agentbase.FieldIndexes)
  2506. }
  2507. if m.FieldCleared(agentbase.FieldDatasetID) {
  2508. fields = append(fields, agentbase.FieldDatasetID)
  2509. }
  2510. if m.FieldCleared(agentbase.FieldCollectionID) {
  2511. fields = append(fields, agentbase.FieldCollectionID)
  2512. }
  2513. if m.FieldCleared(agentbase.FieldSourceName) {
  2514. fields = append(fields, agentbase.FieldSourceName)
  2515. }
  2516. if m.FieldCleared(agentbase.FieldCanWrite) {
  2517. fields = append(fields, agentbase.FieldCanWrite)
  2518. }
  2519. if m.FieldCleared(agentbase.FieldIsOwner) {
  2520. fields = append(fields, agentbase.FieldIsOwner)
  2521. }
  2522. return fields
  2523. }
  2524. // FieldCleared returns a boolean indicating if a field with the given name was
  2525. // cleared in this mutation.
  2526. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2527. _, ok := m.clearedFields[name]
  2528. return ok
  2529. }
  2530. // ClearField clears the value of the field with the given name. It returns an
  2531. // error if the field is not defined in the schema.
  2532. func (m *AgentBaseMutation) ClearField(name string) error {
  2533. switch name {
  2534. case agentbase.FieldQ:
  2535. m.ClearQ()
  2536. return nil
  2537. case agentbase.FieldA:
  2538. m.ClearA()
  2539. return nil
  2540. case agentbase.FieldIndexes:
  2541. m.ClearIndexes()
  2542. return nil
  2543. case agentbase.FieldDatasetID:
  2544. m.ClearDatasetID()
  2545. return nil
  2546. case agentbase.FieldCollectionID:
  2547. m.ClearCollectionID()
  2548. return nil
  2549. case agentbase.FieldSourceName:
  2550. m.ClearSourceName()
  2551. return nil
  2552. case agentbase.FieldCanWrite:
  2553. m.ClearCanWrite()
  2554. return nil
  2555. case agentbase.FieldIsOwner:
  2556. m.ClearIsOwner()
  2557. return nil
  2558. }
  2559. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2560. }
  2561. // ResetField resets all changes in the mutation for the field with the given name.
  2562. // It returns an error if the field is not defined in the schema.
  2563. func (m *AgentBaseMutation) ResetField(name string) error {
  2564. switch name {
  2565. case agentbase.FieldQ:
  2566. m.ResetQ()
  2567. return nil
  2568. case agentbase.FieldA:
  2569. m.ResetA()
  2570. return nil
  2571. case agentbase.FieldChunkIndex:
  2572. m.ResetChunkIndex()
  2573. return nil
  2574. case agentbase.FieldIndexes:
  2575. m.ResetIndexes()
  2576. return nil
  2577. case agentbase.FieldDatasetID:
  2578. m.ResetDatasetID()
  2579. return nil
  2580. case agentbase.FieldCollectionID:
  2581. m.ResetCollectionID()
  2582. return nil
  2583. case agentbase.FieldSourceName:
  2584. m.ResetSourceName()
  2585. return nil
  2586. case agentbase.FieldCanWrite:
  2587. m.ResetCanWrite()
  2588. return nil
  2589. case agentbase.FieldIsOwner:
  2590. m.ResetIsOwner()
  2591. return nil
  2592. }
  2593. return fmt.Errorf("unknown AgentBase field %s", name)
  2594. }
  2595. // AddedEdges returns all edge names that were set/added in this mutation.
  2596. func (m *AgentBaseMutation) AddedEdges() []string {
  2597. edges := make([]string, 0, 1)
  2598. if m.wx_agent != nil {
  2599. edges = append(edges, agentbase.EdgeWxAgent)
  2600. }
  2601. return edges
  2602. }
  2603. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2604. // name in this mutation.
  2605. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2606. switch name {
  2607. case agentbase.EdgeWxAgent:
  2608. ids := make([]ent.Value, 0, len(m.wx_agent))
  2609. for id := range m.wx_agent {
  2610. ids = append(ids, id)
  2611. }
  2612. return ids
  2613. }
  2614. return nil
  2615. }
  2616. // RemovedEdges returns all edge names that were removed in this mutation.
  2617. func (m *AgentBaseMutation) RemovedEdges() []string {
  2618. edges := make([]string, 0, 1)
  2619. if m.removedwx_agent != nil {
  2620. edges = append(edges, agentbase.EdgeWxAgent)
  2621. }
  2622. return edges
  2623. }
  2624. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2625. // the given name in this mutation.
  2626. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2627. switch name {
  2628. case agentbase.EdgeWxAgent:
  2629. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2630. for id := range m.removedwx_agent {
  2631. ids = append(ids, id)
  2632. }
  2633. return ids
  2634. }
  2635. return nil
  2636. }
  2637. // ClearedEdges returns all edge names that were cleared in this mutation.
  2638. func (m *AgentBaseMutation) ClearedEdges() []string {
  2639. edges := make([]string, 0, 1)
  2640. if m.clearedwx_agent {
  2641. edges = append(edges, agentbase.EdgeWxAgent)
  2642. }
  2643. return edges
  2644. }
  2645. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2646. // was cleared in this mutation.
  2647. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2648. switch name {
  2649. case agentbase.EdgeWxAgent:
  2650. return m.clearedwx_agent
  2651. }
  2652. return false
  2653. }
  2654. // ClearEdge clears the value of the edge with the given name. It returns an error
  2655. // if that edge is not defined in the schema.
  2656. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2657. switch name {
  2658. }
  2659. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2660. }
  2661. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2662. // It returns an error if the edge is not defined in the schema.
  2663. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2664. switch name {
  2665. case agentbase.EdgeWxAgent:
  2666. m.ResetWxAgent()
  2667. return nil
  2668. }
  2669. return fmt.Errorf("unknown AgentBase edge %s", name)
  2670. }
  2671. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2672. type AliyunAvatarMutation struct {
  2673. config
  2674. op Op
  2675. typ string
  2676. id *uint64
  2677. created_at *time.Time
  2678. updated_at *time.Time
  2679. deleted_at *time.Time
  2680. user_id *uint64
  2681. adduser_id *int64
  2682. biz_id *string
  2683. access_key_id *string
  2684. access_key_secret *string
  2685. app_id *string
  2686. tenant_id *uint64
  2687. addtenant_id *int64
  2688. response *string
  2689. token *string
  2690. session_id *string
  2691. clearedFields map[string]struct{}
  2692. done bool
  2693. oldValue func(context.Context) (*AliyunAvatar, error)
  2694. predicates []predicate.AliyunAvatar
  2695. }
  2696. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2697. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2698. type aliyunavatarOption func(*AliyunAvatarMutation)
  2699. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2700. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2701. m := &AliyunAvatarMutation{
  2702. config: c,
  2703. op: op,
  2704. typ: TypeAliyunAvatar,
  2705. clearedFields: make(map[string]struct{}),
  2706. }
  2707. for _, opt := range opts {
  2708. opt(m)
  2709. }
  2710. return m
  2711. }
  2712. // withAliyunAvatarID sets the ID field of the mutation.
  2713. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2714. return func(m *AliyunAvatarMutation) {
  2715. var (
  2716. err error
  2717. once sync.Once
  2718. value *AliyunAvatar
  2719. )
  2720. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2721. once.Do(func() {
  2722. if m.done {
  2723. err = errors.New("querying old values post mutation is not allowed")
  2724. } else {
  2725. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2726. }
  2727. })
  2728. return value, err
  2729. }
  2730. m.id = &id
  2731. }
  2732. }
  2733. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2734. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2735. return func(m *AliyunAvatarMutation) {
  2736. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2737. return node, nil
  2738. }
  2739. m.id = &node.ID
  2740. }
  2741. }
  2742. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2743. // executed in a transaction (ent.Tx), a transactional client is returned.
  2744. func (m AliyunAvatarMutation) Client() *Client {
  2745. client := &Client{config: m.config}
  2746. client.init()
  2747. return client
  2748. }
  2749. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2750. // it returns an error otherwise.
  2751. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2752. if _, ok := m.driver.(*txDriver); !ok {
  2753. return nil, errors.New("ent: mutation is not running in a transaction")
  2754. }
  2755. tx := &Tx{config: m.config}
  2756. tx.init()
  2757. return tx, nil
  2758. }
  2759. // SetID sets the value of the id field. Note that this
  2760. // operation is only accepted on creation of AliyunAvatar entities.
  2761. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2762. m.id = &id
  2763. }
  2764. // ID returns the ID value in the mutation. Note that the ID is only available
  2765. // if it was provided to the builder or after it was returned from the database.
  2766. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2767. if m.id == nil {
  2768. return
  2769. }
  2770. return *m.id, true
  2771. }
  2772. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2773. // That means, if the mutation is applied within a transaction with an isolation level such
  2774. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2775. // or updated by the mutation.
  2776. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2777. switch {
  2778. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2779. id, exists := m.ID()
  2780. if exists {
  2781. return []uint64{id}, nil
  2782. }
  2783. fallthrough
  2784. case m.op.Is(OpUpdate | OpDelete):
  2785. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2786. default:
  2787. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2788. }
  2789. }
  2790. // SetCreatedAt sets the "created_at" field.
  2791. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2792. m.created_at = &t
  2793. }
  2794. // CreatedAt returns the value of the "created_at" field in the mutation.
  2795. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2796. v := m.created_at
  2797. if v == nil {
  2798. return
  2799. }
  2800. return *v, true
  2801. }
  2802. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2803. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2805. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2806. if !m.op.Is(OpUpdateOne) {
  2807. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2808. }
  2809. if m.id == nil || m.oldValue == nil {
  2810. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2811. }
  2812. oldValue, err := m.oldValue(ctx)
  2813. if err != nil {
  2814. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2815. }
  2816. return oldValue.CreatedAt, nil
  2817. }
  2818. // ResetCreatedAt resets all changes to the "created_at" field.
  2819. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2820. m.created_at = nil
  2821. }
  2822. // SetUpdatedAt sets the "updated_at" field.
  2823. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2824. m.updated_at = &t
  2825. }
  2826. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2827. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2828. v := m.updated_at
  2829. if v == nil {
  2830. return
  2831. }
  2832. return *v, true
  2833. }
  2834. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2835. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2837. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2838. if !m.op.Is(OpUpdateOne) {
  2839. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2840. }
  2841. if m.id == nil || m.oldValue == nil {
  2842. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2843. }
  2844. oldValue, err := m.oldValue(ctx)
  2845. if err != nil {
  2846. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2847. }
  2848. return oldValue.UpdatedAt, nil
  2849. }
  2850. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2851. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2852. m.updated_at = nil
  2853. }
  2854. // SetDeletedAt sets the "deleted_at" field.
  2855. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2856. m.deleted_at = &t
  2857. }
  2858. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2859. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2860. v := m.deleted_at
  2861. if v == nil {
  2862. return
  2863. }
  2864. return *v, true
  2865. }
  2866. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2867. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2869. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2870. if !m.op.Is(OpUpdateOne) {
  2871. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2872. }
  2873. if m.id == nil || m.oldValue == nil {
  2874. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2875. }
  2876. oldValue, err := m.oldValue(ctx)
  2877. if err != nil {
  2878. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2879. }
  2880. return oldValue.DeletedAt, nil
  2881. }
  2882. // ClearDeletedAt clears the value of the "deleted_at" field.
  2883. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2884. m.deleted_at = nil
  2885. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2886. }
  2887. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2888. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2889. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2890. return ok
  2891. }
  2892. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2893. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2894. m.deleted_at = nil
  2895. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2896. }
  2897. // SetUserID sets the "user_id" field.
  2898. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2899. m.user_id = &u
  2900. m.adduser_id = nil
  2901. }
  2902. // UserID returns the value of the "user_id" field in the mutation.
  2903. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2904. v := m.user_id
  2905. if v == nil {
  2906. return
  2907. }
  2908. return *v, true
  2909. }
  2910. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2911. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2913. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2914. if !m.op.Is(OpUpdateOne) {
  2915. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2916. }
  2917. if m.id == nil || m.oldValue == nil {
  2918. return v, errors.New("OldUserID requires an ID field in the mutation")
  2919. }
  2920. oldValue, err := m.oldValue(ctx)
  2921. if err != nil {
  2922. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2923. }
  2924. return oldValue.UserID, nil
  2925. }
  2926. // AddUserID adds u to the "user_id" field.
  2927. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2928. if m.adduser_id != nil {
  2929. *m.adduser_id += u
  2930. } else {
  2931. m.adduser_id = &u
  2932. }
  2933. }
  2934. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2935. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2936. v := m.adduser_id
  2937. if v == nil {
  2938. return
  2939. }
  2940. return *v, true
  2941. }
  2942. // ResetUserID resets all changes to the "user_id" field.
  2943. func (m *AliyunAvatarMutation) ResetUserID() {
  2944. m.user_id = nil
  2945. m.adduser_id = nil
  2946. }
  2947. // SetBizID sets the "biz_id" field.
  2948. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2949. m.biz_id = &s
  2950. }
  2951. // BizID returns the value of the "biz_id" field in the mutation.
  2952. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2953. v := m.biz_id
  2954. if v == nil {
  2955. return
  2956. }
  2957. return *v, true
  2958. }
  2959. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2960. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2962. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2963. if !m.op.Is(OpUpdateOne) {
  2964. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2965. }
  2966. if m.id == nil || m.oldValue == nil {
  2967. return v, errors.New("OldBizID requires an ID field in the mutation")
  2968. }
  2969. oldValue, err := m.oldValue(ctx)
  2970. if err != nil {
  2971. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2972. }
  2973. return oldValue.BizID, nil
  2974. }
  2975. // ResetBizID resets all changes to the "biz_id" field.
  2976. func (m *AliyunAvatarMutation) ResetBizID() {
  2977. m.biz_id = nil
  2978. }
  2979. // SetAccessKeyID sets the "access_key_id" field.
  2980. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2981. m.access_key_id = &s
  2982. }
  2983. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2984. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2985. v := m.access_key_id
  2986. if v == nil {
  2987. return
  2988. }
  2989. return *v, true
  2990. }
  2991. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2992. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2994. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2995. if !m.op.Is(OpUpdateOne) {
  2996. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2997. }
  2998. if m.id == nil || m.oldValue == nil {
  2999. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  3000. }
  3001. oldValue, err := m.oldValue(ctx)
  3002. if err != nil {
  3003. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3004. }
  3005. return oldValue.AccessKeyID, nil
  3006. }
  3007. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3008. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3009. m.access_key_id = nil
  3010. }
  3011. // SetAccessKeySecret sets the "access_key_secret" field.
  3012. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3013. m.access_key_secret = &s
  3014. }
  3015. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3016. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3017. v := m.access_key_secret
  3018. if v == nil {
  3019. return
  3020. }
  3021. return *v, true
  3022. }
  3023. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3024. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3026. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3027. if !m.op.Is(OpUpdateOne) {
  3028. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3029. }
  3030. if m.id == nil || m.oldValue == nil {
  3031. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3032. }
  3033. oldValue, err := m.oldValue(ctx)
  3034. if err != nil {
  3035. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3036. }
  3037. return oldValue.AccessKeySecret, nil
  3038. }
  3039. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3040. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3041. m.access_key_secret = nil
  3042. }
  3043. // SetAppID sets the "app_id" field.
  3044. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3045. m.app_id = &s
  3046. }
  3047. // AppID returns the value of the "app_id" field in the mutation.
  3048. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3049. v := m.app_id
  3050. if v == nil {
  3051. return
  3052. }
  3053. return *v, true
  3054. }
  3055. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3056. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3058. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3059. if !m.op.Is(OpUpdateOne) {
  3060. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3061. }
  3062. if m.id == nil || m.oldValue == nil {
  3063. return v, errors.New("OldAppID requires an ID field in the mutation")
  3064. }
  3065. oldValue, err := m.oldValue(ctx)
  3066. if err != nil {
  3067. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3068. }
  3069. return oldValue.AppID, nil
  3070. }
  3071. // ClearAppID clears the value of the "app_id" field.
  3072. func (m *AliyunAvatarMutation) ClearAppID() {
  3073. m.app_id = nil
  3074. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3075. }
  3076. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3077. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3078. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3079. return ok
  3080. }
  3081. // ResetAppID resets all changes to the "app_id" field.
  3082. func (m *AliyunAvatarMutation) ResetAppID() {
  3083. m.app_id = nil
  3084. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3085. }
  3086. // SetTenantID sets the "tenant_id" field.
  3087. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3088. m.tenant_id = &u
  3089. m.addtenant_id = nil
  3090. }
  3091. // TenantID returns the value of the "tenant_id" field in the mutation.
  3092. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3093. v := m.tenant_id
  3094. if v == nil {
  3095. return
  3096. }
  3097. return *v, true
  3098. }
  3099. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3100. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3102. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3103. if !m.op.Is(OpUpdateOne) {
  3104. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3105. }
  3106. if m.id == nil || m.oldValue == nil {
  3107. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3108. }
  3109. oldValue, err := m.oldValue(ctx)
  3110. if err != nil {
  3111. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3112. }
  3113. return oldValue.TenantID, nil
  3114. }
  3115. // AddTenantID adds u to the "tenant_id" field.
  3116. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3117. if m.addtenant_id != nil {
  3118. *m.addtenant_id += u
  3119. } else {
  3120. m.addtenant_id = &u
  3121. }
  3122. }
  3123. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3124. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3125. v := m.addtenant_id
  3126. if v == nil {
  3127. return
  3128. }
  3129. return *v, true
  3130. }
  3131. // ResetTenantID resets all changes to the "tenant_id" field.
  3132. func (m *AliyunAvatarMutation) ResetTenantID() {
  3133. m.tenant_id = nil
  3134. m.addtenant_id = nil
  3135. }
  3136. // SetResponse sets the "response" field.
  3137. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3138. m.response = &s
  3139. }
  3140. // Response returns the value of the "response" field in the mutation.
  3141. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3142. v := m.response
  3143. if v == nil {
  3144. return
  3145. }
  3146. return *v, true
  3147. }
  3148. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3149. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3151. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3152. if !m.op.Is(OpUpdateOne) {
  3153. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3154. }
  3155. if m.id == nil || m.oldValue == nil {
  3156. return v, errors.New("OldResponse requires an ID field in the mutation")
  3157. }
  3158. oldValue, err := m.oldValue(ctx)
  3159. if err != nil {
  3160. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3161. }
  3162. return oldValue.Response, nil
  3163. }
  3164. // ResetResponse resets all changes to the "response" field.
  3165. func (m *AliyunAvatarMutation) ResetResponse() {
  3166. m.response = nil
  3167. }
  3168. // SetToken sets the "token" field.
  3169. func (m *AliyunAvatarMutation) SetToken(s string) {
  3170. m.token = &s
  3171. }
  3172. // Token returns the value of the "token" field in the mutation.
  3173. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3174. v := m.token
  3175. if v == nil {
  3176. return
  3177. }
  3178. return *v, true
  3179. }
  3180. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3181. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3183. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3184. if !m.op.Is(OpUpdateOne) {
  3185. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3186. }
  3187. if m.id == nil || m.oldValue == nil {
  3188. return v, errors.New("OldToken requires an ID field in the mutation")
  3189. }
  3190. oldValue, err := m.oldValue(ctx)
  3191. if err != nil {
  3192. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3193. }
  3194. return oldValue.Token, nil
  3195. }
  3196. // ResetToken resets all changes to the "token" field.
  3197. func (m *AliyunAvatarMutation) ResetToken() {
  3198. m.token = nil
  3199. }
  3200. // SetSessionID sets the "session_id" field.
  3201. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3202. m.session_id = &s
  3203. }
  3204. // SessionID returns the value of the "session_id" field in the mutation.
  3205. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3206. v := m.session_id
  3207. if v == nil {
  3208. return
  3209. }
  3210. return *v, true
  3211. }
  3212. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3213. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3215. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3216. if !m.op.Is(OpUpdateOne) {
  3217. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3218. }
  3219. if m.id == nil || m.oldValue == nil {
  3220. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3221. }
  3222. oldValue, err := m.oldValue(ctx)
  3223. if err != nil {
  3224. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3225. }
  3226. return oldValue.SessionID, nil
  3227. }
  3228. // ResetSessionID resets all changes to the "session_id" field.
  3229. func (m *AliyunAvatarMutation) ResetSessionID() {
  3230. m.session_id = nil
  3231. }
  3232. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3233. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3234. m.predicates = append(m.predicates, ps...)
  3235. }
  3236. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3237. // users can use type-assertion to append predicates that do not depend on any generated package.
  3238. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3239. p := make([]predicate.AliyunAvatar, len(ps))
  3240. for i := range ps {
  3241. p[i] = ps[i]
  3242. }
  3243. m.Where(p...)
  3244. }
  3245. // Op returns the operation name.
  3246. func (m *AliyunAvatarMutation) Op() Op {
  3247. return m.op
  3248. }
  3249. // SetOp allows setting the mutation operation.
  3250. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3251. m.op = op
  3252. }
  3253. // Type returns the node type of this mutation (AliyunAvatar).
  3254. func (m *AliyunAvatarMutation) Type() string {
  3255. return m.typ
  3256. }
  3257. // Fields returns all fields that were changed during this mutation. Note that in
  3258. // order to get all numeric fields that were incremented/decremented, call
  3259. // AddedFields().
  3260. func (m *AliyunAvatarMutation) Fields() []string {
  3261. fields := make([]string, 0, 12)
  3262. if m.created_at != nil {
  3263. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3264. }
  3265. if m.updated_at != nil {
  3266. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3267. }
  3268. if m.deleted_at != nil {
  3269. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3270. }
  3271. if m.user_id != nil {
  3272. fields = append(fields, aliyunavatar.FieldUserID)
  3273. }
  3274. if m.biz_id != nil {
  3275. fields = append(fields, aliyunavatar.FieldBizID)
  3276. }
  3277. if m.access_key_id != nil {
  3278. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3279. }
  3280. if m.access_key_secret != nil {
  3281. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3282. }
  3283. if m.app_id != nil {
  3284. fields = append(fields, aliyunavatar.FieldAppID)
  3285. }
  3286. if m.tenant_id != nil {
  3287. fields = append(fields, aliyunavatar.FieldTenantID)
  3288. }
  3289. if m.response != nil {
  3290. fields = append(fields, aliyunavatar.FieldResponse)
  3291. }
  3292. if m.token != nil {
  3293. fields = append(fields, aliyunavatar.FieldToken)
  3294. }
  3295. if m.session_id != nil {
  3296. fields = append(fields, aliyunavatar.FieldSessionID)
  3297. }
  3298. return fields
  3299. }
  3300. // Field returns the value of a field with the given name. The second boolean
  3301. // return value indicates that this field was not set, or was not defined in the
  3302. // schema.
  3303. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3304. switch name {
  3305. case aliyunavatar.FieldCreatedAt:
  3306. return m.CreatedAt()
  3307. case aliyunavatar.FieldUpdatedAt:
  3308. return m.UpdatedAt()
  3309. case aliyunavatar.FieldDeletedAt:
  3310. return m.DeletedAt()
  3311. case aliyunavatar.FieldUserID:
  3312. return m.UserID()
  3313. case aliyunavatar.FieldBizID:
  3314. return m.BizID()
  3315. case aliyunavatar.FieldAccessKeyID:
  3316. return m.AccessKeyID()
  3317. case aliyunavatar.FieldAccessKeySecret:
  3318. return m.AccessKeySecret()
  3319. case aliyunavatar.FieldAppID:
  3320. return m.AppID()
  3321. case aliyunavatar.FieldTenantID:
  3322. return m.TenantID()
  3323. case aliyunavatar.FieldResponse:
  3324. return m.Response()
  3325. case aliyunavatar.FieldToken:
  3326. return m.Token()
  3327. case aliyunavatar.FieldSessionID:
  3328. return m.SessionID()
  3329. }
  3330. return nil, false
  3331. }
  3332. // OldField returns the old value of the field from the database. An error is
  3333. // returned if the mutation operation is not UpdateOne, or the query to the
  3334. // database failed.
  3335. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3336. switch name {
  3337. case aliyunavatar.FieldCreatedAt:
  3338. return m.OldCreatedAt(ctx)
  3339. case aliyunavatar.FieldUpdatedAt:
  3340. return m.OldUpdatedAt(ctx)
  3341. case aliyunavatar.FieldDeletedAt:
  3342. return m.OldDeletedAt(ctx)
  3343. case aliyunavatar.FieldUserID:
  3344. return m.OldUserID(ctx)
  3345. case aliyunavatar.FieldBizID:
  3346. return m.OldBizID(ctx)
  3347. case aliyunavatar.FieldAccessKeyID:
  3348. return m.OldAccessKeyID(ctx)
  3349. case aliyunavatar.FieldAccessKeySecret:
  3350. return m.OldAccessKeySecret(ctx)
  3351. case aliyunavatar.FieldAppID:
  3352. return m.OldAppID(ctx)
  3353. case aliyunavatar.FieldTenantID:
  3354. return m.OldTenantID(ctx)
  3355. case aliyunavatar.FieldResponse:
  3356. return m.OldResponse(ctx)
  3357. case aliyunavatar.FieldToken:
  3358. return m.OldToken(ctx)
  3359. case aliyunavatar.FieldSessionID:
  3360. return m.OldSessionID(ctx)
  3361. }
  3362. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3363. }
  3364. // SetField sets the value of a field with the given name. It returns an error if
  3365. // the field is not defined in the schema, or if the type mismatched the field
  3366. // type.
  3367. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3368. switch name {
  3369. case aliyunavatar.FieldCreatedAt:
  3370. v, ok := value.(time.Time)
  3371. if !ok {
  3372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3373. }
  3374. m.SetCreatedAt(v)
  3375. return nil
  3376. case aliyunavatar.FieldUpdatedAt:
  3377. v, ok := value.(time.Time)
  3378. if !ok {
  3379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3380. }
  3381. m.SetUpdatedAt(v)
  3382. return nil
  3383. case aliyunavatar.FieldDeletedAt:
  3384. v, ok := value.(time.Time)
  3385. if !ok {
  3386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3387. }
  3388. m.SetDeletedAt(v)
  3389. return nil
  3390. case aliyunavatar.FieldUserID:
  3391. v, ok := value.(uint64)
  3392. if !ok {
  3393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3394. }
  3395. m.SetUserID(v)
  3396. return nil
  3397. case aliyunavatar.FieldBizID:
  3398. v, ok := value.(string)
  3399. if !ok {
  3400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3401. }
  3402. m.SetBizID(v)
  3403. return nil
  3404. case aliyunavatar.FieldAccessKeyID:
  3405. v, ok := value.(string)
  3406. if !ok {
  3407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3408. }
  3409. m.SetAccessKeyID(v)
  3410. return nil
  3411. case aliyunavatar.FieldAccessKeySecret:
  3412. v, ok := value.(string)
  3413. if !ok {
  3414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3415. }
  3416. m.SetAccessKeySecret(v)
  3417. return nil
  3418. case aliyunavatar.FieldAppID:
  3419. v, ok := value.(string)
  3420. if !ok {
  3421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3422. }
  3423. m.SetAppID(v)
  3424. return nil
  3425. case aliyunavatar.FieldTenantID:
  3426. v, ok := value.(uint64)
  3427. if !ok {
  3428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3429. }
  3430. m.SetTenantID(v)
  3431. return nil
  3432. case aliyunavatar.FieldResponse:
  3433. v, ok := value.(string)
  3434. if !ok {
  3435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3436. }
  3437. m.SetResponse(v)
  3438. return nil
  3439. case aliyunavatar.FieldToken:
  3440. v, ok := value.(string)
  3441. if !ok {
  3442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3443. }
  3444. m.SetToken(v)
  3445. return nil
  3446. case aliyunavatar.FieldSessionID:
  3447. v, ok := value.(string)
  3448. if !ok {
  3449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3450. }
  3451. m.SetSessionID(v)
  3452. return nil
  3453. }
  3454. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3455. }
  3456. // AddedFields returns all numeric fields that were incremented/decremented during
  3457. // this mutation.
  3458. func (m *AliyunAvatarMutation) AddedFields() []string {
  3459. var fields []string
  3460. if m.adduser_id != nil {
  3461. fields = append(fields, aliyunavatar.FieldUserID)
  3462. }
  3463. if m.addtenant_id != nil {
  3464. fields = append(fields, aliyunavatar.FieldTenantID)
  3465. }
  3466. return fields
  3467. }
  3468. // AddedField returns the numeric value that was incremented/decremented on a field
  3469. // with the given name. The second boolean return value indicates that this field
  3470. // was not set, or was not defined in the schema.
  3471. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3472. switch name {
  3473. case aliyunavatar.FieldUserID:
  3474. return m.AddedUserID()
  3475. case aliyunavatar.FieldTenantID:
  3476. return m.AddedTenantID()
  3477. }
  3478. return nil, false
  3479. }
  3480. // AddField adds the value to the field with the given name. It returns an error if
  3481. // the field is not defined in the schema, or if the type mismatched the field
  3482. // type.
  3483. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3484. switch name {
  3485. case aliyunavatar.FieldUserID:
  3486. v, ok := value.(int64)
  3487. if !ok {
  3488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3489. }
  3490. m.AddUserID(v)
  3491. return nil
  3492. case aliyunavatar.FieldTenantID:
  3493. v, ok := value.(int64)
  3494. if !ok {
  3495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3496. }
  3497. m.AddTenantID(v)
  3498. return nil
  3499. }
  3500. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3501. }
  3502. // ClearedFields returns all nullable fields that were cleared during this
  3503. // mutation.
  3504. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3505. var fields []string
  3506. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3507. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3508. }
  3509. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3510. fields = append(fields, aliyunavatar.FieldAppID)
  3511. }
  3512. return fields
  3513. }
  3514. // FieldCleared returns a boolean indicating if a field with the given name was
  3515. // cleared in this mutation.
  3516. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3517. _, ok := m.clearedFields[name]
  3518. return ok
  3519. }
  3520. // ClearField clears the value of the field with the given name. It returns an
  3521. // error if the field is not defined in the schema.
  3522. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3523. switch name {
  3524. case aliyunavatar.FieldDeletedAt:
  3525. m.ClearDeletedAt()
  3526. return nil
  3527. case aliyunavatar.FieldAppID:
  3528. m.ClearAppID()
  3529. return nil
  3530. }
  3531. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3532. }
  3533. // ResetField resets all changes in the mutation for the field with the given name.
  3534. // It returns an error if the field is not defined in the schema.
  3535. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3536. switch name {
  3537. case aliyunavatar.FieldCreatedAt:
  3538. m.ResetCreatedAt()
  3539. return nil
  3540. case aliyunavatar.FieldUpdatedAt:
  3541. m.ResetUpdatedAt()
  3542. return nil
  3543. case aliyunavatar.FieldDeletedAt:
  3544. m.ResetDeletedAt()
  3545. return nil
  3546. case aliyunavatar.FieldUserID:
  3547. m.ResetUserID()
  3548. return nil
  3549. case aliyunavatar.FieldBizID:
  3550. m.ResetBizID()
  3551. return nil
  3552. case aliyunavatar.FieldAccessKeyID:
  3553. m.ResetAccessKeyID()
  3554. return nil
  3555. case aliyunavatar.FieldAccessKeySecret:
  3556. m.ResetAccessKeySecret()
  3557. return nil
  3558. case aliyunavatar.FieldAppID:
  3559. m.ResetAppID()
  3560. return nil
  3561. case aliyunavatar.FieldTenantID:
  3562. m.ResetTenantID()
  3563. return nil
  3564. case aliyunavatar.FieldResponse:
  3565. m.ResetResponse()
  3566. return nil
  3567. case aliyunavatar.FieldToken:
  3568. m.ResetToken()
  3569. return nil
  3570. case aliyunavatar.FieldSessionID:
  3571. m.ResetSessionID()
  3572. return nil
  3573. }
  3574. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3575. }
  3576. // AddedEdges returns all edge names that were set/added in this mutation.
  3577. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3578. edges := make([]string, 0, 0)
  3579. return edges
  3580. }
  3581. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3582. // name in this mutation.
  3583. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3584. return nil
  3585. }
  3586. // RemovedEdges returns all edge names that were removed in this mutation.
  3587. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3588. edges := make([]string, 0, 0)
  3589. return edges
  3590. }
  3591. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3592. // the given name in this mutation.
  3593. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3594. return nil
  3595. }
  3596. // ClearedEdges returns all edge names that were cleared in this mutation.
  3597. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3598. edges := make([]string, 0, 0)
  3599. return edges
  3600. }
  3601. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3602. // was cleared in this mutation.
  3603. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3604. return false
  3605. }
  3606. // ClearEdge clears the value of the edge with the given name. It returns an error
  3607. // if that edge is not defined in the schema.
  3608. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3609. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3610. }
  3611. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3612. // It returns an error if the edge is not defined in the schema.
  3613. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3614. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3615. }
  3616. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3617. type AllocAgentMutation struct {
  3618. config
  3619. op Op
  3620. typ string
  3621. id *uint64
  3622. created_at *time.Time
  3623. updated_at *time.Time
  3624. deleted_at *time.Time
  3625. user_id *string
  3626. organization_id *uint64
  3627. addorganization_id *int64
  3628. agents *[]uint64
  3629. appendagents []uint64
  3630. status *int
  3631. addstatus *int
  3632. clearedFields map[string]struct{}
  3633. done bool
  3634. oldValue func(context.Context) (*AllocAgent, error)
  3635. predicates []predicate.AllocAgent
  3636. }
  3637. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3638. // allocagentOption allows management of the mutation configuration using functional options.
  3639. type allocagentOption func(*AllocAgentMutation)
  3640. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3641. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3642. m := &AllocAgentMutation{
  3643. config: c,
  3644. op: op,
  3645. typ: TypeAllocAgent,
  3646. clearedFields: make(map[string]struct{}),
  3647. }
  3648. for _, opt := range opts {
  3649. opt(m)
  3650. }
  3651. return m
  3652. }
  3653. // withAllocAgentID sets the ID field of the mutation.
  3654. func withAllocAgentID(id uint64) allocagentOption {
  3655. return func(m *AllocAgentMutation) {
  3656. var (
  3657. err error
  3658. once sync.Once
  3659. value *AllocAgent
  3660. )
  3661. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3662. once.Do(func() {
  3663. if m.done {
  3664. err = errors.New("querying old values post mutation is not allowed")
  3665. } else {
  3666. value, err = m.Client().AllocAgent.Get(ctx, id)
  3667. }
  3668. })
  3669. return value, err
  3670. }
  3671. m.id = &id
  3672. }
  3673. }
  3674. // withAllocAgent sets the old AllocAgent of the mutation.
  3675. func withAllocAgent(node *AllocAgent) allocagentOption {
  3676. return func(m *AllocAgentMutation) {
  3677. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3678. return node, nil
  3679. }
  3680. m.id = &node.ID
  3681. }
  3682. }
  3683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3684. // executed in a transaction (ent.Tx), a transactional client is returned.
  3685. func (m AllocAgentMutation) Client() *Client {
  3686. client := &Client{config: m.config}
  3687. client.init()
  3688. return client
  3689. }
  3690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3691. // it returns an error otherwise.
  3692. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3693. if _, ok := m.driver.(*txDriver); !ok {
  3694. return nil, errors.New("ent: mutation is not running in a transaction")
  3695. }
  3696. tx := &Tx{config: m.config}
  3697. tx.init()
  3698. return tx, nil
  3699. }
  3700. // SetID sets the value of the id field. Note that this
  3701. // operation is only accepted on creation of AllocAgent entities.
  3702. func (m *AllocAgentMutation) SetID(id uint64) {
  3703. m.id = &id
  3704. }
  3705. // ID returns the ID value in the mutation. Note that the ID is only available
  3706. // if it was provided to the builder or after it was returned from the database.
  3707. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3708. if m.id == nil {
  3709. return
  3710. }
  3711. return *m.id, true
  3712. }
  3713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3714. // That means, if the mutation is applied within a transaction with an isolation level such
  3715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3716. // or updated by the mutation.
  3717. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3718. switch {
  3719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3720. id, exists := m.ID()
  3721. if exists {
  3722. return []uint64{id}, nil
  3723. }
  3724. fallthrough
  3725. case m.op.Is(OpUpdate | OpDelete):
  3726. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3727. default:
  3728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3729. }
  3730. }
  3731. // SetCreatedAt sets the "created_at" field.
  3732. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3733. m.created_at = &t
  3734. }
  3735. // CreatedAt returns the value of the "created_at" field in the mutation.
  3736. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3737. v := m.created_at
  3738. if v == nil {
  3739. return
  3740. }
  3741. return *v, true
  3742. }
  3743. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3744. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3746. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3747. if !m.op.Is(OpUpdateOne) {
  3748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3749. }
  3750. if m.id == nil || m.oldValue == nil {
  3751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3752. }
  3753. oldValue, err := m.oldValue(ctx)
  3754. if err != nil {
  3755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3756. }
  3757. return oldValue.CreatedAt, nil
  3758. }
  3759. // ResetCreatedAt resets all changes to the "created_at" field.
  3760. func (m *AllocAgentMutation) ResetCreatedAt() {
  3761. m.created_at = nil
  3762. }
  3763. // SetUpdatedAt sets the "updated_at" field.
  3764. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3765. m.updated_at = &t
  3766. }
  3767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3768. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3769. v := m.updated_at
  3770. if v == nil {
  3771. return
  3772. }
  3773. return *v, true
  3774. }
  3775. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3776. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3778. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3779. if !m.op.Is(OpUpdateOne) {
  3780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3781. }
  3782. if m.id == nil || m.oldValue == nil {
  3783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3784. }
  3785. oldValue, err := m.oldValue(ctx)
  3786. if err != nil {
  3787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3788. }
  3789. return oldValue.UpdatedAt, nil
  3790. }
  3791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3792. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3793. m.updated_at = nil
  3794. }
  3795. // SetDeletedAt sets the "deleted_at" field.
  3796. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3797. m.deleted_at = &t
  3798. }
  3799. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3800. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3801. v := m.deleted_at
  3802. if v == nil {
  3803. return
  3804. }
  3805. return *v, true
  3806. }
  3807. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3808. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3810. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3811. if !m.op.Is(OpUpdateOne) {
  3812. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3813. }
  3814. if m.id == nil || m.oldValue == nil {
  3815. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3816. }
  3817. oldValue, err := m.oldValue(ctx)
  3818. if err != nil {
  3819. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3820. }
  3821. return oldValue.DeletedAt, nil
  3822. }
  3823. // ClearDeletedAt clears the value of the "deleted_at" field.
  3824. func (m *AllocAgentMutation) ClearDeletedAt() {
  3825. m.deleted_at = nil
  3826. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3827. }
  3828. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3829. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3830. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3831. return ok
  3832. }
  3833. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3834. func (m *AllocAgentMutation) ResetDeletedAt() {
  3835. m.deleted_at = nil
  3836. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3837. }
  3838. // SetUserID sets the "user_id" field.
  3839. func (m *AllocAgentMutation) SetUserID(s string) {
  3840. m.user_id = &s
  3841. }
  3842. // UserID returns the value of the "user_id" field in the mutation.
  3843. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3844. v := m.user_id
  3845. if v == nil {
  3846. return
  3847. }
  3848. return *v, true
  3849. }
  3850. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3851. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3853. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3854. if !m.op.Is(OpUpdateOne) {
  3855. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3856. }
  3857. if m.id == nil || m.oldValue == nil {
  3858. return v, errors.New("OldUserID requires an ID field in the mutation")
  3859. }
  3860. oldValue, err := m.oldValue(ctx)
  3861. if err != nil {
  3862. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3863. }
  3864. return oldValue.UserID, nil
  3865. }
  3866. // ClearUserID clears the value of the "user_id" field.
  3867. func (m *AllocAgentMutation) ClearUserID() {
  3868. m.user_id = nil
  3869. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3870. }
  3871. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3872. func (m *AllocAgentMutation) UserIDCleared() bool {
  3873. _, ok := m.clearedFields[allocagent.FieldUserID]
  3874. return ok
  3875. }
  3876. // ResetUserID resets all changes to the "user_id" field.
  3877. func (m *AllocAgentMutation) ResetUserID() {
  3878. m.user_id = nil
  3879. delete(m.clearedFields, allocagent.FieldUserID)
  3880. }
  3881. // SetOrganizationID sets the "organization_id" field.
  3882. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3883. m.organization_id = &u
  3884. m.addorganization_id = nil
  3885. }
  3886. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3887. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3888. v := m.organization_id
  3889. if v == nil {
  3890. return
  3891. }
  3892. return *v, true
  3893. }
  3894. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3895. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3897. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3898. if !m.op.Is(OpUpdateOne) {
  3899. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3900. }
  3901. if m.id == nil || m.oldValue == nil {
  3902. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3903. }
  3904. oldValue, err := m.oldValue(ctx)
  3905. if err != nil {
  3906. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3907. }
  3908. return oldValue.OrganizationID, nil
  3909. }
  3910. // AddOrganizationID adds u to the "organization_id" field.
  3911. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3912. if m.addorganization_id != nil {
  3913. *m.addorganization_id += u
  3914. } else {
  3915. m.addorganization_id = &u
  3916. }
  3917. }
  3918. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3919. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3920. v := m.addorganization_id
  3921. if v == nil {
  3922. return
  3923. }
  3924. return *v, true
  3925. }
  3926. // ClearOrganizationID clears the value of the "organization_id" field.
  3927. func (m *AllocAgentMutation) ClearOrganizationID() {
  3928. m.organization_id = nil
  3929. m.addorganization_id = nil
  3930. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3931. }
  3932. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3933. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3934. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3935. return ok
  3936. }
  3937. // ResetOrganizationID resets all changes to the "organization_id" field.
  3938. func (m *AllocAgentMutation) ResetOrganizationID() {
  3939. m.organization_id = nil
  3940. m.addorganization_id = nil
  3941. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3942. }
  3943. // SetAgents sets the "agents" field.
  3944. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3945. m.agents = &u
  3946. m.appendagents = nil
  3947. }
  3948. // Agents returns the value of the "agents" field in the mutation.
  3949. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3950. v := m.agents
  3951. if v == nil {
  3952. return
  3953. }
  3954. return *v, true
  3955. }
  3956. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3957. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3959. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3960. if !m.op.Is(OpUpdateOne) {
  3961. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3962. }
  3963. if m.id == nil || m.oldValue == nil {
  3964. return v, errors.New("OldAgents requires an ID field in the mutation")
  3965. }
  3966. oldValue, err := m.oldValue(ctx)
  3967. if err != nil {
  3968. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3969. }
  3970. return oldValue.Agents, nil
  3971. }
  3972. // AppendAgents adds u to the "agents" field.
  3973. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3974. m.appendagents = append(m.appendagents, u...)
  3975. }
  3976. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3977. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3978. if len(m.appendagents) == 0 {
  3979. return nil, false
  3980. }
  3981. return m.appendagents, true
  3982. }
  3983. // ResetAgents resets all changes to the "agents" field.
  3984. func (m *AllocAgentMutation) ResetAgents() {
  3985. m.agents = nil
  3986. m.appendagents = nil
  3987. }
  3988. // SetStatus sets the "status" field.
  3989. func (m *AllocAgentMutation) SetStatus(i int) {
  3990. m.status = &i
  3991. m.addstatus = nil
  3992. }
  3993. // Status returns the value of the "status" field in the mutation.
  3994. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3995. v := m.status
  3996. if v == nil {
  3997. return
  3998. }
  3999. return *v, true
  4000. }
  4001. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4002. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4004. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4005. if !m.op.Is(OpUpdateOne) {
  4006. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4007. }
  4008. if m.id == nil || m.oldValue == nil {
  4009. return v, errors.New("OldStatus requires an ID field in the mutation")
  4010. }
  4011. oldValue, err := m.oldValue(ctx)
  4012. if err != nil {
  4013. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4014. }
  4015. return oldValue.Status, nil
  4016. }
  4017. // AddStatus adds i to the "status" field.
  4018. func (m *AllocAgentMutation) AddStatus(i int) {
  4019. if m.addstatus != nil {
  4020. *m.addstatus += i
  4021. } else {
  4022. m.addstatus = &i
  4023. }
  4024. }
  4025. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4026. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4027. v := m.addstatus
  4028. if v == nil {
  4029. return
  4030. }
  4031. return *v, true
  4032. }
  4033. // ClearStatus clears the value of the "status" field.
  4034. func (m *AllocAgentMutation) ClearStatus() {
  4035. m.status = nil
  4036. m.addstatus = nil
  4037. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4038. }
  4039. // StatusCleared returns if the "status" field was cleared in this mutation.
  4040. func (m *AllocAgentMutation) StatusCleared() bool {
  4041. _, ok := m.clearedFields[allocagent.FieldStatus]
  4042. return ok
  4043. }
  4044. // ResetStatus resets all changes to the "status" field.
  4045. func (m *AllocAgentMutation) ResetStatus() {
  4046. m.status = nil
  4047. m.addstatus = nil
  4048. delete(m.clearedFields, allocagent.FieldStatus)
  4049. }
  4050. // Where appends a list predicates to the AllocAgentMutation builder.
  4051. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4052. m.predicates = append(m.predicates, ps...)
  4053. }
  4054. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4055. // users can use type-assertion to append predicates that do not depend on any generated package.
  4056. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4057. p := make([]predicate.AllocAgent, len(ps))
  4058. for i := range ps {
  4059. p[i] = ps[i]
  4060. }
  4061. m.Where(p...)
  4062. }
  4063. // Op returns the operation name.
  4064. func (m *AllocAgentMutation) Op() Op {
  4065. return m.op
  4066. }
  4067. // SetOp allows setting the mutation operation.
  4068. func (m *AllocAgentMutation) SetOp(op Op) {
  4069. m.op = op
  4070. }
  4071. // Type returns the node type of this mutation (AllocAgent).
  4072. func (m *AllocAgentMutation) Type() string {
  4073. return m.typ
  4074. }
  4075. // Fields returns all fields that were changed during this mutation. Note that in
  4076. // order to get all numeric fields that were incremented/decremented, call
  4077. // AddedFields().
  4078. func (m *AllocAgentMutation) Fields() []string {
  4079. fields := make([]string, 0, 7)
  4080. if m.created_at != nil {
  4081. fields = append(fields, allocagent.FieldCreatedAt)
  4082. }
  4083. if m.updated_at != nil {
  4084. fields = append(fields, allocagent.FieldUpdatedAt)
  4085. }
  4086. if m.deleted_at != nil {
  4087. fields = append(fields, allocagent.FieldDeletedAt)
  4088. }
  4089. if m.user_id != nil {
  4090. fields = append(fields, allocagent.FieldUserID)
  4091. }
  4092. if m.organization_id != nil {
  4093. fields = append(fields, allocagent.FieldOrganizationID)
  4094. }
  4095. if m.agents != nil {
  4096. fields = append(fields, allocagent.FieldAgents)
  4097. }
  4098. if m.status != nil {
  4099. fields = append(fields, allocagent.FieldStatus)
  4100. }
  4101. return fields
  4102. }
  4103. // Field returns the value of a field with the given name. The second boolean
  4104. // return value indicates that this field was not set, or was not defined in the
  4105. // schema.
  4106. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4107. switch name {
  4108. case allocagent.FieldCreatedAt:
  4109. return m.CreatedAt()
  4110. case allocagent.FieldUpdatedAt:
  4111. return m.UpdatedAt()
  4112. case allocagent.FieldDeletedAt:
  4113. return m.DeletedAt()
  4114. case allocagent.FieldUserID:
  4115. return m.UserID()
  4116. case allocagent.FieldOrganizationID:
  4117. return m.OrganizationID()
  4118. case allocagent.FieldAgents:
  4119. return m.Agents()
  4120. case allocagent.FieldStatus:
  4121. return m.Status()
  4122. }
  4123. return nil, false
  4124. }
  4125. // OldField returns the old value of the field from the database. An error is
  4126. // returned if the mutation operation is not UpdateOne, or the query to the
  4127. // database failed.
  4128. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4129. switch name {
  4130. case allocagent.FieldCreatedAt:
  4131. return m.OldCreatedAt(ctx)
  4132. case allocagent.FieldUpdatedAt:
  4133. return m.OldUpdatedAt(ctx)
  4134. case allocagent.FieldDeletedAt:
  4135. return m.OldDeletedAt(ctx)
  4136. case allocagent.FieldUserID:
  4137. return m.OldUserID(ctx)
  4138. case allocagent.FieldOrganizationID:
  4139. return m.OldOrganizationID(ctx)
  4140. case allocagent.FieldAgents:
  4141. return m.OldAgents(ctx)
  4142. case allocagent.FieldStatus:
  4143. return m.OldStatus(ctx)
  4144. }
  4145. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4146. }
  4147. // SetField sets the value of a field with the given name. It returns an error if
  4148. // the field is not defined in the schema, or if the type mismatched the field
  4149. // type.
  4150. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4151. switch name {
  4152. case allocagent.FieldCreatedAt:
  4153. v, ok := value.(time.Time)
  4154. if !ok {
  4155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4156. }
  4157. m.SetCreatedAt(v)
  4158. return nil
  4159. case allocagent.FieldUpdatedAt:
  4160. v, ok := value.(time.Time)
  4161. if !ok {
  4162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4163. }
  4164. m.SetUpdatedAt(v)
  4165. return nil
  4166. case allocagent.FieldDeletedAt:
  4167. v, ok := value.(time.Time)
  4168. if !ok {
  4169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4170. }
  4171. m.SetDeletedAt(v)
  4172. return nil
  4173. case allocagent.FieldUserID:
  4174. v, ok := value.(string)
  4175. if !ok {
  4176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4177. }
  4178. m.SetUserID(v)
  4179. return nil
  4180. case allocagent.FieldOrganizationID:
  4181. v, ok := value.(uint64)
  4182. if !ok {
  4183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4184. }
  4185. m.SetOrganizationID(v)
  4186. return nil
  4187. case allocagent.FieldAgents:
  4188. v, ok := value.([]uint64)
  4189. if !ok {
  4190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4191. }
  4192. m.SetAgents(v)
  4193. return nil
  4194. case allocagent.FieldStatus:
  4195. v, ok := value.(int)
  4196. if !ok {
  4197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4198. }
  4199. m.SetStatus(v)
  4200. return nil
  4201. }
  4202. return fmt.Errorf("unknown AllocAgent field %s", name)
  4203. }
  4204. // AddedFields returns all numeric fields that were incremented/decremented during
  4205. // this mutation.
  4206. func (m *AllocAgentMutation) AddedFields() []string {
  4207. var fields []string
  4208. if m.addorganization_id != nil {
  4209. fields = append(fields, allocagent.FieldOrganizationID)
  4210. }
  4211. if m.addstatus != nil {
  4212. fields = append(fields, allocagent.FieldStatus)
  4213. }
  4214. return fields
  4215. }
  4216. // AddedField returns the numeric value that was incremented/decremented on a field
  4217. // with the given name. The second boolean return value indicates that this field
  4218. // was not set, or was not defined in the schema.
  4219. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4220. switch name {
  4221. case allocagent.FieldOrganizationID:
  4222. return m.AddedOrganizationID()
  4223. case allocagent.FieldStatus:
  4224. return m.AddedStatus()
  4225. }
  4226. return nil, false
  4227. }
  4228. // AddField adds the value to the field with the given name. It returns an error if
  4229. // the field is not defined in the schema, or if the type mismatched the field
  4230. // type.
  4231. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4232. switch name {
  4233. case allocagent.FieldOrganizationID:
  4234. v, ok := value.(int64)
  4235. if !ok {
  4236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4237. }
  4238. m.AddOrganizationID(v)
  4239. return nil
  4240. case allocagent.FieldStatus:
  4241. v, ok := value.(int)
  4242. if !ok {
  4243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4244. }
  4245. m.AddStatus(v)
  4246. return nil
  4247. }
  4248. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4249. }
  4250. // ClearedFields returns all nullable fields that were cleared during this
  4251. // mutation.
  4252. func (m *AllocAgentMutation) ClearedFields() []string {
  4253. var fields []string
  4254. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4255. fields = append(fields, allocagent.FieldDeletedAt)
  4256. }
  4257. if m.FieldCleared(allocagent.FieldUserID) {
  4258. fields = append(fields, allocagent.FieldUserID)
  4259. }
  4260. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4261. fields = append(fields, allocagent.FieldOrganizationID)
  4262. }
  4263. if m.FieldCleared(allocagent.FieldStatus) {
  4264. fields = append(fields, allocagent.FieldStatus)
  4265. }
  4266. return fields
  4267. }
  4268. // FieldCleared returns a boolean indicating if a field with the given name was
  4269. // cleared in this mutation.
  4270. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4271. _, ok := m.clearedFields[name]
  4272. return ok
  4273. }
  4274. // ClearField clears the value of the field with the given name. It returns an
  4275. // error if the field is not defined in the schema.
  4276. func (m *AllocAgentMutation) ClearField(name string) error {
  4277. switch name {
  4278. case allocagent.FieldDeletedAt:
  4279. m.ClearDeletedAt()
  4280. return nil
  4281. case allocagent.FieldUserID:
  4282. m.ClearUserID()
  4283. return nil
  4284. case allocagent.FieldOrganizationID:
  4285. m.ClearOrganizationID()
  4286. return nil
  4287. case allocagent.FieldStatus:
  4288. m.ClearStatus()
  4289. return nil
  4290. }
  4291. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4292. }
  4293. // ResetField resets all changes in the mutation for the field with the given name.
  4294. // It returns an error if the field is not defined in the schema.
  4295. func (m *AllocAgentMutation) ResetField(name string) error {
  4296. switch name {
  4297. case allocagent.FieldCreatedAt:
  4298. m.ResetCreatedAt()
  4299. return nil
  4300. case allocagent.FieldUpdatedAt:
  4301. m.ResetUpdatedAt()
  4302. return nil
  4303. case allocagent.FieldDeletedAt:
  4304. m.ResetDeletedAt()
  4305. return nil
  4306. case allocagent.FieldUserID:
  4307. m.ResetUserID()
  4308. return nil
  4309. case allocagent.FieldOrganizationID:
  4310. m.ResetOrganizationID()
  4311. return nil
  4312. case allocagent.FieldAgents:
  4313. m.ResetAgents()
  4314. return nil
  4315. case allocagent.FieldStatus:
  4316. m.ResetStatus()
  4317. return nil
  4318. }
  4319. return fmt.Errorf("unknown AllocAgent field %s", name)
  4320. }
  4321. // AddedEdges returns all edge names that were set/added in this mutation.
  4322. func (m *AllocAgentMutation) AddedEdges() []string {
  4323. edges := make([]string, 0, 0)
  4324. return edges
  4325. }
  4326. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4327. // name in this mutation.
  4328. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4329. return nil
  4330. }
  4331. // RemovedEdges returns all edge names that were removed in this mutation.
  4332. func (m *AllocAgentMutation) RemovedEdges() []string {
  4333. edges := make([]string, 0, 0)
  4334. return edges
  4335. }
  4336. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4337. // the given name in this mutation.
  4338. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4339. return nil
  4340. }
  4341. // ClearedEdges returns all edge names that were cleared in this mutation.
  4342. func (m *AllocAgentMutation) ClearedEdges() []string {
  4343. edges := make([]string, 0, 0)
  4344. return edges
  4345. }
  4346. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4347. // was cleared in this mutation.
  4348. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4349. return false
  4350. }
  4351. // ClearEdge clears the value of the edge with the given name. It returns an error
  4352. // if that edge is not defined in the schema.
  4353. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4354. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4355. }
  4356. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4357. // It returns an error if the edge is not defined in the schema.
  4358. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4359. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4360. }
  4361. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4362. type ApiKeyMutation struct {
  4363. config
  4364. op Op
  4365. typ string
  4366. id *uint64
  4367. created_at *time.Time
  4368. updated_at *time.Time
  4369. deleted_at *time.Time
  4370. title *string
  4371. key *string
  4372. organization_id *uint64
  4373. addorganization_id *int64
  4374. custom_agent_base *string
  4375. custom_agent_key *string
  4376. openai_base *string
  4377. openai_key *string
  4378. clearedFields map[string]struct{}
  4379. agent *uint64
  4380. clearedagent bool
  4381. done bool
  4382. oldValue func(context.Context) (*ApiKey, error)
  4383. predicates []predicate.ApiKey
  4384. }
  4385. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4386. // apikeyOption allows management of the mutation configuration using functional options.
  4387. type apikeyOption func(*ApiKeyMutation)
  4388. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4389. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4390. m := &ApiKeyMutation{
  4391. config: c,
  4392. op: op,
  4393. typ: TypeApiKey,
  4394. clearedFields: make(map[string]struct{}),
  4395. }
  4396. for _, opt := range opts {
  4397. opt(m)
  4398. }
  4399. return m
  4400. }
  4401. // withApiKeyID sets the ID field of the mutation.
  4402. func withApiKeyID(id uint64) apikeyOption {
  4403. return func(m *ApiKeyMutation) {
  4404. var (
  4405. err error
  4406. once sync.Once
  4407. value *ApiKey
  4408. )
  4409. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4410. once.Do(func() {
  4411. if m.done {
  4412. err = errors.New("querying old values post mutation is not allowed")
  4413. } else {
  4414. value, err = m.Client().ApiKey.Get(ctx, id)
  4415. }
  4416. })
  4417. return value, err
  4418. }
  4419. m.id = &id
  4420. }
  4421. }
  4422. // withApiKey sets the old ApiKey of the mutation.
  4423. func withApiKey(node *ApiKey) apikeyOption {
  4424. return func(m *ApiKeyMutation) {
  4425. m.oldValue = func(context.Context) (*ApiKey, error) {
  4426. return node, nil
  4427. }
  4428. m.id = &node.ID
  4429. }
  4430. }
  4431. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4432. // executed in a transaction (ent.Tx), a transactional client is returned.
  4433. func (m ApiKeyMutation) Client() *Client {
  4434. client := &Client{config: m.config}
  4435. client.init()
  4436. return client
  4437. }
  4438. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4439. // it returns an error otherwise.
  4440. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4441. if _, ok := m.driver.(*txDriver); !ok {
  4442. return nil, errors.New("ent: mutation is not running in a transaction")
  4443. }
  4444. tx := &Tx{config: m.config}
  4445. tx.init()
  4446. return tx, nil
  4447. }
  4448. // SetID sets the value of the id field. Note that this
  4449. // operation is only accepted on creation of ApiKey entities.
  4450. func (m *ApiKeyMutation) SetID(id uint64) {
  4451. m.id = &id
  4452. }
  4453. // ID returns the ID value in the mutation. Note that the ID is only available
  4454. // if it was provided to the builder or after it was returned from the database.
  4455. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4456. if m.id == nil {
  4457. return
  4458. }
  4459. return *m.id, true
  4460. }
  4461. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4462. // That means, if the mutation is applied within a transaction with an isolation level such
  4463. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4464. // or updated by the mutation.
  4465. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4466. switch {
  4467. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4468. id, exists := m.ID()
  4469. if exists {
  4470. return []uint64{id}, nil
  4471. }
  4472. fallthrough
  4473. case m.op.Is(OpUpdate | OpDelete):
  4474. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4475. default:
  4476. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4477. }
  4478. }
  4479. // SetCreatedAt sets the "created_at" field.
  4480. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4481. m.created_at = &t
  4482. }
  4483. // CreatedAt returns the value of the "created_at" field in the mutation.
  4484. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4485. v := m.created_at
  4486. if v == nil {
  4487. return
  4488. }
  4489. return *v, true
  4490. }
  4491. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4492. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4494. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4495. if !m.op.Is(OpUpdateOne) {
  4496. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4497. }
  4498. if m.id == nil || m.oldValue == nil {
  4499. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4500. }
  4501. oldValue, err := m.oldValue(ctx)
  4502. if err != nil {
  4503. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4504. }
  4505. return oldValue.CreatedAt, nil
  4506. }
  4507. // ResetCreatedAt resets all changes to the "created_at" field.
  4508. func (m *ApiKeyMutation) ResetCreatedAt() {
  4509. m.created_at = nil
  4510. }
  4511. // SetUpdatedAt sets the "updated_at" field.
  4512. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4513. m.updated_at = &t
  4514. }
  4515. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4516. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4517. v := m.updated_at
  4518. if v == nil {
  4519. return
  4520. }
  4521. return *v, true
  4522. }
  4523. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4524. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4526. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4527. if !m.op.Is(OpUpdateOne) {
  4528. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4529. }
  4530. if m.id == nil || m.oldValue == nil {
  4531. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4532. }
  4533. oldValue, err := m.oldValue(ctx)
  4534. if err != nil {
  4535. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4536. }
  4537. return oldValue.UpdatedAt, nil
  4538. }
  4539. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4540. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4541. m.updated_at = nil
  4542. }
  4543. // SetDeletedAt sets the "deleted_at" field.
  4544. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4545. m.deleted_at = &t
  4546. }
  4547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4548. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4549. v := m.deleted_at
  4550. if v == nil {
  4551. return
  4552. }
  4553. return *v, true
  4554. }
  4555. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4556. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4558. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4559. if !m.op.Is(OpUpdateOne) {
  4560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4561. }
  4562. if m.id == nil || m.oldValue == nil {
  4563. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4564. }
  4565. oldValue, err := m.oldValue(ctx)
  4566. if err != nil {
  4567. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4568. }
  4569. return oldValue.DeletedAt, nil
  4570. }
  4571. // ClearDeletedAt clears the value of the "deleted_at" field.
  4572. func (m *ApiKeyMutation) ClearDeletedAt() {
  4573. m.deleted_at = nil
  4574. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4575. }
  4576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4577. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4578. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4579. return ok
  4580. }
  4581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4582. func (m *ApiKeyMutation) ResetDeletedAt() {
  4583. m.deleted_at = nil
  4584. delete(m.clearedFields, apikey.FieldDeletedAt)
  4585. }
  4586. // SetTitle sets the "title" field.
  4587. func (m *ApiKeyMutation) SetTitle(s string) {
  4588. m.title = &s
  4589. }
  4590. // Title returns the value of the "title" field in the mutation.
  4591. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4592. v := m.title
  4593. if v == nil {
  4594. return
  4595. }
  4596. return *v, true
  4597. }
  4598. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4599. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4601. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4602. if !m.op.Is(OpUpdateOne) {
  4603. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4604. }
  4605. if m.id == nil || m.oldValue == nil {
  4606. return v, errors.New("OldTitle requires an ID field in the mutation")
  4607. }
  4608. oldValue, err := m.oldValue(ctx)
  4609. if err != nil {
  4610. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4611. }
  4612. return oldValue.Title, nil
  4613. }
  4614. // ClearTitle clears the value of the "title" field.
  4615. func (m *ApiKeyMutation) ClearTitle() {
  4616. m.title = nil
  4617. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4618. }
  4619. // TitleCleared returns if the "title" field was cleared in this mutation.
  4620. func (m *ApiKeyMutation) TitleCleared() bool {
  4621. _, ok := m.clearedFields[apikey.FieldTitle]
  4622. return ok
  4623. }
  4624. // ResetTitle resets all changes to the "title" field.
  4625. func (m *ApiKeyMutation) ResetTitle() {
  4626. m.title = nil
  4627. delete(m.clearedFields, apikey.FieldTitle)
  4628. }
  4629. // SetKey sets the "key" field.
  4630. func (m *ApiKeyMutation) SetKey(s string) {
  4631. m.key = &s
  4632. }
  4633. // Key returns the value of the "key" field in the mutation.
  4634. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4635. v := m.key
  4636. if v == nil {
  4637. return
  4638. }
  4639. return *v, true
  4640. }
  4641. // OldKey returns the old "key" field's value of the ApiKey entity.
  4642. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4644. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4645. if !m.op.Is(OpUpdateOne) {
  4646. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4647. }
  4648. if m.id == nil || m.oldValue == nil {
  4649. return v, errors.New("OldKey requires an ID field in the mutation")
  4650. }
  4651. oldValue, err := m.oldValue(ctx)
  4652. if err != nil {
  4653. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4654. }
  4655. return oldValue.Key, nil
  4656. }
  4657. // ClearKey clears the value of the "key" field.
  4658. func (m *ApiKeyMutation) ClearKey() {
  4659. m.key = nil
  4660. m.clearedFields[apikey.FieldKey] = struct{}{}
  4661. }
  4662. // KeyCleared returns if the "key" field was cleared in this mutation.
  4663. func (m *ApiKeyMutation) KeyCleared() bool {
  4664. _, ok := m.clearedFields[apikey.FieldKey]
  4665. return ok
  4666. }
  4667. // ResetKey resets all changes to the "key" field.
  4668. func (m *ApiKeyMutation) ResetKey() {
  4669. m.key = nil
  4670. delete(m.clearedFields, apikey.FieldKey)
  4671. }
  4672. // SetOrganizationID sets the "organization_id" field.
  4673. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4674. m.organization_id = &u
  4675. m.addorganization_id = nil
  4676. }
  4677. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4678. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4679. v := m.organization_id
  4680. if v == nil {
  4681. return
  4682. }
  4683. return *v, true
  4684. }
  4685. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4686. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4688. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4689. if !m.op.Is(OpUpdateOne) {
  4690. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4691. }
  4692. if m.id == nil || m.oldValue == nil {
  4693. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4694. }
  4695. oldValue, err := m.oldValue(ctx)
  4696. if err != nil {
  4697. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4698. }
  4699. return oldValue.OrganizationID, nil
  4700. }
  4701. // AddOrganizationID adds u to the "organization_id" field.
  4702. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4703. if m.addorganization_id != nil {
  4704. *m.addorganization_id += u
  4705. } else {
  4706. m.addorganization_id = &u
  4707. }
  4708. }
  4709. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4710. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4711. v := m.addorganization_id
  4712. if v == nil {
  4713. return
  4714. }
  4715. return *v, true
  4716. }
  4717. // ResetOrganizationID resets all changes to the "organization_id" field.
  4718. func (m *ApiKeyMutation) ResetOrganizationID() {
  4719. m.organization_id = nil
  4720. m.addorganization_id = nil
  4721. }
  4722. // SetAgentID sets the "agent_id" field.
  4723. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4724. m.agent = &u
  4725. }
  4726. // AgentID returns the value of the "agent_id" field in the mutation.
  4727. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4728. v := m.agent
  4729. if v == nil {
  4730. return
  4731. }
  4732. return *v, true
  4733. }
  4734. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4735. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4737. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4738. if !m.op.Is(OpUpdateOne) {
  4739. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4740. }
  4741. if m.id == nil || m.oldValue == nil {
  4742. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4743. }
  4744. oldValue, err := m.oldValue(ctx)
  4745. if err != nil {
  4746. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4747. }
  4748. return oldValue.AgentID, nil
  4749. }
  4750. // ResetAgentID resets all changes to the "agent_id" field.
  4751. func (m *ApiKeyMutation) ResetAgentID() {
  4752. m.agent = nil
  4753. }
  4754. // SetCustomAgentBase sets the "custom_agent_base" field.
  4755. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4756. m.custom_agent_base = &s
  4757. }
  4758. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4759. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4760. v := m.custom_agent_base
  4761. if v == nil {
  4762. return
  4763. }
  4764. return *v, true
  4765. }
  4766. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4767. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4769. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4770. if !m.op.Is(OpUpdateOne) {
  4771. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4772. }
  4773. if m.id == nil || m.oldValue == nil {
  4774. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4775. }
  4776. oldValue, err := m.oldValue(ctx)
  4777. if err != nil {
  4778. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4779. }
  4780. return oldValue.CustomAgentBase, nil
  4781. }
  4782. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4783. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4784. m.custom_agent_base = nil
  4785. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4786. }
  4787. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4788. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4789. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4790. return ok
  4791. }
  4792. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4793. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4794. m.custom_agent_base = nil
  4795. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4796. }
  4797. // SetCustomAgentKey sets the "custom_agent_key" field.
  4798. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4799. m.custom_agent_key = &s
  4800. }
  4801. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4802. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4803. v := m.custom_agent_key
  4804. if v == nil {
  4805. return
  4806. }
  4807. return *v, true
  4808. }
  4809. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4810. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4812. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4813. if !m.op.Is(OpUpdateOne) {
  4814. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4815. }
  4816. if m.id == nil || m.oldValue == nil {
  4817. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4818. }
  4819. oldValue, err := m.oldValue(ctx)
  4820. if err != nil {
  4821. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4822. }
  4823. return oldValue.CustomAgentKey, nil
  4824. }
  4825. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4826. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4827. m.custom_agent_key = nil
  4828. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4829. }
  4830. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4831. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4832. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4833. return ok
  4834. }
  4835. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4836. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4837. m.custom_agent_key = nil
  4838. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4839. }
  4840. // SetOpenaiBase sets the "openai_base" field.
  4841. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4842. m.openai_base = &s
  4843. }
  4844. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4845. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4846. v := m.openai_base
  4847. if v == nil {
  4848. return
  4849. }
  4850. return *v, true
  4851. }
  4852. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4853. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4855. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4856. if !m.op.Is(OpUpdateOne) {
  4857. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4858. }
  4859. if m.id == nil || m.oldValue == nil {
  4860. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4861. }
  4862. oldValue, err := m.oldValue(ctx)
  4863. if err != nil {
  4864. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4865. }
  4866. return oldValue.OpenaiBase, nil
  4867. }
  4868. // ClearOpenaiBase clears the value of the "openai_base" field.
  4869. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4870. m.openai_base = nil
  4871. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4872. }
  4873. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4874. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4875. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4876. return ok
  4877. }
  4878. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4879. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4880. m.openai_base = nil
  4881. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4882. }
  4883. // SetOpenaiKey sets the "openai_key" field.
  4884. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4885. m.openai_key = &s
  4886. }
  4887. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4888. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4889. v := m.openai_key
  4890. if v == nil {
  4891. return
  4892. }
  4893. return *v, true
  4894. }
  4895. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4896. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4898. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4899. if !m.op.Is(OpUpdateOne) {
  4900. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4901. }
  4902. if m.id == nil || m.oldValue == nil {
  4903. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4904. }
  4905. oldValue, err := m.oldValue(ctx)
  4906. if err != nil {
  4907. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4908. }
  4909. return oldValue.OpenaiKey, nil
  4910. }
  4911. // ClearOpenaiKey clears the value of the "openai_key" field.
  4912. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4913. m.openai_key = nil
  4914. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4915. }
  4916. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4917. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4918. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4919. return ok
  4920. }
  4921. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4922. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4923. m.openai_key = nil
  4924. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4925. }
  4926. // ClearAgent clears the "agent" edge to the Agent entity.
  4927. func (m *ApiKeyMutation) ClearAgent() {
  4928. m.clearedagent = true
  4929. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4930. }
  4931. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4932. func (m *ApiKeyMutation) AgentCleared() bool {
  4933. return m.clearedagent
  4934. }
  4935. // AgentIDs returns the "agent" edge IDs in the mutation.
  4936. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4937. // AgentID instead. It exists only for internal usage by the builders.
  4938. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4939. if id := m.agent; id != nil {
  4940. ids = append(ids, *id)
  4941. }
  4942. return
  4943. }
  4944. // ResetAgent resets all changes to the "agent" edge.
  4945. func (m *ApiKeyMutation) ResetAgent() {
  4946. m.agent = nil
  4947. m.clearedagent = false
  4948. }
  4949. // Where appends a list predicates to the ApiKeyMutation builder.
  4950. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4951. m.predicates = append(m.predicates, ps...)
  4952. }
  4953. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4954. // users can use type-assertion to append predicates that do not depend on any generated package.
  4955. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4956. p := make([]predicate.ApiKey, len(ps))
  4957. for i := range ps {
  4958. p[i] = ps[i]
  4959. }
  4960. m.Where(p...)
  4961. }
  4962. // Op returns the operation name.
  4963. func (m *ApiKeyMutation) Op() Op {
  4964. return m.op
  4965. }
  4966. // SetOp allows setting the mutation operation.
  4967. func (m *ApiKeyMutation) SetOp(op Op) {
  4968. m.op = op
  4969. }
  4970. // Type returns the node type of this mutation (ApiKey).
  4971. func (m *ApiKeyMutation) Type() string {
  4972. return m.typ
  4973. }
  4974. // Fields returns all fields that were changed during this mutation. Note that in
  4975. // order to get all numeric fields that were incremented/decremented, call
  4976. // AddedFields().
  4977. func (m *ApiKeyMutation) Fields() []string {
  4978. fields := make([]string, 0, 11)
  4979. if m.created_at != nil {
  4980. fields = append(fields, apikey.FieldCreatedAt)
  4981. }
  4982. if m.updated_at != nil {
  4983. fields = append(fields, apikey.FieldUpdatedAt)
  4984. }
  4985. if m.deleted_at != nil {
  4986. fields = append(fields, apikey.FieldDeletedAt)
  4987. }
  4988. if m.title != nil {
  4989. fields = append(fields, apikey.FieldTitle)
  4990. }
  4991. if m.key != nil {
  4992. fields = append(fields, apikey.FieldKey)
  4993. }
  4994. if m.organization_id != nil {
  4995. fields = append(fields, apikey.FieldOrganizationID)
  4996. }
  4997. if m.agent != nil {
  4998. fields = append(fields, apikey.FieldAgentID)
  4999. }
  5000. if m.custom_agent_base != nil {
  5001. fields = append(fields, apikey.FieldCustomAgentBase)
  5002. }
  5003. if m.custom_agent_key != nil {
  5004. fields = append(fields, apikey.FieldCustomAgentKey)
  5005. }
  5006. if m.openai_base != nil {
  5007. fields = append(fields, apikey.FieldOpenaiBase)
  5008. }
  5009. if m.openai_key != nil {
  5010. fields = append(fields, apikey.FieldOpenaiKey)
  5011. }
  5012. return fields
  5013. }
  5014. // Field returns the value of a field with the given name. The second boolean
  5015. // return value indicates that this field was not set, or was not defined in the
  5016. // schema.
  5017. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5018. switch name {
  5019. case apikey.FieldCreatedAt:
  5020. return m.CreatedAt()
  5021. case apikey.FieldUpdatedAt:
  5022. return m.UpdatedAt()
  5023. case apikey.FieldDeletedAt:
  5024. return m.DeletedAt()
  5025. case apikey.FieldTitle:
  5026. return m.Title()
  5027. case apikey.FieldKey:
  5028. return m.Key()
  5029. case apikey.FieldOrganizationID:
  5030. return m.OrganizationID()
  5031. case apikey.FieldAgentID:
  5032. return m.AgentID()
  5033. case apikey.FieldCustomAgentBase:
  5034. return m.CustomAgentBase()
  5035. case apikey.FieldCustomAgentKey:
  5036. return m.CustomAgentKey()
  5037. case apikey.FieldOpenaiBase:
  5038. return m.OpenaiBase()
  5039. case apikey.FieldOpenaiKey:
  5040. return m.OpenaiKey()
  5041. }
  5042. return nil, false
  5043. }
  5044. // OldField returns the old value of the field from the database. An error is
  5045. // returned if the mutation operation is not UpdateOne, or the query to the
  5046. // database failed.
  5047. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5048. switch name {
  5049. case apikey.FieldCreatedAt:
  5050. return m.OldCreatedAt(ctx)
  5051. case apikey.FieldUpdatedAt:
  5052. return m.OldUpdatedAt(ctx)
  5053. case apikey.FieldDeletedAt:
  5054. return m.OldDeletedAt(ctx)
  5055. case apikey.FieldTitle:
  5056. return m.OldTitle(ctx)
  5057. case apikey.FieldKey:
  5058. return m.OldKey(ctx)
  5059. case apikey.FieldOrganizationID:
  5060. return m.OldOrganizationID(ctx)
  5061. case apikey.FieldAgentID:
  5062. return m.OldAgentID(ctx)
  5063. case apikey.FieldCustomAgentBase:
  5064. return m.OldCustomAgentBase(ctx)
  5065. case apikey.FieldCustomAgentKey:
  5066. return m.OldCustomAgentKey(ctx)
  5067. case apikey.FieldOpenaiBase:
  5068. return m.OldOpenaiBase(ctx)
  5069. case apikey.FieldOpenaiKey:
  5070. return m.OldOpenaiKey(ctx)
  5071. }
  5072. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5073. }
  5074. // SetField sets the value of a field with the given name. It returns an error if
  5075. // the field is not defined in the schema, or if the type mismatched the field
  5076. // type.
  5077. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5078. switch name {
  5079. case apikey.FieldCreatedAt:
  5080. v, ok := value.(time.Time)
  5081. if !ok {
  5082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5083. }
  5084. m.SetCreatedAt(v)
  5085. return nil
  5086. case apikey.FieldUpdatedAt:
  5087. v, ok := value.(time.Time)
  5088. if !ok {
  5089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5090. }
  5091. m.SetUpdatedAt(v)
  5092. return nil
  5093. case apikey.FieldDeletedAt:
  5094. v, ok := value.(time.Time)
  5095. if !ok {
  5096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5097. }
  5098. m.SetDeletedAt(v)
  5099. return nil
  5100. case apikey.FieldTitle:
  5101. v, ok := value.(string)
  5102. if !ok {
  5103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5104. }
  5105. m.SetTitle(v)
  5106. return nil
  5107. case apikey.FieldKey:
  5108. v, ok := value.(string)
  5109. if !ok {
  5110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5111. }
  5112. m.SetKey(v)
  5113. return nil
  5114. case apikey.FieldOrganizationID:
  5115. v, ok := value.(uint64)
  5116. if !ok {
  5117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5118. }
  5119. m.SetOrganizationID(v)
  5120. return nil
  5121. case apikey.FieldAgentID:
  5122. v, ok := value.(uint64)
  5123. if !ok {
  5124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5125. }
  5126. m.SetAgentID(v)
  5127. return nil
  5128. case apikey.FieldCustomAgentBase:
  5129. v, ok := value.(string)
  5130. if !ok {
  5131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5132. }
  5133. m.SetCustomAgentBase(v)
  5134. return nil
  5135. case apikey.FieldCustomAgentKey:
  5136. v, ok := value.(string)
  5137. if !ok {
  5138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5139. }
  5140. m.SetCustomAgentKey(v)
  5141. return nil
  5142. case apikey.FieldOpenaiBase:
  5143. v, ok := value.(string)
  5144. if !ok {
  5145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5146. }
  5147. m.SetOpenaiBase(v)
  5148. return nil
  5149. case apikey.FieldOpenaiKey:
  5150. v, ok := value.(string)
  5151. if !ok {
  5152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5153. }
  5154. m.SetOpenaiKey(v)
  5155. return nil
  5156. }
  5157. return fmt.Errorf("unknown ApiKey field %s", name)
  5158. }
  5159. // AddedFields returns all numeric fields that were incremented/decremented during
  5160. // this mutation.
  5161. func (m *ApiKeyMutation) AddedFields() []string {
  5162. var fields []string
  5163. if m.addorganization_id != nil {
  5164. fields = append(fields, apikey.FieldOrganizationID)
  5165. }
  5166. return fields
  5167. }
  5168. // AddedField returns the numeric value that was incremented/decremented on a field
  5169. // with the given name. The second boolean return value indicates that this field
  5170. // was not set, or was not defined in the schema.
  5171. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5172. switch name {
  5173. case apikey.FieldOrganizationID:
  5174. return m.AddedOrganizationID()
  5175. }
  5176. return nil, false
  5177. }
  5178. // AddField adds the value to the field with the given name. It returns an error if
  5179. // the field is not defined in the schema, or if the type mismatched the field
  5180. // type.
  5181. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5182. switch name {
  5183. case apikey.FieldOrganizationID:
  5184. v, ok := value.(int64)
  5185. if !ok {
  5186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187. }
  5188. m.AddOrganizationID(v)
  5189. return nil
  5190. }
  5191. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5192. }
  5193. // ClearedFields returns all nullable fields that were cleared during this
  5194. // mutation.
  5195. func (m *ApiKeyMutation) ClearedFields() []string {
  5196. var fields []string
  5197. if m.FieldCleared(apikey.FieldDeletedAt) {
  5198. fields = append(fields, apikey.FieldDeletedAt)
  5199. }
  5200. if m.FieldCleared(apikey.FieldTitle) {
  5201. fields = append(fields, apikey.FieldTitle)
  5202. }
  5203. if m.FieldCleared(apikey.FieldKey) {
  5204. fields = append(fields, apikey.FieldKey)
  5205. }
  5206. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5207. fields = append(fields, apikey.FieldCustomAgentBase)
  5208. }
  5209. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5210. fields = append(fields, apikey.FieldCustomAgentKey)
  5211. }
  5212. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5213. fields = append(fields, apikey.FieldOpenaiBase)
  5214. }
  5215. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5216. fields = append(fields, apikey.FieldOpenaiKey)
  5217. }
  5218. return fields
  5219. }
  5220. // FieldCleared returns a boolean indicating if a field with the given name was
  5221. // cleared in this mutation.
  5222. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5223. _, ok := m.clearedFields[name]
  5224. return ok
  5225. }
  5226. // ClearField clears the value of the field with the given name. It returns an
  5227. // error if the field is not defined in the schema.
  5228. func (m *ApiKeyMutation) ClearField(name string) error {
  5229. switch name {
  5230. case apikey.FieldDeletedAt:
  5231. m.ClearDeletedAt()
  5232. return nil
  5233. case apikey.FieldTitle:
  5234. m.ClearTitle()
  5235. return nil
  5236. case apikey.FieldKey:
  5237. m.ClearKey()
  5238. return nil
  5239. case apikey.FieldCustomAgentBase:
  5240. m.ClearCustomAgentBase()
  5241. return nil
  5242. case apikey.FieldCustomAgentKey:
  5243. m.ClearCustomAgentKey()
  5244. return nil
  5245. case apikey.FieldOpenaiBase:
  5246. m.ClearOpenaiBase()
  5247. return nil
  5248. case apikey.FieldOpenaiKey:
  5249. m.ClearOpenaiKey()
  5250. return nil
  5251. }
  5252. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5253. }
  5254. // ResetField resets all changes in the mutation for the field with the given name.
  5255. // It returns an error if the field is not defined in the schema.
  5256. func (m *ApiKeyMutation) ResetField(name string) error {
  5257. switch name {
  5258. case apikey.FieldCreatedAt:
  5259. m.ResetCreatedAt()
  5260. return nil
  5261. case apikey.FieldUpdatedAt:
  5262. m.ResetUpdatedAt()
  5263. return nil
  5264. case apikey.FieldDeletedAt:
  5265. m.ResetDeletedAt()
  5266. return nil
  5267. case apikey.FieldTitle:
  5268. m.ResetTitle()
  5269. return nil
  5270. case apikey.FieldKey:
  5271. m.ResetKey()
  5272. return nil
  5273. case apikey.FieldOrganizationID:
  5274. m.ResetOrganizationID()
  5275. return nil
  5276. case apikey.FieldAgentID:
  5277. m.ResetAgentID()
  5278. return nil
  5279. case apikey.FieldCustomAgentBase:
  5280. m.ResetCustomAgentBase()
  5281. return nil
  5282. case apikey.FieldCustomAgentKey:
  5283. m.ResetCustomAgentKey()
  5284. return nil
  5285. case apikey.FieldOpenaiBase:
  5286. m.ResetOpenaiBase()
  5287. return nil
  5288. case apikey.FieldOpenaiKey:
  5289. m.ResetOpenaiKey()
  5290. return nil
  5291. }
  5292. return fmt.Errorf("unknown ApiKey field %s", name)
  5293. }
  5294. // AddedEdges returns all edge names that were set/added in this mutation.
  5295. func (m *ApiKeyMutation) AddedEdges() []string {
  5296. edges := make([]string, 0, 1)
  5297. if m.agent != nil {
  5298. edges = append(edges, apikey.EdgeAgent)
  5299. }
  5300. return edges
  5301. }
  5302. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5303. // name in this mutation.
  5304. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5305. switch name {
  5306. case apikey.EdgeAgent:
  5307. if id := m.agent; id != nil {
  5308. return []ent.Value{*id}
  5309. }
  5310. }
  5311. return nil
  5312. }
  5313. // RemovedEdges returns all edge names that were removed in this mutation.
  5314. func (m *ApiKeyMutation) RemovedEdges() []string {
  5315. edges := make([]string, 0, 1)
  5316. return edges
  5317. }
  5318. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5319. // the given name in this mutation.
  5320. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5321. return nil
  5322. }
  5323. // ClearedEdges returns all edge names that were cleared in this mutation.
  5324. func (m *ApiKeyMutation) ClearedEdges() []string {
  5325. edges := make([]string, 0, 1)
  5326. if m.clearedagent {
  5327. edges = append(edges, apikey.EdgeAgent)
  5328. }
  5329. return edges
  5330. }
  5331. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5332. // was cleared in this mutation.
  5333. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5334. switch name {
  5335. case apikey.EdgeAgent:
  5336. return m.clearedagent
  5337. }
  5338. return false
  5339. }
  5340. // ClearEdge clears the value of the edge with the given name. It returns an error
  5341. // if that edge is not defined in the schema.
  5342. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5343. switch name {
  5344. case apikey.EdgeAgent:
  5345. m.ClearAgent()
  5346. return nil
  5347. }
  5348. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5349. }
  5350. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5351. // It returns an error if the edge is not defined in the schema.
  5352. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5353. switch name {
  5354. case apikey.EdgeAgent:
  5355. m.ResetAgent()
  5356. return nil
  5357. }
  5358. return fmt.Errorf("unknown ApiKey edge %s", name)
  5359. }
  5360. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5361. type BatchMsgMutation struct {
  5362. config
  5363. op Op
  5364. typ string
  5365. id *uint64
  5366. created_at *time.Time
  5367. updated_at *time.Time
  5368. deleted_at *time.Time
  5369. status *uint8
  5370. addstatus *int8
  5371. batch_no *string
  5372. task_name *string
  5373. fromwxid *string
  5374. msg *string
  5375. tag *string
  5376. tagids *string
  5377. total *int32
  5378. addtotal *int32
  5379. success *int32
  5380. addsuccess *int32
  5381. fail *int32
  5382. addfail *int32
  5383. start_time *time.Time
  5384. stop_time *time.Time
  5385. send_time *time.Time
  5386. _type *int32
  5387. add_type *int32
  5388. organization_id *uint64
  5389. addorganization_id *int64
  5390. ctype *uint64
  5391. addctype *int64
  5392. cc *string
  5393. phone *string
  5394. template_name *string
  5395. template_code *string
  5396. lang *string
  5397. clearedFields map[string]struct{}
  5398. done bool
  5399. oldValue func(context.Context) (*BatchMsg, error)
  5400. predicates []predicate.BatchMsg
  5401. }
  5402. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5403. // batchmsgOption allows management of the mutation configuration using functional options.
  5404. type batchmsgOption func(*BatchMsgMutation)
  5405. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5406. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5407. m := &BatchMsgMutation{
  5408. config: c,
  5409. op: op,
  5410. typ: TypeBatchMsg,
  5411. clearedFields: make(map[string]struct{}),
  5412. }
  5413. for _, opt := range opts {
  5414. opt(m)
  5415. }
  5416. return m
  5417. }
  5418. // withBatchMsgID sets the ID field of the mutation.
  5419. func withBatchMsgID(id uint64) batchmsgOption {
  5420. return func(m *BatchMsgMutation) {
  5421. var (
  5422. err error
  5423. once sync.Once
  5424. value *BatchMsg
  5425. )
  5426. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5427. once.Do(func() {
  5428. if m.done {
  5429. err = errors.New("querying old values post mutation is not allowed")
  5430. } else {
  5431. value, err = m.Client().BatchMsg.Get(ctx, id)
  5432. }
  5433. })
  5434. return value, err
  5435. }
  5436. m.id = &id
  5437. }
  5438. }
  5439. // withBatchMsg sets the old BatchMsg of the mutation.
  5440. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5441. return func(m *BatchMsgMutation) {
  5442. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5443. return node, nil
  5444. }
  5445. m.id = &node.ID
  5446. }
  5447. }
  5448. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5449. // executed in a transaction (ent.Tx), a transactional client is returned.
  5450. func (m BatchMsgMutation) Client() *Client {
  5451. client := &Client{config: m.config}
  5452. client.init()
  5453. return client
  5454. }
  5455. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5456. // it returns an error otherwise.
  5457. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5458. if _, ok := m.driver.(*txDriver); !ok {
  5459. return nil, errors.New("ent: mutation is not running in a transaction")
  5460. }
  5461. tx := &Tx{config: m.config}
  5462. tx.init()
  5463. return tx, nil
  5464. }
  5465. // SetID sets the value of the id field. Note that this
  5466. // operation is only accepted on creation of BatchMsg entities.
  5467. func (m *BatchMsgMutation) SetID(id uint64) {
  5468. m.id = &id
  5469. }
  5470. // ID returns the ID value in the mutation. Note that the ID is only available
  5471. // if it was provided to the builder or after it was returned from the database.
  5472. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5473. if m.id == nil {
  5474. return
  5475. }
  5476. return *m.id, true
  5477. }
  5478. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5479. // That means, if the mutation is applied within a transaction with an isolation level such
  5480. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5481. // or updated by the mutation.
  5482. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5483. switch {
  5484. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5485. id, exists := m.ID()
  5486. if exists {
  5487. return []uint64{id}, nil
  5488. }
  5489. fallthrough
  5490. case m.op.Is(OpUpdate | OpDelete):
  5491. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5492. default:
  5493. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5494. }
  5495. }
  5496. // SetCreatedAt sets the "created_at" field.
  5497. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5498. m.created_at = &t
  5499. }
  5500. // CreatedAt returns the value of the "created_at" field in the mutation.
  5501. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5502. v := m.created_at
  5503. if v == nil {
  5504. return
  5505. }
  5506. return *v, true
  5507. }
  5508. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5509. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5511. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5512. if !m.op.Is(OpUpdateOne) {
  5513. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5514. }
  5515. if m.id == nil || m.oldValue == nil {
  5516. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5517. }
  5518. oldValue, err := m.oldValue(ctx)
  5519. if err != nil {
  5520. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5521. }
  5522. return oldValue.CreatedAt, nil
  5523. }
  5524. // ResetCreatedAt resets all changes to the "created_at" field.
  5525. func (m *BatchMsgMutation) ResetCreatedAt() {
  5526. m.created_at = nil
  5527. }
  5528. // SetUpdatedAt sets the "updated_at" field.
  5529. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5530. m.updated_at = &t
  5531. }
  5532. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5533. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5534. v := m.updated_at
  5535. if v == nil {
  5536. return
  5537. }
  5538. return *v, true
  5539. }
  5540. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5541. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5543. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5544. if !m.op.Is(OpUpdateOne) {
  5545. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5546. }
  5547. if m.id == nil || m.oldValue == nil {
  5548. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5549. }
  5550. oldValue, err := m.oldValue(ctx)
  5551. if err != nil {
  5552. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5553. }
  5554. return oldValue.UpdatedAt, nil
  5555. }
  5556. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5557. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5558. m.updated_at = nil
  5559. }
  5560. // SetDeletedAt sets the "deleted_at" field.
  5561. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5562. m.deleted_at = &t
  5563. }
  5564. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5565. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5566. v := m.deleted_at
  5567. if v == nil {
  5568. return
  5569. }
  5570. return *v, true
  5571. }
  5572. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5573. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5575. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5576. if !m.op.Is(OpUpdateOne) {
  5577. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5578. }
  5579. if m.id == nil || m.oldValue == nil {
  5580. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5581. }
  5582. oldValue, err := m.oldValue(ctx)
  5583. if err != nil {
  5584. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5585. }
  5586. return oldValue.DeletedAt, nil
  5587. }
  5588. // ClearDeletedAt clears the value of the "deleted_at" field.
  5589. func (m *BatchMsgMutation) ClearDeletedAt() {
  5590. m.deleted_at = nil
  5591. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5592. }
  5593. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5594. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5595. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5596. return ok
  5597. }
  5598. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5599. func (m *BatchMsgMutation) ResetDeletedAt() {
  5600. m.deleted_at = nil
  5601. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5602. }
  5603. // SetStatus sets the "status" field.
  5604. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5605. m.status = &u
  5606. m.addstatus = nil
  5607. }
  5608. // Status returns the value of the "status" field in the mutation.
  5609. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5610. v := m.status
  5611. if v == nil {
  5612. return
  5613. }
  5614. return *v, true
  5615. }
  5616. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5617. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5619. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5620. if !m.op.Is(OpUpdateOne) {
  5621. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5622. }
  5623. if m.id == nil || m.oldValue == nil {
  5624. return v, errors.New("OldStatus requires an ID field in the mutation")
  5625. }
  5626. oldValue, err := m.oldValue(ctx)
  5627. if err != nil {
  5628. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5629. }
  5630. return oldValue.Status, nil
  5631. }
  5632. // AddStatus adds u to the "status" field.
  5633. func (m *BatchMsgMutation) AddStatus(u int8) {
  5634. if m.addstatus != nil {
  5635. *m.addstatus += u
  5636. } else {
  5637. m.addstatus = &u
  5638. }
  5639. }
  5640. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5641. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5642. v := m.addstatus
  5643. if v == nil {
  5644. return
  5645. }
  5646. return *v, true
  5647. }
  5648. // ClearStatus clears the value of the "status" field.
  5649. func (m *BatchMsgMutation) ClearStatus() {
  5650. m.status = nil
  5651. m.addstatus = nil
  5652. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5653. }
  5654. // StatusCleared returns if the "status" field was cleared in this mutation.
  5655. func (m *BatchMsgMutation) StatusCleared() bool {
  5656. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5657. return ok
  5658. }
  5659. // ResetStatus resets all changes to the "status" field.
  5660. func (m *BatchMsgMutation) ResetStatus() {
  5661. m.status = nil
  5662. m.addstatus = nil
  5663. delete(m.clearedFields, batchmsg.FieldStatus)
  5664. }
  5665. // SetBatchNo sets the "batch_no" field.
  5666. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5667. m.batch_no = &s
  5668. }
  5669. // BatchNo returns the value of the "batch_no" field in the mutation.
  5670. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5671. v := m.batch_no
  5672. if v == nil {
  5673. return
  5674. }
  5675. return *v, true
  5676. }
  5677. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5678. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5680. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5681. if !m.op.Is(OpUpdateOne) {
  5682. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5683. }
  5684. if m.id == nil || m.oldValue == nil {
  5685. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5686. }
  5687. oldValue, err := m.oldValue(ctx)
  5688. if err != nil {
  5689. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5690. }
  5691. return oldValue.BatchNo, nil
  5692. }
  5693. // ClearBatchNo clears the value of the "batch_no" field.
  5694. func (m *BatchMsgMutation) ClearBatchNo() {
  5695. m.batch_no = nil
  5696. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5697. }
  5698. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5699. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5700. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5701. return ok
  5702. }
  5703. // ResetBatchNo resets all changes to the "batch_no" field.
  5704. func (m *BatchMsgMutation) ResetBatchNo() {
  5705. m.batch_no = nil
  5706. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5707. }
  5708. // SetTaskName sets the "task_name" field.
  5709. func (m *BatchMsgMutation) SetTaskName(s string) {
  5710. m.task_name = &s
  5711. }
  5712. // TaskName returns the value of the "task_name" field in the mutation.
  5713. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5714. v := m.task_name
  5715. if v == nil {
  5716. return
  5717. }
  5718. return *v, true
  5719. }
  5720. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5721. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5723. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5724. if !m.op.Is(OpUpdateOne) {
  5725. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5726. }
  5727. if m.id == nil || m.oldValue == nil {
  5728. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5729. }
  5730. oldValue, err := m.oldValue(ctx)
  5731. if err != nil {
  5732. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5733. }
  5734. return oldValue.TaskName, nil
  5735. }
  5736. // ClearTaskName clears the value of the "task_name" field.
  5737. func (m *BatchMsgMutation) ClearTaskName() {
  5738. m.task_name = nil
  5739. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5740. }
  5741. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5742. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5743. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5744. return ok
  5745. }
  5746. // ResetTaskName resets all changes to the "task_name" field.
  5747. func (m *BatchMsgMutation) ResetTaskName() {
  5748. m.task_name = nil
  5749. delete(m.clearedFields, batchmsg.FieldTaskName)
  5750. }
  5751. // SetFromwxid sets the "fromwxid" field.
  5752. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5753. m.fromwxid = &s
  5754. }
  5755. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5756. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5757. v := m.fromwxid
  5758. if v == nil {
  5759. return
  5760. }
  5761. return *v, true
  5762. }
  5763. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5764. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5766. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5767. if !m.op.Is(OpUpdateOne) {
  5768. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5769. }
  5770. if m.id == nil || m.oldValue == nil {
  5771. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5772. }
  5773. oldValue, err := m.oldValue(ctx)
  5774. if err != nil {
  5775. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5776. }
  5777. return oldValue.Fromwxid, nil
  5778. }
  5779. // ClearFromwxid clears the value of the "fromwxid" field.
  5780. func (m *BatchMsgMutation) ClearFromwxid() {
  5781. m.fromwxid = nil
  5782. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5783. }
  5784. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5785. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5786. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5787. return ok
  5788. }
  5789. // ResetFromwxid resets all changes to the "fromwxid" field.
  5790. func (m *BatchMsgMutation) ResetFromwxid() {
  5791. m.fromwxid = nil
  5792. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5793. }
  5794. // SetMsg sets the "msg" field.
  5795. func (m *BatchMsgMutation) SetMsg(s string) {
  5796. m.msg = &s
  5797. }
  5798. // Msg returns the value of the "msg" field in the mutation.
  5799. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5800. v := m.msg
  5801. if v == nil {
  5802. return
  5803. }
  5804. return *v, true
  5805. }
  5806. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5807. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5809. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5810. if !m.op.Is(OpUpdateOne) {
  5811. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5812. }
  5813. if m.id == nil || m.oldValue == nil {
  5814. return v, errors.New("OldMsg requires an ID field in the mutation")
  5815. }
  5816. oldValue, err := m.oldValue(ctx)
  5817. if err != nil {
  5818. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5819. }
  5820. return oldValue.Msg, nil
  5821. }
  5822. // ClearMsg clears the value of the "msg" field.
  5823. func (m *BatchMsgMutation) ClearMsg() {
  5824. m.msg = nil
  5825. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5826. }
  5827. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5828. func (m *BatchMsgMutation) MsgCleared() bool {
  5829. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5830. return ok
  5831. }
  5832. // ResetMsg resets all changes to the "msg" field.
  5833. func (m *BatchMsgMutation) ResetMsg() {
  5834. m.msg = nil
  5835. delete(m.clearedFields, batchmsg.FieldMsg)
  5836. }
  5837. // SetTag sets the "tag" field.
  5838. func (m *BatchMsgMutation) SetTag(s string) {
  5839. m.tag = &s
  5840. }
  5841. // Tag returns the value of the "tag" field in the mutation.
  5842. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5843. v := m.tag
  5844. if v == nil {
  5845. return
  5846. }
  5847. return *v, true
  5848. }
  5849. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5850. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5852. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5853. if !m.op.Is(OpUpdateOne) {
  5854. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5855. }
  5856. if m.id == nil || m.oldValue == nil {
  5857. return v, errors.New("OldTag requires an ID field in the mutation")
  5858. }
  5859. oldValue, err := m.oldValue(ctx)
  5860. if err != nil {
  5861. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5862. }
  5863. return oldValue.Tag, nil
  5864. }
  5865. // ClearTag clears the value of the "tag" field.
  5866. func (m *BatchMsgMutation) ClearTag() {
  5867. m.tag = nil
  5868. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5869. }
  5870. // TagCleared returns if the "tag" field was cleared in this mutation.
  5871. func (m *BatchMsgMutation) TagCleared() bool {
  5872. _, ok := m.clearedFields[batchmsg.FieldTag]
  5873. return ok
  5874. }
  5875. // ResetTag resets all changes to the "tag" field.
  5876. func (m *BatchMsgMutation) ResetTag() {
  5877. m.tag = nil
  5878. delete(m.clearedFields, batchmsg.FieldTag)
  5879. }
  5880. // SetTagids sets the "tagids" field.
  5881. func (m *BatchMsgMutation) SetTagids(s string) {
  5882. m.tagids = &s
  5883. }
  5884. // Tagids returns the value of the "tagids" field in the mutation.
  5885. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5886. v := m.tagids
  5887. if v == nil {
  5888. return
  5889. }
  5890. return *v, true
  5891. }
  5892. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5893. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5895. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5896. if !m.op.Is(OpUpdateOne) {
  5897. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5898. }
  5899. if m.id == nil || m.oldValue == nil {
  5900. return v, errors.New("OldTagids requires an ID field in the mutation")
  5901. }
  5902. oldValue, err := m.oldValue(ctx)
  5903. if err != nil {
  5904. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5905. }
  5906. return oldValue.Tagids, nil
  5907. }
  5908. // ClearTagids clears the value of the "tagids" field.
  5909. func (m *BatchMsgMutation) ClearTagids() {
  5910. m.tagids = nil
  5911. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5912. }
  5913. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5914. func (m *BatchMsgMutation) TagidsCleared() bool {
  5915. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5916. return ok
  5917. }
  5918. // ResetTagids resets all changes to the "tagids" field.
  5919. func (m *BatchMsgMutation) ResetTagids() {
  5920. m.tagids = nil
  5921. delete(m.clearedFields, batchmsg.FieldTagids)
  5922. }
  5923. // SetTotal sets the "total" field.
  5924. func (m *BatchMsgMutation) SetTotal(i int32) {
  5925. m.total = &i
  5926. m.addtotal = nil
  5927. }
  5928. // Total returns the value of the "total" field in the mutation.
  5929. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5930. v := m.total
  5931. if v == nil {
  5932. return
  5933. }
  5934. return *v, true
  5935. }
  5936. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5937. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5939. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5940. if !m.op.Is(OpUpdateOne) {
  5941. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5942. }
  5943. if m.id == nil || m.oldValue == nil {
  5944. return v, errors.New("OldTotal requires an ID field in the mutation")
  5945. }
  5946. oldValue, err := m.oldValue(ctx)
  5947. if err != nil {
  5948. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5949. }
  5950. return oldValue.Total, nil
  5951. }
  5952. // AddTotal adds i to the "total" field.
  5953. func (m *BatchMsgMutation) AddTotal(i int32) {
  5954. if m.addtotal != nil {
  5955. *m.addtotal += i
  5956. } else {
  5957. m.addtotal = &i
  5958. }
  5959. }
  5960. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5961. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5962. v := m.addtotal
  5963. if v == nil {
  5964. return
  5965. }
  5966. return *v, true
  5967. }
  5968. // ClearTotal clears the value of the "total" field.
  5969. func (m *BatchMsgMutation) ClearTotal() {
  5970. m.total = nil
  5971. m.addtotal = nil
  5972. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5973. }
  5974. // TotalCleared returns if the "total" field was cleared in this mutation.
  5975. func (m *BatchMsgMutation) TotalCleared() bool {
  5976. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5977. return ok
  5978. }
  5979. // ResetTotal resets all changes to the "total" field.
  5980. func (m *BatchMsgMutation) ResetTotal() {
  5981. m.total = nil
  5982. m.addtotal = nil
  5983. delete(m.clearedFields, batchmsg.FieldTotal)
  5984. }
  5985. // SetSuccess sets the "success" field.
  5986. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5987. m.success = &i
  5988. m.addsuccess = nil
  5989. }
  5990. // Success returns the value of the "success" field in the mutation.
  5991. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5992. v := m.success
  5993. if v == nil {
  5994. return
  5995. }
  5996. return *v, true
  5997. }
  5998. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5999. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6001. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6002. if !m.op.Is(OpUpdateOne) {
  6003. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6004. }
  6005. if m.id == nil || m.oldValue == nil {
  6006. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6007. }
  6008. oldValue, err := m.oldValue(ctx)
  6009. if err != nil {
  6010. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6011. }
  6012. return oldValue.Success, nil
  6013. }
  6014. // AddSuccess adds i to the "success" field.
  6015. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6016. if m.addsuccess != nil {
  6017. *m.addsuccess += i
  6018. } else {
  6019. m.addsuccess = &i
  6020. }
  6021. }
  6022. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6023. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6024. v := m.addsuccess
  6025. if v == nil {
  6026. return
  6027. }
  6028. return *v, true
  6029. }
  6030. // ClearSuccess clears the value of the "success" field.
  6031. func (m *BatchMsgMutation) ClearSuccess() {
  6032. m.success = nil
  6033. m.addsuccess = nil
  6034. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6035. }
  6036. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6037. func (m *BatchMsgMutation) SuccessCleared() bool {
  6038. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6039. return ok
  6040. }
  6041. // ResetSuccess resets all changes to the "success" field.
  6042. func (m *BatchMsgMutation) ResetSuccess() {
  6043. m.success = nil
  6044. m.addsuccess = nil
  6045. delete(m.clearedFields, batchmsg.FieldSuccess)
  6046. }
  6047. // SetFail sets the "fail" field.
  6048. func (m *BatchMsgMutation) SetFail(i int32) {
  6049. m.fail = &i
  6050. m.addfail = nil
  6051. }
  6052. // Fail returns the value of the "fail" field in the mutation.
  6053. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6054. v := m.fail
  6055. if v == nil {
  6056. return
  6057. }
  6058. return *v, true
  6059. }
  6060. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6061. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6063. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6064. if !m.op.Is(OpUpdateOne) {
  6065. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6066. }
  6067. if m.id == nil || m.oldValue == nil {
  6068. return v, errors.New("OldFail requires an ID field in the mutation")
  6069. }
  6070. oldValue, err := m.oldValue(ctx)
  6071. if err != nil {
  6072. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6073. }
  6074. return oldValue.Fail, nil
  6075. }
  6076. // AddFail adds i to the "fail" field.
  6077. func (m *BatchMsgMutation) AddFail(i int32) {
  6078. if m.addfail != nil {
  6079. *m.addfail += i
  6080. } else {
  6081. m.addfail = &i
  6082. }
  6083. }
  6084. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6085. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6086. v := m.addfail
  6087. if v == nil {
  6088. return
  6089. }
  6090. return *v, true
  6091. }
  6092. // ClearFail clears the value of the "fail" field.
  6093. func (m *BatchMsgMutation) ClearFail() {
  6094. m.fail = nil
  6095. m.addfail = nil
  6096. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6097. }
  6098. // FailCleared returns if the "fail" field was cleared in this mutation.
  6099. func (m *BatchMsgMutation) FailCleared() bool {
  6100. _, ok := m.clearedFields[batchmsg.FieldFail]
  6101. return ok
  6102. }
  6103. // ResetFail resets all changes to the "fail" field.
  6104. func (m *BatchMsgMutation) ResetFail() {
  6105. m.fail = nil
  6106. m.addfail = nil
  6107. delete(m.clearedFields, batchmsg.FieldFail)
  6108. }
  6109. // SetStartTime sets the "start_time" field.
  6110. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6111. m.start_time = &t
  6112. }
  6113. // StartTime returns the value of the "start_time" field in the mutation.
  6114. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6115. v := m.start_time
  6116. if v == nil {
  6117. return
  6118. }
  6119. return *v, true
  6120. }
  6121. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6122. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6124. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6125. if !m.op.Is(OpUpdateOne) {
  6126. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6127. }
  6128. if m.id == nil || m.oldValue == nil {
  6129. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6130. }
  6131. oldValue, err := m.oldValue(ctx)
  6132. if err != nil {
  6133. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6134. }
  6135. return oldValue.StartTime, nil
  6136. }
  6137. // ClearStartTime clears the value of the "start_time" field.
  6138. func (m *BatchMsgMutation) ClearStartTime() {
  6139. m.start_time = nil
  6140. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6141. }
  6142. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6143. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6144. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6145. return ok
  6146. }
  6147. // ResetStartTime resets all changes to the "start_time" field.
  6148. func (m *BatchMsgMutation) ResetStartTime() {
  6149. m.start_time = nil
  6150. delete(m.clearedFields, batchmsg.FieldStartTime)
  6151. }
  6152. // SetStopTime sets the "stop_time" field.
  6153. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6154. m.stop_time = &t
  6155. }
  6156. // StopTime returns the value of the "stop_time" field in the mutation.
  6157. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6158. v := m.stop_time
  6159. if v == nil {
  6160. return
  6161. }
  6162. return *v, true
  6163. }
  6164. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6165. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6167. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6168. if !m.op.Is(OpUpdateOne) {
  6169. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6170. }
  6171. if m.id == nil || m.oldValue == nil {
  6172. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6173. }
  6174. oldValue, err := m.oldValue(ctx)
  6175. if err != nil {
  6176. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6177. }
  6178. return oldValue.StopTime, nil
  6179. }
  6180. // ClearStopTime clears the value of the "stop_time" field.
  6181. func (m *BatchMsgMutation) ClearStopTime() {
  6182. m.stop_time = nil
  6183. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6184. }
  6185. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6186. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6187. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6188. return ok
  6189. }
  6190. // ResetStopTime resets all changes to the "stop_time" field.
  6191. func (m *BatchMsgMutation) ResetStopTime() {
  6192. m.stop_time = nil
  6193. delete(m.clearedFields, batchmsg.FieldStopTime)
  6194. }
  6195. // SetSendTime sets the "send_time" field.
  6196. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6197. m.send_time = &t
  6198. }
  6199. // SendTime returns the value of the "send_time" field in the mutation.
  6200. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6201. v := m.send_time
  6202. if v == nil {
  6203. return
  6204. }
  6205. return *v, true
  6206. }
  6207. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6208. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6210. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6211. if !m.op.Is(OpUpdateOne) {
  6212. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6213. }
  6214. if m.id == nil || m.oldValue == nil {
  6215. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6216. }
  6217. oldValue, err := m.oldValue(ctx)
  6218. if err != nil {
  6219. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6220. }
  6221. return oldValue.SendTime, nil
  6222. }
  6223. // ClearSendTime clears the value of the "send_time" field.
  6224. func (m *BatchMsgMutation) ClearSendTime() {
  6225. m.send_time = nil
  6226. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6227. }
  6228. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6229. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6230. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6231. return ok
  6232. }
  6233. // ResetSendTime resets all changes to the "send_time" field.
  6234. func (m *BatchMsgMutation) ResetSendTime() {
  6235. m.send_time = nil
  6236. delete(m.clearedFields, batchmsg.FieldSendTime)
  6237. }
  6238. // SetType sets the "type" field.
  6239. func (m *BatchMsgMutation) SetType(i int32) {
  6240. m._type = &i
  6241. m.add_type = nil
  6242. }
  6243. // GetType returns the value of the "type" field in the mutation.
  6244. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6245. v := m._type
  6246. if v == nil {
  6247. return
  6248. }
  6249. return *v, true
  6250. }
  6251. // OldType returns the old "type" field's value of the BatchMsg entity.
  6252. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6254. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6255. if !m.op.Is(OpUpdateOne) {
  6256. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6257. }
  6258. if m.id == nil || m.oldValue == nil {
  6259. return v, errors.New("OldType requires an ID field in the mutation")
  6260. }
  6261. oldValue, err := m.oldValue(ctx)
  6262. if err != nil {
  6263. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6264. }
  6265. return oldValue.Type, nil
  6266. }
  6267. // AddType adds i to the "type" field.
  6268. func (m *BatchMsgMutation) AddType(i int32) {
  6269. if m.add_type != nil {
  6270. *m.add_type += i
  6271. } else {
  6272. m.add_type = &i
  6273. }
  6274. }
  6275. // AddedType returns the value that was added to the "type" field in this mutation.
  6276. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6277. v := m.add_type
  6278. if v == nil {
  6279. return
  6280. }
  6281. return *v, true
  6282. }
  6283. // ClearType clears the value of the "type" field.
  6284. func (m *BatchMsgMutation) ClearType() {
  6285. m._type = nil
  6286. m.add_type = nil
  6287. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6288. }
  6289. // TypeCleared returns if the "type" field was cleared in this mutation.
  6290. func (m *BatchMsgMutation) TypeCleared() bool {
  6291. _, ok := m.clearedFields[batchmsg.FieldType]
  6292. return ok
  6293. }
  6294. // ResetType resets all changes to the "type" field.
  6295. func (m *BatchMsgMutation) ResetType() {
  6296. m._type = nil
  6297. m.add_type = nil
  6298. delete(m.clearedFields, batchmsg.FieldType)
  6299. }
  6300. // SetOrganizationID sets the "organization_id" field.
  6301. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6302. m.organization_id = &u
  6303. m.addorganization_id = nil
  6304. }
  6305. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6306. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6307. v := m.organization_id
  6308. if v == nil {
  6309. return
  6310. }
  6311. return *v, true
  6312. }
  6313. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6314. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6316. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6317. if !m.op.Is(OpUpdateOne) {
  6318. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6319. }
  6320. if m.id == nil || m.oldValue == nil {
  6321. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6322. }
  6323. oldValue, err := m.oldValue(ctx)
  6324. if err != nil {
  6325. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6326. }
  6327. return oldValue.OrganizationID, nil
  6328. }
  6329. // AddOrganizationID adds u to the "organization_id" field.
  6330. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6331. if m.addorganization_id != nil {
  6332. *m.addorganization_id += u
  6333. } else {
  6334. m.addorganization_id = &u
  6335. }
  6336. }
  6337. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6338. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6339. v := m.addorganization_id
  6340. if v == nil {
  6341. return
  6342. }
  6343. return *v, true
  6344. }
  6345. // ResetOrganizationID resets all changes to the "organization_id" field.
  6346. func (m *BatchMsgMutation) ResetOrganizationID() {
  6347. m.organization_id = nil
  6348. m.addorganization_id = nil
  6349. }
  6350. // SetCtype sets the "ctype" field.
  6351. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6352. m.ctype = &u
  6353. m.addctype = nil
  6354. }
  6355. // Ctype returns the value of the "ctype" field in the mutation.
  6356. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6357. v := m.ctype
  6358. if v == nil {
  6359. return
  6360. }
  6361. return *v, true
  6362. }
  6363. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6364. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6366. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6367. if !m.op.Is(OpUpdateOne) {
  6368. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6369. }
  6370. if m.id == nil || m.oldValue == nil {
  6371. return v, errors.New("OldCtype requires an ID field in the mutation")
  6372. }
  6373. oldValue, err := m.oldValue(ctx)
  6374. if err != nil {
  6375. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6376. }
  6377. return oldValue.Ctype, nil
  6378. }
  6379. // AddCtype adds u to the "ctype" field.
  6380. func (m *BatchMsgMutation) AddCtype(u int64) {
  6381. if m.addctype != nil {
  6382. *m.addctype += u
  6383. } else {
  6384. m.addctype = &u
  6385. }
  6386. }
  6387. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6388. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6389. v := m.addctype
  6390. if v == nil {
  6391. return
  6392. }
  6393. return *v, true
  6394. }
  6395. // ResetCtype resets all changes to the "ctype" field.
  6396. func (m *BatchMsgMutation) ResetCtype() {
  6397. m.ctype = nil
  6398. m.addctype = nil
  6399. }
  6400. // SetCc sets the "cc" field.
  6401. func (m *BatchMsgMutation) SetCc(s string) {
  6402. m.cc = &s
  6403. }
  6404. // Cc returns the value of the "cc" field in the mutation.
  6405. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6406. v := m.cc
  6407. if v == nil {
  6408. return
  6409. }
  6410. return *v, true
  6411. }
  6412. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6413. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6415. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6416. if !m.op.Is(OpUpdateOne) {
  6417. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6418. }
  6419. if m.id == nil || m.oldValue == nil {
  6420. return v, errors.New("OldCc requires an ID field in the mutation")
  6421. }
  6422. oldValue, err := m.oldValue(ctx)
  6423. if err != nil {
  6424. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6425. }
  6426. return oldValue.Cc, nil
  6427. }
  6428. // ClearCc clears the value of the "cc" field.
  6429. func (m *BatchMsgMutation) ClearCc() {
  6430. m.cc = nil
  6431. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6432. }
  6433. // CcCleared returns if the "cc" field was cleared in this mutation.
  6434. func (m *BatchMsgMutation) CcCleared() bool {
  6435. _, ok := m.clearedFields[batchmsg.FieldCc]
  6436. return ok
  6437. }
  6438. // ResetCc resets all changes to the "cc" field.
  6439. func (m *BatchMsgMutation) ResetCc() {
  6440. m.cc = nil
  6441. delete(m.clearedFields, batchmsg.FieldCc)
  6442. }
  6443. // SetPhone sets the "phone" field.
  6444. func (m *BatchMsgMutation) SetPhone(s string) {
  6445. m.phone = &s
  6446. }
  6447. // Phone returns the value of the "phone" field in the mutation.
  6448. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6449. v := m.phone
  6450. if v == nil {
  6451. return
  6452. }
  6453. return *v, true
  6454. }
  6455. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6456. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6458. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6459. if !m.op.Is(OpUpdateOne) {
  6460. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6461. }
  6462. if m.id == nil || m.oldValue == nil {
  6463. return v, errors.New("OldPhone requires an ID field in the mutation")
  6464. }
  6465. oldValue, err := m.oldValue(ctx)
  6466. if err != nil {
  6467. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6468. }
  6469. return oldValue.Phone, nil
  6470. }
  6471. // ClearPhone clears the value of the "phone" field.
  6472. func (m *BatchMsgMutation) ClearPhone() {
  6473. m.phone = nil
  6474. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6475. }
  6476. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6477. func (m *BatchMsgMutation) PhoneCleared() bool {
  6478. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6479. return ok
  6480. }
  6481. // ResetPhone resets all changes to the "phone" field.
  6482. func (m *BatchMsgMutation) ResetPhone() {
  6483. m.phone = nil
  6484. delete(m.clearedFields, batchmsg.FieldPhone)
  6485. }
  6486. // SetTemplateName sets the "template_name" field.
  6487. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6488. m.template_name = &s
  6489. }
  6490. // TemplateName returns the value of the "template_name" field in the mutation.
  6491. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6492. v := m.template_name
  6493. if v == nil {
  6494. return
  6495. }
  6496. return *v, true
  6497. }
  6498. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6499. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6501. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6502. if !m.op.Is(OpUpdateOne) {
  6503. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6504. }
  6505. if m.id == nil || m.oldValue == nil {
  6506. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6507. }
  6508. oldValue, err := m.oldValue(ctx)
  6509. if err != nil {
  6510. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6511. }
  6512. return oldValue.TemplateName, nil
  6513. }
  6514. // ClearTemplateName clears the value of the "template_name" field.
  6515. func (m *BatchMsgMutation) ClearTemplateName() {
  6516. m.template_name = nil
  6517. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6518. }
  6519. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6520. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6521. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6522. return ok
  6523. }
  6524. // ResetTemplateName resets all changes to the "template_name" field.
  6525. func (m *BatchMsgMutation) ResetTemplateName() {
  6526. m.template_name = nil
  6527. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6528. }
  6529. // SetTemplateCode sets the "template_code" field.
  6530. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6531. m.template_code = &s
  6532. }
  6533. // TemplateCode returns the value of the "template_code" field in the mutation.
  6534. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6535. v := m.template_code
  6536. if v == nil {
  6537. return
  6538. }
  6539. return *v, true
  6540. }
  6541. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6542. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6544. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6545. if !m.op.Is(OpUpdateOne) {
  6546. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6547. }
  6548. if m.id == nil || m.oldValue == nil {
  6549. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6550. }
  6551. oldValue, err := m.oldValue(ctx)
  6552. if err != nil {
  6553. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6554. }
  6555. return oldValue.TemplateCode, nil
  6556. }
  6557. // ClearTemplateCode clears the value of the "template_code" field.
  6558. func (m *BatchMsgMutation) ClearTemplateCode() {
  6559. m.template_code = nil
  6560. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6561. }
  6562. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6563. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6564. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6565. return ok
  6566. }
  6567. // ResetTemplateCode resets all changes to the "template_code" field.
  6568. func (m *BatchMsgMutation) ResetTemplateCode() {
  6569. m.template_code = nil
  6570. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6571. }
  6572. // SetLang sets the "lang" field.
  6573. func (m *BatchMsgMutation) SetLang(s string) {
  6574. m.lang = &s
  6575. }
  6576. // Lang returns the value of the "lang" field in the mutation.
  6577. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6578. v := m.lang
  6579. if v == nil {
  6580. return
  6581. }
  6582. return *v, true
  6583. }
  6584. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6585. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6587. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6588. if !m.op.Is(OpUpdateOne) {
  6589. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6590. }
  6591. if m.id == nil || m.oldValue == nil {
  6592. return v, errors.New("OldLang requires an ID field in the mutation")
  6593. }
  6594. oldValue, err := m.oldValue(ctx)
  6595. if err != nil {
  6596. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6597. }
  6598. return oldValue.Lang, nil
  6599. }
  6600. // ClearLang clears the value of the "lang" field.
  6601. func (m *BatchMsgMutation) ClearLang() {
  6602. m.lang = nil
  6603. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6604. }
  6605. // LangCleared returns if the "lang" field was cleared in this mutation.
  6606. func (m *BatchMsgMutation) LangCleared() bool {
  6607. _, ok := m.clearedFields[batchmsg.FieldLang]
  6608. return ok
  6609. }
  6610. // ResetLang resets all changes to the "lang" field.
  6611. func (m *BatchMsgMutation) ResetLang() {
  6612. m.lang = nil
  6613. delete(m.clearedFields, batchmsg.FieldLang)
  6614. }
  6615. // Where appends a list predicates to the BatchMsgMutation builder.
  6616. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6617. m.predicates = append(m.predicates, ps...)
  6618. }
  6619. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6620. // users can use type-assertion to append predicates that do not depend on any generated package.
  6621. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6622. p := make([]predicate.BatchMsg, len(ps))
  6623. for i := range ps {
  6624. p[i] = ps[i]
  6625. }
  6626. m.Where(p...)
  6627. }
  6628. // Op returns the operation name.
  6629. func (m *BatchMsgMutation) Op() Op {
  6630. return m.op
  6631. }
  6632. // SetOp allows setting the mutation operation.
  6633. func (m *BatchMsgMutation) SetOp(op Op) {
  6634. m.op = op
  6635. }
  6636. // Type returns the node type of this mutation (BatchMsg).
  6637. func (m *BatchMsgMutation) Type() string {
  6638. return m.typ
  6639. }
  6640. // Fields returns all fields that were changed during this mutation. Note that in
  6641. // order to get all numeric fields that were incremented/decremented, call
  6642. // AddedFields().
  6643. func (m *BatchMsgMutation) Fields() []string {
  6644. fields := make([]string, 0, 24)
  6645. if m.created_at != nil {
  6646. fields = append(fields, batchmsg.FieldCreatedAt)
  6647. }
  6648. if m.updated_at != nil {
  6649. fields = append(fields, batchmsg.FieldUpdatedAt)
  6650. }
  6651. if m.deleted_at != nil {
  6652. fields = append(fields, batchmsg.FieldDeletedAt)
  6653. }
  6654. if m.status != nil {
  6655. fields = append(fields, batchmsg.FieldStatus)
  6656. }
  6657. if m.batch_no != nil {
  6658. fields = append(fields, batchmsg.FieldBatchNo)
  6659. }
  6660. if m.task_name != nil {
  6661. fields = append(fields, batchmsg.FieldTaskName)
  6662. }
  6663. if m.fromwxid != nil {
  6664. fields = append(fields, batchmsg.FieldFromwxid)
  6665. }
  6666. if m.msg != nil {
  6667. fields = append(fields, batchmsg.FieldMsg)
  6668. }
  6669. if m.tag != nil {
  6670. fields = append(fields, batchmsg.FieldTag)
  6671. }
  6672. if m.tagids != nil {
  6673. fields = append(fields, batchmsg.FieldTagids)
  6674. }
  6675. if m.total != nil {
  6676. fields = append(fields, batchmsg.FieldTotal)
  6677. }
  6678. if m.success != nil {
  6679. fields = append(fields, batchmsg.FieldSuccess)
  6680. }
  6681. if m.fail != nil {
  6682. fields = append(fields, batchmsg.FieldFail)
  6683. }
  6684. if m.start_time != nil {
  6685. fields = append(fields, batchmsg.FieldStartTime)
  6686. }
  6687. if m.stop_time != nil {
  6688. fields = append(fields, batchmsg.FieldStopTime)
  6689. }
  6690. if m.send_time != nil {
  6691. fields = append(fields, batchmsg.FieldSendTime)
  6692. }
  6693. if m._type != nil {
  6694. fields = append(fields, batchmsg.FieldType)
  6695. }
  6696. if m.organization_id != nil {
  6697. fields = append(fields, batchmsg.FieldOrganizationID)
  6698. }
  6699. if m.ctype != nil {
  6700. fields = append(fields, batchmsg.FieldCtype)
  6701. }
  6702. if m.cc != nil {
  6703. fields = append(fields, batchmsg.FieldCc)
  6704. }
  6705. if m.phone != nil {
  6706. fields = append(fields, batchmsg.FieldPhone)
  6707. }
  6708. if m.template_name != nil {
  6709. fields = append(fields, batchmsg.FieldTemplateName)
  6710. }
  6711. if m.template_code != nil {
  6712. fields = append(fields, batchmsg.FieldTemplateCode)
  6713. }
  6714. if m.lang != nil {
  6715. fields = append(fields, batchmsg.FieldLang)
  6716. }
  6717. return fields
  6718. }
  6719. // Field returns the value of a field with the given name. The second boolean
  6720. // return value indicates that this field was not set, or was not defined in the
  6721. // schema.
  6722. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6723. switch name {
  6724. case batchmsg.FieldCreatedAt:
  6725. return m.CreatedAt()
  6726. case batchmsg.FieldUpdatedAt:
  6727. return m.UpdatedAt()
  6728. case batchmsg.FieldDeletedAt:
  6729. return m.DeletedAt()
  6730. case batchmsg.FieldStatus:
  6731. return m.Status()
  6732. case batchmsg.FieldBatchNo:
  6733. return m.BatchNo()
  6734. case batchmsg.FieldTaskName:
  6735. return m.TaskName()
  6736. case batchmsg.FieldFromwxid:
  6737. return m.Fromwxid()
  6738. case batchmsg.FieldMsg:
  6739. return m.Msg()
  6740. case batchmsg.FieldTag:
  6741. return m.Tag()
  6742. case batchmsg.FieldTagids:
  6743. return m.Tagids()
  6744. case batchmsg.FieldTotal:
  6745. return m.Total()
  6746. case batchmsg.FieldSuccess:
  6747. return m.Success()
  6748. case batchmsg.FieldFail:
  6749. return m.Fail()
  6750. case batchmsg.FieldStartTime:
  6751. return m.StartTime()
  6752. case batchmsg.FieldStopTime:
  6753. return m.StopTime()
  6754. case batchmsg.FieldSendTime:
  6755. return m.SendTime()
  6756. case batchmsg.FieldType:
  6757. return m.GetType()
  6758. case batchmsg.FieldOrganizationID:
  6759. return m.OrganizationID()
  6760. case batchmsg.FieldCtype:
  6761. return m.Ctype()
  6762. case batchmsg.FieldCc:
  6763. return m.Cc()
  6764. case batchmsg.FieldPhone:
  6765. return m.Phone()
  6766. case batchmsg.FieldTemplateName:
  6767. return m.TemplateName()
  6768. case batchmsg.FieldTemplateCode:
  6769. return m.TemplateCode()
  6770. case batchmsg.FieldLang:
  6771. return m.Lang()
  6772. }
  6773. return nil, false
  6774. }
  6775. // OldField returns the old value of the field from the database. An error is
  6776. // returned if the mutation operation is not UpdateOne, or the query to the
  6777. // database failed.
  6778. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6779. switch name {
  6780. case batchmsg.FieldCreatedAt:
  6781. return m.OldCreatedAt(ctx)
  6782. case batchmsg.FieldUpdatedAt:
  6783. return m.OldUpdatedAt(ctx)
  6784. case batchmsg.FieldDeletedAt:
  6785. return m.OldDeletedAt(ctx)
  6786. case batchmsg.FieldStatus:
  6787. return m.OldStatus(ctx)
  6788. case batchmsg.FieldBatchNo:
  6789. return m.OldBatchNo(ctx)
  6790. case batchmsg.FieldTaskName:
  6791. return m.OldTaskName(ctx)
  6792. case batchmsg.FieldFromwxid:
  6793. return m.OldFromwxid(ctx)
  6794. case batchmsg.FieldMsg:
  6795. return m.OldMsg(ctx)
  6796. case batchmsg.FieldTag:
  6797. return m.OldTag(ctx)
  6798. case batchmsg.FieldTagids:
  6799. return m.OldTagids(ctx)
  6800. case batchmsg.FieldTotal:
  6801. return m.OldTotal(ctx)
  6802. case batchmsg.FieldSuccess:
  6803. return m.OldSuccess(ctx)
  6804. case batchmsg.FieldFail:
  6805. return m.OldFail(ctx)
  6806. case batchmsg.FieldStartTime:
  6807. return m.OldStartTime(ctx)
  6808. case batchmsg.FieldStopTime:
  6809. return m.OldStopTime(ctx)
  6810. case batchmsg.FieldSendTime:
  6811. return m.OldSendTime(ctx)
  6812. case batchmsg.FieldType:
  6813. return m.OldType(ctx)
  6814. case batchmsg.FieldOrganizationID:
  6815. return m.OldOrganizationID(ctx)
  6816. case batchmsg.FieldCtype:
  6817. return m.OldCtype(ctx)
  6818. case batchmsg.FieldCc:
  6819. return m.OldCc(ctx)
  6820. case batchmsg.FieldPhone:
  6821. return m.OldPhone(ctx)
  6822. case batchmsg.FieldTemplateName:
  6823. return m.OldTemplateName(ctx)
  6824. case batchmsg.FieldTemplateCode:
  6825. return m.OldTemplateCode(ctx)
  6826. case batchmsg.FieldLang:
  6827. return m.OldLang(ctx)
  6828. }
  6829. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6830. }
  6831. // SetField sets the value of a field with the given name. It returns an error if
  6832. // the field is not defined in the schema, or if the type mismatched the field
  6833. // type.
  6834. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6835. switch name {
  6836. case batchmsg.FieldCreatedAt:
  6837. v, ok := value.(time.Time)
  6838. if !ok {
  6839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6840. }
  6841. m.SetCreatedAt(v)
  6842. return nil
  6843. case batchmsg.FieldUpdatedAt:
  6844. v, ok := value.(time.Time)
  6845. if !ok {
  6846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6847. }
  6848. m.SetUpdatedAt(v)
  6849. return nil
  6850. case batchmsg.FieldDeletedAt:
  6851. v, ok := value.(time.Time)
  6852. if !ok {
  6853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6854. }
  6855. m.SetDeletedAt(v)
  6856. return nil
  6857. case batchmsg.FieldStatus:
  6858. v, ok := value.(uint8)
  6859. if !ok {
  6860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6861. }
  6862. m.SetStatus(v)
  6863. return nil
  6864. case batchmsg.FieldBatchNo:
  6865. v, ok := value.(string)
  6866. if !ok {
  6867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6868. }
  6869. m.SetBatchNo(v)
  6870. return nil
  6871. case batchmsg.FieldTaskName:
  6872. v, ok := value.(string)
  6873. if !ok {
  6874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6875. }
  6876. m.SetTaskName(v)
  6877. return nil
  6878. case batchmsg.FieldFromwxid:
  6879. v, ok := value.(string)
  6880. if !ok {
  6881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6882. }
  6883. m.SetFromwxid(v)
  6884. return nil
  6885. case batchmsg.FieldMsg:
  6886. v, ok := value.(string)
  6887. if !ok {
  6888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6889. }
  6890. m.SetMsg(v)
  6891. return nil
  6892. case batchmsg.FieldTag:
  6893. v, ok := value.(string)
  6894. if !ok {
  6895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6896. }
  6897. m.SetTag(v)
  6898. return nil
  6899. case batchmsg.FieldTagids:
  6900. v, ok := value.(string)
  6901. if !ok {
  6902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6903. }
  6904. m.SetTagids(v)
  6905. return nil
  6906. case batchmsg.FieldTotal:
  6907. v, ok := value.(int32)
  6908. if !ok {
  6909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6910. }
  6911. m.SetTotal(v)
  6912. return nil
  6913. case batchmsg.FieldSuccess:
  6914. v, ok := value.(int32)
  6915. if !ok {
  6916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6917. }
  6918. m.SetSuccess(v)
  6919. return nil
  6920. case batchmsg.FieldFail:
  6921. v, ok := value.(int32)
  6922. if !ok {
  6923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6924. }
  6925. m.SetFail(v)
  6926. return nil
  6927. case batchmsg.FieldStartTime:
  6928. v, ok := value.(time.Time)
  6929. if !ok {
  6930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6931. }
  6932. m.SetStartTime(v)
  6933. return nil
  6934. case batchmsg.FieldStopTime:
  6935. v, ok := value.(time.Time)
  6936. if !ok {
  6937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6938. }
  6939. m.SetStopTime(v)
  6940. return nil
  6941. case batchmsg.FieldSendTime:
  6942. v, ok := value.(time.Time)
  6943. if !ok {
  6944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6945. }
  6946. m.SetSendTime(v)
  6947. return nil
  6948. case batchmsg.FieldType:
  6949. v, ok := value.(int32)
  6950. if !ok {
  6951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6952. }
  6953. m.SetType(v)
  6954. return nil
  6955. case batchmsg.FieldOrganizationID:
  6956. v, ok := value.(uint64)
  6957. if !ok {
  6958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6959. }
  6960. m.SetOrganizationID(v)
  6961. return nil
  6962. case batchmsg.FieldCtype:
  6963. v, ok := value.(uint64)
  6964. if !ok {
  6965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6966. }
  6967. m.SetCtype(v)
  6968. return nil
  6969. case batchmsg.FieldCc:
  6970. v, ok := value.(string)
  6971. if !ok {
  6972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6973. }
  6974. m.SetCc(v)
  6975. return nil
  6976. case batchmsg.FieldPhone:
  6977. v, ok := value.(string)
  6978. if !ok {
  6979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6980. }
  6981. m.SetPhone(v)
  6982. return nil
  6983. case batchmsg.FieldTemplateName:
  6984. v, ok := value.(string)
  6985. if !ok {
  6986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6987. }
  6988. m.SetTemplateName(v)
  6989. return nil
  6990. case batchmsg.FieldTemplateCode:
  6991. v, ok := value.(string)
  6992. if !ok {
  6993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6994. }
  6995. m.SetTemplateCode(v)
  6996. return nil
  6997. case batchmsg.FieldLang:
  6998. v, ok := value.(string)
  6999. if !ok {
  7000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7001. }
  7002. m.SetLang(v)
  7003. return nil
  7004. }
  7005. return fmt.Errorf("unknown BatchMsg field %s", name)
  7006. }
  7007. // AddedFields returns all numeric fields that were incremented/decremented during
  7008. // this mutation.
  7009. func (m *BatchMsgMutation) AddedFields() []string {
  7010. var fields []string
  7011. if m.addstatus != nil {
  7012. fields = append(fields, batchmsg.FieldStatus)
  7013. }
  7014. if m.addtotal != nil {
  7015. fields = append(fields, batchmsg.FieldTotal)
  7016. }
  7017. if m.addsuccess != nil {
  7018. fields = append(fields, batchmsg.FieldSuccess)
  7019. }
  7020. if m.addfail != nil {
  7021. fields = append(fields, batchmsg.FieldFail)
  7022. }
  7023. if m.add_type != nil {
  7024. fields = append(fields, batchmsg.FieldType)
  7025. }
  7026. if m.addorganization_id != nil {
  7027. fields = append(fields, batchmsg.FieldOrganizationID)
  7028. }
  7029. if m.addctype != nil {
  7030. fields = append(fields, batchmsg.FieldCtype)
  7031. }
  7032. return fields
  7033. }
  7034. // AddedField returns the numeric value that was incremented/decremented on a field
  7035. // with the given name. The second boolean return value indicates that this field
  7036. // was not set, or was not defined in the schema.
  7037. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7038. switch name {
  7039. case batchmsg.FieldStatus:
  7040. return m.AddedStatus()
  7041. case batchmsg.FieldTotal:
  7042. return m.AddedTotal()
  7043. case batchmsg.FieldSuccess:
  7044. return m.AddedSuccess()
  7045. case batchmsg.FieldFail:
  7046. return m.AddedFail()
  7047. case batchmsg.FieldType:
  7048. return m.AddedType()
  7049. case batchmsg.FieldOrganizationID:
  7050. return m.AddedOrganizationID()
  7051. case batchmsg.FieldCtype:
  7052. return m.AddedCtype()
  7053. }
  7054. return nil, false
  7055. }
  7056. // AddField adds the value to the field with the given name. It returns an error if
  7057. // the field is not defined in the schema, or if the type mismatched the field
  7058. // type.
  7059. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7060. switch name {
  7061. case batchmsg.FieldStatus:
  7062. v, ok := value.(int8)
  7063. if !ok {
  7064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7065. }
  7066. m.AddStatus(v)
  7067. return nil
  7068. case batchmsg.FieldTotal:
  7069. v, ok := value.(int32)
  7070. if !ok {
  7071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7072. }
  7073. m.AddTotal(v)
  7074. return nil
  7075. case batchmsg.FieldSuccess:
  7076. v, ok := value.(int32)
  7077. if !ok {
  7078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7079. }
  7080. m.AddSuccess(v)
  7081. return nil
  7082. case batchmsg.FieldFail:
  7083. v, ok := value.(int32)
  7084. if !ok {
  7085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7086. }
  7087. m.AddFail(v)
  7088. return nil
  7089. case batchmsg.FieldType:
  7090. v, ok := value.(int32)
  7091. if !ok {
  7092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7093. }
  7094. m.AddType(v)
  7095. return nil
  7096. case batchmsg.FieldOrganizationID:
  7097. v, ok := value.(int64)
  7098. if !ok {
  7099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7100. }
  7101. m.AddOrganizationID(v)
  7102. return nil
  7103. case batchmsg.FieldCtype:
  7104. v, ok := value.(int64)
  7105. if !ok {
  7106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7107. }
  7108. m.AddCtype(v)
  7109. return nil
  7110. }
  7111. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7112. }
  7113. // ClearedFields returns all nullable fields that were cleared during this
  7114. // mutation.
  7115. func (m *BatchMsgMutation) ClearedFields() []string {
  7116. var fields []string
  7117. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7118. fields = append(fields, batchmsg.FieldDeletedAt)
  7119. }
  7120. if m.FieldCleared(batchmsg.FieldStatus) {
  7121. fields = append(fields, batchmsg.FieldStatus)
  7122. }
  7123. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7124. fields = append(fields, batchmsg.FieldBatchNo)
  7125. }
  7126. if m.FieldCleared(batchmsg.FieldTaskName) {
  7127. fields = append(fields, batchmsg.FieldTaskName)
  7128. }
  7129. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7130. fields = append(fields, batchmsg.FieldFromwxid)
  7131. }
  7132. if m.FieldCleared(batchmsg.FieldMsg) {
  7133. fields = append(fields, batchmsg.FieldMsg)
  7134. }
  7135. if m.FieldCleared(batchmsg.FieldTag) {
  7136. fields = append(fields, batchmsg.FieldTag)
  7137. }
  7138. if m.FieldCleared(batchmsg.FieldTagids) {
  7139. fields = append(fields, batchmsg.FieldTagids)
  7140. }
  7141. if m.FieldCleared(batchmsg.FieldTotal) {
  7142. fields = append(fields, batchmsg.FieldTotal)
  7143. }
  7144. if m.FieldCleared(batchmsg.FieldSuccess) {
  7145. fields = append(fields, batchmsg.FieldSuccess)
  7146. }
  7147. if m.FieldCleared(batchmsg.FieldFail) {
  7148. fields = append(fields, batchmsg.FieldFail)
  7149. }
  7150. if m.FieldCleared(batchmsg.FieldStartTime) {
  7151. fields = append(fields, batchmsg.FieldStartTime)
  7152. }
  7153. if m.FieldCleared(batchmsg.FieldStopTime) {
  7154. fields = append(fields, batchmsg.FieldStopTime)
  7155. }
  7156. if m.FieldCleared(batchmsg.FieldSendTime) {
  7157. fields = append(fields, batchmsg.FieldSendTime)
  7158. }
  7159. if m.FieldCleared(batchmsg.FieldType) {
  7160. fields = append(fields, batchmsg.FieldType)
  7161. }
  7162. if m.FieldCleared(batchmsg.FieldCc) {
  7163. fields = append(fields, batchmsg.FieldCc)
  7164. }
  7165. if m.FieldCleared(batchmsg.FieldPhone) {
  7166. fields = append(fields, batchmsg.FieldPhone)
  7167. }
  7168. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7169. fields = append(fields, batchmsg.FieldTemplateName)
  7170. }
  7171. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7172. fields = append(fields, batchmsg.FieldTemplateCode)
  7173. }
  7174. if m.FieldCleared(batchmsg.FieldLang) {
  7175. fields = append(fields, batchmsg.FieldLang)
  7176. }
  7177. return fields
  7178. }
  7179. // FieldCleared returns a boolean indicating if a field with the given name was
  7180. // cleared in this mutation.
  7181. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7182. _, ok := m.clearedFields[name]
  7183. return ok
  7184. }
  7185. // ClearField clears the value of the field with the given name. It returns an
  7186. // error if the field is not defined in the schema.
  7187. func (m *BatchMsgMutation) ClearField(name string) error {
  7188. switch name {
  7189. case batchmsg.FieldDeletedAt:
  7190. m.ClearDeletedAt()
  7191. return nil
  7192. case batchmsg.FieldStatus:
  7193. m.ClearStatus()
  7194. return nil
  7195. case batchmsg.FieldBatchNo:
  7196. m.ClearBatchNo()
  7197. return nil
  7198. case batchmsg.FieldTaskName:
  7199. m.ClearTaskName()
  7200. return nil
  7201. case batchmsg.FieldFromwxid:
  7202. m.ClearFromwxid()
  7203. return nil
  7204. case batchmsg.FieldMsg:
  7205. m.ClearMsg()
  7206. return nil
  7207. case batchmsg.FieldTag:
  7208. m.ClearTag()
  7209. return nil
  7210. case batchmsg.FieldTagids:
  7211. m.ClearTagids()
  7212. return nil
  7213. case batchmsg.FieldTotal:
  7214. m.ClearTotal()
  7215. return nil
  7216. case batchmsg.FieldSuccess:
  7217. m.ClearSuccess()
  7218. return nil
  7219. case batchmsg.FieldFail:
  7220. m.ClearFail()
  7221. return nil
  7222. case batchmsg.FieldStartTime:
  7223. m.ClearStartTime()
  7224. return nil
  7225. case batchmsg.FieldStopTime:
  7226. m.ClearStopTime()
  7227. return nil
  7228. case batchmsg.FieldSendTime:
  7229. m.ClearSendTime()
  7230. return nil
  7231. case batchmsg.FieldType:
  7232. m.ClearType()
  7233. return nil
  7234. case batchmsg.FieldCc:
  7235. m.ClearCc()
  7236. return nil
  7237. case batchmsg.FieldPhone:
  7238. m.ClearPhone()
  7239. return nil
  7240. case batchmsg.FieldTemplateName:
  7241. m.ClearTemplateName()
  7242. return nil
  7243. case batchmsg.FieldTemplateCode:
  7244. m.ClearTemplateCode()
  7245. return nil
  7246. case batchmsg.FieldLang:
  7247. m.ClearLang()
  7248. return nil
  7249. }
  7250. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7251. }
  7252. // ResetField resets all changes in the mutation for the field with the given name.
  7253. // It returns an error if the field is not defined in the schema.
  7254. func (m *BatchMsgMutation) ResetField(name string) error {
  7255. switch name {
  7256. case batchmsg.FieldCreatedAt:
  7257. m.ResetCreatedAt()
  7258. return nil
  7259. case batchmsg.FieldUpdatedAt:
  7260. m.ResetUpdatedAt()
  7261. return nil
  7262. case batchmsg.FieldDeletedAt:
  7263. m.ResetDeletedAt()
  7264. return nil
  7265. case batchmsg.FieldStatus:
  7266. m.ResetStatus()
  7267. return nil
  7268. case batchmsg.FieldBatchNo:
  7269. m.ResetBatchNo()
  7270. return nil
  7271. case batchmsg.FieldTaskName:
  7272. m.ResetTaskName()
  7273. return nil
  7274. case batchmsg.FieldFromwxid:
  7275. m.ResetFromwxid()
  7276. return nil
  7277. case batchmsg.FieldMsg:
  7278. m.ResetMsg()
  7279. return nil
  7280. case batchmsg.FieldTag:
  7281. m.ResetTag()
  7282. return nil
  7283. case batchmsg.FieldTagids:
  7284. m.ResetTagids()
  7285. return nil
  7286. case batchmsg.FieldTotal:
  7287. m.ResetTotal()
  7288. return nil
  7289. case batchmsg.FieldSuccess:
  7290. m.ResetSuccess()
  7291. return nil
  7292. case batchmsg.FieldFail:
  7293. m.ResetFail()
  7294. return nil
  7295. case batchmsg.FieldStartTime:
  7296. m.ResetStartTime()
  7297. return nil
  7298. case batchmsg.FieldStopTime:
  7299. m.ResetStopTime()
  7300. return nil
  7301. case batchmsg.FieldSendTime:
  7302. m.ResetSendTime()
  7303. return nil
  7304. case batchmsg.FieldType:
  7305. m.ResetType()
  7306. return nil
  7307. case batchmsg.FieldOrganizationID:
  7308. m.ResetOrganizationID()
  7309. return nil
  7310. case batchmsg.FieldCtype:
  7311. m.ResetCtype()
  7312. return nil
  7313. case batchmsg.FieldCc:
  7314. m.ResetCc()
  7315. return nil
  7316. case batchmsg.FieldPhone:
  7317. m.ResetPhone()
  7318. return nil
  7319. case batchmsg.FieldTemplateName:
  7320. m.ResetTemplateName()
  7321. return nil
  7322. case batchmsg.FieldTemplateCode:
  7323. m.ResetTemplateCode()
  7324. return nil
  7325. case batchmsg.FieldLang:
  7326. m.ResetLang()
  7327. return nil
  7328. }
  7329. return fmt.Errorf("unknown BatchMsg field %s", name)
  7330. }
  7331. // AddedEdges returns all edge names that were set/added in this mutation.
  7332. func (m *BatchMsgMutation) AddedEdges() []string {
  7333. edges := make([]string, 0, 0)
  7334. return edges
  7335. }
  7336. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7337. // name in this mutation.
  7338. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7339. return nil
  7340. }
  7341. // RemovedEdges returns all edge names that were removed in this mutation.
  7342. func (m *BatchMsgMutation) RemovedEdges() []string {
  7343. edges := make([]string, 0, 0)
  7344. return edges
  7345. }
  7346. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7347. // the given name in this mutation.
  7348. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7349. return nil
  7350. }
  7351. // ClearedEdges returns all edge names that were cleared in this mutation.
  7352. func (m *BatchMsgMutation) ClearedEdges() []string {
  7353. edges := make([]string, 0, 0)
  7354. return edges
  7355. }
  7356. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7357. // was cleared in this mutation.
  7358. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7359. return false
  7360. }
  7361. // ClearEdge clears the value of the edge with the given name. It returns an error
  7362. // if that edge is not defined in the schema.
  7363. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7364. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7365. }
  7366. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7367. // It returns an error if the edge is not defined in the schema.
  7368. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7369. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7370. }
  7371. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7372. type CategoryMutation struct {
  7373. config
  7374. op Op
  7375. typ string
  7376. id *uint64
  7377. created_at *time.Time
  7378. updated_at *time.Time
  7379. deleted_at *time.Time
  7380. name *string
  7381. organization_id *uint64
  7382. addorganization_id *int64
  7383. clearedFields map[string]struct{}
  7384. done bool
  7385. oldValue func(context.Context) (*Category, error)
  7386. predicates []predicate.Category
  7387. }
  7388. var _ ent.Mutation = (*CategoryMutation)(nil)
  7389. // categoryOption allows management of the mutation configuration using functional options.
  7390. type categoryOption func(*CategoryMutation)
  7391. // newCategoryMutation creates new mutation for the Category entity.
  7392. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7393. m := &CategoryMutation{
  7394. config: c,
  7395. op: op,
  7396. typ: TypeCategory,
  7397. clearedFields: make(map[string]struct{}),
  7398. }
  7399. for _, opt := range opts {
  7400. opt(m)
  7401. }
  7402. return m
  7403. }
  7404. // withCategoryID sets the ID field of the mutation.
  7405. func withCategoryID(id uint64) categoryOption {
  7406. return func(m *CategoryMutation) {
  7407. var (
  7408. err error
  7409. once sync.Once
  7410. value *Category
  7411. )
  7412. m.oldValue = func(ctx context.Context) (*Category, error) {
  7413. once.Do(func() {
  7414. if m.done {
  7415. err = errors.New("querying old values post mutation is not allowed")
  7416. } else {
  7417. value, err = m.Client().Category.Get(ctx, id)
  7418. }
  7419. })
  7420. return value, err
  7421. }
  7422. m.id = &id
  7423. }
  7424. }
  7425. // withCategory sets the old Category of the mutation.
  7426. func withCategory(node *Category) categoryOption {
  7427. return func(m *CategoryMutation) {
  7428. m.oldValue = func(context.Context) (*Category, error) {
  7429. return node, nil
  7430. }
  7431. m.id = &node.ID
  7432. }
  7433. }
  7434. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7435. // executed in a transaction (ent.Tx), a transactional client is returned.
  7436. func (m CategoryMutation) Client() *Client {
  7437. client := &Client{config: m.config}
  7438. client.init()
  7439. return client
  7440. }
  7441. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7442. // it returns an error otherwise.
  7443. func (m CategoryMutation) Tx() (*Tx, error) {
  7444. if _, ok := m.driver.(*txDriver); !ok {
  7445. return nil, errors.New("ent: mutation is not running in a transaction")
  7446. }
  7447. tx := &Tx{config: m.config}
  7448. tx.init()
  7449. return tx, nil
  7450. }
  7451. // SetID sets the value of the id field. Note that this
  7452. // operation is only accepted on creation of Category entities.
  7453. func (m *CategoryMutation) SetID(id uint64) {
  7454. m.id = &id
  7455. }
  7456. // ID returns the ID value in the mutation. Note that the ID is only available
  7457. // if it was provided to the builder or after it was returned from the database.
  7458. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7459. if m.id == nil {
  7460. return
  7461. }
  7462. return *m.id, true
  7463. }
  7464. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7465. // That means, if the mutation is applied within a transaction with an isolation level such
  7466. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7467. // or updated by the mutation.
  7468. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7469. switch {
  7470. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7471. id, exists := m.ID()
  7472. if exists {
  7473. return []uint64{id}, nil
  7474. }
  7475. fallthrough
  7476. case m.op.Is(OpUpdate | OpDelete):
  7477. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7478. default:
  7479. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7480. }
  7481. }
  7482. // SetCreatedAt sets the "created_at" field.
  7483. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7484. m.created_at = &t
  7485. }
  7486. // CreatedAt returns the value of the "created_at" field in the mutation.
  7487. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7488. v := m.created_at
  7489. if v == nil {
  7490. return
  7491. }
  7492. return *v, true
  7493. }
  7494. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7495. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7497. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7498. if !m.op.Is(OpUpdateOne) {
  7499. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7500. }
  7501. if m.id == nil || m.oldValue == nil {
  7502. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7503. }
  7504. oldValue, err := m.oldValue(ctx)
  7505. if err != nil {
  7506. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7507. }
  7508. return oldValue.CreatedAt, nil
  7509. }
  7510. // ResetCreatedAt resets all changes to the "created_at" field.
  7511. func (m *CategoryMutation) ResetCreatedAt() {
  7512. m.created_at = nil
  7513. }
  7514. // SetUpdatedAt sets the "updated_at" field.
  7515. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7516. m.updated_at = &t
  7517. }
  7518. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7519. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7520. v := m.updated_at
  7521. if v == nil {
  7522. return
  7523. }
  7524. return *v, true
  7525. }
  7526. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7527. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7529. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7530. if !m.op.Is(OpUpdateOne) {
  7531. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7532. }
  7533. if m.id == nil || m.oldValue == nil {
  7534. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7535. }
  7536. oldValue, err := m.oldValue(ctx)
  7537. if err != nil {
  7538. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7539. }
  7540. return oldValue.UpdatedAt, nil
  7541. }
  7542. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7543. func (m *CategoryMutation) ResetUpdatedAt() {
  7544. m.updated_at = nil
  7545. }
  7546. // SetDeletedAt sets the "deleted_at" field.
  7547. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7548. m.deleted_at = &t
  7549. }
  7550. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7551. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7552. v := m.deleted_at
  7553. if v == nil {
  7554. return
  7555. }
  7556. return *v, true
  7557. }
  7558. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7559. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7561. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7562. if !m.op.Is(OpUpdateOne) {
  7563. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7564. }
  7565. if m.id == nil || m.oldValue == nil {
  7566. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7567. }
  7568. oldValue, err := m.oldValue(ctx)
  7569. if err != nil {
  7570. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7571. }
  7572. return oldValue.DeletedAt, nil
  7573. }
  7574. // ClearDeletedAt clears the value of the "deleted_at" field.
  7575. func (m *CategoryMutation) ClearDeletedAt() {
  7576. m.deleted_at = nil
  7577. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7578. }
  7579. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7580. func (m *CategoryMutation) DeletedAtCleared() bool {
  7581. _, ok := m.clearedFields[category.FieldDeletedAt]
  7582. return ok
  7583. }
  7584. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7585. func (m *CategoryMutation) ResetDeletedAt() {
  7586. m.deleted_at = nil
  7587. delete(m.clearedFields, category.FieldDeletedAt)
  7588. }
  7589. // SetName sets the "name" field.
  7590. func (m *CategoryMutation) SetName(s string) {
  7591. m.name = &s
  7592. }
  7593. // Name returns the value of the "name" field in the mutation.
  7594. func (m *CategoryMutation) Name() (r string, exists bool) {
  7595. v := m.name
  7596. if v == nil {
  7597. return
  7598. }
  7599. return *v, true
  7600. }
  7601. // OldName returns the old "name" field's value of the Category entity.
  7602. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7604. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7605. if !m.op.Is(OpUpdateOne) {
  7606. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7607. }
  7608. if m.id == nil || m.oldValue == nil {
  7609. return v, errors.New("OldName requires an ID field in the mutation")
  7610. }
  7611. oldValue, err := m.oldValue(ctx)
  7612. if err != nil {
  7613. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7614. }
  7615. return oldValue.Name, nil
  7616. }
  7617. // ResetName resets all changes to the "name" field.
  7618. func (m *CategoryMutation) ResetName() {
  7619. m.name = nil
  7620. }
  7621. // SetOrganizationID sets the "organization_id" field.
  7622. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7623. m.organization_id = &u
  7624. m.addorganization_id = nil
  7625. }
  7626. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7627. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7628. v := m.organization_id
  7629. if v == nil {
  7630. return
  7631. }
  7632. return *v, true
  7633. }
  7634. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7635. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7637. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7638. if !m.op.Is(OpUpdateOne) {
  7639. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7640. }
  7641. if m.id == nil || m.oldValue == nil {
  7642. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7643. }
  7644. oldValue, err := m.oldValue(ctx)
  7645. if err != nil {
  7646. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7647. }
  7648. return oldValue.OrganizationID, nil
  7649. }
  7650. // AddOrganizationID adds u to the "organization_id" field.
  7651. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7652. if m.addorganization_id != nil {
  7653. *m.addorganization_id += u
  7654. } else {
  7655. m.addorganization_id = &u
  7656. }
  7657. }
  7658. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7659. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7660. v := m.addorganization_id
  7661. if v == nil {
  7662. return
  7663. }
  7664. return *v, true
  7665. }
  7666. // ResetOrganizationID resets all changes to the "organization_id" field.
  7667. func (m *CategoryMutation) ResetOrganizationID() {
  7668. m.organization_id = nil
  7669. m.addorganization_id = nil
  7670. }
  7671. // Where appends a list predicates to the CategoryMutation builder.
  7672. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7673. m.predicates = append(m.predicates, ps...)
  7674. }
  7675. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7676. // users can use type-assertion to append predicates that do not depend on any generated package.
  7677. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7678. p := make([]predicate.Category, len(ps))
  7679. for i := range ps {
  7680. p[i] = ps[i]
  7681. }
  7682. m.Where(p...)
  7683. }
  7684. // Op returns the operation name.
  7685. func (m *CategoryMutation) Op() Op {
  7686. return m.op
  7687. }
  7688. // SetOp allows setting the mutation operation.
  7689. func (m *CategoryMutation) SetOp(op Op) {
  7690. m.op = op
  7691. }
  7692. // Type returns the node type of this mutation (Category).
  7693. func (m *CategoryMutation) Type() string {
  7694. return m.typ
  7695. }
  7696. // Fields returns all fields that were changed during this mutation. Note that in
  7697. // order to get all numeric fields that were incremented/decremented, call
  7698. // AddedFields().
  7699. func (m *CategoryMutation) Fields() []string {
  7700. fields := make([]string, 0, 5)
  7701. if m.created_at != nil {
  7702. fields = append(fields, category.FieldCreatedAt)
  7703. }
  7704. if m.updated_at != nil {
  7705. fields = append(fields, category.FieldUpdatedAt)
  7706. }
  7707. if m.deleted_at != nil {
  7708. fields = append(fields, category.FieldDeletedAt)
  7709. }
  7710. if m.name != nil {
  7711. fields = append(fields, category.FieldName)
  7712. }
  7713. if m.organization_id != nil {
  7714. fields = append(fields, category.FieldOrganizationID)
  7715. }
  7716. return fields
  7717. }
  7718. // Field returns the value of a field with the given name. The second boolean
  7719. // return value indicates that this field was not set, or was not defined in the
  7720. // schema.
  7721. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7722. switch name {
  7723. case category.FieldCreatedAt:
  7724. return m.CreatedAt()
  7725. case category.FieldUpdatedAt:
  7726. return m.UpdatedAt()
  7727. case category.FieldDeletedAt:
  7728. return m.DeletedAt()
  7729. case category.FieldName:
  7730. return m.Name()
  7731. case category.FieldOrganizationID:
  7732. return m.OrganizationID()
  7733. }
  7734. return nil, false
  7735. }
  7736. // OldField returns the old value of the field from the database. An error is
  7737. // returned if the mutation operation is not UpdateOne, or the query to the
  7738. // database failed.
  7739. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7740. switch name {
  7741. case category.FieldCreatedAt:
  7742. return m.OldCreatedAt(ctx)
  7743. case category.FieldUpdatedAt:
  7744. return m.OldUpdatedAt(ctx)
  7745. case category.FieldDeletedAt:
  7746. return m.OldDeletedAt(ctx)
  7747. case category.FieldName:
  7748. return m.OldName(ctx)
  7749. case category.FieldOrganizationID:
  7750. return m.OldOrganizationID(ctx)
  7751. }
  7752. return nil, fmt.Errorf("unknown Category field %s", name)
  7753. }
  7754. // SetField sets the value of a field with the given name. It returns an error if
  7755. // the field is not defined in the schema, or if the type mismatched the field
  7756. // type.
  7757. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7758. switch name {
  7759. case category.FieldCreatedAt:
  7760. v, ok := value.(time.Time)
  7761. if !ok {
  7762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7763. }
  7764. m.SetCreatedAt(v)
  7765. return nil
  7766. case category.FieldUpdatedAt:
  7767. v, ok := value.(time.Time)
  7768. if !ok {
  7769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7770. }
  7771. m.SetUpdatedAt(v)
  7772. return nil
  7773. case category.FieldDeletedAt:
  7774. v, ok := value.(time.Time)
  7775. if !ok {
  7776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7777. }
  7778. m.SetDeletedAt(v)
  7779. return nil
  7780. case category.FieldName:
  7781. v, ok := value.(string)
  7782. if !ok {
  7783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7784. }
  7785. m.SetName(v)
  7786. return nil
  7787. case category.FieldOrganizationID:
  7788. v, ok := value.(uint64)
  7789. if !ok {
  7790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7791. }
  7792. m.SetOrganizationID(v)
  7793. return nil
  7794. }
  7795. return fmt.Errorf("unknown Category field %s", name)
  7796. }
  7797. // AddedFields returns all numeric fields that were incremented/decremented during
  7798. // this mutation.
  7799. func (m *CategoryMutation) AddedFields() []string {
  7800. var fields []string
  7801. if m.addorganization_id != nil {
  7802. fields = append(fields, category.FieldOrganizationID)
  7803. }
  7804. return fields
  7805. }
  7806. // AddedField returns the numeric value that was incremented/decremented on a field
  7807. // with the given name. The second boolean return value indicates that this field
  7808. // was not set, or was not defined in the schema.
  7809. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7810. switch name {
  7811. case category.FieldOrganizationID:
  7812. return m.AddedOrganizationID()
  7813. }
  7814. return nil, false
  7815. }
  7816. // AddField adds the value to the field with the given name. It returns an error if
  7817. // the field is not defined in the schema, or if the type mismatched the field
  7818. // type.
  7819. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7820. switch name {
  7821. case category.FieldOrganizationID:
  7822. v, ok := value.(int64)
  7823. if !ok {
  7824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7825. }
  7826. m.AddOrganizationID(v)
  7827. return nil
  7828. }
  7829. return fmt.Errorf("unknown Category numeric field %s", name)
  7830. }
  7831. // ClearedFields returns all nullable fields that were cleared during this
  7832. // mutation.
  7833. func (m *CategoryMutation) ClearedFields() []string {
  7834. var fields []string
  7835. if m.FieldCleared(category.FieldDeletedAt) {
  7836. fields = append(fields, category.FieldDeletedAt)
  7837. }
  7838. return fields
  7839. }
  7840. // FieldCleared returns a boolean indicating if a field with the given name was
  7841. // cleared in this mutation.
  7842. func (m *CategoryMutation) FieldCleared(name string) bool {
  7843. _, ok := m.clearedFields[name]
  7844. return ok
  7845. }
  7846. // ClearField clears the value of the field with the given name. It returns an
  7847. // error if the field is not defined in the schema.
  7848. func (m *CategoryMutation) ClearField(name string) error {
  7849. switch name {
  7850. case category.FieldDeletedAt:
  7851. m.ClearDeletedAt()
  7852. return nil
  7853. }
  7854. return fmt.Errorf("unknown Category nullable field %s", name)
  7855. }
  7856. // ResetField resets all changes in the mutation for the field with the given name.
  7857. // It returns an error if the field is not defined in the schema.
  7858. func (m *CategoryMutation) ResetField(name string) error {
  7859. switch name {
  7860. case category.FieldCreatedAt:
  7861. m.ResetCreatedAt()
  7862. return nil
  7863. case category.FieldUpdatedAt:
  7864. m.ResetUpdatedAt()
  7865. return nil
  7866. case category.FieldDeletedAt:
  7867. m.ResetDeletedAt()
  7868. return nil
  7869. case category.FieldName:
  7870. m.ResetName()
  7871. return nil
  7872. case category.FieldOrganizationID:
  7873. m.ResetOrganizationID()
  7874. return nil
  7875. }
  7876. return fmt.Errorf("unknown Category field %s", name)
  7877. }
  7878. // AddedEdges returns all edge names that were set/added in this mutation.
  7879. func (m *CategoryMutation) AddedEdges() []string {
  7880. edges := make([]string, 0, 0)
  7881. return edges
  7882. }
  7883. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7884. // name in this mutation.
  7885. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7886. return nil
  7887. }
  7888. // RemovedEdges returns all edge names that were removed in this mutation.
  7889. func (m *CategoryMutation) RemovedEdges() []string {
  7890. edges := make([]string, 0, 0)
  7891. return edges
  7892. }
  7893. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7894. // the given name in this mutation.
  7895. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7896. return nil
  7897. }
  7898. // ClearedEdges returns all edge names that were cleared in this mutation.
  7899. func (m *CategoryMutation) ClearedEdges() []string {
  7900. edges := make([]string, 0, 0)
  7901. return edges
  7902. }
  7903. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7904. // was cleared in this mutation.
  7905. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7906. return false
  7907. }
  7908. // ClearEdge clears the value of the edge with the given name. It returns an error
  7909. // if that edge is not defined in the schema.
  7910. func (m *CategoryMutation) ClearEdge(name string) error {
  7911. return fmt.Errorf("unknown Category unique edge %s", name)
  7912. }
  7913. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7914. // It returns an error if the edge is not defined in the schema.
  7915. func (m *CategoryMutation) ResetEdge(name string) error {
  7916. return fmt.Errorf("unknown Category edge %s", name)
  7917. }
  7918. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7919. type ChatRecordsMutation struct {
  7920. config
  7921. op Op
  7922. typ string
  7923. id *uint64
  7924. created_at *time.Time
  7925. updated_at *time.Time
  7926. deleted_at *time.Time
  7927. content *string
  7928. content_type *uint8
  7929. addcontent_type *int8
  7930. session_id *uint64
  7931. addsession_id *int64
  7932. user_id *uint64
  7933. adduser_id *int64
  7934. bot_id *uint64
  7935. addbot_id *int64
  7936. bot_type *uint8
  7937. addbot_type *int8
  7938. clearedFields map[string]struct{}
  7939. done bool
  7940. oldValue func(context.Context) (*ChatRecords, error)
  7941. predicates []predicate.ChatRecords
  7942. }
  7943. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7944. // chatrecordsOption allows management of the mutation configuration using functional options.
  7945. type chatrecordsOption func(*ChatRecordsMutation)
  7946. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7947. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7948. m := &ChatRecordsMutation{
  7949. config: c,
  7950. op: op,
  7951. typ: TypeChatRecords,
  7952. clearedFields: make(map[string]struct{}),
  7953. }
  7954. for _, opt := range opts {
  7955. opt(m)
  7956. }
  7957. return m
  7958. }
  7959. // withChatRecordsID sets the ID field of the mutation.
  7960. func withChatRecordsID(id uint64) chatrecordsOption {
  7961. return func(m *ChatRecordsMutation) {
  7962. var (
  7963. err error
  7964. once sync.Once
  7965. value *ChatRecords
  7966. )
  7967. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7968. once.Do(func() {
  7969. if m.done {
  7970. err = errors.New("querying old values post mutation is not allowed")
  7971. } else {
  7972. value, err = m.Client().ChatRecords.Get(ctx, id)
  7973. }
  7974. })
  7975. return value, err
  7976. }
  7977. m.id = &id
  7978. }
  7979. }
  7980. // withChatRecords sets the old ChatRecords of the mutation.
  7981. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7982. return func(m *ChatRecordsMutation) {
  7983. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7984. return node, nil
  7985. }
  7986. m.id = &node.ID
  7987. }
  7988. }
  7989. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7990. // executed in a transaction (ent.Tx), a transactional client is returned.
  7991. func (m ChatRecordsMutation) Client() *Client {
  7992. client := &Client{config: m.config}
  7993. client.init()
  7994. return client
  7995. }
  7996. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7997. // it returns an error otherwise.
  7998. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7999. if _, ok := m.driver.(*txDriver); !ok {
  8000. return nil, errors.New("ent: mutation is not running in a transaction")
  8001. }
  8002. tx := &Tx{config: m.config}
  8003. tx.init()
  8004. return tx, nil
  8005. }
  8006. // SetID sets the value of the id field. Note that this
  8007. // operation is only accepted on creation of ChatRecords entities.
  8008. func (m *ChatRecordsMutation) SetID(id uint64) {
  8009. m.id = &id
  8010. }
  8011. // ID returns the ID value in the mutation. Note that the ID is only available
  8012. // if it was provided to the builder or after it was returned from the database.
  8013. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8014. if m.id == nil {
  8015. return
  8016. }
  8017. return *m.id, true
  8018. }
  8019. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8020. // That means, if the mutation is applied within a transaction with an isolation level such
  8021. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8022. // or updated by the mutation.
  8023. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8024. switch {
  8025. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8026. id, exists := m.ID()
  8027. if exists {
  8028. return []uint64{id}, nil
  8029. }
  8030. fallthrough
  8031. case m.op.Is(OpUpdate | OpDelete):
  8032. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8033. default:
  8034. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8035. }
  8036. }
  8037. // SetCreatedAt sets the "created_at" field.
  8038. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8039. m.created_at = &t
  8040. }
  8041. // CreatedAt returns the value of the "created_at" field in the mutation.
  8042. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8043. v := m.created_at
  8044. if v == nil {
  8045. return
  8046. }
  8047. return *v, true
  8048. }
  8049. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8050. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8052. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8053. if !m.op.Is(OpUpdateOne) {
  8054. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8055. }
  8056. if m.id == nil || m.oldValue == nil {
  8057. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8058. }
  8059. oldValue, err := m.oldValue(ctx)
  8060. if err != nil {
  8061. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8062. }
  8063. return oldValue.CreatedAt, nil
  8064. }
  8065. // ResetCreatedAt resets all changes to the "created_at" field.
  8066. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8067. m.created_at = nil
  8068. }
  8069. // SetUpdatedAt sets the "updated_at" field.
  8070. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8071. m.updated_at = &t
  8072. }
  8073. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8074. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8075. v := m.updated_at
  8076. if v == nil {
  8077. return
  8078. }
  8079. return *v, true
  8080. }
  8081. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8082. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8084. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8085. if !m.op.Is(OpUpdateOne) {
  8086. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8087. }
  8088. if m.id == nil || m.oldValue == nil {
  8089. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8090. }
  8091. oldValue, err := m.oldValue(ctx)
  8092. if err != nil {
  8093. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8094. }
  8095. return oldValue.UpdatedAt, nil
  8096. }
  8097. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8098. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8099. m.updated_at = nil
  8100. }
  8101. // SetDeletedAt sets the "deleted_at" field.
  8102. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8103. m.deleted_at = &t
  8104. }
  8105. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8106. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8107. v := m.deleted_at
  8108. if v == nil {
  8109. return
  8110. }
  8111. return *v, true
  8112. }
  8113. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8114. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8116. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8117. if !m.op.Is(OpUpdateOne) {
  8118. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8119. }
  8120. if m.id == nil || m.oldValue == nil {
  8121. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8122. }
  8123. oldValue, err := m.oldValue(ctx)
  8124. if err != nil {
  8125. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8126. }
  8127. return oldValue.DeletedAt, nil
  8128. }
  8129. // ClearDeletedAt clears the value of the "deleted_at" field.
  8130. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8131. m.deleted_at = nil
  8132. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8133. }
  8134. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8135. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8136. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8137. return ok
  8138. }
  8139. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8140. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8141. m.deleted_at = nil
  8142. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8143. }
  8144. // SetContent sets the "content" field.
  8145. func (m *ChatRecordsMutation) SetContent(s string) {
  8146. m.content = &s
  8147. }
  8148. // Content returns the value of the "content" field in the mutation.
  8149. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8150. v := m.content
  8151. if v == nil {
  8152. return
  8153. }
  8154. return *v, true
  8155. }
  8156. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8157. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8159. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8160. if !m.op.Is(OpUpdateOne) {
  8161. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8162. }
  8163. if m.id == nil || m.oldValue == nil {
  8164. return v, errors.New("OldContent requires an ID field in the mutation")
  8165. }
  8166. oldValue, err := m.oldValue(ctx)
  8167. if err != nil {
  8168. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8169. }
  8170. return oldValue.Content, nil
  8171. }
  8172. // ResetContent resets all changes to the "content" field.
  8173. func (m *ChatRecordsMutation) ResetContent() {
  8174. m.content = nil
  8175. }
  8176. // SetContentType sets the "content_type" field.
  8177. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8178. m.content_type = &u
  8179. m.addcontent_type = nil
  8180. }
  8181. // ContentType returns the value of the "content_type" field in the mutation.
  8182. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8183. v := m.content_type
  8184. if v == nil {
  8185. return
  8186. }
  8187. return *v, true
  8188. }
  8189. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8190. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8192. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8193. if !m.op.Is(OpUpdateOne) {
  8194. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8195. }
  8196. if m.id == nil || m.oldValue == nil {
  8197. return v, errors.New("OldContentType requires an ID field in the mutation")
  8198. }
  8199. oldValue, err := m.oldValue(ctx)
  8200. if err != nil {
  8201. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8202. }
  8203. return oldValue.ContentType, nil
  8204. }
  8205. // AddContentType adds u to the "content_type" field.
  8206. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8207. if m.addcontent_type != nil {
  8208. *m.addcontent_type += u
  8209. } else {
  8210. m.addcontent_type = &u
  8211. }
  8212. }
  8213. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8214. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8215. v := m.addcontent_type
  8216. if v == nil {
  8217. return
  8218. }
  8219. return *v, true
  8220. }
  8221. // ResetContentType resets all changes to the "content_type" field.
  8222. func (m *ChatRecordsMutation) ResetContentType() {
  8223. m.content_type = nil
  8224. m.addcontent_type = nil
  8225. }
  8226. // SetSessionID sets the "session_id" field.
  8227. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8228. m.session_id = &u
  8229. m.addsession_id = nil
  8230. }
  8231. // SessionID returns the value of the "session_id" field in the mutation.
  8232. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8233. v := m.session_id
  8234. if v == nil {
  8235. return
  8236. }
  8237. return *v, true
  8238. }
  8239. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8240. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8242. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8243. if !m.op.Is(OpUpdateOne) {
  8244. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8245. }
  8246. if m.id == nil || m.oldValue == nil {
  8247. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8248. }
  8249. oldValue, err := m.oldValue(ctx)
  8250. if err != nil {
  8251. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8252. }
  8253. return oldValue.SessionID, nil
  8254. }
  8255. // AddSessionID adds u to the "session_id" field.
  8256. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8257. if m.addsession_id != nil {
  8258. *m.addsession_id += u
  8259. } else {
  8260. m.addsession_id = &u
  8261. }
  8262. }
  8263. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8264. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8265. v := m.addsession_id
  8266. if v == nil {
  8267. return
  8268. }
  8269. return *v, true
  8270. }
  8271. // ResetSessionID resets all changes to the "session_id" field.
  8272. func (m *ChatRecordsMutation) ResetSessionID() {
  8273. m.session_id = nil
  8274. m.addsession_id = nil
  8275. }
  8276. // SetUserID sets the "user_id" field.
  8277. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8278. m.user_id = &u
  8279. m.adduser_id = nil
  8280. }
  8281. // UserID returns the value of the "user_id" field in the mutation.
  8282. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8283. v := m.user_id
  8284. if v == nil {
  8285. return
  8286. }
  8287. return *v, true
  8288. }
  8289. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8290. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8292. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8293. if !m.op.Is(OpUpdateOne) {
  8294. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8295. }
  8296. if m.id == nil || m.oldValue == nil {
  8297. return v, errors.New("OldUserID requires an ID field in the mutation")
  8298. }
  8299. oldValue, err := m.oldValue(ctx)
  8300. if err != nil {
  8301. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8302. }
  8303. return oldValue.UserID, nil
  8304. }
  8305. // AddUserID adds u to the "user_id" field.
  8306. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8307. if m.adduser_id != nil {
  8308. *m.adduser_id += u
  8309. } else {
  8310. m.adduser_id = &u
  8311. }
  8312. }
  8313. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8314. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8315. v := m.adduser_id
  8316. if v == nil {
  8317. return
  8318. }
  8319. return *v, true
  8320. }
  8321. // ResetUserID resets all changes to the "user_id" field.
  8322. func (m *ChatRecordsMutation) ResetUserID() {
  8323. m.user_id = nil
  8324. m.adduser_id = nil
  8325. }
  8326. // SetBotID sets the "bot_id" field.
  8327. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8328. m.bot_id = &u
  8329. m.addbot_id = nil
  8330. }
  8331. // BotID returns the value of the "bot_id" field in the mutation.
  8332. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8333. v := m.bot_id
  8334. if v == nil {
  8335. return
  8336. }
  8337. return *v, true
  8338. }
  8339. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8340. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8342. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8343. if !m.op.Is(OpUpdateOne) {
  8344. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8345. }
  8346. if m.id == nil || m.oldValue == nil {
  8347. return v, errors.New("OldBotID requires an ID field in the mutation")
  8348. }
  8349. oldValue, err := m.oldValue(ctx)
  8350. if err != nil {
  8351. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8352. }
  8353. return oldValue.BotID, nil
  8354. }
  8355. // AddBotID adds u to the "bot_id" field.
  8356. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8357. if m.addbot_id != nil {
  8358. *m.addbot_id += u
  8359. } else {
  8360. m.addbot_id = &u
  8361. }
  8362. }
  8363. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8364. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8365. v := m.addbot_id
  8366. if v == nil {
  8367. return
  8368. }
  8369. return *v, true
  8370. }
  8371. // ResetBotID resets all changes to the "bot_id" field.
  8372. func (m *ChatRecordsMutation) ResetBotID() {
  8373. m.bot_id = nil
  8374. m.addbot_id = nil
  8375. }
  8376. // SetBotType sets the "bot_type" field.
  8377. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8378. m.bot_type = &u
  8379. m.addbot_type = nil
  8380. }
  8381. // BotType returns the value of the "bot_type" field in the mutation.
  8382. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8383. v := m.bot_type
  8384. if v == nil {
  8385. return
  8386. }
  8387. return *v, true
  8388. }
  8389. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8390. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8392. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8393. if !m.op.Is(OpUpdateOne) {
  8394. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8395. }
  8396. if m.id == nil || m.oldValue == nil {
  8397. return v, errors.New("OldBotType requires an ID field in the mutation")
  8398. }
  8399. oldValue, err := m.oldValue(ctx)
  8400. if err != nil {
  8401. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8402. }
  8403. return oldValue.BotType, nil
  8404. }
  8405. // AddBotType adds u to the "bot_type" field.
  8406. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8407. if m.addbot_type != nil {
  8408. *m.addbot_type += u
  8409. } else {
  8410. m.addbot_type = &u
  8411. }
  8412. }
  8413. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8414. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8415. v := m.addbot_type
  8416. if v == nil {
  8417. return
  8418. }
  8419. return *v, true
  8420. }
  8421. // ResetBotType resets all changes to the "bot_type" field.
  8422. func (m *ChatRecordsMutation) ResetBotType() {
  8423. m.bot_type = nil
  8424. m.addbot_type = nil
  8425. }
  8426. // Where appends a list predicates to the ChatRecordsMutation builder.
  8427. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8428. m.predicates = append(m.predicates, ps...)
  8429. }
  8430. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8431. // users can use type-assertion to append predicates that do not depend on any generated package.
  8432. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8433. p := make([]predicate.ChatRecords, len(ps))
  8434. for i := range ps {
  8435. p[i] = ps[i]
  8436. }
  8437. m.Where(p...)
  8438. }
  8439. // Op returns the operation name.
  8440. func (m *ChatRecordsMutation) Op() Op {
  8441. return m.op
  8442. }
  8443. // SetOp allows setting the mutation operation.
  8444. func (m *ChatRecordsMutation) SetOp(op Op) {
  8445. m.op = op
  8446. }
  8447. // Type returns the node type of this mutation (ChatRecords).
  8448. func (m *ChatRecordsMutation) Type() string {
  8449. return m.typ
  8450. }
  8451. // Fields returns all fields that were changed during this mutation. Note that in
  8452. // order to get all numeric fields that were incremented/decremented, call
  8453. // AddedFields().
  8454. func (m *ChatRecordsMutation) Fields() []string {
  8455. fields := make([]string, 0, 9)
  8456. if m.created_at != nil {
  8457. fields = append(fields, chatrecords.FieldCreatedAt)
  8458. }
  8459. if m.updated_at != nil {
  8460. fields = append(fields, chatrecords.FieldUpdatedAt)
  8461. }
  8462. if m.deleted_at != nil {
  8463. fields = append(fields, chatrecords.FieldDeletedAt)
  8464. }
  8465. if m.content != nil {
  8466. fields = append(fields, chatrecords.FieldContent)
  8467. }
  8468. if m.content_type != nil {
  8469. fields = append(fields, chatrecords.FieldContentType)
  8470. }
  8471. if m.session_id != nil {
  8472. fields = append(fields, chatrecords.FieldSessionID)
  8473. }
  8474. if m.user_id != nil {
  8475. fields = append(fields, chatrecords.FieldUserID)
  8476. }
  8477. if m.bot_id != nil {
  8478. fields = append(fields, chatrecords.FieldBotID)
  8479. }
  8480. if m.bot_type != nil {
  8481. fields = append(fields, chatrecords.FieldBotType)
  8482. }
  8483. return fields
  8484. }
  8485. // Field returns the value of a field with the given name. The second boolean
  8486. // return value indicates that this field was not set, or was not defined in the
  8487. // schema.
  8488. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8489. switch name {
  8490. case chatrecords.FieldCreatedAt:
  8491. return m.CreatedAt()
  8492. case chatrecords.FieldUpdatedAt:
  8493. return m.UpdatedAt()
  8494. case chatrecords.FieldDeletedAt:
  8495. return m.DeletedAt()
  8496. case chatrecords.FieldContent:
  8497. return m.Content()
  8498. case chatrecords.FieldContentType:
  8499. return m.ContentType()
  8500. case chatrecords.FieldSessionID:
  8501. return m.SessionID()
  8502. case chatrecords.FieldUserID:
  8503. return m.UserID()
  8504. case chatrecords.FieldBotID:
  8505. return m.BotID()
  8506. case chatrecords.FieldBotType:
  8507. return m.BotType()
  8508. }
  8509. return nil, false
  8510. }
  8511. // OldField returns the old value of the field from the database. An error is
  8512. // returned if the mutation operation is not UpdateOne, or the query to the
  8513. // database failed.
  8514. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8515. switch name {
  8516. case chatrecords.FieldCreatedAt:
  8517. return m.OldCreatedAt(ctx)
  8518. case chatrecords.FieldUpdatedAt:
  8519. return m.OldUpdatedAt(ctx)
  8520. case chatrecords.FieldDeletedAt:
  8521. return m.OldDeletedAt(ctx)
  8522. case chatrecords.FieldContent:
  8523. return m.OldContent(ctx)
  8524. case chatrecords.FieldContentType:
  8525. return m.OldContentType(ctx)
  8526. case chatrecords.FieldSessionID:
  8527. return m.OldSessionID(ctx)
  8528. case chatrecords.FieldUserID:
  8529. return m.OldUserID(ctx)
  8530. case chatrecords.FieldBotID:
  8531. return m.OldBotID(ctx)
  8532. case chatrecords.FieldBotType:
  8533. return m.OldBotType(ctx)
  8534. }
  8535. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8536. }
  8537. // SetField sets the value of a field with the given name. It returns an error if
  8538. // the field is not defined in the schema, or if the type mismatched the field
  8539. // type.
  8540. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8541. switch name {
  8542. case chatrecords.FieldCreatedAt:
  8543. v, ok := value.(time.Time)
  8544. if !ok {
  8545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8546. }
  8547. m.SetCreatedAt(v)
  8548. return nil
  8549. case chatrecords.FieldUpdatedAt:
  8550. v, ok := value.(time.Time)
  8551. if !ok {
  8552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8553. }
  8554. m.SetUpdatedAt(v)
  8555. return nil
  8556. case chatrecords.FieldDeletedAt:
  8557. v, ok := value.(time.Time)
  8558. if !ok {
  8559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8560. }
  8561. m.SetDeletedAt(v)
  8562. return nil
  8563. case chatrecords.FieldContent:
  8564. v, ok := value.(string)
  8565. if !ok {
  8566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8567. }
  8568. m.SetContent(v)
  8569. return nil
  8570. case chatrecords.FieldContentType:
  8571. v, ok := value.(uint8)
  8572. if !ok {
  8573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8574. }
  8575. m.SetContentType(v)
  8576. return nil
  8577. case chatrecords.FieldSessionID:
  8578. v, ok := value.(uint64)
  8579. if !ok {
  8580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8581. }
  8582. m.SetSessionID(v)
  8583. return nil
  8584. case chatrecords.FieldUserID:
  8585. v, ok := value.(uint64)
  8586. if !ok {
  8587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8588. }
  8589. m.SetUserID(v)
  8590. return nil
  8591. case chatrecords.FieldBotID:
  8592. v, ok := value.(uint64)
  8593. if !ok {
  8594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8595. }
  8596. m.SetBotID(v)
  8597. return nil
  8598. case chatrecords.FieldBotType:
  8599. v, ok := value.(uint8)
  8600. if !ok {
  8601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8602. }
  8603. m.SetBotType(v)
  8604. return nil
  8605. }
  8606. return fmt.Errorf("unknown ChatRecords field %s", name)
  8607. }
  8608. // AddedFields returns all numeric fields that were incremented/decremented during
  8609. // this mutation.
  8610. func (m *ChatRecordsMutation) AddedFields() []string {
  8611. var fields []string
  8612. if m.addcontent_type != nil {
  8613. fields = append(fields, chatrecords.FieldContentType)
  8614. }
  8615. if m.addsession_id != nil {
  8616. fields = append(fields, chatrecords.FieldSessionID)
  8617. }
  8618. if m.adduser_id != nil {
  8619. fields = append(fields, chatrecords.FieldUserID)
  8620. }
  8621. if m.addbot_id != nil {
  8622. fields = append(fields, chatrecords.FieldBotID)
  8623. }
  8624. if m.addbot_type != nil {
  8625. fields = append(fields, chatrecords.FieldBotType)
  8626. }
  8627. return fields
  8628. }
  8629. // AddedField returns the numeric value that was incremented/decremented on a field
  8630. // with the given name. The second boolean return value indicates that this field
  8631. // was not set, or was not defined in the schema.
  8632. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8633. switch name {
  8634. case chatrecords.FieldContentType:
  8635. return m.AddedContentType()
  8636. case chatrecords.FieldSessionID:
  8637. return m.AddedSessionID()
  8638. case chatrecords.FieldUserID:
  8639. return m.AddedUserID()
  8640. case chatrecords.FieldBotID:
  8641. return m.AddedBotID()
  8642. case chatrecords.FieldBotType:
  8643. return m.AddedBotType()
  8644. }
  8645. return nil, false
  8646. }
  8647. // AddField adds the value to the field with the given name. It returns an error if
  8648. // the field is not defined in the schema, or if the type mismatched the field
  8649. // type.
  8650. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8651. switch name {
  8652. case chatrecords.FieldContentType:
  8653. v, ok := value.(int8)
  8654. if !ok {
  8655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8656. }
  8657. m.AddContentType(v)
  8658. return nil
  8659. case chatrecords.FieldSessionID:
  8660. v, ok := value.(int64)
  8661. if !ok {
  8662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8663. }
  8664. m.AddSessionID(v)
  8665. return nil
  8666. case chatrecords.FieldUserID:
  8667. v, ok := value.(int64)
  8668. if !ok {
  8669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8670. }
  8671. m.AddUserID(v)
  8672. return nil
  8673. case chatrecords.FieldBotID:
  8674. v, ok := value.(int64)
  8675. if !ok {
  8676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8677. }
  8678. m.AddBotID(v)
  8679. return nil
  8680. case chatrecords.FieldBotType:
  8681. v, ok := value.(int8)
  8682. if !ok {
  8683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8684. }
  8685. m.AddBotType(v)
  8686. return nil
  8687. }
  8688. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8689. }
  8690. // ClearedFields returns all nullable fields that were cleared during this
  8691. // mutation.
  8692. func (m *ChatRecordsMutation) ClearedFields() []string {
  8693. var fields []string
  8694. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8695. fields = append(fields, chatrecords.FieldDeletedAt)
  8696. }
  8697. return fields
  8698. }
  8699. // FieldCleared returns a boolean indicating if a field with the given name was
  8700. // cleared in this mutation.
  8701. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8702. _, ok := m.clearedFields[name]
  8703. return ok
  8704. }
  8705. // ClearField clears the value of the field with the given name. It returns an
  8706. // error if the field is not defined in the schema.
  8707. func (m *ChatRecordsMutation) ClearField(name string) error {
  8708. switch name {
  8709. case chatrecords.FieldDeletedAt:
  8710. m.ClearDeletedAt()
  8711. return nil
  8712. }
  8713. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8714. }
  8715. // ResetField resets all changes in the mutation for the field with the given name.
  8716. // It returns an error if the field is not defined in the schema.
  8717. func (m *ChatRecordsMutation) ResetField(name string) error {
  8718. switch name {
  8719. case chatrecords.FieldCreatedAt:
  8720. m.ResetCreatedAt()
  8721. return nil
  8722. case chatrecords.FieldUpdatedAt:
  8723. m.ResetUpdatedAt()
  8724. return nil
  8725. case chatrecords.FieldDeletedAt:
  8726. m.ResetDeletedAt()
  8727. return nil
  8728. case chatrecords.FieldContent:
  8729. m.ResetContent()
  8730. return nil
  8731. case chatrecords.FieldContentType:
  8732. m.ResetContentType()
  8733. return nil
  8734. case chatrecords.FieldSessionID:
  8735. m.ResetSessionID()
  8736. return nil
  8737. case chatrecords.FieldUserID:
  8738. m.ResetUserID()
  8739. return nil
  8740. case chatrecords.FieldBotID:
  8741. m.ResetBotID()
  8742. return nil
  8743. case chatrecords.FieldBotType:
  8744. m.ResetBotType()
  8745. return nil
  8746. }
  8747. return fmt.Errorf("unknown ChatRecords field %s", name)
  8748. }
  8749. // AddedEdges returns all edge names that were set/added in this mutation.
  8750. func (m *ChatRecordsMutation) AddedEdges() []string {
  8751. edges := make([]string, 0, 0)
  8752. return edges
  8753. }
  8754. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8755. // name in this mutation.
  8756. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8757. return nil
  8758. }
  8759. // RemovedEdges returns all edge names that were removed in this mutation.
  8760. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8761. edges := make([]string, 0, 0)
  8762. return edges
  8763. }
  8764. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8765. // the given name in this mutation.
  8766. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8767. return nil
  8768. }
  8769. // ClearedEdges returns all edge names that were cleared in this mutation.
  8770. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8771. edges := make([]string, 0, 0)
  8772. return edges
  8773. }
  8774. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8775. // was cleared in this mutation.
  8776. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8777. return false
  8778. }
  8779. // ClearEdge clears the value of the edge with the given name. It returns an error
  8780. // if that edge is not defined in the schema.
  8781. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8782. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8783. }
  8784. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8785. // It returns an error if the edge is not defined in the schema.
  8786. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8787. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8788. }
  8789. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8790. type ChatSessionMutation struct {
  8791. config
  8792. op Op
  8793. typ string
  8794. id *uint64
  8795. created_at *time.Time
  8796. updated_at *time.Time
  8797. deleted_at *time.Time
  8798. name *string
  8799. user_id *uint64
  8800. adduser_id *int64
  8801. bot_id *uint64
  8802. addbot_id *int64
  8803. bot_type *uint8
  8804. addbot_type *int8
  8805. clearedFields map[string]struct{}
  8806. done bool
  8807. oldValue func(context.Context) (*ChatSession, error)
  8808. predicates []predicate.ChatSession
  8809. }
  8810. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8811. // chatsessionOption allows management of the mutation configuration using functional options.
  8812. type chatsessionOption func(*ChatSessionMutation)
  8813. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8814. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8815. m := &ChatSessionMutation{
  8816. config: c,
  8817. op: op,
  8818. typ: TypeChatSession,
  8819. clearedFields: make(map[string]struct{}),
  8820. }
  8821. for _, opt := range opts {
  8822. opt(m)
  8823. }
  8824. return m
  8825. }
  8826. // withChatSessionID sets the ID field of the mutation.
  8827. func withChatSessionID(id uint64) chatsessionOption {
  8828. return func(m *ChatSessionMutation) {
  8829. var (
  8830. err error
  8831. once sync.Once
  8832. value *ChatSession
  8833. )
  8834. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8835. once.Do(func() {
  8836. if m.done {
  8837. err = errors.New("querying old values post mutation is not allowed")
  8838. } else {
  8839. value, err = m.Client().ChatSession.Get(ctx, id)
  8840. }
  8841. })
  8842. return value, err
  8843. }
  8844. m.id = &id
  8845. }
  8846. }
  8847. // withChatSession sets the old ChatSession of the mutation.
  8848. func withChatSession(node *ChatSession) chatsessionOption {
  8849. return func(m *ChatSessionMutation) {
  8850. m.oldValue = func(context.Context) (*ChatSession, error) {
  8851. return node, nil
  8852. }
  8853. m.id = &node.ID
  8854. }
  8855. }
  8856. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8857. // executed in a transaction (ent.Tx), a transactional client is returned.
  8858. func (m ChatSessionMutation) Client() *Client {
  8859. client := &Client{config: m.config}
  8860. client.init()
  8861. return client
  8862. }
  8863. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8864. // it returns an error otherwise.
  8865. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8866. if _, ok := m.driver.(*txDriver); !ok {
  8867. return nil, errors.New("ent: mutation is not running in a transaction")
  8868. }
  8869. tx := &Tx{config: m.config}
  8870. tx.init()
  8871. return tx, nil
  8872. }
  8873. // SetID sets the value of the id field. Note that this
  8874. // operation is only accepted on creation of ChatSession entities.
  8875. func (m *ChatSessionMutation) SetID(id uint64) {
  8876. m.id = &id
  8877. }
  8878. // ID returns the ID value in the mutation. Note that the ID is only available
  8879. // if it was provided to the builder or after it was returned from the database.
  8880. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8881. if m.id == nil {
  8882. return
  8883. }
  8884. return *m.id, true
  8885. }
  8886. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8887. // That means, if the mutation is applied within a transaction with an isolation level such
  8888. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8889. // or updated by the mutation.
  8890. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8891. switch {
  8892. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8893. id, exists := m.ID()
  8894. if exists {
  8895. return []uint64{id}, nil
  8896. }
  8897. fallthrough
  8898. case m.op.Is(OpUpdate | OpDelete):
  8899. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8900. default:
  8901. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8902. }
  8903. }
  8904. // SetCreatedAt sets the "created_at" field.
  8905. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8906. m.created_at = &t
  8907. }
  8908. // CreatedAt returns the value of the "created_at" field in the mutation.
  8909. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8910. v := m.created_at
  8911. if v == nil {
  8912. return
  8913. }
  8914. return *v, true
  8915. }
  8916. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8917. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8919. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8920. if !m.op.Is(OpUpdateOne) {
  8921. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8922. }
  8923. if m.id == nil || m.oldValue == nil {
  8924. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8925. }
  8926. oldValue, err := m.oldValue(ctx)
  8927. if err != nil {
  8928. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8929. }
  8930. return oldValue.CreatedAt, nil
  8931. }
  8932. // ResetCreatedAt resets all changes to the "created_at" field.
  8933. func (m *ChatSessionMutation) ResetCreatedAt() {
  8934. m.created_at = nil
  8935. }
  8936. // SetUpdatedAt sets the "updated_at" field.
  8937. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8938. m.updated_at = &t
  8939. }
  8940. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8941. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8942. v := m.updated_at
  8943. if v == nil {
  8944. return
  8945. }
  8946. return *v, true
  8947. }
  8948. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8949. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8951. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8952. if !m.op.Is(OpUpdateOne) {
  8953. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8954. }
  8955. if m.id == nil || m.oldValue == nil {
  8956. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8957. }
  8958. oldValue, err := m.oldValue(ctx)
  8959. if err != nil {
  8960. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8961. }
  8962. return oldValue.UpdatedAt, nil
  8963. }
  8964. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8965. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8966. m.updated_at = nil
  8967. }
  8968. // SetDeletedAt sets the "deleted_at" field.
  8969. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8970. m.deleted_at = &t
  8971. }
  8972. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8973. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8974. v := m.deleted_at
  8975. if v == nil {
  8976. return
  8977. }
  8978. return *v, true
  8979. }
  8980. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8981. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8983. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8984. if !m.op.Is(OpUpdateOne) {
  8985. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8986. }
  8987. if m.id == nil || m.oldValue == nil {
  8988. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8989. }
  8990. oldValue, err := m.oldValue(ctx)
  8991. if err != nil {
  8992. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8993. }
  8994. return oldValue.DeletedAt, nil
  8995. }
  8996. // ClearDeletedAt clears the value of the "deleted_at" field.
  8997. func (m *ChatSessionMutation) ClearDeletedAt() {
  8998. m.deleted_at = nil
  8999. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  9000. }
  9001. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9002. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9003. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9004. return ok
  9005. }
  9006. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9007. func (m *ChatSessionMutation) ResetDeletedAt() {
  9008. m.deleted_at = nil
  9009. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9010. }
  9011. // SetName sets the "name" field.
  9012. func (m *ChatSessionMutation) SetName(s string) {
  9013. m.name = &s
  9014. }
  9015. // Name returns the value of the "name" field in the mutation.
  9016. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9017. v := m.name
  9018. if v == nil {
  9019. return
  9020. }
  9021. return *v, true
  9022. }
  9023. // OldName returns the old "name" field's value of the ChatSession entity.
  9024. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9026. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9027. if !m.op.Is(OpUpdateOne) {
  9028. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9029. }
  9030. if m.id == nil || m.oldValue == nil {
  9031. return v, errors.New("OldName requires an ID field in the mutation")
  9032. }
  9033. oldValue, err := m.oldValue(ctx)
  9034. if err != nil {
  9035. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9036. }
  9037. return oldValue.Name, nil
  9038. }
  9039. // ResetName resets all changes to the "name" field.
  9040. func (m *ChatSessionMutation) ResetName() {
  9041. m.name = nil
  9042. }
  9043. // SetUserID sets the "user_id" field.
  9044. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9045. m.user_id = &u
  9046. m.adduser_id = nil
  9047. }
  9048. // UserID returns the value of the "user_id" field in the mutation.
  9049. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9050. v := m.user_id
  9051. if v == nil {
  9052. return
  9053. }
  9054. return *v, true
  9055. }
  9056. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9057. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9059. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9060. if !m.op.Is(OpUpdateOne) {
  9061. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9062. }
  9063. if m.id == nil || m.oldValue == nil {
  9064. return v, errors.New("OldUserID requires an ID field in the mutation")
  9065. }
  9066. oldValue, err := m.oldValue(ctx)
  9067. if err != nil {
  9068. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9069. }
  9070. return oldValue.UserID, nil
  9071. }
  9072. // AddUserID adds u to the "user_id" field.
  9073. func (m *ChatSessionMutation) AddUserID(u int64) {
  9074. if m.adduser_id != nil {
  9075. *m.adduser_id += u
  9076. } else {
  9077. m.adduser_id = &u
  9078. }
  9079. }
  9080. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9081. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9082. v := m.adduser_id
  9083. if v == nil {
  9084. return
  9085. }
  9086. return *v, true
  9087. }
  9088. // ResetUserID resets all changes to the "user_id" field.
  9089. func (m *ChatSessionMutation) ResetUserID() {
  9090. m.user_id = nil
  9091. m.adduser_id = nil
  9092. }
  9093. // SetBotID sets the "bot_id" field.
  9094. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9095. m.bot_id = &u
  9096. m.addbot_id = nil
  9097. }
  9098. // BotID returns the value of the "bot_id" field in the mutation.
  9099. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9100. v := m.bot_id
  9101. if v == nil {
  9102. return
  9103. }
  9104. return *v, true
  9105. }
  9106. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9107. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9109. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9110. if !m.op.Is(OpUpdateOne) {
  9111. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9112. }
  9113. if m.id == nil || m.oldValue == nil {
  9114. return v, errors.New("OldBotID requires an ID field in the mutation")
  9115. }
  9116. oldValue, err := m.oldValue(ctx)
  9117. if err != nil {
  9118. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9119. }
  9120. return oldValue.BotID, nil
  9121. }
  9122. // AddBotID adds u to the "bot_id" field.
  9123. func (m *ChatSessionMutation) AddBotID(u int64) {
  9124. if m.addbot_id != nil {
  9125. *m.addbot_id += u
  9126. } else {
  9127. m.addbot_id = &u
  9128. }
  9129. }
  9130. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9131. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9132. v := m.addbot_id
  9133. if v == nil {
  9134. return
  9135. }
  9136. return *v, true
  9137. }
  9138. // ResetBotID resets all changes to the "bot_id" field.
  9139. func (m *ChatSessionMutation) ResetBotID() {
  9140. m.bot_id = nil
  9141. m.addbot_id = nil
  9142. }
  9143. // SetBotType sets the "bot_type" field.
  9144. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9145. m.bot_type = &u
  9146. m.addbot_type = nil
  9147. }
  9148. // BotType returns the value of the "bot_type" field in the mutation.
  9149. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9150. v := m.bot_type
  9151. if v == nil {
  9152. return
  9153. }
  9154. return *v, true
  9155. }
  9156. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9157. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9159. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9160. if !m.op.Is(OpUpdateOne) {
  9161. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9162. }
  9163. if m.id == nil || m.oldValue == nil {
  9164. return v, errors.New("OldBotType requires an ID field in the mutation")
  9165. }
  9166. oldValue, err := m.oldValue(ctx)
  9167. if err != nil {
  9168. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9169. }
  9170. return oldValue.BotType, nil
  9171. }
  9172. // AddBotType adds u to the "bot_type" field.
  9173. func (m *ChatSessionMutation) AddBotType(u int8) {
  9174. if m.addbot_type != nil {
  9175. *m.addbot_type += u
  9176. } else {
  9177. m.addbot_type = &u
  9178. }
  9179. }
  9180. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9181. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9182. v := m.addbot_type
  9183. if v == nil {
  9184. return
  9185. }
  9186. return *v, true
  9187. }
  9188. // ResetBotType resets all changes to the "bot_type" field.
  9189. func (m *ChatSessionMutation) ResetBotType() {
  9190. m.bot_type = nil
  9191. m.addbot_type = nil
  9192. }
  9193. // Where appends a list predicates to the ChatSessionMutation builder.
  9194. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9195. m.predicates = append(m.predicates, ps...)
  9196. }
  9197. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9198. // users can use type-assertion to append predicates that do not depend on any generated package.
  9199. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9200. p := make([]predicate.ChatSession, len(ps))
  9201. for i := range ps {
  9202. p[i] = ps[i]
  9203. }
  9204. m.Where(p...)
  9205. }
  9206. // Op returns the operation name.
  9207. func (m *ChatSessionMutation) Op() Op {
  9208. return m.op
  9209. }
  9210. // SetOp allows setting the mutation operation.
  9211. func (m *ChatSessionMutation) SetOp(op Op) {
  9212. m.op = op
  9213. }
  9214. // Type returns the node type of this mutation (ChatSession).
  9215. func (m *ChatSessionMutation) Type() string {
  9216. return m.typ
  9217. }
  9218. // Fields returns all fields that were changed during this mutation. Note that in
  9219. // order to get all numeric fields that were incremented/decremented, call
  9220. // AddedFields().
  9221. func (m *ChatSessionMutation) Fields() []string {
  9222. fields := make([]string, 0, 7)
  9223. if m.created_at != nil {
  9224. fields = append(fields, chatsession.FieldCreatedAt)
  9225. }
  9226. if m.updated_at != nil {
  9227. fields = append(fields, chatsession.FieldUpdatedAt)
  9228. }
  9229. if m.deleted_at != nil {
  9230. fields = append(fields, chatsession.FieldDeletedAt)
  9231. }
  9232. if m.name != nil {
  9233. fields = append(fields, chatsession.FieldName)
  9234. }
  9235. if m.user_id != nil {
  9236. fields = append(fields, chatsession.FieldUserID)
  9237. }
  9238. if m.bot_id != nil {
  9239. fields = append(fields, chatsession.FieldBotID)
  9240. }
  9241. if m.bot_type != nil {
  9242. fields = append(fields, chatsession.FieldBotType)
  9243. }
  9244. return fields
  9245. }
  9246. // Field returns the value of a field with the given name. The second boolean
  9247. // return value indicates that this field was not set, or was not defined in the
  9248. // schema.
  9249. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9250. switch name {
  9251. case chatsession.FieldCreatedAt:
  9252. return m.CreatedAt()
  9253. case chatsession.FieldUpdatedAt:
  9254. return m.UpdatedAt()
  9255. case chatsession.FieldDeletedAt:
  9256. return m.DeletedAt()
  9257. case chatsession.FieldName:
  9258. return m.Name()
  9259. case chatsession.FieldUserID:
  9260. return m.UserID()
  9261. case chatsession.FieldBotID:
  9262. return m.BotID()
  9263. case chatsession.FieldBotType:
  9264. return m.BotType()
  9265. }
  9266. return nil, false
  9267. }
  9268. // OldField returns the old value of the field from the database. An error is
  9269. // returned if the mutation operation is not UpdateOne, or the query to the
  9270. // database failed.
  9271. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9272. switch name {
  9273. case chatsession.FieldCreatedAt:
  9274. return m.OldCreatedAt(ctx)
  9275. case chatsession.FieldUpdatedAt:
  9276. return m.OldUpdatedAt(ctx)
  9277. case chatsession.FieldDeletedAt:
  9278. return m.OldDeletedAt(ctx)
  9279. case chatsession.FieldName:
  9280. return m.OldName(ctx)
  9281. case chatsession.FieldUserID:
  9282. return m.OldUserID(ctx)
  9283. case chatsession.FieldBotID:
  9284. return m.OldBotID(ctx)
  9285. case chatsession.FieldBotType:
  9286. return m.OldBotType(ctx)
  9287. }
  9288. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9289. }
  9290. // SetField sets the value of a field with the given name. It returns an error if
  9291. // the field is not defined in the schema, or if the type mismatched the field
  9292. // type.
  9293. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9294. switch name {
  9295. case chatsession.FieldCreatedAt:
  9296. v, ok := value.(time.Time)
  9297. if !ok {
  9298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9299. }
  9300. m.SetCreatedAt(v)
  9301. return nil
  9302. case chatsession.FieldUpdatedAt:
  9303. v, ok := value.(time.Time)
  9304. if !ok {
  9305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9306. }
  9307. m.SetUpdatedAt(v)
  9308. return nil
  9309. case chatsession.FieldDeletedAt:
  9310. v, ok := value.(time.Time)
  9311. if !ok {
  9312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9313. }
  9314. m.SetDeletedAt(v)
  9315. return nil
  9316. case chatsession.FieldName:
  9317. v, ok := value.(string)
  9318. if !ok {
  9319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9320. }
  9321. m.SetName(v)
  9322. return nil
  9323. case chatsession.FieldUserID:
  9324. v, ok := value.(uint64)
  9325. if !ok {
  9326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9327. }
  9328. m.SetUserID(v)
  9329. return nil
  9330. case chatsession.FieldBotID:
  9331. v, ok := value.(uint64)
  9332. if !ok {
  9333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9334. }
  9335. m.SetBotID(v)
  9336. return nil
  9337. case chatsession.FieldBotType:
  9338. v, ok := value.(uint8)
  9339. if !ok {
  9340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9341. }
  9342. m.SetBotType(v)
  9343. return nil
  9344. }
  9345. return fmt.Errorf("unknown ChatSession field %s", name)
  9346. }
  9347. // AddedFields returns all numeric fields that were incremented/decremented during
  9348. // this mutation.
  9349. func (m *ChatSessionMutation) AddedFields() []string {
  9350. var fields []string
  9351. if m.adduser_id != nil {
  9352. fields = append(fields, chatsession.FieldUserID)
  9353. }
  9354. if m.addbot_id != nil {
  9355. fields = append(fields, chatsession.FieldBotID)
  9356. }
  9357. if m.addbot_type != nil {
  9358. fields = append(fields, chatsession.FieldBotType)
  9359. }
  9360. return fields
  9361. }
  9362. // AddedField returns the numeric value that was incremented/decremented on a field
  9363. // with the given name. The second boolean return value indicates that this field
  9364. // was not set, or was not defined in the schema.
  9365. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9366. switch name {
  9367. case chatsession.FieldUserID:
  9368. return m.AddedUserID()
  9369. case chatsession.FieldBotID:
  9370. return m.AddedBotID()
  9371. case chatsession.FieldBotType:
  9372. return m.AddedBotType()
  9373. }
  9374. return nil, false
  9375. }
  9376. // AddField adds the value to the field with the given name. It returns an error if
  9377. // the field is not defined in the schema, or if the type mismatched the field
  9378. // type.
  9379. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9380. switch name {
  9381. case chatsession.FieldUserID:
  9382. v, ok := value.(int64)
  9383. if !ok {
  9384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9385. }
  9386. m.AddUserID(v)
  9387. return nil
  9388. case chatsession.FieldBotID:
  9389. v, ok := value.(int64)
  9390. if !ok {
  9391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9392. }
  9393. m.AddBotID(v)
  9394. return nil
  9395. case chatsession.FieldBotType:
  9396. v, ok := value.(int8)
  9397. if !ok {
  9398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9399. }
  9400. m.AddBotType(v)
  9401. return nil
  9402. }
  9403. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9404. }
  9405. // ClearedFields returns all nullable fields that were cleared during this
  9406. // mutation.
  9407. func (m *ChatSessionMutation) ClearedFields() []string {
  9408. var fields []string
  9409. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9410. fields = append(fields, chatsession.FieldDeletedAt)
  9411. }
  9412. return fields
  9413. }
  9414. // FieldCleared returns a boolean indicating if a field with the given name was
  9415. // cleared in this mutation.
  9416. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9417. _, ok := m.clearedFields[name]
  9418. return ok
  9419. }
  9420. // ClearField clears the value of the field with the given name. It returns an
  9421. // error if the field is not defined in the schema.
  9422. func (m *ChatSessionMutation) ClearField(name string) error {
  9423. switch name {
  9424. case chatsession.FieldDeletedAt:
  9425. m.ClearDeletedAt()
  9426. return nil
  9427. }
  9428. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9429. }
  9430. // ResetField resets all changes in the mutation for the field with the given name.
  9431. // It returns an error if the field is not defined in the schema.
  9432. func (m *ChatSessionMutation) ResetField(name string) error {
  9433. switch name {
  9434. case chatsession.FieldCreatedAt:
  9435. m.ResetCreatedAt()
  9436. return nil
  9437. case chatsession.FieldUpdatedAt:
  9438. m.ResetUpdatedAt()
  9439. return nil
  9440. case chatsession.FieldDeletedAt:
  9441. m.ResetDeletedAt()
  9442. return nil
  9443. case chatsession.FieldName:
  9444. m.ResetName()
  9445. return nil
  9446. case chatsession.FieldUserID:
  9447. m.ResetUserID()
  9448. return nil
  9449. case chatsession.FieldBotID:
  9450. m.ResetBotID()
  9451. return nil
  9452. case chatsession.FieldBotType:
  9453. m.ResetBotType()
  9454. return nil
  9455. }
  9456. return fmt.Errorf("unknown ChatSession field %s", name)
  9457. }
  9458. // AddedEdges returns all edge names that were set/added in this mutation.
  9459. func (m *ChatSessionMutation) AddedEdges() []string {
  9460. edges := make([]string, 0, 0)
  9461. return edges
  9462. }
  9463. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9464. // name in this mutation.
  9465. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9466. return nil
  9467. }
  9468. // RemovedEdges returns all edge names that were removed in this mutation.
  9469. func (m *ChatSessionMutation) RemovedEdges() []string {
  9470. edges := make([]string, 0, 0)
  9471. return edges
  9472. }
  9473. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9474. // the given name in this mutation.
  9475. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9476. return nil
  9477. }
  9478. // ClearedEdges returns all edge names that were cleared in this mutation.
  9479. func (m *ChatSessionMutation) ClearedEdges() []string {
  9480. edges := make([]string, 0, 0)
  9481. return edges
  9482. }
  9483. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9484. // was cleared in this mutation.
  9485. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9486. return false
  9487. }
  9488. // ClearEdge clears the value of the edge with the given name. It returns an error
  9489. // if that edge is not defined in the schema.
  9490. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9491. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9492. }
  9493. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9494. // It returns an error if the edge is not defined in the schema.
  9495. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9496. return fmt.Errorf("unknown ChatSession edge %s", name)
  9497. }
  9498. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9499. type CompapiAsynctaskMutation struct {
  9500. config
  9501. op Op
  9502. typ string
  9503. id *uint64
  9504. created_at *time.Time
  9505. updated_at *time.Time
  9506. auth_token *string
  9507. event_type *string
  9508. chat_id *string
  9509. response_chat_item_id *string
  9510. organization_id *uint64
  9511. addorganization_id *int64
  9512. openai_base *string
  9513. openai_key *string
  9514. request_raw *string
  9515. response_raw *string
  9516. callback_url *string
  9517. callback_response_raw *string
  9518. model *string
  9519. task_status *int8
  9520. addtask_status *int8
  9521. retry_count *int8
  9522. addretry_count *int8
  9523. last_error *string
  9524. clearedFields map[string]struct{}
  9525. done bool
  9526. oldValue func(context.Context) (*CompapiAsynctask, error)
  9527. predicates []predicate.CompapiAsynctask
  9528. }
  9529. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9530. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9531. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9532. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9533. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9534. m := &CompapiAsynctaskMutation{
  9535. config: c,
  9536. op: op,
  9537. typ: TypeCompapiAsynctask,
  9538. clearedFields: make(map[string]struct{}),
  9539. }
  9540. for _, opt := range opts {
  9541. opt(m)
  9542. }
  9543. return m
  9544. }
  9545. // withCompapiAsynctaskID sets the ID field of the mutation.
  9546. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9547. return func(m *CompapiAsynctaskMutation) {
  9548. var (
  9549. err error
  9550. once sync.Once
  9551. value *CompapiAsynctask
  9552. )
  9553. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9554. once.Do(func() {
  9555. if m.done {
  9556. err = errors.New("querying old values post mutation is not allowed")
  9557. } else {
  9558. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9559. }
  9560. })
  9561. return value, err
  9562. }
  9563. m.id = &id
  9564. }
  9565. }
  9566. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9567. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9568. return func(m *CompapiAsynctaskMutation) {
  9569. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9570. return node, nil
  9571. }
  9572. m.id = &node.ID
  9573. }
  9574. }
  9575. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9576. // executed in a transaction (ent.Tx), a transactional client is returned.
  9577. func (m CompapiAsynctaskMutation) Client() *Client {
  9578. client := &Client{config: m.config}
  9579. client.init()
  9580. return client
  9581. }
  9582. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9583. // it returns an error otherwise.
  9584. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9585. if _, ok := m.driver.(*txDriver); !ok {
  9586. return nil, errors.New("ent: mutation is not running in a transaction")
  9587. }
  9588. tx := &Tx{config: m.config}
  9589. tx.init()
  9590. return tx, nil
  9591. }
  9592. // SetID sets the value of the id field. Note that this
  9593. // operation is only accepted on creation of CompapiAsynctask entities.
  9594. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9595. m.id = &id
  9596. }
  9597. // ID returns the ID value in the mutation. Note that the ID is only available
  9598. // if it was provided to the builder or after it was returned from the database.
  9599. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9600. if m.id == nil {
  9601. return
  9602. }
  9603. return *m.id, true
  9604. }
  9605. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9606. // That means, if the mutation is applied within a transaction with an isolation level such
  9607. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9608. // or updated by the mutation.
  9609. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9610. switch {
  9611. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9612. id, exists := m.ID()
  9613. if exists {
  9614. return []uint64{id}, nil
  9615. }
  9616. fallthrough
  9617. case m.op.Is(OpUpdate | OpDelete):
  9618. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9619. default:
  9620. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9621. }
  9622. }
  9623. // SetCreatedAt sets the "created_at" field.
  9624. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9625. m.created_at = &t
  9626. }
  9627. // CreatedAt returns the value of the "created_at" field in the mutation.
  9628. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9629. v := m.created_at
  9630. if v == nil {
  9631. return
  9632. }
  9633. return *v, true
  9634. }
  9635. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9636. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9638. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9639. if !m.op.Is(OpUpdateOne) {
  9640. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9641. }
  9642. if m.id == nil || m.oldValue == nil {
  9643. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9644. }
  9645. oldValue, err := m.oldValue(ctx)
  9646. if err != nil {
  9647. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9648. }
  9649. return oldValue.CreatedAt, nil
  9650. }
  9651. // ResetCreatedAt resets all changes to the "created_at" field.
  9652. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9653. m.created_at = nil
  9654. }
  9655. // SetUpdatedAt sets the "updated_at" field.
  9656. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9657. m.updated_at = &t
  9658. }
  9659. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9660. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9661. v := m.updated_at
  9662. if v == nil {
  9663. return
  9664. }
  9665. return *v, true
  9666. }
  9667. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9668. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9670. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9671. if !m.op.Is(OpUpdateOne) {
  9672. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9673. }
  9674. if m.id == nil || m.oldValue == nil {
  9675. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9676. }
  9677. oldValue, err := m.oldValue(ctx)
  9678. if err != nil {
  9679. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9680. }
  9681. return oldValue.UpdatedAt, nil
  9682. }
  9683. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9684. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9685. m.updated_at = nil
  9686. }
  9687. // SetAuthToken sets the "auth_token" field.
  9688. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9689. m.auth_token = &s
  9690. }
  9691. // AuthToken returns the value of the "auth_token" field in the mutation.
  9692. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9693. v := m.auth_token
  9694. if v == nil {
  9695. return
  9696. }
  9697. return *v, true
  9698. }
  9699. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9700. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9702. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9703. if !m.op.Is(OpUpdateOne) {
  9704. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9705. }
  9706. if m.id == nil || m.oldValue == nil {
  9707. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9708. }
  9709. oldValue, err := m.oldValue(ctx)
  9710. if err != nil {
  9711. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9712. }
  9713. return oldValue.AuthToken, nil
  9714. }
  9715. // ResetAuthToken resets all changes to the "auth_token" field.
  9716. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9717. m.auth_token = nil
  9718. }
  9719. // SetEventType sets the "event_type" field.
  9720. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9721. m.event_type = &s
  9722. }
  9723. // EventType returns the value of the "event_type" field in the mutation.
  9724. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9725. v := m.event_type
  9726. if v == nil {
  9727. return
  9728. }
  9729. return *v, true
  9730. }
  9731. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9732. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9734. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9735. if !m.op.Is(OpUpdateOne) {
  9736. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9737. }
  9738. if m.id == nil || m.oldValue == nil {
  9739. return v, errors.New("OldEventType requires an ID field in the mutation")
  9740. }
  9741. oldValue, err := m.oldValue(ctx)
  9742. if err != nil {
  9743. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9744. }
  9745. return oldValue.EventType, nil
  9746. }
  9747. // ResetEventType resets all changes to the "event_type" field.
  9748. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9749. m.event_type = nil
  9750. }
  9751. // SetChatID sets the "chat_id" field.
  9752. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9753. m.chat_id = &s
  9754. }
  9755. // ChatID returns the value of the "chat_id" field in the mutation.
  9756. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9757. v := m.chat_id
  9758. if v == nil {
  9759. return
  9760. }
  9761. return *v, true
  9762. }
  9763. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9764. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9766. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9767. if !m.op.Is(OpUpdateOne) {
  9768. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9769. }
  9770. if m.id == nil || m.oldValue == nil {
  9771. return v, errors.New("OldChatID requires an ID field in the mutation")
  9772. }
  9773. oldValue, err := m.oldValue(ctx)
  9774. if err != nil {
  9775. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9776. }
  9777. return oldValue.ChatID, nil
  9778. }
  9779. // ClearChatID clears the value of the "chat_id" field.
  9780. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9781. m.chat_id = nil
  9782. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9783. }
  9784. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9785. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9786. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9787. return ok
  9788. }
  9789. // ResetChatID resets all changes to the "chat_id" field.
  9790. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9791. m.chat_id = nil
  9792. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9793. }
  9794. // SetResponseChatItemID sets the "response_chat_item_id" field.
  9795. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  9796. m.response_chat_item_id = &s
  9797. }
  9798. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  9799. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  9800. v := m.response_chat_item_id
  9801. if v == nil {
  9802. return
  9803. }
  9804. return *v, true
  9805. }
  9806. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  9807. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9809. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  9810. if !m.op.Is(OpUpdateOne) {
  9811. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  9812. }
  9813. if m.id == nil || m.oldValue == nil {
  9814. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  9815. }
  9816. oldValue, err := m.oldValue(ctx)
  9817. if err != nil {
  9818. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  9819. }
  9820. return oldValue.ResponseChatItemID, nil
  9821. }
  9822. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  9823. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  9824. m.response_chat_item_id = nil
  9825. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  9826. }
  9827. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  9828. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  9829. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  9830. return ok
  9831. }
  9832. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  9833. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  9834. m.response_chat_item_id = nil
  9835. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  9836. }
  9837. // SetOrganizationID sets the "organization_id" field.
  9838. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  9839. m.organization_id = &u
  9840. m.addorganization_id = nil
  9841. }
  9842. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9843. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  9844. v := m.organization_id
  9845. if v == nil {
  9846. return
  9847. }
  9848. return *v, true
  9849. }
  9850. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  9851. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9853. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9854. if !m.op.Is(OpUpdateOne) {
  9855. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9856. }
  9857. if m.id == nil || m.oldValue == nil {
  9858. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9859. }
  9860. oldValue, err := m.oldValue(ctx)
  9861. if err != nil {
  9862. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9863. }
  9864. return oldValue.OrganizationID, nil
  9865. }
  9866. // AddOrganizationID adds u to the "organization_id" field.
  9867. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  9868. if m.addorganization_id != nil {
  9869. *m.addorganization_id += u
  9870. } else {
  9871. m.addorganization_id = &u
  9872. }
  9873. }
  9874. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9875. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  9876. v := m.addorganization_id
  9877. if v == nil {
  9878. return
  9879. }
  9880. return *v, true
  9881. }
  9882. // ResetOrganizationID resets all changes to the "organization_id" field.
  9883. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  9884. m.organization_id = nil
  9885. m.addorganization_id = nil
  9886. }
  9887. // SetOpenaiBase sets the "openai_base" field.
  9888. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9889. m.openai_base = &s
  9890. }
  9891. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9892. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9893. v := m.openai_base
  9894. if v == nil {
  9895. return
  9896. }
  9897. return *v, true
  9898. }
  9899. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9900. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9902. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9903. if !m.op.Is(OpUpdateOne) {
  9904. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9905. }
  9906. if m.id == nil || m.oldValue == nil {
  9907. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9908. }
  9909. oldValue, err := m.oldValue(ctx)
  9910. if err != nil {
  9911. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9912. }
  9913. return oldValue.OpenaiBase, nil
  9914. }
  9915. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9916. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9917. m.openai_base = nil
  9918. }
  9919. // SetOpenaiKey sets the "openai_key" field.
  9920. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  9921. m.openai_key = &s
  9922. }
  9923. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  9924. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  9925. v := m.openai_key
  9926. if v == nil {
  9927. return
  9928. }
  9929. return *v, true
  9930. }
  9931. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  9932. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9934. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  9935. if !m.op.Is(OpUpdateOne) {
  9936. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  9937. }
  9938. if m.id == nil || m.oldValue == nil {
  9939. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  9940. }
  9941. oldValue, err := m.oldValue(ctx)
  9942. if err != nil {
  9943. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  9944. }
  9945. return oldValue.OpenaiKey, nil
  9946. }
  9947. // ResetOpenaiKey resets all changes to the "openai_key" field.
  9948. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  9949. m.openai_key = nil
  9950. }
  9951. // SetRequestRaw sets the "request_raw" field.
  9952. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  9953. m.request_raw = &s
  9954. }
  9955. // RequestRaw returns the value of the "request_raw" field in the mutation.
  9956. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  9957. v := m.request_raw
  9958. if v == nil {
  9959. return
  9960. }
  9961. return *v, true
  9962. }
  9963. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  9964. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9966. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  9967. if !m.op.Is(OpUpdateOne) {
  9968. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  9969. }
  9970. if m.id == nil || m.oldValue == nil {
  9971. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  9972. }
  9973. oldValue, err := m.oldValue(ctx)
  9974. if err != nil {
  9975. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  9976. }
  9977. return oldValue.RequestRaw, nil
  9978. }
  9979. // ResetRequestRaw resets all changes to the "request_raw" field.
  9980. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  9981. m.request_raw = nil
  9982. }
  9983. // SetResponseRaw sets the "response_raw" field.
  9984. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  9985. m.response_raw = &s
  9986. }
  9987. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  9988. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  9989. v := m.response_raw
  9990. if v == nil {
  9991. return
  9992. }
  9993. return *v, true
  9994. }
  9995. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  9996. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9998. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  9999. if !m.op.Is(OpUpdateOne) {
  10000. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  10001. }
  10002. if m.id == nil || m.oldValue == nil {
  10003. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  10004. }
  10005. oldValue, err := m.oldValue(ctx)
  10006. if err != nil {
  10007. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  10008. }
  10009. return oldValue.ResponseRaw, nil
  10010. }
  10011. // ClearResponseRaw clears the value of the "response_raw" field.
  10012. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  10013. m.response_raw = nil
  10014. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  10015. }
  10016. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  10017. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  10018. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  10019. return ok
  10020. }
  10021. // ResetResponseRaw resets all changes to the "response_raw" field.
  10022. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  10023. m.response_raw = nil
  10024. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  10025. }
  10026. // SetCallbackURL sets the "callback_url" field.
  10027. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  10028. m.callback_url = &s
  10029. }
  10030. // CallbackURL returns the value of the "callback_url" field in the mutation.
  10031. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  10032. v := m.callback_url
  10033. if v == nil {
  10034. return
  10035. }
  10036. return *v, true
  10037. }
  10038. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  10039. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10041. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  10042. if !m.op.Is(OpUpdateOne) {
  10043. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  10044. }
  10045. if m.id == nil || m.oldValue == nil {
  10046. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  10047. }
  10048. oldValue, err := m.oldValue(ctx)
  10049. if err != nil {
  10050. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  10051. }
  10052. return oldValue.CallbackURL, nil
  10053. }
  10054. // ResetCallbackURL resets all changes to the "callback_url" field.
  10055. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  10056. m.callback_url = nil
  10057. }
  10058. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  10059. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  10060. m.callback_response_raw = &s
  10061. }
  10062. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  10063. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  10064. v := m.callback_response_raw
  10065. if v == nil {
  10066. return
  10067. }
  10068. return *v, true
  10069. }
  10070. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  10071. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10073. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  10074. if !m.op.Is(OpUpdateOne) {
  10075. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  10076. }
  10077. if m.id == nil || m.oldValue == nil {
  10078. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  10079. }
  10080. oldValue, err := m.oldValue(ctx)
  10081. if err != nil {
  10082. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  10083. }
  10084. return oldValue.CallbackResponseRaw, nil
  10085. }
  10086. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  10087. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  10088. m.callback_response_raw = nil
  10089. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  10090. }
  10091. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  10092. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  10093. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  10094. return ok
  10095. }
  10096. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  10097. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  10098. m.callback_response_raw = nil
  10099. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  10100. }
  10101. // SetModel sets the "model" field.
  10102. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  10103. m.model = &s
  10104. }
  10105. // Model returns the value of the "model" field in the mutation.
  10106. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  10107. v := m.model
  10108. if v == nil {
  10109. return
  10110. }
  10111. return *v, true
  10112. }
  10113. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  10114. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10116. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  10117. if !m.op.Is(OpUpdateOne) {
  10118. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10119. }
  10120. if m.id == nil || m.oldValue == nil {
  10121. return v, errors.New("OldModel requires an ID field in the mutation")
  10122. }
  10123. oldValue, err := m.oldValue(ctx)
  10124. if err != nil {
  10125. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10126. }
  10127. return oldValue.Model, nil
  10128. }
  10129. // ClearModel clears the value of the "model" field.
  10130. func (m *CompapiAsynctaskMutation) ClearModel() {
  10131. m.model = nil
  10132. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  10133. }
  10134. // ModelCleared returns if the "model" field was cleared in this mutation.
  10135. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  10136. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  10137. return ok
  10138. }
  10139. // ResetModel resets all changes to the "model" field.
  10140. func (m *CompapiAsynctaskMutation) ResetModel() {
  10141. m.model = nil
  10142. delete(m.clearedFields, compapiasynctask.FieldModel)
  10143. }
  10144. // SetTaskStatus sets the "task_status" field.
  10145. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  10146. m.task_status = &i
  10147. m.addtask_status = nil
  10148. }
  10149. // TaskStatus returns the value of the "task_status" field in the mutation.
  10150. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  10151. v := m.task_status
  10152. if v == nil {
  10153. return
  10154. }
  10155. return *v, true
  10156. }
  10157. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  10158. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10160. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  10161. if !m.op.Is(OpUpdateOne) {
  10162. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  10163. }
  10164. if m.id == nil || m.oldValue == nil {
  10165. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  10166. }
  10167. oldValue, err := m.oldValue(ctx)
  10168. if err != nil {
  10169. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  10170. }
  10171. return oldValue.TaskStatus, nil
  10172. }
  10173. // AddTaskStatus adds i to the "task_status" field.
  10174. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  10175. if m.addtask_status != nil {
  10176. *m.addtask_status += i
  10177. } else {
  10178. m.addtask_status = &i
  10179. }
  10180. }
  10181. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  10182. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  10183. v := m.addtask_status
  10184. if v == nil {
  10185. return
  10186. }
  10187. return *v, true
  10188. }
  10189. // ClearTaskStatus clears the value of the "task_status" field.
  10190. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  10191. m.task_status = nil
  10192. m.addtask_status = nil
  10193. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  10194. }
  10195. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  10196. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  10197. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  10198. return ok
  10199. }
  10200. // ResetTaskStatus resets all changes to the "task_status" field.
  10201. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  10202. m.task_status = nil
  10203. m.addtask_status = nil
  10204. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  10205. }
  10206. // SetRetryCount sets the "retry_count" field.
  10207. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  10208. m.retry_count = &i
  10209. m.addretry_count = nil
  10210. }
  10211. // RetryCount returns the value of the "retry_count" field in the mutation.
  10212. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  10213. v := m.retry_count
  10214. if v == nil {
  10215. return
  10216. }
  10217. return *v, true
  10218. }
  10219. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  10220. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10222. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  10223. if !m.op.Is(OpUpdateOne) {
  10224. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  10225. }
  10226. if m.id == nil || m.oldValue == nil {
  10227. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  10228. }
  10229. oldValue, err := m.oldValue(ctx)
  10230. if err != nil {
  10231. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  10232. }
  10233. return oldValue.RetryCount, nil
  10234. }
  10235. // AddRetryCount adds i to the "retry_count" field.
  10236. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  10237. if m.addretry_count != nil {
  10238. *m.addretry_count += i
  10239. } else {
  10240. m.addretry_count = &i
  10241. }
  10242. }
  10243. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  10244. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  10245. v := m.addretry_count
  10246. if v == nil {
  10247. return
  10248. }
  10249. return *v, true
  10250. }
  10251. // ClearRetryCount clears the value of the "retry_count" field.
  10252. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  10253. m.retry_count = nil
  10254. m.addretry_count = nil
  10255. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  10256. }
  10257. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  10258. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  10259. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  10260. return ok
  10261. }
  10262. // ResetRetryCount resets all changes to the "retry_count" field.
  10263. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  10264. m.retry_count = nil
  10265. m.addretry_count = nil
  10266. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  10267. }
  10268. // SetLastError sets the "last_error" field.
  10269. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  10270. m.last_error = &s
  10271. }
  10272. // LastError returns the value of the "last_error" field in the mutation.
  10273. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  10274. v := m.last_error
  10275. if v == nil {
  10276. return
  10277. }
  10278. return *v, true
  10279. }
  10280. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  10281. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10283. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  10284. if !m.op.Is(OpUpdateOne) {
  10285. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  10286. }
  10287. if m.id == nil || m.oldValue == nil {
  10288. return v, errors.New("OldLastError requires an ID field in the mutation")
  10289. }
  10290. oldValue, err := m.oldValue(ctx)
  10291. if err != nil {
  10292. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  10293. }
  10294. return oldValue.LastError, nil
  10295. }
  10296. // ClearLastError clears the value of the "last_error" field.
  10297. func (m *CompapiAsynctaskMutation) ClearLastError() {
  10298. m.last_error = nil
  10299. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  10300. }
  10301. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  10302. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  10303. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  10304. return ok
  10305. }
  10306. // ResetLastError resets all changes to the "last_error" field.
  10307. func (m *CompapiAsynctaskMutation) ResetLastError() {
  10308. m.last_error = nil
  10309. delete(m.clearedFields, compapiasynctask.FieldLastError)
  10310. }
  10311. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  10312. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  10313. m.predicates = append(m.predicates, ps...)
  10314. }
  10315. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  10316. // users can use type-assertion to append predicates that do not depend on any generated package.
  10317. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10318. p := make([]predicate.CompapiAsynctask, len(ps))
  10319. for i := range ps {
  10320. p[i] = ps[i]
  10321. }
  10322. m.Where(p...)
  10323. }
  10324. // Op returns the operation name.
  10325. func (m *CompapiAsynctaskMutation) Op() Op {
  10326. return m.op
  10327. }
  10328. // SetOp allows setting the mutation operation.
  10329. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  10330. m.op = op
  10331. }
  10332. // Type returns the node type of this mutation (CompapiAsynctask).
  10333. func (m *CompapiAsynctaskMutation) Type() string {
  10334. return m.typ
  10335. }
  10336. // Fields returns all fields that were changed during this mutation. Note that in
  10337. // order to get all numeric fields that were incremented/decremented, call
  10338. // AddedFields().
  10339. func (m *CompapiAsynctaskMutation) Fields() []string {
  10340. fields := make([]string, 0, 17)
  10341. if m.created_at != nil {
  10342. fields = append(fields, compapiasynctask.FieldCreatedAt)
  10343. }
  10344. if m.updated_at != nil {
  10345. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  10346. }
  10347. if m.auth_token != nil {
  10348. fields = append(fields, compapiasynctask.FieldAuthToken)
  10349. }
  10350. if m.event_type != nil {
  10351. fields = append(fields, compapiasynctask.FieldEventType)
  10352. }
  10353. if m.chat_id != nil {
  10354. fields = append(fields, compapiasynctask.FieldChatID)
  10355. }
  10356. if m.response_chat_item_id != nil {
  10357. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10358. }
  10359. if m.organization_id != nil {
  10360. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10361. }
  10362. if m.openai_base != nil {
  10363. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  10364. }
  10365. if m.openai_key != nil {
  10366. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  10367. }
  10368. if m.request_raw != nil {
  10369. fields = append(fields, compapiasynctask.FieldRequestRaw)
  10370. }
  10371. if m.response_raw != nil {
  10372. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10373. }
  10374. if m.callback_url != nil {
  10375. fields = append(fields, compapiasynctask.FieldCallbackURL)
  10376. }
  10377. if m.callback_response_raw != nil {
  10378. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10379. }
  10380. if m.model != nil {
  10381. fields = append(fields, compapiasynctask.FieldModel)
  10382. }
  10383. if m.task_status != nil {
  10384. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10385. }
  10386. if m.retry_count != nil {
  10387. fields = append(fields, compapiasynctask.FieldRetryCount)
  10388. }
  10389. if m.last_error != nil {
  10390. fields = append(fields, compapiasynctask.FieldLastError)
  10391. }
  10392. return fields
  10393. }
  10394. // Field returns the value of a field with the given name. The second boolean
  10395. // return value indicates that this field was not set, or was not defined in the
  10396. // schema.
  10397. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  10398. switch name {
  10399. case compapiasynctask.FieldCreatedAt:
  10400. return m.CreatedAt()
  10401. case compapiasynctask.FieldUpdatedAt:
  10402. return m.UpdatedAt()
  10403. case compapiasynctask.FieldAuthToken:
  10404. return m.AuthToken()
  10405. case compapiasynctask.FieldEventType:
  10406. return m.EventType()
  10407. case compapiasynctask.FieldChatID:
  10408. return m.ChatID()
  10409. case compapiasynctask.FieldResponseChatItemID:
  10410. return m.ResponseChatItemID()
  10411. case compapiasynctask.FieldOrganizationID:
  10412. return m.OrganizationID()
  10413. case compapiasynctask.FieldOpenaiBase:
  10414. return m.OpenaiBase()
  10415. case compapiasynctask.FieldOpenaiKey:
  10416. return m.OpenaiKey()
  10417. case compapiasynctask.FieldRequestRaw:
  10418. return m.RequestRaw()
  10419. case compapiasynctask.FieldResponseRaw:
  10420. return m.ResponseRaw()
  10421. case compapiasynctask.FieldCallbackURL:
  10422. return m.CallbackURL()
  10423. case compapiasynctask.FieldCallbackResponseRaw:
  10424. return m.CallbackResponseRaw()
  10425. case compapiasynctask.FieldModel:
  10426. return m.Model()
  10427. case compapiasynctask.FieldTaskStatus:
  10428. return m.TaskStatus()
  10429. case compapiasynctask.FieldRetryCount:
  10430. return m.RetryCount()
  10431. case compapiasynctask.FieldLastError:
  10432. return m.LastError()
  10433. }
  10434. return nil, false
  10435. }
  10436. // OldField returns the old value of the field from the database. An error is
  10437. // returned if the mutation operation is not UpdateOne, or the query to the
  10438. // database failed.
  10439. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10440. switch name {
  10441. case compapiasynctask.FieldCreatedAt:
  10442. return m.OldCreatedAt(ctx)
  10443. case compapiasynctask.FieldUpdatedAt:
  10444. return m.OldUpdatedAt(ctx)
  10445. case compapiasynctask.FieldAuthToken:
  10446. return m.OldAuthToken(ctx)
  10447. case compapiasynctask.FieldEventType:
  10448. return m.OldEventType(ctx)
  10449. case compapiasynctask.FieldChatID:
  10450. return m.OldChatID(ctx)
  10451. case compapiasynctask.FieldResponseChatItemID:
  10452. return m.OldResponseChatItemID(ctx)
  10453. case compapiasynctask.FieldOrganizationID:
  10454. return m.OldOrganizationID(ctx)
  10455. case compapiasynctask.FieldOpenaiBase:
  10456. return m.OldOpenaiBase(ctx)
  10457. case compapiasynctask.FieldOpenaiKey:
  10458. return m.OldOpenaiKey(ctx)
  10459. case compapiasynctask.FieldRequestRaw:
  10460. return m.OldRequestRaw(ctx)
  10461. case compapiasynctask.FieldResponseRaw:
  10462. return m.OldResponseRaw(ctx)
  10463. case compapiasynctask.FieldCallbackURL:
  10464. return m.OldCallbackURL(ctx)
  10465. case compapiasynctask.FieldCallbackResponseRaw:
  10466. return m.OldCallbackResponseRaw(ctx)
  10467. case compapiasynctask.FieldModel:
  10468. return m.OldModel(ctx)
  10469. case compapiasynctask.FieldTaskStatus:
  10470. return m.OldTaskStatus(ctx)
  10471. case compapiasynctask.FieldRetryCount:
  10472. return m.OldRetryCount(ctx)
  10473. case compapiasynctask.FieldLastError:
  10474. return m.OldLastError(ctx)
  10475. }
  10476. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10477. }
  10478. // SetField sets the value of a field with the given name. It returns an error if
  10479. // the field is not defined in the schema, or if the type mismatched the field
  10480. // type.
  10481. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10482. switch name {
  10483. case compapiasynctask.FieldCreatedAt:
  10484. v, ok := value.(time.Time)
  10485. if !ok {
  10486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10487. }
  10488. m.SetCreatedAt(v)
  10489. return nil
  10490. case compapiasynctask.FieldUpdatedAt:
  10491. v, ok := value.(time.Time)
  10492. if !ok {
  10493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10494. }
  10495. m.SetUpdatedAt(v)
  10496. return nil
  10497. case compapiasynctask.FieldAuthToken:
  10498. v, ok := value.(string)
  10499. if !ok {
  10500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10501. }
  10502. m.SetAuthToken(v)
  10503. return nil
  10504. case compapiasynctask.FieldEventType:
  10505. v, ok := value.(string)
  10506. if !ok {
  10507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10508. }
  10509. m.SetEventType(v)
  10510. return nil
  10511. case compapiasynctask.FieldChatID:
  10512. v, ok := value.(string)
  10513. if !ok {
  10514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10515. }
  10516. m.SetChatID(v)
  10517. return nil
  10518. case compapiasynctask.FieldResponseChatItemID:
  10519. v, ok := value.(string)
  10520. if !ok {
  10521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10522. }
  10523. m.SetResponseChatItemID(v)
  10524. return nil
  10525. case compapiasynctask.FieldOrganizationID:
  10526. v, ok := value.(uint64)
  10527. if !ok {
  10528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10529. }
  10530. m.SetOrganizationID(v)
  10531. return nil
  10532. case compapiasynctask.FieldOpenaiBase:
  10533. v, ok := value.(string)
  10534. if !ok {
  10535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10536. }
  10537. m.SetOpenaiBase(v)
  10538. return nil
  10539. case compapiasynctask.FieldOpenaiKey:
  10540. v, ok := value.(string)
  10541. if !ok {
  10542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10543. }
  10544. m.SetOpenaiKey(v)
  10545. return nil
  10546. case compapiasynctask.FieldRequestRaw:
  10547. v, ok := value.(string)
  10548. if !ok {
  10549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10550. }
  10551. m.SetRequestRaw(v)
  10552. return nil
  10553. case compapiasynctask.FieldResponseRaw:
  10554. v, ok := value.(string)
  10555. if !ok {
  10556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10557. }
  10558. m.SetResponseRaw(v)
  10559. return nil
  10560. case compapiasynctask.FieldCallbackURL:
  10561. v, ok := value.(string)
  10562. if !ok {
  10563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10564. }
  10565. m.SetCallbackURL(v)
  10566. return nil
  10567. case compapiasynctask.FieldCallbackResponseRaw:
  10568. v, ok := value.(string)
  10569. if !ok {
  10570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10571. }
  10572. m.SetCallbackResponseRaw(v)
  10573. return nil
  10574. case compapiasynctask.FieldModel:
  10575. v, ok := value.(string)
  10576. if !ok {
  10577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10578. }
  10579. m.SetModel(v)
  10580. return nil
  10581. case compapiasynctask.FieldTaskStatus:
  10582. v, ok := value.(int8)
  10583. if !ok {
  10584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10585. }
  10586. m.SetTaskStatus(v)
  10587. return nil
  10588. case compapiasynctask.FieldRetryCount:
  10589. v, ok := value.(int8)
  10590. if !ok {
  10591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10592. }
  10593. m.SetRetryCount(v)
  10594. return nil
  10595. case compapiasynctask.FieldLastError:
  10596. v, ok := value.(string)
  10597. if !ok {
  10598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10599. }
  10600. m.SetLastError(v)
  10601. return nil
  10602. }
  10603. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10604. }
  10605. // AddedFields returns all numeric fields that were incremented/decremented during
  10606. // this mutation.
  10607. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10608. var fields []string
  10609. if m.addorganization_id != nil {
  10610. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10611. }
  10612. if m.addtask_status != nil {
  10613. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10614. }
  10615. if m.addretry_count != nil {
  10616. fields = append(fields, compapiasynctask.FieldRetryCount)
  10617. }
  10618. return fields
  10619. }
  10620. // AddedField returns the numeric value that was incremented/decremented on a field
  10621. // with the given name. The second boolean return value indicates that this field
  10622. // was not set, or was not defined in the schema.
  10623. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10624. switch name {
  10625. case compapiasynctask.FieldOrganizationID:
  10626. return m.AddedOrganizationID()
  10627. case compapiasynctask.FieldTaskStatus:
  10628. return m.AddedTaskStatus()
  10629. case compapiasynctask.FieldRetryCount:
  10630. return m.AddedRetryCount()
  10631. }
  10632. return nil, false
  10633. }
  10634. // AddField adds the value to the field with the given name. It returns an error if
  10635. // the field is not defined in the schema, or if the type mismatched the field
  10636. // type.
  10637. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10638. switch name {
  10639. case compapiasynctask.FieldOrganizationID:
  10640. v, ok := value.(int64)
  10641. if !ok {
  10642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10643. }
  10644. m.AddOrganizationID(v)
  10645. return nil
  10646. case compapiasynctask.FieldTaskStatus:
  10647. v, ok := value.(int8)
  10648. if !ok {
  10649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10650. }
  10651. m.AddTaskStatus(v)
  10652. return nil
  10653. case compapiasynctask.FieldRetryCount:
  10654. v, ok := value.(int8)
  10655. if !ok {
  10656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10657. }
  10658. m.AddRetryCount(v)
  10659. return nil
  10660. }
  10661. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10662. }
  10663. // ClearedFields returns all nullable fields that were cleared during this
  10664. // mutation.
  10665. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10666. var fields []string
  10667. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10668. fields = append(fields, compapiasynctask.FieldChatID)
  10669. }
  10670. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  10671. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10672. }
  10673. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10674. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10675. }
  10676. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  10677. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10678. }
  10679. if m.FieldCleared(compapiasynctask.FieldModel) {
  10680. fields = append(fields, compapiasynctask.FieldModel)
  10681. }
  10682. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10683. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10684. }
  10685. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10686. fields = append(fields, compapiasynctask.FieldRetryCount)
  10687. }
  10688. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10689. fields = append(fields, compapiasynctask.FieldLastError)
  10690. }
  10691. return fields
  10692. }
  10693. // FieldCleared returns a boolean indicating if a field with the given name was
  10694. // cleared in this mutation.
  10695. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10696. _, ok := m.clearedFields[name]
  10697. return ok
  10698. }
  10699. // ClearField clears the value of the field with the given name. It returns an
  10700. // error if the field is not defined in the schema.
  10701. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10702. switch name {
  10703. case compapiasynctask.FieldChatID:
  10704. m.ClearChatID()
  10705. return nil
  10706. case compapiasynctask.FieldResponseChatItemID:
  10707. m.ClearResponseChatItemID()
  10708. return nil
  10709. case compapiasynctask.FieldResponseRaw:
  10710. m.ClearResponseRaw()
  10711. return nil
  10712. case compapiasynctask.FieldCallbackResponseRaw:
  10713. m.ClearCallbackResponseRaw()
  10714. return nil
  10715. case compapiasynctask.FieldModel:
  10716. m.ClearModel()
  10717. return nil
  10718. case compapiasynctask.FieldTaskStatus:
  10719. m.ClearTaskStatus()
  10720. return nil
  10721. case compapiasynctask.FieldRetryCount:
  10722. m.ClearRetryCount()
  10723. return nil
  10724. case compapiasynctask.FieldLastError:
  10725. m.ClearLastError()
  10726. return nil
  10727. }
  10728. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10729. }
  10730. // ResetField resets all changes in the mutation for the field with the given name.
  10731. // It returns an error if the field is not defined in the schema.
  10732. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10733. switch name {
  10734. case compapiasynctask.FieldCreatedAt:
  10735. m.ResetCreatedAt()
  10736. return nil
  10737. case compapiasynctask.FieldUpdatedAt:
  10738. m.ResetUpdatedAt()
  10739. return nil
  10740. case compapiasynctask.FieldAuthToken:
  10741. m.ResetAuthToken()
  10742. return nil
  10743. case compapiasynctask.FieldEventType:
  10744. m.ResetEventType()
  10745. return nil
  10746. case compapiasynctask.FieldChatID:
  10747. m.ResetChatID()
  10748. return nil
  10749. case compapiasynctask.FieldResponseChatItemID:
  10750. m.ResetResponseChatItemID()
  10751. return nil
  10752. case compapiasynctask.FieldOrganizationID:
  10753. m.ResetOrganizationID()
  10754. return nil
  10755. case compapiasynctask.FieldOpenaiBase:
  10756. m.ResetOpenaiBase()
  10757. return nil
  10758. case compapiasynctask.FieldOpenaiKey:
  10759. m.ResetOpenaiKey()
  10760. return nil
  10761. case compapiasynctask.FieldRequestRaw:
  10762. m.ResetRequestRaw()
  10763. return nil
  10764. case compapiasynctask.FieldResponseRaw:
  10765. m.ResetResponseRaw()
  10766. return nil
  10767. case compapiasynctask.FieldCallbackURL:
  10768. m.ResetCallbackURL()
  10769. return nil
  10770. case compapiasynctask.FieldCallbackResponseRaw:
  10771. m.ResetCallbackResponseRaw()
  10772. return nil
  10773. case compapiasynctask.FieldModel:
  10774. m.ResetModel()
  10775. return nil
  10776. case compapiasynctask.FieldTaskStatus:
  10777. m.ResetTaskStatus()
  10778. return nil
  10779. case compapiasynctask.FieldRetryCount:
  10780. m.ResetRetryCount()
  10781. return nil
  10782. case compapiasynctask.FieldLastError:
  10783. m.ResetLastError()
  10784. return nil
  10785. }
  10786. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10787. }
  10788. // AddedEdges returns all edge names that were set/added in this mutation.
  10789. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10790. edges := make([]string, 0, 0)
  10791. return edges
  10792. }
  10793. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10794. // name in this mutation.
  10795. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10796. return nil
  10797. }
  10798. // RemovedEdges returns all edge names that were removed in this mutation.
  10799. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10800. edges := make([]string, 0, 0)
  10801. return edges
  10802. }
  10803. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10804. // the given name in this mutation.
  10805. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10806. return nil
  10807. }
  10808. // ClearedEdges returns all edge names that were cleared in this mutation.
  10809. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10810. edges := make([]string, 0, 0)
  10811. return edges
  10812. }
  10813. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10814. // was cleared in this mutation.
  10815. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10816. return false
  10817. }
  10818. // ClearEdge clears the value of the edge with the given name. It returns an error
  10819. // if that edge is not defined in the schema.
  10820. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10821. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10822. }
  10823. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10824. // It returns an error if the edge is not defined in the schema.
  10825. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10826. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10827. }
  10828. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10829. type ContactMutation struct {
  10830. config
  10831. op Op
  10832. typ string
  10833. id *uint64
  10834. created_at *time.Time
  10835. updated_at *time.Time
  10836. status *uint8
  10837. addstatus *int8
  10838. deleted_at *time.Time
  10839. wx_wxid *string
  10840. _type *int
  10841. add_type *int
  10842. wxid *string
  10843. account *string
  10844. nickname *string
  10845. markname *string
  10846. headimg *string
  10847. sex *int
  10848. addsex *int
  10849. starrole *string
  10850. dontseeit *int
  10851. adddontseeit *int
  10852. dontseeme *int
  10853. adddontseeme *int
  10854. lag *string
  10855. gid *string
  10856. gname *string
  10857. v3 *string
  10858. organization_id *uint64
  10859. addorganization_id *int64
  10860. ctype *uint64
  10861. addctype *int64
  10862. cage *int
  10863. addcage *int
  10864. cname *string
  10865. carea *string
  10866. cbirthday *string
  10867. cbirtharea *string
  10868. cidcard_no *string
  10869. ctitle *string
  10870. cc *string
  10871. phone *string
  10872. clearedFields map[string]struct{}
  10873. contact_relationships map[uint64]struct{}
  10874. removedcontact_relationships map[uint64]struct{}
  10875. clearedcontact_relationships bool
  10876. contact_fields map[uint64]struct{}
  10877. removedcontact_fields map[uint64]struct{}
  10878. clearedcontact_fields bool
  10879. contact_messages map[uint64]struct{}
  10880. removedcontact_messages map[uint64]struct{}
  10881. clearedcontact_messages bool
  10882. done bool
  10883. oldValue func(context.Context) (*Contact, error)
  10884. predicates []predicate.Contact
  10885. }
  10886. var _ ent.Mutation = (*ContactMutation)(nil)
  10887. // contactOption allows management of the mutation configuration using functional options.
  10888. type contactOption func(*ContactMutation)
  10889. // newContactMutation creates new mutation for the Contact entity.
  10890. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10891. m := &ContactMutation{
  10892. config: c,
  10893. op: op,
  10894. typ: TypeContact,
  10895. clearedFields: make(map[string]struct{}),
  10896. }
  10897. for _, opt := range opts {
  10898. opt(m)
  10899. }
  10900. return m
  10901. }
  10902. // withContactID sets the ID field of the mutation.
  10903. func withContactID(id uint64) contactOption {
  10904. return func(m *ContactMutation) {
  10905. var (
  10906. err error
  10907. once sync.Once
  10908. value *Contact
  10909. )
  10910. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10911. once.Do(func() {
  10912. if m.done {
  10913. err = errors.New("querying old values post mutation is not allowed")
  10914. } else {
  10915. value, err = m.Client().Contact.Get(ctx, id)
  10916. }
  10917. })
  10918. return value, err
  10919. }
  10920. m.id = &id
  10921. }
  10922. }
  10923. // withContact sets the old Contact of the mutation.
  10924. func withContact(node *Contact) contactOption {
  10925. return func(m *ContactMutation) {
  10926. m.oldValue = func(context.Context) (*Contact, error) {
  10927. return node, nil
  10928. }
  10929. m.id = &node.ID
  10930. }
  10931. }
  10932. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10933. // executed in a transaction (ent.Tx), a transactional client is returned.
  10934. func (m ContactMutation) Client() *Client {
  10935. client := &Client{config: m.config}
  10936. client.init()
  10937. return client
  10938. }
  10939. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10940. // it returns an error otherwise.
  10941. func (m ContactMutation) Tx() (*Tx, error) {
  10942. if _, ok := m.driver.(*txDriver); !ok {
  10943. return nil, errors.New("ent: mutation is not running in a transaction")
  10944. }
  10945. tx := &Tx{config: m.config}
  10946. tx.init()
  10947. return tx, nil
  10948. }
  10949. // SetID sets the value of the id field. Note that this
  10950. // operation is only accepted on creation of Contact entities.
  10951. func (m *ContactMutation) SetID(id uint64) {
  10952. m.id = &id
  10953. }
  10954. // ID returns the ID value in the mutation. Note that the ID is only available
  10955. // if it was provided to the builder or after it was returned from the database.
  10956. func (m *ContactMutation) ID() (id uint64, exists bool) {
  10957. if m.id == nil {
  10958. return
  10959. }
  10960. return *m.id, true
  10961. }
  10962. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10963. // That means, if the mutation is applied within a transaction with an isolation level such
  10964. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10965. // or updated by the mutation.
  10966. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  10967. switch {
  10968. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10969. id, exists := m.ID()
  10970. if exists {
  10971. return []uint64{id}, nil
  10972. }
  10973. fallthrough
  10974. case m.op.Is(OpUpdate | OpDelete):
  10975. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  10976. default:
  10977. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10978. }
  10979. }
  10980. // SetCreatedAt sets the "created_at" field.
  10981. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  10982. m.created_at = &t
  10983. }
  10984. // CreatedAt returns the value of the "created_at" field in the mutation.
  10985. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  10986. v := m.created_at
  10987. if v == nil {
  10988. return
  10989. }
  10990. return *v, true
  10991. }
  10992. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  10993. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10995. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10996. if !m.op.Is(OpUpdateOne) {
  10997. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10998. }
  10999. if m.id == nil || m.oldValue == nil {
  11000. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11001. }
  11002. oldValue, err := m.oldValue(ctx)
  11003. if err != nil {
  11004. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11005. }
  11006. return oldValue.CreatedAt, nil
  11007. }
  11008. // ResetCreatedAt resets all changes to the "created_at" field.
  11009. func (m *ContactMutation) ResetCreatedAt() {
  11010. m.created_at = nil
  11011. }
  11012. // SetUpdatedAt sets the "updated_at" field.
  11013. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  11014. m.updated_at = &t
  11015. }
  11016. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11017. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  11018. v := m.updated_at
  11019. if v == nil {
  11020. return
  11021. }
  11022. return *v, true
  11023. }
  11024. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  11025. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11027. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11028. if !m.op.Is(OpUpdateOne) {
  11029. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11030. }
  11031. if m.id == nil || m.oldValue == nil {
  11032. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11033. }
  11034. oldValue, err := m.oldValue(ctx)
  11035. if err != nil {
  11036. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11037. }
  11038. return oldValue.UpdatedAt, nil
  11039. }
  11040. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11041. func (m *ContactMutation) ResetUpdatedAt() {
  11042. m.updated_at = nil
  11043. }
  11044. // SetStatus sets the "status" field.
  11045. func (m *ContactMutation) SetStatus(u uint8) {
  11046. m.status = &u
  11047. m.addstatus = nil
  11048. }
  11049. // Status returns the value of the "status" field in the mutation.
  11050. func (m *ContactMutation) Status() (r uint8, exists bool) {
  11051. v := m.status
  11052. if v == nil {
  11053. return
  11054. }
  11055. return *v, true
  11056. }
  11057. // OldStatus returns the old "status" field's value of the Contact entity.
  11058. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11060. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11061. if !m.op.Is(OpUpdateOne) {
  11062. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11063. }
  11064. if m.id == nil || m.oldValue == nil {
  11065. return v, errors.New("OldStatus requires an ID field in the mutation")
  11066. }
  11067. oldValue, err := m.oldValue(ctx)
  11068. if err != nil {
  11069. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11070. }
  11071. return oldValue.Status, nil
  11072. }
  11073. // AddStatus adds u to the "status" field.
  11074. func (m *ContactMutation) AddStatus(u int8) {
  11075. if m.addstatus != nil {
  11076. *m.addstatus += u
  11077. } else {
  11078. m.addstatus = &u
  11079. }
  11080. }
  11081. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11082. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  11083. v := m.addstatus
  11084. if v == nil {
  11085. return
  11086. }
  11087. return *v, true
  11088. }
  11089. // ClearStatus clears the value of the "status" field.
  11090. func (m *ContactMutation) ClearStatus() {
  11091. m.status = nil
  11092. m.addstatus = nil
  11093. m.clearedFields[contact.FieldStatus] = struct{}{}
  11094. }
  11095. // StatusCleared returns if the "status" field was cleared in this mutation.
  11096. func (m *ContactMutation) StatusCleared() bool {
  11097. _, ok := m.clearedFields[contact.FieldStatus]
  11098. return ok
  11099. }
  11100. // ResetStatus resets all changes to the "status" field.
  11101. func (m *ContactMutation) ResetStatus() {
  11102. m.status = nil
  11103. m.addstatus = nil
  11104. delete(m.clearedFields, contact.FieldStatus)
  11105. }
  11106. // SetDeletedAt sets the "deleted_at" field.
  11107. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  11108. m.deleted_at = &t
  11109. }
  11110. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11111. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  11112. v := m.deleted_at
  11113. if v == nil {
  11114. return
  11115. }
  11116. return *v, true
  11117. }
  11118. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  11119. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11121. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11122. if !m.op.Is(OpUpdateOne) {
  11123. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11124. }
  11125. if m.id == nil || m.oldValue == nil {
  11126. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11127. }
  11128. oldValue, err := m.oldValue(ctx)
  11129. if err != nil {
  11130. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11131. }
  11132. return oldValue.DeletedAt, nil
  11133. }
  11134. // ClearDeletedAt clears the value of the "deleted_at" field.
  11135. func (m *ContactMutation) ClearDeletedAt() {
  11136. m.deleted_at = nil
  11137. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  11138. }
  11139. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11140. func (m *ContactMutation) DeletedAtCleared() bool {
  11141. _, ok := m.clearedFields[contact.FieldDeletedAt]
  11142. return ok
  11143. }
  11144. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11145. func (m *ContactMutation) ResetDeletedAt() {
  11146. m.deleted_at = nil
  11147. delete(m.clearedFields, contact.FieldDeletedAt)
  11148. }
  11149. // SetWxWxid sets the "wx_wxid" field.
  11150. func (m *ContactMutation) SetWxWxid(s string) {
  11151. m.wx_wxid = &s
  11152. }
  11153. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11154. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  11155. v := m.wx_wxid
  11156. if v == nil {
  11157. return
  11158. }
  11159. return *v, true
  11160. }
  11161. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  11162. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11164. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11165. if !m.op.Is(OpUpdateOne) {
  11166. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11167. }
  11168. if m.id == nil || m.oldValue == nil {
  11169. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11170. }
  11171. oldValue, err := m.oldValue(ctx)
  11172. if err != nil {
  11173. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11174. }
  11175. return oldValue.WxWxid, nil
  11176. }
  11177. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11178. func (m *ContactMutation) ResetWxWxid() {
  11179. m.wx_wxid = nil
  11180. }
  11181. // SetType sets the "type" field.
  11182. func (m *ContactMutation) SetType(i int) {
  11183. m._type = &i
  11184. m.add_type = nil
  11185. }
  11186. // GetType returns the value of the "type" field in the mutation.
  11187. func (m *ContactMutation) GetType() (r int, exists bool) {
  11188. v := m._type
  11189. if v == nil {
  11190. return
  11191. }
  11192. return *v, true
  11193. }
  11194. // OldType returns the old "type" field's value of the Contact entity.
  11195. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11197. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  11198. if !m.op.Is(OpUpdateOne) {
  11199. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11200. }
  11201. if m.id == nil || m.oldValue == nil {
  11202. return v, errors.New("OldType requires an ID field in the mutation")
  11203. }
  11204. oldValue, err := m.oldValue(ctx)
  11205. if err != nil {
  11206. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11207. }
  11208. return oldValue.Type, nil
  11209. }
  11210. // AddType adds i to the "type" field.
  11211. func (m *ContactMutation) AddType(i int) {
  11212. if m.add_type != nil {
  11213. *m.add_type += i
  11214. } else {
  11215. m.add_type = &i
  11216. }
  11217. }
  11218. // AddedType returns the value that was added to the "type" field in this mutation.
  11219. func (m *ContactMutation) AddedType() (r int, exists bool) {
  11220. v := m.add_type
  11221. if v == nil {
  11222. return
  11223. }
  11224. return *v, true
  11225. }
  11226. // ClearType clears the value of the "type" field.
  11227. func (m *ContactMutation) ClearType() {
  11228. m._type = nil
  11229. m.add_type = nil
  11230. m.clearedFields[contact.FieldType] = struct{}{}
  11231. }
  11232. // TypeCleared returns if the "type" field was cleared in this mutation.
  11233. func (m *ContactMutation) TypeCleared() bool {
  11234. _, ok := m.clearedFields[contact.FieldType]
  11235. return ok
  11236. }
  11237. // ResetType resets all changes to the "type" field.
  11238. func (m *ContactMutation) ResetType() {
  11239. m._type = nil
  11240. m.add_type = nil
  11241. delete(m.clearedFields, contact.FieldType)
  11242. }
  11243. // SetWxid sets the "wxid" field.
  11244. func (m *ContactMutation) SetWxid(s string) {
  11245. m.wxid = &s
  11246. }
  11247. // Wxid returns the value of the "wxid" field in the mutation.
  11248. func (m *ContactMutation) Wxid() (r string, exists bool) {
  11249. v := m.wxid
  11250. if v == nil {
  11251. return
  11252. }
  11253. return *v, true
  11254. }
  11255. // OldWxid returns the old "wxid" field's value of the Contact entity.
  11256. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11258. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  11259. if !m.op.Is(OpUpdateOne) {
  11260. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11261. }
  11262. if m.id == nil || m.oldValue == nil {
  11263. return v, errors.New("OldWxid requires an ID field in the mutation")
  11264. }
  11265. oldValue, err := m.oldValue(ctx)
  11266. if err != nil {
  11267. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11268. }
  11269. return oldValue.Wxid, nil
  11270. }
  11271. // ResetWxid resets all changes to the "wxid" field.
  11272. func (m *ContactMutation) ResetWxid() {
  11273. m.wxid = nil
  11274. }
  11275. // SetAccount sets the "account" field.
  11276. func (m *ContactMutation) SetAccount(s string) {
  11277. m.account = &s
  11278. }
  11279. // Account returns the value of the "account" field in the mutation.
  11280. func (m *ContactMutation) Account() (r string, exists bool) {
  11281. v := m.account
  11282. if v == nil {
  11283. return
  11284. }
  11285. return *v, true
  11286. }
  11287. // OldAccount returns the old "account" field's value of the Contact entity.
  11288. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11290. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  11291. if !m.op.Is(OpUpdateOne) {
  11292. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11293. }
  11294. if m.id == nil || m.oldValue == nil {
  11295. return v, errors.New("OldAccount requires an ID field in the mutation")
  11296. }
  11297. oldValue, err := m.oldValue(ctx)
  11298. if err != nil {
  11299. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11300. }
  11301. return oldValue.Account, nil
  11302. }
  11303. // ResetAccount resets all changes to the "account" field.
  11304. func (m *ContactMutation) ResetAccount() {
  11305. m.account = nil
  11306. }
  11307. // SetNickname sets the "nickname" field.
  11308. func (m *ContactMutation) SetNickname(s string) {
  11309. m.nickname = &s
  11310. }
  11311. // Nickname returns the value of the "nickname" field in the mutation.
  11312. func (m *ContactMutation) Nickname() (r string, exists bool) {
  11313. v := m.nickname
  11314. if v == nil {
  11315. return
  11316. }
  11317. return *v, true
  11318. }
  11319. // OldNickname returns the old "nickname" field's value of the Contact entity.
  11320. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11322. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  11323. if !m.op.Is(OpUpdateOne) {
  11324. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11325. }
  11326. if m.id == nil || m.oldValue == nil {
  11327. return v, errors.New("OldNickname requires an ID field in the mutation")
  11328. }
  11329. oldValue, err := m.oldValue(ctx)
  11330. if err != nil {
  11331. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11332. }
  11333. return oldValue.Nickname, nil
  11334. }
  11335. // ResetNickname resets all changes to the "nickname" field.
  11336. func (m *ContactMutation) ResetNickname() {
  11337. m.nickname = nil
  11338. }
  11339. // SetMarkname sets the "markname" field.
  11340. func (m *ContactMutation) SetMarkname(s string) {
  11341. m.markname = &s
  11342. }
  11343. // Markname returns the value of the "markname" field in the mutation.
  11344. func (m *ContactMutation) Markname() (r string, exists bool) {
  11345. v := m.markname
  11346. if v == nil {
  11347. return
  11348. }
  11349. return *v, true
  11350. }
  11351. // OldMarkname returns the old "markname" field's value of the Contact entity.
  11352. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11354. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  11355. if !m.op.Is(OpUpdateOne) {
  11356. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  11357. }
  11358. if m.id == nil || m.oldValue == nil {
  11359. return v, errors.New("OldMarkname requires an ID field in the mutation")
  11360. }
  11361. oldValue, err := m.oldValue(ctx)
  11362. if err != nil {
  11363. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  11364. }
  11365. return oldValue.Markname, nil
  11366. }
  11367. // ResetMarkname resets all changes to the "markname" field.
  11368. func (m *ContactMutation) ResetMarkname() {
  11369. m.markname = nil
  11370. }
  11371. // SetHeadimg sets the "headimg" field.
  11372. func (m *ContactMutation) SetHeadimg(s string) {
  11373. m.headimg = &s
  11374. }
  11375. // Headimg returns the value of the "headimg" field in the mutation.
  11376. func (m *ContactMutation) Headimg() (r string, exists bool) {
  11377. v := m.headimg
  11378. if v == nil {
  11379. return
  11380. }
  11381. return *v, true
  11382. }
  11383. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  11384. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11386. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  11387. if !m.op.Is(OpUpdateOne) {
  11388. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  11389. }
  11390. if m.id == nil || m.oldValue == nil {
  11391. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  11392. }
  11393. oldValue, err := m.oldValue(ctx)
  11394. if err != nil {
  11395. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  11396. }
  11397. return oldValue.Headimg, nil
  11398. }
  11399. // ResetHeadimg resets all changes to the "headimg" field.
  11400. func (m *ContactMutation) ResetHeadimg() {
  11401. m.headimg = nil
  11402. }
  11403. // SetSex sets the "sex" field.
  11404. func (m *ContactMutation) SetSex(i int) {
  11405. m.sex = &i
  11406. m.addsex = nil
  11407. }
  11408. // Sex returns the value of the "sex" field in the mutation.
  11409. func (m *ContactMutation) Sex() (r int, exists bool) {
  11410. v := m.sex
  11411. if v == nil {
  11412. return
  11413. }
  11414. return *v, true
  11415. }
  11416. // OldSex returns the old "sex" field's value of the Contact entity.
  11417. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11419. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  11420. if !m.op.Is(OpUpdateOne) {
  11421. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  11422. }
  11423. if m.id == nil || m.oldValue == nil {
  11424. return v, errors.New("OldSex requires an ID field in the mutation")
  11425. }
  11426. oldValue, err := m.oldValue(ctx)
  11427. if err != nil {
  11428. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  11429. }
  11430. return oldValue.Sex, nil
  11431. }
  11432. // AddSex adds i to the "sex" field.
  11433. func (m *ContactMutation) AddSex(i int) {
  11434. if m.addsex != nil {
  11435. *m.addsex += i
  11436. } else {
  11437. m.addsex = &i
  11438. }
  11439. }
  11440. // AddedSex returns the value that was added to the "sex" field in this mutation.
  11441. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  11442. v := m.addsex
  11443. if v == nil {
  11444. return
  11445. }
  11446. return *v, true
  11447. }
  11448. // ResetSex resets all changes to the "sex" field.
  11449. func (m *ContactMutation) ResetSex() {
  11450. m.sex = nil
  11451. m.addsex = nil
  11452. }
  11453. // SetStarrole sets the "starrole" field.
  11454. func (m *ContactMutation) SetStarrole(s string) {
  11455. m.starrole = &s
  11456. }
  11457. // Starrole returns the value of the "starrole" field in the mutation.
  11458. func (m *ContactMutation) Starrole() (r string, exists bool) {
  11459. v := m.starrole
  11460. if v == nil {
  11461. return
  11462. }
  11463. return *v, true
  11464. }
  11465. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  11466. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11468. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  11469. if !m.op.Is(OpUpdateOne) {
  11470. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  11471. }
  11472. if m.id == nil || m.oldValue == nil {
  11473. return v, errors.New("OldStarrole requires an ID field in the mutation")
  11474. }
  11475. oldValue, err := m.oldValue(ctx)
  11476. if err != nil {
  11477. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  11478. }
  11479. return oldValue.Starrole, nil
  11480. }
  11481. // ResetStarrole resets all changes to the "starrole" field.
  11482. func (m *ContactMutation) ResetStarrole() {
  11483. m.starrole = nil
  11484. }
  11485. // SetDontseeit sets the "dontseeit" field.
  11486. func (m *ContactMutation) SetDontseeit(i int) {
  11487. m.dontseeit = &i
  11488. m.adddontseeit = nil
  11489. }
  11490. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  11491. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  11492. v := m.dontseeit
  11493. if v == nil {
  11494. return
  11495. }
  11496. return *v, true
  11497. }
  11498. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  11499. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11501. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  11502. if !m.op.Is(OpUpdateOne) {
  11503. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  11504. }
  11505. if m.id == nil || m.oldValue == nil {
  11506. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  11507. }
  11508. oldValue, err := m.oldValue(ctx)
  11509. if err != nil {
  11510. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11511. }
  11512. return oldValue.Dontseeit, nil
  11513. }
  11514. // AddDontseeit adds i to the "dontseeit" field.
  11515. func (m *ContactMutation) AddDontseeit(i int) {
  11516. if m.adddontseeit != nil {
  11517. *m.adddontseeit += i
  11518. } else {
  11519. m.adddontseeit = &i
  11520. }
  11521. }
  11522. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11523. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11524. v := m.adddontseeit
  11525. if v == nil {
  11526. return
  11527. }
  11528. return *v, true
  11529. }
  11530. // ResetDontseeit resets all changes to the "dontseeit" field.
  11531. func (m *ContactMutation) ResetDontseeit() {
  11532. m.dontseeit = nil
  11533. m.adddontseeit = nil
  11534. }
  11535. // SetDontseeme sets the "dontseeme" field.
  11536. func (m *ContactMutation) SetDontseeme(i int) {
  11537. m.dontseeme = &i
  11538. m.adddontseeme = nil
  11539. }
  11540. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11541. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11542. v := m.dontseeme
  11543. if v == nil {
  11544. return
  11545. }
  11546. return *v, true
  11547. }
  11548. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11549. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11551. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11552. if !m.op.Is(OpUpdateOne) {
  11553. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11554. }
  11555. if m.id == nil || m.oldValue == nil {
  11556. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11557. }
  11558. oldValue, err := m.oldValue(ctx)
  11559. if err != nil {
  11560. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11561. }
  11562. return oldValue.Dontseeme, nil
  11563. }
  11564. // AddDontseeme adds i to the "dontseeme" field.
  11565. func (m *ContactMutation) AddDontseeme(i int) {
  11566. if m.adddontseeme != nil {
  11567. *m.adddontseeme += i
  11568. } else {
  11569. m.adddontseeme = &i
  11570. }
  11571. }
  11572. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11573. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11574. v := m.adddontseeme
  11575. if v == nil {
  11576. return
  11577. }
  11578. return *v, true
  11579. }
  11580. // ResetDontseeme resets all changes to the "dontseeme" field.
  11581. func (m *ContactMutation) ResetDontseeme() {
  11582. m.dontseeme = nil
  11583. m.adddontseeme = nil
  11584. }
  11585. // SetLag sets the "lag" field.
  11586. func (m *ContactMutation) SetLag(s string) {
  11587. m.lag = &s
  11588. }
  11589. // Lag returns the value of the "lag" field in the mutation.
  11590. func (m *ContactMutation) Lag() (r string, exists bool) {
  11591. v := m.lag
  11592. if v == nil {
  11593. return
  11594. }
  11595. return *v, true
  11596. }
  11597. // OldLag returns the old "lag" field's value of the Contact entity.
  11598. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11600. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11601. if !m.op.Is(OpUpdateOne) {
  11602. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11603. }
  11604. if m.id == nil || m.oldValue == nil {
  11605. return v, errors.New("OldLag requires an ID field in the mutation")
  11606. }
  11607. oldValue, err := m.oldValue(ctx)
  11608. if err != nil {
  11609. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11610. }
  11611. return oldValue.Lag, nil
  11612. }
  11613. // ResetLag resets all changes to the "lag" field.
  11614. func (m *ContactMutation) ResetLag() {
  11615. m.lag = nil
  11616. }
  11617. // SetGid sets the "gid" field.
  11618. func (m *ContactMutation) SetGid(s string) {
  11619. m.gid = &s
  11620. }
  11621. // Gid returns the value of the "gid" field in the mutation.
  11622. func (m *ContactMutation) Gid() (r string, exists bool) {
  11623. v := m.gid
  11624. if v == nil {
  11625. return
  11626. }
  11627. return *v, true
  11628. }
  11629. // OldGid returns the old "gid" field's value of the Contact entity.
  11630. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11632. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11633. if !m.op.Is(OpUpdateOne) {
  11634. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11635. }
  11636. if m.id == nil || m.oldValue == nil {
  11637. return v, errors.New("OldGid requires an ID field in the mutation")
  11638. }
  11639. oldValue, err := m.oldValue(ctx)
  11640. if err != nil {
  11641. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11642. }
  11643. return oldValue.Gid, nil
  11644. }
  11645. // ResetGid resets all changes to the "gid" field.
  11646. func (m *ContactMutation) ResetGid() {
  11647. m.gid = nil
  11648. }
  11649. // SetGname sets the "gname" field.
  11650. func (m *ContactMutation) SetGname(s string) {
  11651. m.gname = &s
  11652. }
  11653. // Gname returns the value of the "gname" field in the mutation.
  11654. func (m *ContactMutation) Gname() (r string, exists bool) {
  11655. v := m.gname
  11656. if v == nil {
  11657. return
  11658. }
  11659. return *v, true
  11660. }
  11661. // OldGname returns the old "gname" field's value of the Contact entity.
  11662. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11664. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11665. if !m.op.Is(OpUpdateOne) {
  11666. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11667. }
  11668. if m.id == nil || m.oldValue == nil {
  11669. return v, errors.New("OldGname requires an ID field in the mutation")
  11670. }
  11671. oldValue, err := m.oldValue(ctx)
  11672. if err != nil {
  11673. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11674. }
  11675. return oldValue.Gname, nil
  11676. }
  11677. // ResetGname resets all changes to the "gname" field.
  11678. func (m *ContactMutation) ResetGname() {
  11679. m.gname = nil
  11680. }
  11681. // SetV3 sets the "v3" field.
  11682. func (m *ContactMutation) SetV3(s string) {
  11683. m.v3 = &s
  11684. }
  11685. // V3 returns the value of the "v3" field in the mutation.
  11686. func (m *ContactMutation) V3() (r string, exists bool) {
  11687. v := m.v3
  11688. if v == nil {
  11689. return
  11690. }
  11691. return *v, true
  11692. }
  11693. // OldV3 returns the old "v3" field's value of the Contact entity.
  11694. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11696. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11697. if !m.op.Is(OpUpdateOne) {
  11698. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11699. }
  11700. if m.id == nil || m.oldValue == nil {
  11701. return v, errors.New("OldV3 requires an ID field in the mutation")
  11702. }
  11703. oldValue, err := m.oldValue(ctx)
  11704. if err != nil {
  11705. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11706. }
  11707. return oldValue.V3, nil
  11708. }
  11709. // ResetV3 resets all changes to the "v3" field.
  11710. func (m *ContactMutation) ResetV3() {
  11711. m.v3 = nil
  11712. }
  11713. // SetOrganizationID sets the "organization_id" field.
  11714. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11715. m.organization_id = &u
  11716. m.addorganization_id = nil
  11717. }
  11718. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11719. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11720. v := m.organization_id
  11721. if v == nil {
  11722. return
  11723. }
  11724. return *v, true
  11725. }
  11726. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11727. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11729. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11730. if !m.op.Is(OpUpdateOne) {
  11731. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11732. }
  11733. if m.id == nil || m.oldValue == nil {
  11734. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11735. }
  11736. oldValue, err := m.oldValue(ctx)
  11737. if err != nil {
  11738. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11739. }
  11740. return oldValue.OrganizationID, nil
  11741. }
  11742. // AddOrganizationID adds u to the "organization_id" field.
  11743. func (m *ContactMutation) AddOrganizationID(u int64) {
  11744. if m.addorganization_id != nil {
  11745. *m.addorganization_id += u
  11746. } else {
  11747. m.addorganization_id = &u
  11748. }
  11749. }
  11750. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11751. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11752. v := m.addorganization_id
  11753. if v == nil {
  11754. return
  11755. }
  11756. return *v, true
  11757. }
  11758. // ClearOrganizationID clears the value of the "organization_id" field.
  11759. func (m *ContactMutation) ClearOrganizationID() {
  11760. m.organization_id = nil
  11761. m.addorganization_id = nil
  11762. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11763. }
  11764. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11765. func (m *ContactMutation) OrganizationIDCleared() bool {
  11766. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11767. return ok
  11768. }
  11769. // ResetOrganizationID resets all changes to the "organization_id" field.
  11770. func (m *ContactMutation) ResetOrganizationID() {
  11771. m.organization_id = nil
  11772. m.addorganization_id = nil
  11773. delete(m.clearedFields, contact.FieldOrganizationID)
  11774. }
  11775. // SetCtype sets the "ctype" field.
  11776. func (m *ContactMutation) SetCtype(u uint64) {
  11777. m.ctype = &u
  11778. m.addctype = nil
  11779. }
  11780. // Ctype returns the value of the "ctype" field in the mutation.
  11781. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11782. v := m.ctype
  11783. if v == nil {
  11784. return
  11785. }
  11786. return *v, true
  11787. }
  11788. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11789. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11791. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11792. if !m.op.Is(OpUpdateOne) {
  11793. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11794. }
  11795. if m.id == nil || m.oldValue == nil {
  11796. return v, errors.New("OldCtype requires an ID field in the mutation")
  11797. }
  11798. oldValue, err := m.oldValue(ctx)
  11799. if err != nil {
  11800. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11801. }
  11802. return oldValue.Ctype, nil
  11803. }
  11804. // AddCtype adds u to the "ctype" field.
  11805. func (m *ContactMutation) AddCtype(u int64) {
  11806. if m.addctype != nil {
  11807. *m.addctype += u
  11808. } else {
  11809. m.addctype = &u
  11810. }
  11811. }
  11812. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11813. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11814. v := m.addctype
  11815. if v == nil {
  11816. return
  11817. }
  11818. return *v, true
  11819. }
  11820. // ResetCtype resets all changes to the "ctype" field.
  11821. func (m *ContactMutation) ResetCtype() {
  11822. m.ctype = nil
  11823. m.addctype = nil
  11824. }
  11825. // SetCage sets the "cage" field.
  11826. func (m *ContactMutation) SetCage(i int) {
  11827. m.cage = &i
  11828. m.addcage = nil
  11829. }
  11830. // Cage returns the value of the "cage" field in the mutation.
  11831. func (m *ContactMutation) Cage() (r int, exists bool) {
  11832. v := m.cage
  11833. if v == nil {
  11834. return
  11835. }
  11836. return *v, true
  11837. }
  11838. // OldCage returns the old "cage" field's value of the Contact entity.
  11839. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11841. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11842. if !m.op.Is(OpUpdateOne) {
  11843. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11844. }
  11845. if m.id == nil || m.oldValue == nil {
  11846. return v, errors.New("OldCage requires an ID field in the mutation")
  11847. }
  11848. oldValue, err := m.oldValue(ctx)
  11849. if err != nil {
  11850. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11851. }
  11852. return oldValue.Cage, nil
  11853. }
  11854. // AddCage adds i to the "cage" field.
  11855. func (m *ContactMutation) AddCage(i int) {
  11856. if m.addcage != nil {
  11857. *m.addcage += i
  11858. } else {
  11859. m.addcage = &i
  11860. }
  11861. }
  11862. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11863. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11864. v := m.addcage
  11865. if v == nil {
  11866. return
  11867. }
  11868. return *v, true
  11869. }
  11870. // ResetCage resets all changes to the "cage" field.
  11871. func (m *ContactMutation) ResetCage() {
  11872. m.cage = nil
  11873. m.addcage = nil
  11874. }
  11875. // SetCname sets the "cname" field.
  11876. func (m *ContactMutation) SetCname(s string) {
  11877. m.cname = &s
  11878. }
  11879. // Cname returns the value of the "cname" field in the mutation.
  11880. func (m *ContactMutation) Cname() (r string, exists bool) {
  11881. v := m.cname
  11882. if v == nil {
  11883. return
  11884. }
  11885. return *v, true
  11886. }
  11887. // OldCname returns the old "cname" field's value of the Contact entity.
  11888. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11890. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11891. if !m.op.Is(OpUpdateOne) {
  11892. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11893. }
  11894. if m.id == nil || m.oldValue == nil {
  11895. return v, errors.New("OldCname requires an ID field in the mutation")
  11896. }
  11897. oldValue, err := m.oldValue(ctx)
  11898. if err != nil {
  11899. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11900. }
  11901. return oldValue.Cname, nil
  11902. }
  11903. // ResetCname resets all changes to the "cname" field.
  11904. func (m *ContactMutation) ResetCname() {
  11905. m.cname = nil
  11906. }
  11907. // SetCarea sets the "carea" field.
  11908. func (m *ContactMutation) SetCarea(s string) {
  11909. m.carea = &s
  11910. }
  11911. // Carea returns the value of the "carea" field in the mutation.
  11912. func (m *ContactMutation) Carea() (r string, exists bool) {
  11913. v := m.carea
  11914. if v == nil {
  11915. return
  11916. }
  11917. return *v, true
  11918. }
  11919. // OldCarea returns the old "carea" field's value of the Contact entity.
  11920. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11922. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  11923. if !m.op.Is(OpUpdateOne) {
  11924. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  11925. }
  11926. if m.id == nil || m.oldValue == nil {
  11927. return v, errors.New("OldCarea requires an ID field in the mutation")
  11928. }
  11929. oldValue, err := m.oldValue(ctx)
  11930. if err != nil {
  11931. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  11932. }
  11933. return oldValue.Carea, nil
  11934. }
  11935. // ResetCarea resets all changes to the "carea" field.
  11936. func (m *ContactMutation) ResetCarea() {
  11937. m.carea = nil
  11938. }
  11939. // SetCbirthday sets the "cbirthday" field.
  11940. func (m *ContactMutation) SetCbirthday(s string) {
  11941. m.cbirthday = &s
  11942. }
  11943. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  11944. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  11945. v := m.cbirthday
  11946. if v == nil {
  11947. return
  11948. }
  11949. return *v, true
  11950. }
  11951. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  11952. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11954. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  11955. if !m.op.Is(OpUpdateOne) {
  11956. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  11957. }
  11958. if m.id == nil || m.oldValue == nil {
  11959. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  11960. }
  11961. oldValue, err := m.oldValue(ctx)
  11962. if err != nil {
  11963. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  11964. }
  11965. return oldValue.Cbirthday, nil
  11966. }
  11967. // ResetCbirthday resets all changes to the "cbirthday" field.
  11968. func (m *ContactMutation) ResetCbirthday() {
  11969. m.cbirthday = nil
  11970. }
  11971. // SetCbirtharea sets the "cbirtharea" field.
  11972. func (m *ContactMutation) SetCbirtharea(s string) {
  11973. m.cbirtharea = &s
  11974. }
  11975. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  11976. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  11977. v := m.cbirtharea
  11978. if v == nil {
  11979. return
  11980. }
  11981. return *v, true
  11982. }
  11983. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  11984. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11986. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  11987. if !m.op.Is(OpUpdateOne) {
  11988. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  11989. }
  11990. if m.id == nil || m.oldValue == nil {
  11991. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  11992. }
  11993. oldValue, err := m.oldValue(ctx)
  11994. if err != nil {
  11995. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  11996. }
  11997. return oldValue.Cbirtharea, nil
  11998. }
  11999. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  12000. func (m *ContactMutation) ResetCbirtharea() {
  12001. m.cbirtharea = nil
  12002. }
  12003. // SetCidcardNo sets the "cidcard_no" field.
  12004. func (m *ContactMutation) SetCidcardNo(s string) {
  12005. m.cidcard_no = &s
  12006. }
  12007. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  12008. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  12009. v := m.cidcard_no
  12010. if v == nil {
  12011. return
  12012. }
  12013. return *v, true
  12014. }
  12015. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  12016. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12018. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  12019. if !m.op.Is(OpUpdateOne) {
  12020. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  12021. }
  12022. if m.id == nil || m.oldValue == nil {
  12023. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  12024. }
  12025. oldValue, err := m.oldValue(ctx)
  12026. if err != nil {
  12027. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  12028. }
  12029. return oldValue.CidcardNo, nil
  12030. }
  12031. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  12032. func (m *ContactMutation) ResetCidcardNo() {
  12033. m.cidcard_no = nil
  12034. }
  12035. // SetCtitle sets the "ctitle" field.
  12036. func (m *ContactMutation) SetCtitle(s string) {
  12037. m.ctitle = &s
  12038. }
  12039. // Ctitle returns the value of the "ctitle" field in the mutation.
  12040. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  12041. v := m.ctitle
  12042. if v == nil {
  12043. return
  12044. }
  12045. return *v, true
  12046. }
  12047. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  12048. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12050. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  12051. if !m.op.Is(OpUpdateOne) {
  12052. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  12053. }
  12054. if m.id == nil || m.oldValue == nil {
  12055. return v, errors.New("OldCtitle requires an ID field in the mutation")
  12056. }
  12057. oldValue, err := m.oldValue(ctx)
  12058. if err != nil {
  12059. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  12060. }
  12061. return oldValue.Ctitle, nil
  12062. }
  12063. // ResetCtitle resets all changes to the "ctitle" field.
  12064. func (m *ContactMutation) ResetCtitle() {
  12065. m.ctitle = nil
  12066. }
  12067. // SetCc sets the "cc" field.
  12068. func (m *ContactMutation) SetCc(s string) {
  12069. m.cc = &s
  12070. }
  12071. // Cc returns the value of the "cc" field in the mutation.
  12072. func (m *ContactMutation) Cc() (r string, exists bool) {
  12073. v := m.cc
  12074. if v == nil {
  12075. return
  12076. }
  12077. return *v, true
  12078. }
  12079. // OldCc returns the old "cc" field's value of the Contact entity.
  12080. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12082. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  12083. if !m.op.Is(OpUpdateOne) {
  12084. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  12085. }
  12086. if m.id == nil || m.oldValue == nil {
  12087. return v, errors.New("OldCc requires an ID field in the mutation")
  12088. }
  12089. oldValue, err := m.oldValue(ctx)
  12090. if err != nil {
  12091. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  12092. }
  12093. return oldValue.Cc, nil
  12094. }
  12095. // ResetCc resets all changes to the "cc" field.
  12096. func (m *ContactMutation) ResetCc() {
  12097. m.cc = nil
  12098. }
  12099. // SetPhone sets the "phone" field.
  12100. func (m *ContactMutation) SetPhone(s string) {
  12101. m.phone = &s
  12102. }
  12103. // Phone returns the value of the "phone" field in the mutation.
  12104. func (m *ContactMutation) Phone() (r string, exists bool) {
  12105. v := m.phone
  12106. if v == nil {
  12107. return
  12108. }
  12109. return *v, true
  12110. }
  12111. // OldPhone returns the old "phone" field's value of the Contact entity.
  12112. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12114. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  12115. if !m.op.Is(OpUpdateOne) {
  12116. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  12117. }
  12118. if m.id == nil || m.oldValue == nil {
  12119. return v, errors.New("OldPhone requires an ID field in the mutation")
  12120. }
  12121. oldValue, err := m.oldValue(ctx)
  12122. if err != nil {
  12123. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  12124. }
  12125. return oldValue.Phone, nil
  12126. }
  12127. // ResetPhone resets all changes to the "phone" field.
  12128. func (m *ContactMutation) ResetPhone() {
  12129. m.phone = nil
  12130. }
  12131. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  12132. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  12133. if m.contact_relationships == nil {
  12134. m.contact_relationships = make(map[uint64]struct{})
  12135. }
  12136. for i := range ids {
  12137. m.contact_relationships[ids[i]] = struct{}{}
  12138. }
  12139. }
  12140. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  12141. func (m *ContactMutation) ClearContactRelationships() {
  12142. m.clearedcontact_relationships = true
  12143. }
  12144. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  12145. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  12146. return m.clearedcontact_relationships
  12147. }
  12148. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  12149. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  12150. if m.removedcontact_relationships == nil {
  12151. m.removedcontact_relationships = make(map[uint64]struct{})
  12152. }
  12153. for i := range ids {
  12154. delete(m.contact_relationships, ids[i])
  12155. m.removedcontact_relationships[ids[i]] = struct{}{}
  12156. }
  12157. }
  12158. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  12159. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  12160. for id := range m.removedcontact_relationships {
  12161. ids = append(ids, id)
  12162. }
  12163. return
  12164. }
  12165. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  12166. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  12167. for id := range m.contact_relationships {
  12168. ids = append(ids, id)
  12169. }
  12170. return
  12171. }
  12172. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  12173. func (m *ContactMutation) ResetContactRelationships() {
  12174. m.contact_relationships = nil
  12175. m.clearedcontact_relationships = false
  12176. m.removedcontact_relationships = nil
  12177. }
  12178. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  12179. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  12180. if m.contact_fields == nil {
  12181. m.contact_fields = make(map[uint64]struct{})
  12182. }
  12183. for i := range ids {
  12184. m.contact_fields[ids[i]] = struct{}{}
  12185. }
  12186. }
  12187. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  12188. func (m *ContactMutation) ClearContactFields() {
  12189. m.clearedcontact_fields = true
  12190. }
  12191. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  12192. func (m *ContactMutation) ContactFieldsCleared() bool {
  12193. return m.clearedcontact_fields
  12194. }
  12195. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  12196. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  12197. if m.removedcontact_fields == nil {
  12198. m.removedcontact_fields = make(map[uint64]struct{})
  12199. }
  12200. for i := range ids {
  12201. delete(m.contact_fields, ids[i])
  12202. m.removedcontact_fields[ids[i]] = struct{}{}
  12203. }
  12204. }
  12205. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  12206. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  12207. for id := range m.removedcontact_fields {
  12208. ids = append(ids, id)
  12209. }
  12210. return
  12211. }
  12212. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  12213. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  12214. for id := range m.contact_fields {
  12215. ids = append(ids, id)
  12216. }
  12217. return
  12218. }
  12219. // ResetContactFields resets all changes to the "contact_fields" edge.
  12220. func (m *ContactMutation) ResetContactFields() {
  12221. m.contact_fields = nil
  12222. m.clearedcontact_fields = false
  12223. m.removedcontact_fields = nil
  12224. }
  12225. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  12226. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  12227. if m.contact_messages == nil {
  12228. m.contact_messages = make(map[uint64]struct{})
  12229. }
  12230. for i := range ids {
  12231. m.contact_messages[ids[i]] = struct{}{}
  12232. }
  12233. }
  12234. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  12235. func (m *ContactMutation) ClearContactMessages() {
  12236. m.clearedcontact_messages = true
  12237. }
  12238. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  12239. func (m *ContactMutation) ContactMessagesCleared() bool {
  12240. return m.clearedcontact_messages
  12241. }
  12242. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  12243. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  12244. if m.removedcontact_messages == nil {
  12245. m.removedcontact_messages = make(map[uint64]struct{})
  12246. }
  12247. for i := range ids {
  12248. delete(m.contact_messages, ids[i])
  12249. m.removedcontact_messages[ids[i]] = struct{}{}
  12250. }
  12251. }
  12252. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  12253. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  12254. for id := range m.removedcontact_messages {
  12255. ids = append(ids, id)
  12256. }
  12257. return
  12258. }
  12259. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  12260. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  12261. for id := range m.contact_messages {
  12262. ids = append(ids, id)
  12263. }
  12264. return
  12265. }
  12266. // ResetContactMessages resets all changes to the "contact_messages" edge.
  12267. func (m *ContactMutation) ResetContactMessages() {
  12268. m.contact_messages = nil
  12269. m.clearedcontact_messages = false
  12270. m.removedcontact_messages = nil
  12271. }
  12272. // Where appends a list predicates to the ContactMutation builder.
  12273. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  12274. m.predicates = append(m.predicates, ps...)
  12275. }
  12276. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  12277. // users can use type-assertion to append predicates that do not depend on any generated package.
  12278. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  12279. p := make([]predicate.Contact, len(ps))
  12280. for i := range ps {
  12281. p[i] = ps[i]
  12282. }
  12283. m.Where(p...)
  12284. }
  12285. // Op returns the operation name.
  12286. func (m *ContactMutation) Op() Op {
  12287. return m.op
  12288. }
  12289. // SetOp allows setting the mutation operation.
  12290. func (m *ContactMutation) SetOp(op Op) {
  12291. m.op = op
  12292. }
  12293. // Type returns the node type of this mutation (Contact).
  12294. func (m *ContactMutation) Type() string {
  12295. return m.typ
  12296. }
  12297. // Fields returns all fields that were changed during this mutation. Note that in
  12298. // order to get all numeric fields that were incremented/decremented, call
  12299. // AddedFields().
  12300. func (m *ContactMutation) Fields() []string {
  12301. fields := make([]string, 0, 30)
  12302. if m.created_at != nil {
  12303. fields = append(fields, contact.FieldCreatedAt)
  12304. }
  12305. if m.updated_at != nil {
  12306. fields = append(fields, contact.FieldUpdatedAt)
  12307. }
  12308. if m.status != nil {
  12309. fields = append(fields, contact.FieldStatus)
  12310. }
  12311. if m.deleted_at != nil {
  12312. fields = append(fields, contact.FieldDeletedAt)
  12313. }
  12314. if m.wx_wxid != nil {
  12315. fields = append(fields, contact.FieldWxWxid)
  12316. }
  12317. if m._type != nil {
  12318. fields = append(fields, contact.FieldType)
  12319. }
  12320. if m.wxid != nil {
  12321. fields = append(fields, contact.FieldWxid)
  12322. }
  12323. if m.account != nil {
  12324. fields = append(fields, contact.FieldAccount)
  12325. }
  12326. if m.nickname != nil {
  12327. fields = append(fields, contact.FieldNickname)
  12328. }
  12329. if m.markname != nil {
  12330. fields = append(fields, contact.FieldMarkname)
  12331. }
  12332. if m.headimg != nil {
  12333. fields = append(fields, contact.FieldHeadimg)
  12334. }
  12335. if m.sex != nil {
  12336. fields = append(fields, contact.FieldSex)
  12337. }
  12338. if m.starrole != nil {
  12339. fields = append(fields, contact.FieldStarrole)
  12340. }
  12341. if m.dontseeit != nil {
  12342. fields = append(fields, contact.FieldDontseeit)
  12343. }
  12344. if m.dontseeme != nil {
  12345. fields = append(fields, contact.FieldDontseeme)
  12346. }
  12347. if m.lag != nil {
  12348. fields = append(fields, contact.FieldLag)
  12349. }
  12350. if m.gid != nil {
  12351. fields = append(fields, contact.FieldGid)
  12352. }
  12353. if m.gname != nil {
  12354. fields = append(fields, contact.FieldGname)
  12355. }
  12356. if m.v3 != nil {
  12357. fields = append(fields, contact.FieldV3)
  12358. }
  12359. if m.organization_id != nil {
  12360. fields = append(fields, contact.FieldOrganizationID)
  12361. }
  12362. if m.ctype != nil {
  12363. fields = append(fields, contact.FieldCtype)
  12364. }
  12365. if m.cage != nil {
  12366. fields = append(fields, contact.FieldCage)
  12367. }
  12368. if m.cname != nil {
  12369. fields = append(fields, contact.FieldCname)
  12370. }
  12371. if m.carea != nil {
  12372. fields = append(fields, contact.FieldCarea)
  12373. }
  12374. if m.cbirthday != nil {
  12375. fields = append(fields, contact.FieldCbirthday)
  12376. }
  12377. if m.cbirtharea != nil {
  12378. fields = append(fields, contact.FieldCbirtharea)
  12379. }
  12380. if m.cidcard_no != nil {
  12381. fields = append(fields, contact.FieldCidcardNo)
  12382. }
  12383. if m.ctitle != nil {
  12384. fields = append(fields, contact.FieldCtitle)
  12385. }
  12386. if m.cc != nil {
  12387. fields = append(fields, contact.FieldCc)
  12388. }
  12389. if m.phone != nil {
  12390. fields = append(fields, contact.FieldPhone)
  12391. }
  12392. return fields
  12393. }
  12394. // Field returns the value of a field with the given name. The second boolean
  12395. // return value indicates that this field was not set, or was not defined in the
  12396. // schema.
  12397. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  12398. switch name {
  12399. case contact.FieldCreatedAt:
  12400. return m.CreatedAt()
  12401. case contact.FieldUpdatedAt:
  12402. return m.UpdatedAt()
  12403. case contact.FieldStatus:
  12404. return m.Status()
  12405. case contact.FieldDeletedAt:
  12406. return m.DeletedAt()
  12407. case contact.FieldWxWxid:
  12408. return m.WxWxid()
  12409. case contact.FieldType:
  12410. return m.GetType()
  12411. case contact.FieldWxid:
  12412. return m.Wxid()
  12413. case contact.FieldAccount:
  12414. return m.Account()
  12415. case contact.FieldNickname:
  12416. return m.Nickname()
  12417. case contact.FieldMarkname:
  12418. return m.Markname()
  12419. case contact.FieldHeadimg:
  12420. return m.Headimg()
  12421. case contact.FieldSex:
  12422. return m.Sex()
  12423. case contact.FieldStarrole:
  12424. return m.Starrole()
  12425. case contact.FieldDontseeit:
  12426. return m.Dontseeit()
  12427. case contact.FieldDontseeme:
  12428. return m.Dontseeme()
  12429. case contact.FieldLag:
  12430. return m.Lag()
  12431. case contact.FieldGid:
  12432. return m.Gid()
  12433. case contact.FieldGname:
  12434. return m.Gname()
  12435. case contact.FieldV3:
  12436. return m.V3()
  12437. case contact.FieldOrganizationID:
  12438. return m.OrganizationID()
  12439. case contact.FieldCtype:
  12440. return m.Ctype()
  12441. case contact.FieldCage:
  12442. return m.Cage()
  12443. case contact.FieldCname:
  12444. return m.Cname()
  12445. case contact.FieldCarea:
  12446. return m.Carea()
  12447. case contact.FieldCbirthday:
  12448. return m.Cbirthday()
  12449. case contact.FieldCbirtharea:
  12450. return m.Cbirtharea()
  12451. case contact.FieldCidcardNo:
  12452. return m.CidcardNo()
  12453. case contact.FieldCtitle:
  12454. return m.Ctitle()
  12455. case contact.FieldCc:
  12456. return m.Cc()
  12457. case contact.FieldPhone:
  12458. return m.Phone()
  12459. }
  12460. return nil, false
  12461. }
  12462. // OldField returns the old value of the field from the database. An error is
  12463. // returned if the mutation operation is not UpdateOne, or the query to the
  12464. // database failed.
  12465. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12466. switch name {
  12467. case contact.FieldCreatedAt:
  12468. return m.OldCreatedAt(ctx)
  12469. case contact.FieldUpdatedAt:
  12470. return m.OldUpdatedAt(ctx)
  12471. case contact.FieldStatus:
  12472. return m.OldStatus(ctx)
  12473. case contact.FieldDeletedAt:
  12474. return m.OldDeletedAt(ctx)
  12475. case contact.FieldWxWxid:
  12476. return m.OldWxWxid(ctx)
  12477. case contact.FieldType:
  12478. return m.OldType(ctx)
  12479. case contact.FieldWxid:
  12480. return m.OldWxid(ctx)
  12481. case contact.FieldAccount:
  12482. return m.OldAccount(ctx)
  12483. case contact.FieldNickname:
  12484. return m.OldNickname(ctx)
  12485. case contact.FieldMarkname:
  12486. return m.OldMarkname(ctx)
  12487. case contact.FieldHeadimg:
  12488. return m.OldHeadimg(ctx)
  12489. case contact.FieldSex:
  12490. return m.OldSex(ctx)
  12491. case contact.FieldStarrole:
  12492. return m.OldStarrole(ctx)
  12493. case contact.FieldDontseeit:
  12494. return m.OldDontseeit(ctx)
  12495. case contact.FieldDontseeme:
  12496. return m.OldDontseeme(ctx)
  12497. case contact.FieldLag:
  12498. return m.OldLag(ctx)
  12499. case contact.FieldGid:
  12500. return m.OldGid(ctx)
  12501. case contact.FieldGname:
  12502. return m.OldGname(ctx)
  12503. case contact.FieldV3:
  12504. return m.OldV3(ctx)
  12505. case contact.FieldOrganizationID:
  12506. return m.OldOrganizationID(ctx)
  12507. case contact.FieldCtype:
  12508. return m.OldCtype(ctx)
  12509. case contact.FieldCage:
  12510. return m.OldCage(ctx)
  12511. case contact.FieldCname:
  12512. return m.OldCname(ctx)
  12513. case contact.FieldCarea:
  12514. return m.OldCarea(ctx)
  12515. case contact.FieldCbirthday:
  12516. return m.OldCbirthday(ctx)
  12517. case contact.FieldCbirtharea:
  12518. return m.OldCbirtharea(ctx)
  12519. case contact.FieldCidcardNo:
  12520. return m.OldCidcardNo(ctx)
  12521. case contact.FieldCtitle:
  12522. return m.OldCtitle(ctx)
  12523. case contact.FieldCc:
  12524. return m.OldCc(ctx)
  12525. case contact.FieldPhone:
  12526. return m.OldPhone(ctx)
  12527. }
  12528. return nil, fmt.Errorf("unknown Contact field %s", name)
  12529. }
  12530. // SetField sets the value of a field with the given name. It returns an error if
  12531. // the field is not defined in the schema, or if the type mismatched the field
  12532. // type.
  12533. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  12534. switch name {
  12535. case contact.FieldCreatedAt:
  12536. v, ok := value.(time.Time)
  12537. if !ok {
  12538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12539. }
  12540. m.SetCreatedAt(v)
  12541. return nil
  12542. case contact.FieldUpdatedAt:
  12543. v, ok := value.(time.Time)
  12544. if !ok {
  12545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12546. }
  12547. m.SetUpdatedAt(v)
  12548. return nil
  12549. case contact.FieldStatus:
  12550. v, ok := value.(uint8)
  12551. if !ok {
  12552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12553. }
  12554. m.SetStatus(v)
  12555. return nil
  12556. case contact.FieldDeletedAt:
  12557. v, ok := value.(time.Time)
  12558. if !ok {
  12559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12560. }
  12561. m.SetDeletedAt(v)
  12562. return nil
  12563. case contact.FieldWxWxid:
  12564. v, ok := value.(string)
  12565. if !ok {
  12566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12567. }
  12568. m.SetWxWxid(v)
  12569. return nil
  12570. case contact.FieldType:
  12571. v, ok := value.(int)
  12572. if !ok {
  12573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12574. }
  12575. m.SetType(v)
  12576. return nil
  12577. case contact.FieldWxid:
  12578. v, ok := value.(string)
  12579. if !ok {
  12580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12581. }
  12582. m.SetWxid(v)
  12583. return nil
  12584. case contact.FieldAccount:
  12585. v, ok := value.(string)
  12586. if !ok {
  12587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12588. }
  12589. m.SetAccount(v)
  12590. return nil
  12591. case contact.FieldNickname:
  12592. v, ok := value.(string)
  12593. if !ok {
  12594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12595. }
  12596. m.SetNickname(v)
  12597. return nil
  12598. case contact.FieldMarkname:
  12599. v, ok := value.(string)
  12600. if !ok {
  12601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12602. }
  12603. m.SetMarkname(v)
  12604. return nil
  12605. case contact.FieldHeadimg:
  12606. v, ok := value.(string)
  12607. if !ok {
  12608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12609. }
  12610. m.SetHeadimg(v)
  12611. return nil
  12612. case contact.FieldSex:
  12613. v, ok := value.(int)
  12614. if !ok {
  12615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12616. }
  12617. m.SetSex(v)
  12618. return nil
  12619. case contact.FieldStarrole:
  12620. v, ok := value.(string)
  12621. if !ok {
  12622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12623. }
  12624. m.SetStarrole(v)
  12625. return nil
  12626. case contact.FieldDontseeit:
  12627. v, ok := value.(int)
  12628. if !ok {
  12629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12630. }
  12631. m.SetDontseeit(v)
  12632. return nil
  12633. case contact.FieldDontseeme:
  12634. v, ok := value.(int)
  12635. if !ok {
  12636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12637. }
  12638. m.SetDontseeme(v)
  12639. return nil
  12640. case contact.FieldLag:
  12641. v, ok := value.(string)
  12642. if !ok {
  12643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12644. }
  12645. m.SetLag(v)
  12646. return nil
  12647. case contact.FieldGid:
  12648. v, ok := value.(string)
  12649. if !ok {
  12650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12651. }
  12652. m.SetGid(v)
  12653. return nil
  12654. case contact.FieldGname:
  12655. v, ok := value.(string)
  12656. if !ok {
  12657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12658. }
  12659. m.SetGname(v)
  12660. return nil
  12661. case contact.FieldV3:
  12662. v, ok := value.(string)
  12663. if !ok {
  12664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12665. }
  12666. m.SetV3(v)
  12667. return nil
  12668. case contact.FieldOrganizationID:
  12669. v, ok := value.(uint64)
  12670. if !ok {
  12671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12672. }
  12673. m.SetOrganizationID(v)
  12674. return nil
  12675. case contact.FieldCtype:
  12676. v, ok := value.(uint64)
  12677. if !ok {
  12678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12679. }
  12680. m.SetCtype(v)
  12681. return nil
  12682. case contact.FieldCage:
  12683. v, ok := value.(int)
  12684. if !ok {
  12685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12686. }
  12687. m.SetCage(v)
  12688. return nil
  12689. case contact.FieldCname:
  12690. v, ok := value.(string)
  12691. if !ok {
  12692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12693. }
  12694. m.SetCname(v)
  12695. return nil
  12696. case contact.FieldCarea:
  12697. v, ok := value.(string)
  12698. if !ok {
  12699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12700. }
  12701. m.SetCarea(v)
  12702. return nil
  12703. case contact.FieldCbirthday:
  12704. v, ok := value.(string)
  12705. if !ok {
  12706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12707. }
  12708. m.SetCbirthday(v)
  12709. return nil
  12710. case contact.FieldCbirtharea:
  12711. v, ok := value.(string)
  12712. if !ok {
  12713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12714. }
  12715. m.SetCbirtharea(v)
  12716. return nil
  12717. case contact.FieldCidcardNo:
  12718. v, ok := value.(string)
  12719. if !ok {
  12720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12721. }
  12722. m.SetCidcardNo(v)
  12723. return nil
  12724. case contact.FieldCtitle:
  12725. v, ok := value.(string)
  12726. if !ok {
  12727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12728. }
  12729. m.SetCtitle(v)
  12730. return nil
  12731. case contact.FieldCc:
  12732. v, ok := value.(string)
  12733. if !ok {
  12734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12735. }
  12736. m.SetCc(v)
  12737. return nil
  12738. case contact.FieldPhone:
  12739. v, ok := value.(string)
  12740. if !ok {
  12741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12742. }
  12743. m.SetPhone(v)
  12744. return nil
  12745. }
  12746. return fmt.Errorf("unknown Contact field %s", name)
  12747. }
  12748. // AddedFields returns all numeric fields that were incremented/decremented during
  12749. // this mutation.
  12750. func (m *ContactMutation) AddedFields() []string {
  12751. var fields []string
  12752. if m.addstatus != nil {
  12753. fields = append(fields, contact.FieldStatus)
  12754. }
  12755. if m.add_type != nil {
  12756. fields = append(fields, contact.FieldType)
  12757. }
  12758. if m.addsex != nil {
  12759. fields = append(fields, contact.FieldSex)
  12760. }
  12761. if m.adddontseeit != nil {
  12762. fields = append(fields, contact.FieldDontseeit)
  12763. }
  12764. if m.adddontseeme != nil {
  12765. fields = append(fields, contact.FieldDontseeme)
  12766. }
  12767. if m.addorganization_id != nil {
  12768. fields = append(fields, contact.FieldOrganizationID)
  12769. }
  12770. if m.addctype != nil {
  12771. fields = append(fields, contact.FieldCtype)
  12772. }
  12773. if m.addcage != nil {
  12774. fields = append(fields, contact.FieldCage)
  12775. }
  12776. return fields
  12777. }
  12778. // AddedField returns the numeric value that was incremented/decremented on a field
  12779. // with the given name. The second boolean return value indicates that this field
  12780. // was not set, or was not defined in the schema.
  12781. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12782. switch name {
  12783. case contact.FieldStatus:
  12784. return m.AddedStatus()
  12785. case contact.FieldType:
  12786. return m.AddedType()
  12787. case contact.FieldSex:
  12788. return m.AddedSex()
  12789. case contact.FieldDontseeit:
  12790. return m.AddedDontseeit()
  12791. case contact.FieldDontseeme:
  12792. return m.AddedDontseeme()
  12793. case contact.FieldOrganizationID:
  12794. return m.AddedOrganizationID()
  12795. case contact.FieldCtype:
  12796. return m.AddedCtype()
  12797. case contact.FieldCage:
  12798. return m.AddedCage()
  12799. }
  12800. return nil, false
  12801. }
  12802. // AddField adds the value to the field with the given name. It returns an error if
  12803. // the field is not defined in the schema, or if the type mismatched the field
  12804. // type.
  12805. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12806. switch name {
  12807. case contact.FieldStatus:
  12808. v, ok := value.(int8)
  12809. if !ok {
  12810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12811. }
  12812. m.AddStatus(v)
  12813. return nil
  12814. case contact.FieldType:
  12815. v, ok := value.(int)
  12816. if !ok {
  12817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12818. }
  12819. m.AddType(v)
  12820. return nil
  12821. case contact.FieldSex:
  12822. v, ok := value.(int)
  12823. if !ok {
  12824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12825. }
  12826. m.AddSex(v)
  12827. return nil
  12828. case contact.FieldDontseeit:
  12829. v, ok := value.(int)
  12830. if !ok {
  12831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12832. }
  12833. m.AddDontseeit(v)
  12834. return nil
  12835. case contact.FieldDontseeme:
  12836. v, ok := value.(int)
  12837. if !ok {
  12838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12839. }
  12840. m.AddDontseeme(v)
  12841. return nil
  12842. case contact.FieldOrganizationID:
  12843. v, ok := value.(int64)
  12844. if !ok {
  12845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12846. }
  12847. m.AddOrganizationID(v)
  12848. return nil
  12849. case contact.FieldCtype:
  12850. v, ok := value.(int64)
  12851. if !ok {
  12852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12853. }
  12854. m.AddCtype(v)
  12855. return nil
  12856. case contact.FieldCage:
  12857. v, ok := value.(int)
  12858. if !ok {
  12859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12860. }
  12861. m.AddCage(v)
  12862. return nil
  12863. }
  12864. return fmt.Errorf("unknown Contact numeric field %s", name)
  12865. }
  12866. // ClearedFields returns all nullable fields that were cleared during this
  12867. // mutation.
  12868. func (m *ContactMutation) ClearedFields() []string {
  12869. var fields []string
  12870. if m.FieldCleared(contact.FieldStatus) {
  12871. fields = append(fields, contact.FieldStatus)
  12872. }
  12873. if m.FieldCleared(contact.FieldDeletedAt) {
  12874. fields = append(fields, contact.FieldDeletedAt)
  12875. }
  12876. if m.FieldCleared(contact.FieldType) {
  12877. fields = append(fields, contact.FieldType)
  12878. }
  12879. if m.FieldCleared(contact.FieldOrganizationID) {
  12880. fields = append(fields, contact.FieldOrganizationID)
  12881. }
  12882. return fields
  12883. }
  12884. // FieldCleared returns a boolean indicating if a field with the given name was
  12885. // cleared in this mutation.
  12886. func (m *ContactMutation) FieldCleared(name string) bool {
  12887. _, ok := m.clearedFields[name]
  12888. return ok
  12889. }
  12890. // ClearField clears the value of the field with the given name. It returns an
  12891. // error if the field is not defined in the schema.
  12892. func (m *ContactMutation) ClearField(name string) error {
  12893. switch name {
  12894. case contact.FieldStatus:
  12895. m.ClearStatus()
  12896. return nil
  12897. case contact.FieldDeletedAt:
  12898. m.ClearDeletedAt()
  12899. return nil
  12900. case contact.FieldType:
  12901. m.ClearType()
  12902. return nil
  12903. case contact.FieldOrganizationID:
  12904. m.ClearOrganizationID()
  12905. return nil
  12906. }
  12907. return fmt.Errorf("unknown Contact nullable field %s", name)
  12908. }
  12909. // ResetField resets all changes in the mutation for the field with the given name.
  12910. // It returns an error if the field is not defined in the schema.
  12911. func (m *ContactMutation) ResetField(name string) error {
  12912. switch name {
  12913. case contact.FieldCreatedAt:
  12914. m.ResetCreatedAt()
  12915. return nil
  12916. case contact.FieldUpdatedAt:
  12917. m.ResetUpdatedAt()
  12918. return nil
  12919. case contact.FieldStatus:
  12920. m.ResetStatus()
  12921. return nil
  12922. case contact.FieldDeletedAt:
  12923. m.ResetDeletedAt()
  12924. return nil
  12925. case contact.FieldWxWxid:
  12926. m.ResetWxWxid()
  12927. return nil
  12928. case contact.FieldType:
  12929. m.ResetType()
  12930. return nil
  12931. case contact.FieldWxid:
  12932. m.ResetWxid()
  12933. return nil
  12934. case contact.FieldAccount:
  12935. m.ResetAccount()
  12936. return nil
  12937. case contact.FieldNickname:
  12938. m.ResetNickname()
  12939. return nil
  12940. case contact.FieldMarkname:
  12941. m.ResetMarkname()
  12942. return nil
  12943. case contact.FieldHeadimg:
  12944. m.ResetHeadimg()
  12945. return nil
  12946. case contact.FieldSex:
  12947. m.ResetSex()
  12948. return nil
  12949. case contact.FieldStarrole:
  12950. m.ResetStarrole()
  12951. return nil
  12952. case contact.FieldDontseeit:
  12953. m.ResetDontseeit()
  12954. return nil
  12955. case contact.FieldDontseeme:
  12956. m.ResetDontseeme()
  12957. return nil
  12958. case contact.FieldLag:
  12959. m.ResetLag()
  12960. return nil
  12961. case contact.FieldGid:
  12962. m.ResetGid()
  12963. return nil
  12964. case contact.FieldGname:
  12965. m.ResetGname()
  12966. return nil
  12967. case contact.FieldV3:
  12968. m.ResetV3()
  12969. return nil
  12970. case contact.FieldOrganizationID:
  12971. m.ResetOrganizationID()
  12972. return nil
  12973. case contact.FieldCtype:
  12974. m.ResetCtype()
  12975. return nil
  12976. case contact.FieldCage:
  12977. m.ResetCage()
  12978. return nil
  12979. case contact.FieldCname:
  12980. m.ResetCname()
  12981. return nil
  12982. case contact.FieldCarea:
  12983. m.ResetCarea()
  12984. return nil
  12985. case contact.FieldCbirthday:
  12986. m.ResetCbirthday()
  12987. return nil
  12988. case contact.FieldCbirtharea:
  12989. m.ResetCbirtharea()
  12990. return nil
  12991. case contact.FieldCidcardNo:
  12992. m.ResetCidcardNo()
  12993. return nil
  12994. case contact.FieldCtitle:
  12995. m.ResetCtitle()
  12996. return nil
  12997. case contact.FieldCc:
  12998. m.ResetCc()
  12999. return nil
  13000. case contact.FieldPhone:
  13001. m.ResetPhone()
  13002. return nil
  13003. }
  13004. return fmt.Errorf("unknown Contact field %s", name)
  13005. }
  13006. // AddedEdges returns all edge names that were set/added in this mutation.
  13007. func (m *ContactMutation) AddedEdges() []string {
  13008. edges := make([]string, 0, 3)
  13009. if m.contact_relationships != nil {
  13010. edges = append(edges, contact.EdgeContactRelationships)
  13011. }
  13012. if m.contact_fields != nil {
  13013. edges = append(edges, contact.EdgeContactFields)
  13014. }
  13015. if m.contact_messages != nil {
  13016. edges = append(edges, contact.EdgeContactMessages)
  13017. }
  13018. return edges
  13019. }
  13020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13021. // name in this mutation.
  13022. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  13023. switch name {
  13024. case contact.EdgeContactRelationships:
  13025. ids := make([]ent.Value, 0, len(m.contact_relationships))
  13026. for id := range m.contact_relationships {
  13027. ids = append(ids, id)
  13028. }
  13029. return ids
  13030. case contact.EdgeContactFields:
  13031. ids := make([]ent.Value, 0, len(m.contact_fields))
  13032. for id := range m.contact_fields {
  13033. ids = append(ids, id)
  13034. }
  13035. return ids
  13036. case contact.EdgeContactMessages:
  13037. ids := make([]ent.Value, 0, len(m.contact_messages))
  13038. for id := range m.contact_messages {
  13039. ids = append(ids, id)
  13040. }
  13041. return ids
  13042. }
  13043. return nil
  13044. }
  13045. // RemovedEdges returns all edge names that were removed in this mutation.
  13046. func (m *ContactMutation) RemovedEdges() []string {
  13047. edges := make([]string, 0, 3)
  13048. if m.removedcontact_relationships != nil {
  13049. edges = append(edges, contact.EdgeContactRelationships)
  13050. }
  13051. if m.removedcontact_fields != nil {
  13052. edges = append(edges, contact.EdgeContactFields)
  13053. }
  13054. if m.removedcontact_messages != nil {
  13055. edges = append(edges, contact.EdgeContactMessages)
  13056. }
  13057. return edges
  13058. }
  13059. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13060. // the given name in this mutation.
  13061. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  13062. switch name {
  13063. case contact.EdgeContactRelationships:
  13064. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  13065. for id := range m.removedcontact_relationships {
  13066. ids = append(ids, id)
  13067. }
  13068. return ids
  13069. case contact.EdgeContactFields:
  13070. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  13071. for id := range m.removedcontact_fields {
  13072. ids = append(ids, id)
  13073. }
  13074. return ids
  13075. case contact.EdgeContactMessages:
  13076. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  13077. for id := range m.removedcontact_messages {
  13078. ids = append(ids, id)
  13079. }
  13080. return ids
  13081. }
  13082. return nil
  13083. }
  13084. // ClearedEdges returns all edge names that were cleared in this mutation.
  13085. func (m *ContactMutation) ClearedEdges() []string {
  13086. edges := make([]string, 0, 3)
  13087. if m.clearedcontact_relationships {
  13088. edges = append(edges, contact.EdgeContactRelationships)
  13089. }
  13090. if m.clearedcontact_fields {
  13091. edges = append(edges, contact.EdgeContactFields)
  13092. }
  13093. if m.clearedcontact_messages {
  13094. edges = append(edges, contact.EdgeContactMessages)
  13095. }
  13096. return edges
  13097. }
  13098. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13099. // was cleared in this mutation.
  13100. func (m *ContactMutation) EdgeCleared(name string) bool {
  13101. switch name {
  13102. case contact.EdgeContactRelationships:
  13103. return m.clearedcontact_relationships
  13104. case contact.EdgeContactFields:
  13105. return m.clearedcontact_fields
  13106. case contact.EdgeContactMessages:
  13107. return m.clearedcontact_messages
  13108. }
  13109. return false
  13110. }
  13111. // ClearEdge clears the value of the edge with the given name. It returns an error
  13112. // if that edge is not defined in the schema.
  13113. func (m *ContactMutation) ClearEdge(name string) error {
  13114. switch name {
  13115. }
  13116. return fmt.Errorf("unknown Contact unique edge %s", name)
  13117. }
  13118. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13119. // It returns an error if the edge is not defined in the schema.
  13120. func (m *ContactMutation) ResetEdge(name string) error {
  13121. switch name {
  13122. case contact.EdgeContactRelationships:
  13123. m.ResetContactRelationships()
  13124. return nil
  13125. case contact.EdgeContactFields:
  13126. m.ResetContactFields()
  13127. return nil
  13128. case contact.EdgeContactMessages:
  13129. m.ResetContactMessages()
  13130. return nil
  13131. }
  13132. return fmt.Errorf("unknown Contact edge %s", name)
  13133. }
  13134. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  13135. type ContactFieldMutation struct {
  13136. config
  13137. op Op
  13138. typ string
  13139. id *uint64
  13140. created_at *time.Time
  13141. updated_at *time.Time
  13142. status *uint8
  13143. addstatus *int8
  13144. deleted_at *time.Time
  13145. form_id *string
  13146. value *[]string
  13147. appendvalue []string
  13148. clearedFields map[string]struct{}
  13149. field_contact *uint64
  13150. clearedfield_contact bool
  13151. done bool
  13152. oldValue func(context.Context) (*ContactField, error)
  13153. predicates []predicate.ContactField
  13154. }
  13155. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  13156. // contactfieldOption allows management of the mutation configuration using functional options.
  13157. type contactfieldOption func(*ContactFieldMutation)
  13158. // newContactFieldMutation creates new mutation for the ContactField entity.
  13159. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  13160. m := &ContactFieldMutation{
  13161. config: c,
  13162. op: op,
  13163. typ: TypeContactField,
  13164. clearedFields: make(map[string]struct{}),
  13165. }
  13166. for _, opt := range opts {
  13167. opt(m)
  13168. }
  13169. return m
  13170. }
  13171. // withContactFieldID sets the ID field of the mutation.
  13172. func withContactFieldID(id uint64) contactfieldOption {
  13173. return func(m *ContactFieldMutation) {
  13174. var (
  13175. err error
  13176. once sync.Once
  13177. value *ContactField
  13178. )
  13179. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  13180. once.Do(func() {
  13181. if m.done {
  13182. err = errors.New("querying old values post mutation is not allowed")
  13183. } else {
  13184. value, err = m.Client().ContactField.Get(ctx, id)
  13185. }
  13186. })
  13187. return value, err
  13188. }
  13189. m.id = &id
  13190. }
  13191. }
  13192. // withContactField sets the old ContactField of the mutation.
  13193. func withContactField(node *ContactField) contactfieldOption {
  13194. return func(m *ContactFieldMutation) {
  13195. m.oldValue = func(context.Context) (*ContactField, error) {
  13196. return node, nil
  13197. }
  13198. m.id = &node.ID
  13199. }
  13200. }
  13201. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13202. // executed in a transaction (ent.Tx), a transactional client is returned.
  13203. func (m ContactFieldMutation) Client() *Client {
  13204. client := &Client{config: m.config}
  13205. client.init()
  13206. return client
  13207. }
  13208. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13209. // it returns an error otherwise.
  13210. func (m ContactFieldMutation) Tx() (*Tx, error) {
  13211. if _, ok := m.driver.(*txDriver); !ok {
  13212. return nil, errors.New("ent: mutation is not running in a transaction")
  13213. }
  13214. tx := &Tx{config: m.config}
  13215. tx.init()
  13216. return tx, nil
  13217. }
  13218. // SetID sets the value of the id field. Note that this
  13219. // operation is only accepted on creation of ContactField entities.
  13220. func (m *ContactFieldMutation) SetID(id uint64) {
  13221. m.id = &id
  13222. }
  13223. // ID returns the ID value in the mutation. Note that the ID is only available
  13224. // if it was provided to the builder or after it was returned from the database.
  13225. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  13226. if m.id == nil {
  13227. return
  13228. }
  13229. return *m.id, true
  13230. }
  13231. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13232. // That means, if the mutation is applied within a transaction with an isolation level such
  13233. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13234. // or updated by the mutation.
  13235. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  13236. switch {
  13237. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13238. id, exists := m.ID()
  13239. if exists {
  13240. return []uint64{id}, nil
  13241. }
  13242. fallthrough
  13243. case m.op.Is(OpUpdate | OpDelete):
  13244. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  13245. default:
  13246. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13247. }
  13248. }
  13249. // SetCreatedAt sets the "created_at" field.
  13250. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  13251. m.created_at = &t
  13252. }
  13253. // CreatedAt returns the value of the "created_at" field in the mutation.
  13254. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  13255. v := m.created_at
  13256. if v == nil {
  13257. return
  13258. }
  13259. return *v, true
  13260. }
  13261. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  13262. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13264. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13265. if !m.op.Is(OpUpdateOne) {
  13266. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13267. }
  13268. if m.id == nil || m.oldValue == nil {
  13269. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13270. }
  13271. oldValue, err := m.oldValue(ctx)
  13272. if err != nil {
  13273. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13274. }
  13275. return oldValue.CreatedAt, nil
  13276. }
  13277. // ResetCreatedAt resets all changes to the "created_at" field.
  13278. func (m *ContactFieldMutation) ResetCreatedAt() {
  13279. m.created_at = nil
  13280. }
  13281. // SetUpdatedAt sets the "updated_at" field.
  13282. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  13283. m.updated_at = &t
  13284. }
  13285. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13286. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  13287. v := m.updated_at
  13288. if v == nil {
  13289. return
  13290. }
  13291. return *v, true
  13292. }
  13293. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  13294. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13296. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13297. if !m.op.Is(OpUpdateOne) {
  13298. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13299. }
  13300. if m.id == nil || m.oldValue == nil {
  13301. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13302. }
  13303. oldValue, err := m.oldValue(ctx)
  13304. if err != nil {
  13305. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13306. }
  13307. return oldValue.UpdatedAt, nil
  13308. }
  13309. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13310. func (m *ContactFieldMutation) ResetUpdatedAt() {
  13311. m.updated_at = nil
  13312. }
  13313. // SetStatus sets the "status" field.
  13314. func (m *ContactFieldMutation) SetStatus(u uint8) {
  13315. m.status = &u
  13316. m.addstatus = nil
  13317. }
  13318. // Status returns the value of the "status" field in the mutation.
  13319. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  13320. v := m.status
  13321. if v == nil {
  13322. return
  13323. }
  13324. return *v, true
  13325. }
  13326. // OldStatus returns the old "status" field's value of the ContactField entity.
  13327. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13329. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13330. if !m.op.Is(OpUpdateOne) {
  13331. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13332. }
  13333. if m.id == nil || m.oldValue == nil {
  13334. return v, errors.New("OldStatus requires an ID field in the mutation")
  13335. }
  13336. oldValue, err := m.oldValue(ctx)
  13337. if err != nil {
  13338. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13339. }
  13340. return oldValue.Status, nil
  13341. }
  13342. // AddStatus adds u to the "status" field.
  13343. func (m *ContactFieldMutation) AddStatus(u int8) {
  13344. if m.addstatus != nil {
  13345. *m.addstatus += u
  13346. } else {
  13347. m.addstatus = &u
  13348. }
  13349. }
  13350. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13351. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  13352. v := m.addstatus
  13353. if v == nil {
  13354. return
  13355. }
  13356. return *v, true
  13357. }
  13358. // ClearStatus clears the value of the "status" field.
  13359. func (m *ContactFieldMutation) ClearStatus() {
  13360. m.status = nil
  13361. m.addstatus = nil
  13362. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  13363. }
  13364. // StatusCleared returns if the "status" field was cleared in this mutation.
  13365. func (m *ContactFieldMutation) StatusCleared() bool {
  13366. _, ok := m.clearedFields[contactfield.FieldStatus]
  13367. return ok
  13368. }
  13369. // ResetStatus resets all changes to the "status" field.
  13370. func (m *ContactFieldMutation) ResetStatus() {
  13371. m.status = nil
  13372. m.addstatus = nil
  13373. delete(m.clearedFields, contactfield.FieldStatus)
  13374. }
  13375. // SetDeletedAt sets the "deleted_at" field.
  13376. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  13377. m.deleted_at = &t
  13378. }
  13379. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13380. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  13381. v := m.deleted_at
  13382. if v == nil {
  13383. return
  13384. }
  13385. return *v, true
  13386. }
  13387. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  13388. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13390. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13391. if !m.op.Is(OpUpdateOne) {
  13392. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13393. }
  13394. if m.id == nil || m.oldValue == nil {
  13395. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13396. }
  13397. oldValue, err := m.oldValue(ctx)
  13398. if err != nil {
  13399. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13400. }
  13401. return oldValue.DeletedAt, nil
  13402. }
  13403. // ClearDeletedAt clears the value of the "deleted_at" field.
  13404. func (m *ContactFieldMutation) ClearDeletedAt() {
  13405. m.deleted_at = nil
  13406. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  13407. }
  13408. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13409. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  13410. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  13411. return ok
  13412. }
  13413. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13414. func (m *ContactFieldMutation) ResetDeletedAt() {
  13415. m.deleted_at = nil
  13416. delete(m.clearedFields, contactfield.FieldDeletedAt)
  13417. }
  13418. // SetContactID sets the "contact_id" field.
  13419. func (m *ContactFieldMutation) SetContactID(u uint64) {
  13420. m.field_contact = &u
  13421. }
  13422. // ContactID returns the value of the "contact_id" field in the mutation.
  13423. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  13424. v := m.field_contact
  13425. if v == nil {
  13426. return
  13427. }
  13428. return *v, true
  13429. }
  13430. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  13431. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13433. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13434. if !m.op.Is(OpUpdateOne) {
  13435. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13436. }
  13437. if m.id == nil || m.oldValue == nil {
  13438. return v, errors.New("OldContactID requires an ID field in the mutation")
  13439. }
  13440. oldValue, err := m.oldValue(ctx)
  13441. if err != nil {
  13442. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13443. }
  13444. return oldValue.ContactID, nil
  13445. }
  13446. // ResetContactID resets all changes to the "contact_id" field.
  13447. func (m *ContactFieldMutation) ResetContactID() {
  13448. m.field_contact = nil
  13449. }
  13450. // SetFormID sets the "form_id" field.
  13451. func (m *ContactFieldMutation) SetFormID(s string) {
  13452. m.form_id = &s
  13453. }
  13454. // FormID returns the value of the "form_id" field in the mutation.
  13455. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  13456. v := m.form_id
  13457. if v == nil {
  13458. return
  13459. }
  13460. return *v, true
  13461. }
  13462. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  13463. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13465. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  13466. if !m.op.Is(OpUpdateOne) {
  13467. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  13468. }
  13469. if m.id == nil || m.oldValue == nil {
  13470. return v, errors.New("OldFormID requires an ID field in the mutation")
  13471. }
  13472. oldValue, err := m.oldValue(ctx)
  13473. if err != nil {
  13474. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  13475. }
  13476. return oldValue.FormID, nil
  13477. }
  13478. // ResetFormID resets all changes to the "form_id" field.
  13479. func (m *ContactFieldMutation) ResetFormID() {
  13480. m.form_id = nil
  13481. }
  13482. // SetValue sets the "value" field.
  13483. func (m *ContactFieldMutation) SetValue(s []string) {
  13484. m.value = &s
  13485. m.appendvalue = nil
  13486. }
  13487. // Value returns the value of the "value" field in the mutation.
  13488. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  13489. v := m.value
  13490. if v == nil {
  13491. return
  13492. }
  13493. return *v, true
  13494. }
  13495. // OldValue returns the old "value" field's value of the ContactField entity.
  13496. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13498. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  13499. if !m.op.Is(OpUpdateOne) {
  13500. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  13501. }
  13502. if m.id == nil || m.oldValue == nil {
  13503. return v, errors.New("OldValue requires an ID field in the mutation")
  13504. }
  13505. oldValue, err := m.oldValue(ctx)
  13506. if err != nil {
  13507. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  13508. }
  13509. return oldValue.Value, nil
  13510. }
  13511. // AppendValue adds s to the "value" field.
  13512. func (m *ContactFieldMutation) AppendValue(s []string) {
  13513. m.appendvalue = append(m.appendvalue, s...)
  13514. }
  13515. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  13516. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  13517. if len(m.appendvalue) == 0 {
  13518. return nil, false
  13519. }
  13520. return m.appendvalue, true
  13521. }
  13522. // ResetValue resets all changes to the "value" field.
  13523. func (m *ContactFieldMutation) ResetValue() {
  13524. m.value = nil
  13525. m.appendvalue = nil
  13526. }
  13527. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  13528. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  13529. m.field_contact = &id
  13530. }
  13531. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  13532. func (m *ContactFieldMutation) ClearFieldContact() {
  13533. m.clearedfield_contact = true
  13534. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  13535. }
  13536. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  13537. func (m *ContactFieldMutation) FieldContactCleared() bool {
  13538. return m.clearedfield_contact
  13539. }
  13540. // FieldContactID returns the "field_contact" edge ID in the mutation.
  13541. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  13542. if m.field_contact != nil {
  13543. return *m.field_contact, true
  13544. }
  13545. return
  13546. }
  13547. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  13548. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13549. // FieldContactID instead. It exists only for internal usage by the builders.
  13550. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  13551. if id := m.field_contact; id != nil {
  13552. ids = append(ids, *id)
  13553. }
  13554. return
  13555. }
  13556. // ResetFieldContact resets all changes to the "field_contact" edge.
  13557. func (m *ContactFieldMutation) ResetFieldContact() {
  13558. m.field_contact = nil
  13559. m.clearedfield_contact = false
  13560. }
  13561. // Where appends a list predicates to the ContactFieldMutation builder.
  13562. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  13563. m.predicates = append(m.predicates, ps...)
  13564. }
  13565. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  13566. // users can use type-assertion to append predicates that do not depend on any generated package.
  13567. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  13568. p := make([]predicate.ContactField, len(ps))
  13569. for i := range ps {
  13570. p[i] = ps[i]
  13571. }
  13572. m.Where(p...)
  13573. }
  13574. // Op returns the operation name.
  13575. func (m *ContactFieldMutation) Op() Op {
  13576. return m.op
  13577. }
  13578. // SetOp allows setting the mutation operation.
  13579. func (m *ContactFieldMutation) SetOp(op Op) {
  13580. m.op = op
  13581. }
  13582. // Type returns the node type of this mutation (ContactField).
  13583. func (m *ContactFieldMutation) Type() string {
  13584. return m.typ
  13585. }
  13586. // Fields returns all fields that were changed during this mutation. Note that in
  13587. // order to get all numeric fields that were incremented/decremented, call
  13588. // AddedFields().
  13589. func (m *ContactFieldMutation) Fields() []string {
  13590. fields := make([]string, 0, 7)
  13591. if m.created_at != nil {
  13592. fields = append(fields, contactfield.FieldCreatedAt)
  13593. }
  13594. if m.updated_at != nil {
  13595. fields = append(fields, contactfield.FieldUpdatedAt)
  13596. }
  13597. if m.status != nil {
  13598. fields = append(fields, contactfield.FieldStatus)
  13599. }
  13600. if m.deleted_at != nil {
  13601. fields = append(fields, contactfield.FieldDeletedAt)
  13602. }
  13603. if m.field_contact != nil {
  13604. fields = append(fields, contactfield.FieldContactID)
  13605. }
  13606. if m.form_id != nil {
  13607. fields = append(fields, contactfield.FieldFormID)
  13608. }
  13609. if m.value != nil {
  13610. fields = append(fields, contactfield.FieldValue)
  13611. }
  13612. return fields
  13613. }
  13614. // Field returns the value of a field with the given name. The second boolean
  13615. // return value indicates that this field was not set, or was not defined in the
  13616. // schema.
  13617. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  13618. switch name {
  13619. case contactfield.FieldCreatedAt:
  13620. return m.CreatedAt()
  13621. case contactfield.FieldUpdatedAt:
  13622. return m.UpdatedAt()
  13623. case contactfield.FieldStatus:
  13624. return m.Status()
  13625. case contactfield.FieldDeletedAt:
  13626. return m.DeletedAt()
  13627. case contactfield.FieldContactID:
  13628. return m.ContactID()
  13629. case contactfield.FieldFormID:
  13630. return m.FormID()
  13631. case contactfield.FieldValue:
  13632. return m.Value()
  13633. }
  13634. return nil, false
  13635. }
  13636. // OldField returns the old value of the field from the database. An error is
  13637. // returned if the mutation operation is not UpdateOne, or the query to the
  13638. // database failed.
  13639. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13640. switch name {
  13641. case contactfield.FieldCreatedAt:
  13642. return m.OldCreatedAt(ctx)
  13643. case contactfield.FieldUpdatedAt:
  13644. return m.OldUpdatedAt(ctx)
  13645. case contactfield.FieldStatus:
  13646. return m.OldStatus(ctx)
  13647. case contactfield.FieldDeletedAt:
  13648. return m.OldDeletedAt(ctx)
  13649. case contactfield.FieldContactID:
  13650. return m.OldContactID(ctx)
  13651. case contactfield.FieldFormID:
  13652. return m.OldFormID(ctx)
  13653. case contactfield.FieldValue:
  13654. return m.OldValue(ctx)
  13655. }
  13656. return nil, fmt.Errorf("unknown ContactField field %s", name)
  13657. }
  13658. // SetField sets the value of a field with the given name. It returns an error if
  13659. // the field is not defined in the schema, or if the type mismatched the field
  13660. // type.
  13661. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  13662. switch name {
  13663. case contactfield.FieldCreatedAt:
  13664. v, ok := value.(time.Time)
  13665. if !ok {
  13666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13667. }
  13668. m.SetCreatedAt(v)
  13669. return nil
  13670. case contactfield.FieldUpdatedAt:
  13671. v, ok := value.(time.Time)
  13672. if !ok {
  13673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13674. }
  13675. m.SetUpdatedAt(v)
  13676. return nil
  13677. case contactfield.FieldStatus:
  13678. v, ok := value.(uint8)
  13679. if !ok {
  13680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13681. }
  13682. m.SetStatus(v)
  13683. return nil
  13684. case contactfield.FieldDeletedAt:
  13685. v, ok := value.(time.Time)
  13686. if !ok {
  13687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13688. }
  13689. m.SetDeletedAt(v)
  13690. return nil
  13691. case contactfield.FieldContactID:
  13692. v, ok := value.(uint64)
  13693. if !ok {
  13694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13695. }
  13696. m.SetContactID(v)
  13697. return nil
  13698. case contactfield.FieldFormID:
  13699. v, ok := value.(string)
  13700. if !ok {
  13701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13702. }
  13703. m.SetFormID(v)
  13704. return nil
  13705. case contactfield.FieldValue:
  13706. v, ok := value.([]string)
  13707. if !ok {
  13708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13709. }
  13710. m.SetValue(v)
  13711. return nil
  13712. }
  13713. return fmt.Errorf("unknown ContactField field %s", name)
  13714. }
  13715. // AddedFields returns all numeric fields that were incremented/decremented during
  13716. // this mutation.
  13717. func (m *ContactFieldMutation) AddedFields() []string {
  13718. var fields []string
  13719. if m.addstatus != nil {
  13720. fields = append(fields, contactfield.FieldStatus)
  13721. }
  13722. return fields
  13723. }
  13724. // AddedField returns the numeric value that was incremented/decremented on a field
  13725. // with the given name. The second boolean return value indicates that this field
  13726. // was not set, or was not defined in the schema.
  13727. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  13728. switch name {
  13729. case contactfield.FieldStatus:
  13730. return m.AddedStatus()
  13731. }
  13732. return nil, false
  13733. }
  13734. // AddField adds the value to the field with the given name. It returns an error if
  13735. // the field is not defined in the schema, or if the type mismatched the field
  13736. // type.
  13737. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  13738. switch name {
  13739. case contactfield.FieldStatus:
  13740. v, ok := value.(int8)
  13741. if !ok {
  13742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13743. }
  13744. m.AddStatus(v)
  13745. return nil
  13746. }
  13747. return fmt.Errorf("unknown ContactField numeric field %s", name)
  13748. }
  13749. // ClearedFields returns all nullable fields that were cleared during this
  13750. // mutation.
  13751. func (m *ContactFieldMutation) ClearedFields() []string {
  13752. var fields []string
  13753. if m.FieldCleared(contactfield.FieldStatus) {
  13754. fields = append(fields, contactfield.FieldStatus)
  13755. }
  13756. if m.FieldCleared(contactfield.FieldDeletedAt) {
  13757. fields = append(fields, contactfield.FieldDeletedAt)
  13758. }
  13759. return fields
  13760. }
  13761. // FieldCleared returns a boolean indicating if a field with the given name was
  13762. // cleared in this mutation.
  13763. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  13764. _, ok := m.clearedFields[name]
  13765. return ok
  13766. }
  13767. // ClearField clears the value of the field with the given name. It returns an
  13768. // error if the field is not defined in the schema.
  13769. func (m *ContactFieldMutation) ClearField(name string) error {
  13770. switch name {
  13771. case contactfield.FieldStatus:
  13772. m.ClearStatus()
  13773. return nil
  13774. case contactfield.FieldDeletedAt:
  13775. m.ClearDeletedAt()
  13776. return nil
  13777. }
  13778. return fmt.Errorf("unknown ContactField nullable field %s", name)
  13779. }
  13780. // ResetField resets all changes in the mutation for the field with the given name.
  13781. // It returns an error if the field is not defined in the schema.
  13782. func (m *ContactFieldMutation) ResetField(name string) error {
  13783. switch name {
  13784. case contactfield.FieldCreatedAt:
  13785. m.ResetCreatedAt()
  13786. return nil
  13787. case contactfield.FieldUpdatedAt:
  13788. m.ResetUpdatedAt()
  13789. return nil
  13790. case contactfield.FieldStatus:
  13791. m.ResetStatus()
  13792. return nil
  13793. case contactfield.FieldDeletedAt:
  13794. m.ResetDeletedAt()
  13795. return nil
  13796. case contactfield.FieldContactID:
  13797. m.ResetContactID()
  13798. return nil
  13799. case contactfield.FieldFormID:
  13800. m.ResetFormID()
  13801. return nil
  13802. case contactfield.FieldValue:
  13803. m.ResetValue()
  13804. return nil
  13805. }
  13806. return fmt.Errorf("unknown ContactField field %s", name)
  13807. }
  13808. // AddedEdges returns all edge names that were set/added in this mutation.
  13809. func (m *ContactFieldMutation) AddedEdges() []string {
  13810. edges := make([]string, 0, 1)
  13811. if m.field_contact != nil {
  13812. edges = append(edges, contactfield.EdgeFieldContact)
  13813. }
  13814. return edges
  13815. }
  13816. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13817. // name in this mutation.
  13818. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  13819. switch name {
  13820. case contactfield.EdgeFieldContact:
  13821. if id := m.field_contact; id != nil {
  13822. return []ent.Value{*id}
  13823. }
  13824. }
  13825. return nil
  13826. }
  13827. // RemovedEdges returns all edge names that were removed in this mutation.
  13828. func (m *ContactFieldMutation) RemovedEdges() []string {
  13829. edges := make([]string, 0, 1)
  13830. return edges
  13831. }
  13832. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13833. // the given name in this mutation.
  13834. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  13835. return nil
  13836. }
  13837. // ClearedEdges returns all edge names that were cleared in this mutation.
  13838. func (m *ContactFieldMutation) ClearedEdges() []string {
  13839. edges := make([]string, 0, 1)
  13840. if m.clearedfield_contact {
  13841. edges = append(edges, contactfield.EdgeFieldContact)
  13842. }
  13843. return edges
  13844. }
  13845. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13846. // was cleared in this mutation.
  13847. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  13848. switch name {
  13849. case contactfield.EdgeFieldContact:
  13850. return m.clearedfield_contact
  13851. }
  13852. return false
  13853. }
  13854. // ClearEdge clears the value of the edge with the given name. It returns an error
  13855. // if that edge is not defined in the schema.
  13856. func (m *ContactFieldMutation) ClearEdge(name string) error {
  13857. switch name {
  13858. case contactfield.EdgeFieldContact:
  13859. m.ClearFieldContact()
  13860. return nil
  13861. }
  13862. return fmt.Errorf("unknown ContactField unique edge %s", name)
  13863. }
  13864. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13865. // It returns an error if the edge is not defined in the schema.
  13866. func (m *ContactFieldMutation) ResetEdge(name string) error {
  13867. switch name {
  13868. case contactfield.EdgeFieldContact:
  13869. m.ResetFieldContact()
  13870. return nil
  13871. }
  13872. return fmt.Errorf("unknown ContactField edge %s", name)
  13873. }
  13874. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  13875. type ContactFieldTemplateMutation struct {
  13876. config
  13877. op Op
  13878. typ string
  13879. id *uint64
  13880. created_at *time.Time
  13881. updated_at *time.Time
  13882. status *uint8
  13883. addstatus *int8
  13884. deleted_at *time.Time
  13885. organization_id *uint64
  13886. addorganization_id *int64
  13887. template *[]custom_types.ContactFieldTemplate
  13888. appendtemplate []custom_types.ContactFieldTemplate
  13889. clearedFields map[string]struct{}
  13890. done bool
  13891. oldValue func(context.Context) (*ContactFieldTemplate, error)
  13892. predicates []predicate.ContactFieldTemplate
  13893. }
  13894. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  13895. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  13896. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  13897. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  13898. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  13899. m := &ContactFieldTemplateMutation{
  13900. config: c,
  13901. op: op,
  13902. typ: TypeContactFieldTemplate,
  13903. clearedFields: make(map[string]struct{}),
  13904. }
  13905. for _, opt := range opts {
  13906. opt(m)
  13907. }
  13908. return m
  13909. }
  13910. // withContactFieldTemplateID sets the ID field of the mutation.
  13911. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  13912. return func(m *ContactFieldTemplateMutation) {
  13913. var (
  13914. err error
  13915. once sync.Once
  13916. value *ContactFieldTemplate
  13917. )
  13918. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  13919. once.Do(func() {
  13920. if m.done {
  13921. err = errors.New("querying old values post mutation is not allowed")
  13922. } else {
  13923. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  13924. }
  13925. })
  13926. return value, err
  13927. }
  13928. m.id = &id
  13929. }
  13930. }
  13931. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  13932. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  13933. return func(m *ContactFieldTemplateMutation) {
  13934. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  13935. return node, nil
  13936. }
  13937. m.id = &node.ID
  13938. }
  13939. }
  13940. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13941. // executed in a transaction (ent.Tx), a transactional client is returned.
  13942. func (m ContactFieldTemplateMutation) Client() *Client {
  13943. client := &Client{config: m.config}
  13944. client.init()
  13945. return client
  13946. }
  13947. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13948. // it returns an error otherwise.
  13949. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  13950. if _, ok := m.driver.(*txDriver); !ok {
  13951. return nil, errors.New("ent: mutation is not running in a transaction")
  13952. }
  13953. tx := &Tx{config: m.config}
  13954. tx.init()
  13955. return tx, nil
  13956. }
  13957. // SetID sets the value of the id field. Note that this
  13958. // operation is only accepted on creation of ContactFieldTemplate entities.
  13959. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  13960. m.id = &id
  13961. }
  13962. // ID returns the ID value in the mutation. Note that the ID is only available
  13963. // if it was provided to the builder or after it was returned from the database.
  13964. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  13965. if m.id == nil {
  13966. return
  13967. }
  13968. return *m.id, true
  13969. }
  13970. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13971. // That means, if the mutation is applied within a transaction with an isolation level such
  13972. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13973. // or updated by the mutation.
  13974. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  13975. switch {
  13976. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13977. id, exists := m.ID()
  13978. if exists {
  13979. return []uint64{id}, nil
  13980. }
  13981. fallthrough
  13982. case m.op.Is(OpUpdate | OpDelete):
  13983. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  13984. default:
  13985. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13986. }
  13987. }
  13988. // SetCreatedAt sets the "created_at" field.
  13989. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  13990. m.created_at = &t
  13991. }
  13992. // CreatedAt returns the value of the "created_at" field in the mutation.
  13993. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  13994. v := m.created_at
  13995. if v == nil {
  13996. return
  13997. }
  13998. return *v, true
  13999. }
  14000. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  14001. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14003. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14004. if !m.op.Is(OpUpdateOne) {
  14005. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14006. }
  14007. if m.id == nil || m.oldValue == nil {
  14008. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14009. }
  14010. oldValue, err := m.oldValue(ctx)
  14011. if err != nil {
  14012. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14013. }
  14014. return oldValue.CreatedAt, nil
  14015. }
  14016. // ResetCreatedAt resets all changes to the "created_at" field.
  14017. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  14018. m.created_at = nil
  14019. }
  14020. // SetUpdatedAt sets the "updated_at" field.
  14021. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  14022. m.updated_at = &t
  14023. }
  14024. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14025. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  14026. v := m.updated_at
  14027. if v == nil {
  14028. return
  14029. }
  14030. return *v, true
  14031. }
  14032. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  14033. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14035. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14036. if !m.op.Is(OpUpdateOne) {
  14037. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14038. }
  14039. if m.id == nil || m.oldValue == nil {
  14040. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14041. }
  14042. oldValue, err := m.oldValue(ctx)
  14043. if err != nil {
  14044. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14045. }
  14046. return oldValue.UpdatedAt, nil
  14047. }
  14048. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14049. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  14050. m.updated_at = nil
  14051. }
  14052. // SetStatus sets the "status" field.
  14053. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  14054. m.status = &u
  14055. m.addstatus = nil
  14056. }
  14057. // Status returns the value of the "status" field in the mutation.
  14058. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  14059. v := m.status
  14060. if v == nil {
  14061. return
  14062. }
  14063. return *v, true
  14064. }
  14065. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  14066. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14068. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14069. if !m.op.Is(OpUpdateOne) {
  14070. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14071. }
  14072. if m.id == nil || m.oldValue == nil {
  14073. return v, errors.New("OldStatus requires an ID field in the mutation")
  14074. }
  14075. oldValue, err := m.oldValue(ctx)
  14076. if err != nil {
  14077. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14078. }
  14079. return oldValue.Status, nil
  14080. }
  14081. // AddStatus adds u to the "status" field.
  14082. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  14083. if m.addstatus != nil {
  14084. *m.addstatus += u
  14085. } else {
  14086. m.addstatus = &u
  14087. }
  14088. }
  14089. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14090. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  14091. v := m.addstatus
  14092. if v == nil {
  14093. return
  14094. }
  14095. return *v, true
  14096. }
  14097. // ClearStatus clears the value of the "status" field.
  14098. func (m *ContactFieldTemplateMutation) ClearStatus() {
  14099. m.status = nil
  14100. m.addstatus = nil
  14101. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  14102. }
  14103. // StatusCleared returns if the "status" field was cleared in this mutation.
  14104. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  14105. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  14106. return ok
  14107. }
  14108. // ResetStatus resets all changes to the "status" field.
  14109. func (m *ContactFieldTemplateMutation) ResetStatus() {
  14110. m.status = nil
  14111. m.addstatus = nil
  14112. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  14113. }
  14114. // SetDeletedAt sets the "deleted_at" field.
  14115. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  14116. m.deleted_at = &t
  14117. }
  14118. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14119. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  14120. v := m.deleted_at
  14121. if v == nil {
  14122. return
  14123. }
  14124. return *v, true
  14125. }
  14126. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  14127. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14129. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14130. if !m.op.Is(OpUpdateOne) {
  14131. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14132. }
  14133. if m.id == nil || m.oldValue == nil {
  14134. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14135. }
  14136. oldValue, err := m.oldValue(ctx)
  14137. if err != nil {
  14138. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14139. }
  14140. return oldValue.DeletedAt, nil
  14141. }
  14142. // ClearDeletedAt clears the value of the "deleted_at" field.
  14143. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  14144. m.deleted_at = nil
  14145. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  14146. }
  14147. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14148. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  14149. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  14150. return ok
  14151. }
  14152. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14153. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  14154. m.deleted_at = nil
  14155. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  14156. }
  14157. // SetOrganizationID sets the "organization_id" field.
  14158. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  14159. m.organization_id = &u
  14160. m.addorganization_id = nil
  14161. }
  14162. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14163. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  14164. v := m.organization_id
  14165. if v == nil {
  14166. return
  14167. }
  14168. return *v, true
  14169. }
  14170. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  14171. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14173. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14174. if !m.op.Is(OpUpdateOne) {
  14175. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14176. }
  14177. if m.id == nil || m.oldValue == nil {
  14178. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14179. }
  14180. oldValue, err := m.oldValue(ctx)
  14181. if err != nil {
  14182. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14183. }
  14184. return oldValue.OrganizationID, nil
  14185. }
  14186. // AddOrganizationID adds u to the "organization_id" field.
  14187. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  14188. if m.addorganization_id != nil {
  14189. *m.addorganization_id += u
  14190. } else {
  14191. m.addorganization_id = &u
  14192. }
  14193. }
  14194. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14195. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  14196. v := m.addorganization_id
  14197. if v == nil {
  14198. return
  14199. }
  14200. return *v, true
  14201. }
  14202. // ResetOrganizationID resets all changes to the "organization_id" field.
  14203. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  14204. m.organization_id = nil
  14205. m.addorganization_id = nil
  14206. }
  14207. // SetTemplate sets the "template" field.
  14208. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  14209. m.template = &ctft
  14210. m.appendtemplate = nil
  14211. }
  14212. // Template returns the value of the "template" field in the mutation.
  14213. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  14214. v := m.template
  14215. if v == nil {
  14216. return
  14217. }
  14218. return *v, true
  14219. }
  14220. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  14221. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14223. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  14224. if !m.op.Is(OpUpdateOne) {
  14225. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  14226. }
  14227. if m.id == nil || m.oldValue == nil {
  14228. return v, errors.New("OldTemplate requires an ID field in the mutation")
  14229. }
  14230. oldValue, err := m.oldValue(ctx)
  14231. if err != nil {
  14232. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  14233. }
  14234. return oldValue.Template, nil
  14235. }
  14236. // AppendTemplate adds ctft to the "template" field.
  14237. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  14238. m.appendtemplate = append(m.appendtemplate, ctft...)
  14239. }
  14240. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  14241. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  14242. if len(m.appendtemplate) == 0 {
  14243. return nil, false
  14244. }
  14245. return m.appendtemplate, true
  14246. }
  14247. // ResetTemplate resets all changes to the "template" field.
  14248. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  14249. m.template = nil
  14250. m.appendtemplate = nil
  14251. }
  14252. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  14253. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  14254. m.predicates = append(m.predicates, ps...)
  14255. }
  14256. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  14257. // users can use type-assertion to append predicates that do not depend on any generated package.
  14258. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  14259. p := make([]predicate.ContactFieldTemplate, len(ps))
  14260. for i := range ps {
  14261. p[i] = ps[i]
  14262. }
  14263. m.Where(p...)
  14264. }
  14265. // Op returns the operation name.
  14266. func (m *ContactFieldTemplateMutation) Op() Op {
  14267. return m.op
  14268. }
  14269. // SetOp allows setting the mutation operation.
  14270. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  14271. m.op = op
  14272. }
  14273. // Type returns the node type of this mutation (ContactFieldTemplate).
  14274. func (m *ContactFieldTemplateMutation) Type() string {
  14275. return m.typ
  14276. }
  14277. // Fields returns all fields that were changed during this mutation. Note that in
  14278. // order to get all numeric fields that were incremented/decremented, call
  14279. // AddedFields().
  14280. func (m *ContactFieldTemplateMutation) Fields() []string {
  14281. fields := make([]string, 0, 6)
  14282. if m.created_at != nil {
  14283. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  14284. }
  14285. if m.updated_at != nil {
  14286. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  14287. }
  14288. if m.status != nil {
  14289. fields = append(fields, contactfieldtemplate.FieldStatus)
  14290. }
  14291. if m.deleted_at != nil {
  14292. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14293. }
  14294. if m.organization_id != nil {
  14295. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14296. }
  14297. if m.template != nil {
  14298. fields = append(fields, contactfieldtemplate.FieldTemplate)
  14299. }
  14300. return fields
  14301. }
  14302. // Field returns the value of a field with the given name. The second boolean
  14303. // return value indicates that this field was not set, or was not defined in the
  14304. // schema.
  14305. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  14306. switch name {
  14307. case contactfieldtemplate.FieldCreatedAt:
  14308. return m.CreatedAt()
  14309. case contactfieldtemplate.FieldUpdatedAt:
  14310. return m.UpdatedAt()
  14311. case contactfieldtemplate.FieldStatus:
  14312. return m.Status()
  14313. case contactfieldtemplate.FieldDeletedAt:
  14314. return m.DeletedAt()
  14315. case contactfieldtemplate.FieldOrganizationID:
  14316. return m.OrganizationID()
  14317. case contactfieldtemplate.FieldTemplate:
  14318. return m.Template()
  14319. }
  14320. return nil, false
  14321. }
  14322. // OldField returns the old value of the field from the database. An error is
  14323. // returned if the mutation operation is not UpdateOne, or the query to the
  14324. // database failed.
  14325. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14326. switch name {
  14327. case contactfieldtemplate.FieldCreatedAt:
  14328. return m.OldCreatedAt(ctx)
  14329. case contactfieldtemplate.FieldUpdatedAt:
  14330. return m.OldUpdatedAt(ctx)
  14331. case contactfieldtemplate.FieldStatus:
  14332. return m.OldStatus(ctx)
  14333. case contactfieldtemplate.FieldDeletedAt:
  14334. return m.OldDeletedAt(ctx)
  14335. case contactfieldtemplate.FieldOrganizationID:
  14336. return m.OldOrganizationID(ctx)
  14337. case contactfieldtemplate.FieldTemplate:
  14338. return m.OldTemplate(ctx)
  14339. }
  14340. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14341. }
  14342. // SetField sets the value of a field with the given name. It returns an error if
  14343. // the field is not defined in the schema, or if the type mismatched the field
  14344. // type.
  14345. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  14346. switch name {
  14347. case contactfieldtemplate.FieldCreatedAt:
  14348. v, ok := value.(time.Time)
  14349. if !ok {
  14350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14351. }
  14352. m.SetCreatedAt(v)
  14353. return nil
  14354. case contactfieldtemplate.FieldUpdatedAt:
  14355. v, ok := value.(time.Time)
  14356. if !ok {
  14357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14358. }
  14359. m.SetUpdatedAt(v)
  14360. return nil
  14361. case contactfieldtemplate.FieldStatus:
  14362. v, ok := value.(uint8)
  14363. if !ok {
  14364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14365. }
  14366. m.SetStatus(v)
  14367. return nil
  14368. case contactfieldtemplate.FieldDeletedAt:
  14369. v, ok := value.(time.Time)
  14370. if !ok {
  14371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14372. }
  14373. m.SetDeletedAt(v)
  14374. return nil
  14375. case contactfieldtemplate.FieldOrganizationID:
  14376. v, ok := value.(uint64)
  14377. if !ok {
  14378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14379. }
  14380. m.SetOrganizationID(v)
  14381. return nil
  14382. case contactfieldtemplate.FieldTemplate:
  14383. v, ok := value.([]custom_types.ContactFieldTemplate)
  14384. if !ok {
  14385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14386. }
  14387. m.SetTemplate(v)
  14388. return nil
  14389. }
  14390. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14391. }
  14392. // AddedFields returns all numeric fields that were incremented/decremented during
  14393. // this mutation.
  14394. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  14395. var fields []string
  14396. if m.addstatus != nil {
  14397. fields = append(fields, contactfieldtemplate.FieldStatus)
  14398. }
  14399. if m.addorganization_id != nil {
  14400. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14401. }
  14402. return fields
  14403. }
  14404. // AddedField returns the numeric value that was incremented/decremented on a field
  14405. // with the given name. The second boolean return value indicates that this field
  14406. // was not set, or was not defined in the schema.
  14407. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  14408. switch name {
  14409. case contactfieldtemplate.FieldStatus:
  14410. return m.AddedStatus()
  14411. case contactfieldtemplate.FieldOrganizationID:
  14412. return m.AddedOrganizationID()
  14413. }
  14414. return nil, false
  14415. }
  14416. // AddField adds the value to the field with the given name. It returns an error if
  14417. // the field is not defined in the schema, or if the type mismatched the field
  14418. // type.
  14419. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  14420. switch name {
  14421. case contactfieldtemplate.FieldStatus:
  14422. v, ok := value.(int8)
  14423. if !ok {
  14424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14425. }
  14426. m.AddStatus(v)
  14427. return nil
  14428. case contactfieldtemplate.FieldOrganizationID:
  14429. v, ok := value.(int64)
  14430. if !ok {
  14431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14432. }
  14433. m.AddOrganizationID(v)
  14434. return nil
  14435. }
  14436. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  14437. }
  14438. // ClearedFields returns all nullable fields that were cleared during this
  14439. // mutation.
  14440. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  14441. var fields []string
  14442. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  14443. fields = append(fields, contactfieldtemplate.FieldStatus)
  14444. }
  14445. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  14446. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14447. }
  14448. return fields
  14449. }
  14450. // FieldCleared returns a boolean indicating if a field with the given name was
  14451. // cleared in this mutation.
  14452. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  14453. _, ok := m.clearedFields[name]
  14454. return ok
  14455. }
  14456. // ClearField clears the value of the field with the given name. It returns an
  14457. // error if the field is not defined in the schema.
  14458. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  14459. switch name {
  14460. case contactfieldtemplate.FieldStatus:
  14461. m.ClearStatus()
  14462. return nil
  14463. case contactfieldtemplate.FieldDeletedAt:
  14464. m.ClearDeletedAt()
  14465. return nil
  14466. }
  14467. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  14468. }
  14469. // ResetField resets all changes in the mutation for the field with the given name.
  14470. // It returns an error if the field is not defined in the schema.
  14471. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  14472. switch name {
  14473. case contactfieldtemplate.FieldCreatedAt:
  14474. m.ResetCreatedAt()
  14475. return nil
  14476. case contactfieldtemplate.FieldUpdatedAt:
  14477. m.ResetUpdatedAt()
  14478. return nil
  14479. case contactfieldtemplate.FieldStatus:
  14480. m.ResetStatus()
  14481. return nil
  14482. case contactfieldtemplate.FieldDeletedAt:
  14483. m.ResetDeletedAt()
  14484. return nil
  14485. case contactfieldtemplate.FieldOrganizationID:
  14486. m.ResetOrganizationID()
  14487. return nil
  14488. case contactfieldtemplate.FieldTemplate:
  14489. m.ResetTemplate()
  14490. return nil
  14491. }
  14492. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14493. }
  14494. // AddedEdges returns all edge names that were set/added in this mutation.
  14495. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  14496. edges := make([]string, 0, 0)
  14497. return edges
  14498. }
  14499. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14500. // name in this mutation.
  14501. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  14502. return nil
  14503. }
  14504. // RemovedEdges returns all edge names that were removed in this mutation.
  14505. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  14506. edges := make([]string, 0, 0)
  14507. return edges
  14508. }
  14509. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14510. // the given name in this mutation.
  14511. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  14512. return nil
  14513. }
  14514. // ClearedEdges returns all edge names that were cleared in this mutation.
  14515. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  14516. edges := make([]string, 0, 0)
  14517. return edges
  14518. }
  14519. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14520. // was cleared in this mutation.
  14521. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  14522. return false
  14523. }
  14524. // ClearEdge clears the value of the edge with the given name. It returns an error
  14525. // if that edge is not defined in the schema.
  14526. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  14527. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  14528. }
  14529. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14530. // It returns an error if the edge is not defined in the schema.
  14531. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  14532. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  14533. }
  14534. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  14535. type CreditBalanceMutation struct {
  14536. config
  14537. op Op
  14538. typ string
  14539. id *uint64
  14540. created_at *time.Time
  14541. updated_at *time.Time
  14542. deleted_at *time.Time
  14543. user_id *string
  14544. balance *float32
  14545. addbalance *float32
  14546. status *int
  14547. addstatus *int
  14548. organization_id *uint64
  14549. addorganization_id *int64
  14550. clearedFields map[string]struct{}
  14551. done bool
  14552. oldValue func(context.Context) (*CreditBalance, error)
  14553. predicates []predicate.CreditBalance
  14554. }
  14555. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  14556. // creditbalanceOption allows management of the mutation configuration using functional options.
  14557. type creditbalanceOption func(*CreditBalanceMutation)
  14558. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  14559. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  14560. m := &CreditBalanceMutation{
  14561. config: c,
  14562. op: op,
  14563. typ: TypeCreditBalance,
  14564. clearedFields: make(map[string]struct{}),
  14565. }
  14566. for _, opt := range opts {
  14567. opt(m)
  14568. }
  14569. return m
  14570. }
  14571. // withCreditBalanceID sets the ID field of the mutation.
  14572. func withCreditBalanceID(id uint64) creditbalanceOption {
  14573. return func(m *CreditBalanceMutation) {
  14574. var (
  14575. err error
  14576. once sync.Once
  14577. value *CreditBalance
  14578. )
  14579. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  14580. once.Do(func() {
  14581. if m.done {
  14582. err = errors.New("querying old values post mutation is not allowed")
  14583. } else {
  14584. value, err = m.Client().CreditBalance.Get(ctx, id)
  14585. }
  14586. })
  14587. return value, err
  14588. }
  14589. m.id = &id
  14590. }
  14591. }
  14592. // withCreditBalance sets the old CreditBalance of the mutation.
  14593. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  14594. return func(m *CreditBalanceMutation) {
  14595. m.oldValue = func(context.Context) (*CreditBalance, error) {
  14596. return node, nil
  14597. }
  14598. m.id = &node.ID
  14599. }
  14600. }
  14601. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14602. // executed in a transaction (ent.Tx), a transactional client is returned.
  14603. func (m CreditBalanceMutation) Client() *Client {
  14604. client := &Client{config: m.config}
  14605. client.init()
  14606. return client
  14607. }
  14608. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14609. // it returns an error otherwise.
  14610. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  14611. if _, ok := m.driver.(*txDriver); !ok {
  14612. return nil, errors.New("ent: mutation is not running in a transaction")
  14613. }
  14614. tx := &Tx{config: m.config}
  14615. tx.init()
  14616. return tx, nil
  14617. }
  14618. // SetID sets the value of the id field. Note that this
  14619. // operation is only accepted on creation of CreditBalance entities.
  14620. func (m *CreditBalanceMutation) SetID(id uint64) {
  14621. m.id = &id
  14622. }
  14623. // ID returns the ID value in the mutation. Note that the ID is only available
  14624. // if it was provided to the builder or after it was returned from the database.
  14625. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  14626. if m.id == nil {
  14627. return
  14628. }
  14629. return *m.id, true
  14630. }
  14631. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14632. // That means, if the mutation is applied within a transaction with an isolation level such
  14633. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14634. // or updated by the mutation.
  14635. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  14636. switch {
  14637. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14638. id, exists := m.ID()
  14639. if exists {
  14640. return []uint64{id}, nil
  14641. }
  14642. fallthrough
  14643. case m.op.Is(OpUpdate | OpDelete):
  14644. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  14645. default:
  14646. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14647. }
  14648. }
  14649. // SetCreatedAt sets the "created_at" field.
  14650. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  14651. m.created_at = &t
  14652. }
  14653. // CreatedAt returns the value of the "created_at" field in the mutation.
  14654. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  14655. v := m.created_at
  14656. if v == nil {
  14657. return
  14658. }
  14659. return *v, true
  14660. }
  14661. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  14662. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14664. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14665. if !m.op.Is(OpUpdateOne) {
  14666. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14667. }
  14668. if m.id == nil || m.oldValue == nil {
  14669. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14670. }
  14671. oldValue, err := m.oldValue(ctx)
  14672. if err != nil {
  14673. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14674. }
  14675. return oldValue.CreatedAt, nil
  14676. }
  14677. // ResetCreatedAt resets all changes to the "created_at" field.
  14678. func (m *CreditBalanceMutation) ResetCreatedAt() {
  14679. m.created_at = nil
  14680. }
  14681. // SetUpdatedAt sets the "updated_at" field.
  14682. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  14683. m.updated_at = &t
  14684. }
  14685. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14686. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  14687. v := m.updated_at
  14688. if v == nil {
  14689. return
  14690. }
  14691. return *v, true
  14692. }
  14693. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  14694. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14696. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14697. if !m.op.Is(OpUpdateOne) {
  14698. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14699. }
  14700. if m.id == nil || m.oldValue == nil {
  14701. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14702. }
  14703. oldValue, err := m.oldValue(ctx)
  14704. if err != nil {
  14705. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14706. }
  14707. return oldValue.UpdatedAt, nil
  14708. }
  14709. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14710. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  14711. m.updated_at = nil
  14712. }
  14713. // SetDeletedAt sets the "deleted_at" field.
  14714. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  14715. m.deleted_at = &t
  14716. }
  14717. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14718. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  14719. v := m.deleted_at
  14720. if v == nil {
  14721. return
  14722. }
  14723. return *v, true
  14724. }
  14725. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  14726. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14728. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14729. if !m.op.Is(OpUpdateOne) {
  14730. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14731. }
  14732. if m.id == nil || m.oldValue == nil {
  14733. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14734. }
  14735. oldValue, err := m.oldValue(ctx)
  14736. if err != nil {
  14737. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14738. }
  14739. return oldValue.DeletedAt, nil
  14740. }
  14741. // ClearDeletedAt clears the value of the "deleted_at" field.
  14742. func (m *CreditBalanceMutation) ClearDeletedAt() {
  14743. m.deleted_at = nil
  14744. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  14745. }
  14746. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14747. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  14748. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  14749. return ok
  14750. }
  14751. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14752. func (m *CreditBalanceMutation) ResetDeletedAt() {
  14753. m.deleted_at = nil
  14754. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  14755. }
  14756. // SetUserID sets the "user_id" field.
  14757. func (m *CreditBalanceMutation) SetUserID(s string) {
  14758. m.user_id = &s
  14759. }
  14760. // UserID returns the value of the "user_id" field in the mutation.
  14761. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  14762. v := m.user_id
  14763. if v == nil {
  14764. return
  14765. }
  14766. return *v, true
  14767. }
  14768. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  14769. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14771. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  14772. if !m.op.Is(OpUpdateOne) {
  14773. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14774. }
  14775. if m.id == nil || m.oldValue == nil {
  14776. return v, errors.New("OldUserID requires an ID field in the mutation")
  14777. }
  14778. oldValue, err := m.oldValue(ctx)
  14779. if err != nil {
  14780. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14781. }
  14782. return oldValue.UserID, nil
  14783. }
  14784. // ClearUserID clears the value of the "user_id" field.
  14785. func (m *CreditBalanceMutation) ClearUserID() {
  14786. m.user_id = nil
  14787. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  14788. }
  14789. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14790. func (m *CreditBalanceMutation) UserIDCleared() bool {
  14791. _, ok := m.clearedFields[creditbalance.FieldUserID]
  14792. return ok
  14793. }
  14794. // ResetUserID resets all changes to the "user_id" field.
  14795. func (m *CreditBalanceMutation) ResetUserID() {
  14796. m.user_id = nil
  14797. delete(m.clearedFields, creditbalance.FieldUserID)
  14798. }
  14799. // SetBalance sets the "balance" field.
  14800. func (m *CreditBalanceMutation) SetBalance(f float32) {
  14801. m.balance = &f
  14802. m.addbalance = nil
  14803. }
  14804. // Balance returns the value of the "balance" field in the mutation.
  14805. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  14806. v := m.balance
  14807. if v == nil {
  14808. return
  14809. }
  14810. return *v, true
  14811. }
  14812. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  14813. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14815. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  14816. if !m.op.Is(OpUpdateOne) {
  14817. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  14818. }
  14819. if m.id == nil || m.oldValue == nil {
  14820. return v, errors.New("OldBalance requires an ID field in the mutation")
  14821. }
  14822. oldValue, err := m.oldValue(ctx)
  14823. if err != nil {
  14824. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  14825. }
  14826. return oldValue.Balance, nil
  14827. }
  14828. // AddBalance adds f to the "balance" field.
  14829. func (m *CreditBalanceMutation) AddBalance(f float32) {
  14830. if m.addbalance != nil {
  14831. *m.addbalance += f
  14832. } else {
  14833. m.addbalance = &f
  14834. }
  14835. }
  14836. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  14837. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  14838. v := m.addbalance
  14839. if v == nil {
  14840. return
  14841. }
  14842. return *v, true
  14843. }
  14844. // ResetBalance resets all changes to the "balance" field.
  14845. func (m *CreditBalanceMutation) ResetBalance() {
  14846. m.balance = nil
  14847. m.addbalance = nil
  14848. }
  14849. // SetStatus sets the "status" field.
  14850. func (m *CreditBalanceMutation) SetStatus(i int) {
  14851. m.status = &i
  14852. m.addstatus = nil
  14853. }
  14854. // Status returns the value of the "status" field in the mutation.
  14855. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  14856. v := m.status
  14857. if v == nil {
  14858. return
  14859. }
  14860. return *v, true
  14861. }
  14862. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  14863. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14865. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  14866. if !m.op.Is(OpUpdateOne) {
  14867. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14868. }
  14869. if m.id == nil || m.oldValue == nil {
  14870. return v, errors.New("OldStatus requires an ID field in the mutation")
  14871. }
  14872. oldValue, err := m.oldValue(ctx)
  14873. if err != nil {
  14874. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14875. }
  14876. return oldValue.Status, nil
  14877. }
  14878. // AddStatus adds i to the "status" field.
  14879. func (m *CreditBalanceMutation) AddStatus(i int) {
  14880. if m.addstatus != nil {
  14881. *m.addstatus += i
  14882. } else {
  14883. m.addstatus = &i
  14884. }
  14885. }
  14886. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14887. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  14888. v := m.addstatus
  14889. if v == nil {
  14890. return
  14891. }
  14892. return *v, true
  14893. }
  14894. // ClearStatus clears the value of the "status" field.
  14895. func (m *CreditBalanceMutation) ClearStatus() {
  14896. m.status = nil
  14897. m.addstatus = nil
  14898. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  14899. }
  14900. // StatusCleared returns if the "status" field was cleared in this mutation.
  14901. func (m *CreditBalanceMutation) StatusCleared() bool {
  14902. _, ok := m.clearedFields[creditbalance.FieldStatus]
  14903. return ok
  14904. }
  14905. // ResetStatus resets all changes to the "status" field.
  14906. func (m *CreditBalanceMutation) ResetStatus() {
  14907. m.status = nil
  14908. m.addstatus = nil
  14909. delete(m.clearedFields, creditbalance.FieldStatus)
  14910. }
  14911. // SetOrganizationID sets the "organization_id" field.
  14912. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  14913. m.organization_id = &u
  14914. m.addorganization_id = nil
  14915. }
  14916. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14917. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  14918. v := m.organization_id
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  14925. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14927. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14928. if !m.op.Is(OpUpdateOne) {
  14929. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14930. }
  14931. if m.id == nil || m.oldValue == nil {
  14932. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14933. }
  14934. oldValue, err := m.oldValue(ctx)
  14935. if err != nil {
  14936. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14937. }
  14938. return oldValue.OrganizationID, nil
  14939. }
  14940. // AddOrganizationID adds u to the "organization_id" field.
  14941. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  14942. if m.addorganization_id != nil {
  14943. *m.addorganization_id += u
  14944. } else {
  14945. m.addorganization_id = &u
  14946. }
  14947. }
  14948. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14949. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  14950. v := m.addorganization_id
  14951. if v == nil {
  14952. return
  14953. }
  14954. return *v, true
  14955. }
  14956. // ClearOrganizationID clears the value of the "organization_id" field.
  14957. func (m *CreditBalanceMutation) ClearOrganizationID() {
  14958. m.organization_id = nil
  14959. m.addorganization_id = nil
  14960. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  14961. }
  14962. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14963. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  14964. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  14965. return ok
  14966. }
  14967. // ResetOrganizationID resets all changes to the "organization_id" field.
  14968. func (m *CreditBalanceMutation) ResetOrganizationID() {
  14969. m.organization_id = nil
  14970. m.addorganization_id = nil
  14971. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  14972. }
  14973. // Where appends a list predicates to the CreditBalanceMutation builder.
  14974. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  14975. m.predicates = append(m.predicates, ps...)
  14976. }
  14977. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  14978. // users can use type-assertion to append predicates that do not depend on any generated package.
  14979. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  14980. p := make([]predicate.CreditBalance, len(ps))
  14981. for i := range ps {
  14982. p[i] = ps[i]
  14983. }
  14984. m.Where(p...)
  14985. }
  14986. // Op returns the operation name.
  14987. func (m *CreditBalanceMutation) Op() Op {
  14988. return m.op
  14989. }
  14990. // SetOp allows setting the mutation operation.
  14991. func (m *CreditBalanceMutation) SetOp(op Op) {
  14992. m.op = op
  14993. }
  14994. // Type returns the node type of this mutation (CreditBalance).
  14995. func (m *CreditBalanceMutation) Type() string {
  14996. return m.typ
  14997. }
  14998. // Fields returns all fields that were changed during this mutation. Note that in
  14999. // order to get all numeric fields that were incremented/decremented, call
  15000. // AddedFields().
  15001. func (m *CreditBalanceMutation) Fields() []string {
  15002. fields := make([]string, 0, 7)
  15003. if m.created_at != nil {
  15004. fields = append(fields, creditbalance.FieldCreatedAt)
  15005. }
  15006. if m.updated_at != nil {
  15007. fields = append(fields, creditbalance.FieldUpdatedAt)
  15008. }
  15009. if m.deleted_at != nil {
  15010. fields = append(fields, creditbalance.FieldDeletedAt)
  15011. }
  15012. if m.user_id != nil {
  15013. fields = append(fields, creditbalance.FieldUserID)
  15014. }
  15015. if m.balance != nil {
  15016. fields = append(fields, creditbalance.FieldBalance)
  15017. }
  15018. if m.status != nil {
  15019. fields = append(fields, creditbalance.FieldStatus)
  15020. }
  15021. if m.organization_id != nil {
  15022. fields = append(fields, creditbalance.FieldOrganizationID)
  15023. }
  15024. return fields
  15025. }
  15026. // Field returns the value of a field with the given name. The second boolean
  15027. // return value indicates that this field was not set, or was not defined in the
  15028. // schema.
  15029. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  15030. switch name {
  15031. case creditbalance.FieldCreatedAt:
  15032. return m.CreatedAt()
  15033. case creditbalance.FieldUpdatedAt:
  15034. return m.UpdatedAt()
  15035. case creditbalance.FieldDeletedAt:
  15036. return m.DeletedAt()
  15037. case creditbalance.FieldUserID:
  15038. return m.UserID()
  15039. case creditbalance.FieldBalance:
  15040. return m.Balance()
  15041. case creditbalance.FieldStatus:
  15042. return m.Status()
  15043. case creditbalance.FieldOrganizationID:
  15044. return m.OrganizationID()
  15045. }
  15046. return nil, false
  15047. }
  15048. // OldField returns the old value of the field from the database. An error is
  15049. // returned if the mutation operation is not UpdateOne, or the query to the
  15050. // database failed.
  15051. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15052. switch name {
  15053. case creditbalance.FieldCreatedAt:
  15054. return m.OldCreatedAt(ctx)
  15055. case creditbalance.FieldUpdatedAt:
  15056. return m.OldUpdatedAt(ctx)
  15057. case creditbalance.FieldDeletedAt:
  15058. return m.OldDeletedAt(ctx)
  15059. case creditbalance.FieldUserID:
  15060. return m.OldUserID(ctx)
  15061. case creditbalance.FieldBalance:
  15062. return m.OldBalance(ctx)
  15063. case creditbalance.FieldStatus:
  15064. return m.OldStatus(ctx)
  15065. case creditbalance.FieldOrganizationID:
  15066. return m.OldOrganizationID(ctx)
  15067. }
  15068. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  15069. }
  15070. // SetField sets the value of a field with the given name. It returns an error if
  15071. // the field is not defined in the schema, or if the type mismatched the field
  15072. // type.
  15073. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  15074. switch name {
  15075. case creditbalance.FieldCreatedAt:
  15076. v, ok := value.(time.Time)
  15077. if !ok {
  15078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15079. }
  15080. m.SetCreatedAt(v)
  15081. return nil
  15082. case creditbalance.FieldUpdatedAt:
  15083. v, ok := value.(time.Time)
  15084. if !ok {
  15085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15086. }
  15087. m.SetUpdatedAt(v)
  15088. return nil
  15089. case creditbalance.FieldDeletedAt:
  15090. v, ok := value.(time.Time)
  15091. if !ok {
  15092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15093. }
  15094. m.SetDeletedAt(v)
  15095. return nil
  15096. case creditbalance.FieldUserID:
  15097. v, ok := value.(string)
  15098. if !ok {
  15099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15100. }
  15101. m.SetUserID(v)
  15102. return nil
  15103. case creditbalance.FieldBalance:
  15104. v, ok := value.(float32)
  15105. if !ok {
  15106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15107. }
  15108. m.SetBalance(v)
  15109. return nil
  15110. case creditbalance.FieldStatus:
  15111. v, ok := value.(int)
  15112. if !ok {
  15113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15114. }
  15115. m.SetStatus(v)
  15116. return nil
  15117. case creditbalance.FieldOrganizationID:
  15118. v, ok := value.(uint64)
  15119. if !ok {
  15120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15121. }
  15122. m.SetOrganizationID(v)
  15123. return nil
  15124. }
  15125. return fmt.Errorf("unknown CreditBalance field %s", name)
  15126. }
  15127. // AddedFields returns all numeric fields that were incremented/decremented during
  15128. // this mutation.
  15129. func (m *CreditBalanceMutation) AddedFields() []string {
  15130. var fields []string
  15131. if m.addbalance != nil {
  15132. fields = append(fields, creditbalance.FieldBalance)
  15133. }
  15134. if m.addstatus != nil {
  15135. fields = append(fields, creditbalance.FieldStatus)
  15136. }
  15137. if m.addorganization_id != nil {
  15138. fields = append(fields, creditbalance.FieldOrganizationID)
  15139. }
  15140. return fields
  15141. }
  15142. // AddedField returns the numeric value that was incremented/decremented on a field
  15143. // with the given name. The second boolean return value indicates that this field
  15144. // was not set, or was not defined in the schema.
  15145. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  15146. switch name {
  15147. case creditbalance.FieldBalance:
  15148. return m.AddedBalance()
  15149. case creditbalance.FieldStatus:
  15150. return m.AddedStatus()
  15151. case creditbalance.FieldOrganizationID:
  15152. return m.AddedOrganizationID()
  15153. }
  15154. return nil, false
  15155. }
  15156. // AddField adds the value to the field with the given name. It returns an error if
  15157. // the field is not defined in the schema, or if the type mismatched the field
  15158. // type.
  15159. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  15160. switch name {
  15161. case creditbalance.FieldBalance:
  15162. v, ok := value.(float32)
  15163. if !ok {
  15164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15165. }
  15166. m.AddBalance(v)
  15167. return nil
  15168. case creditbalance.FieldStatus:
  15169. v, ok := value.(int)
  15170. if !ok {
  15171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15172. }
  15173. m.AddStatus(v)
  15174. return nil
  15175. case creditbalance.FieldOrganizationID:
  15176. v, ok := value.(int64)
  15177. if !ok {
  15178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15179. }
  15180. m.AddOrganizationID(v)
  15181. return nil
  15182. }
  15183. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  15184. }
  15185. // ClearedFields returns all nullable fields that were cleared during this
  15186. // mutation.
  15187. func (m *CreditBalanceMutation) ClearedFields() []string {
  15188. var fields []string
  15189. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  15190. fields = append(fields, creditbalance.FieldDeletedAt)
  15191. }
  15192. if m.FieldCleared(creditbalance.FieldUserID) {
  15193. fields = append(fields, creditbalance.FieldUserID)
  15194. }
  15195. if m.FieldCleared(creditbalance.FieldStatus) {
  15196. fields = append(fields, creditbalance.FieldStatus)
  15197. }
  15198. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  15199. fields = append(fields, creditbalance.FieldOrganizationID)
  15200. }
  15201. return fields
  15202. }
  15203. // FieldCleared returns a boolean indicating if a field with the given name was
  15204. // cleared in this mutation.
  15205. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  15206. _, ok := m.clearedFields[name]
  15207. return ok
  15208. }
  15209. // ClearField clears the value of the field with the given name. It returns an
  15210. // error if the field is not defined in the schema.
  15211. func (m *CreditBalanceMutation) ClearField(name string) error {
  15212. switch name {
  15213. case creditbalance.FieldDeletedAt:
  15214. m.ClearDeletedAt()
  15215. return nil
  15216. case creditbalance.FieldUserID:
  15217. m.ClearUserID()
  15218. return nil
  15219. case creditbalance.FieldStatus:
  15220. m.ClearStatus()
  15221. return nil
  15222. case creditbalance.FieldOrganizationID:
  15223. m.ClearOrganizationID()
  15224. return nil
  15225. }
  15226. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  15227. }
  15228. // ResetField resets all changes in the mutation for the field with the given name.
  15229. // It returns an error if the field is not defined in the schema.
  15230. func (m *CreditBalanceMutation) ResetField(name string) error {
  15231. switch name {
  15232. case creditbalance.FieldCreatedAt:
  15233. m.ResetCreatedAt()
  15234. return nil
  15235. case creditbalance.FieldUpdatedAt:
  15236. m.ResetUpdatedAt()
  15237. return nil
  15238. case creditbalance.FieldDeletedAt:
  15239. m.ResetDeletedAt()
  15240. return nil
  15241. case creditbalance.FieldUserID:
  15242. m.ResetUserID()
  15243. return nil
  15244. case creditbalance.FieldBalance:
  15245. m.ResetBalance()
  15246. return nil
  15247. case creditbalance.FieldStatus:
  15248. m.ResetStatus()
  15249. return nil
  15250. case creditbalance.FieldOrganizationID:
  15251. m.ResetOrganizationID()
  15252. return nil
  15253. }
  15254. return fmt.Errorf("unknown CreditBalance field %s", name)
  15255. }
  15256. // AddedEdges returns all edge names that were set/added in this mutation.
  15257. func (m *CreditBalanceMutation) AddedEdges() []string {
  15258. edges := make([]string, 0, 0)
  15259. return edges
  15260. }
  15261. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15262. // name in this mutation.
  15263. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  15264. return nil
  15265. }
  15266. // RemovedEdges returns all edge names that were removed in this mutation.
  15267. func (m *CreditBalanceMutation) RemovedEdges() []string {
  15268. edges := make([]string, 0, 0)
  15269. return edges
  15270. }
  15271. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15272. // the given name in this mutation.
  15273. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  15274. return nil
  15275. }
  15276. // ClearedEdges returns all edge names that were cleared in this mutation.
  15277. func (m *CreditBalanceMutation) ClearedEdges() []string {
  15278. edges := make([]string, 0, 0)
  15279. return edges
  15280. }
  15281. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15282. // was cleared in this mutation.
  15283. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  15284. return false
  15285. }
  15286. // ClearEdge clears the value of the edge with the given name. It returns an error
  15287. // if that edge is not defined in the schema.
  15288. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  15289. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  15290. }
  15291. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15292. // It returns an error if the edge is not defined in the schema.
  15293. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  15294. return fmt.Errorf("unknown CreditBalance edge %s", name)
  15295. }
  15296. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  15297. type CreditUsageMutation struct {
  15298. config
  15299. op Op
  15300. typ string
  15301. id *uint64
  15302. created_at *time.Time
  15303. updated_at *time.Time
  15304. deleted_at *time.Time
  15305. user_id *string
  15306. number *float32
  15307. addnumber *float32
  15308. status *int
  15309. addstatus *int
  15310. ntype *int
  15311. addntype *int
  15312. table *string
  15313. organization_id *uint64
  15314. addorganization_id *int64
  15315. nid *uint64
  15316. addnid *int64
  15317. reason *string
  15318. operator *string
  15319. clearedFields map[string]struct{}
  15320. done bool
  15321. oldValue func(context.Context) (*CreditUsage, error)
  15322. predicates []predicate.CreditUsage
  15323. }
  15324. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  15325. // creditusageOption allows management of the mutation configuration using functional options.
  15326. type creditusageOption func(*CreditUsageMutation)
  15327. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  15328. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  15329. m := &CreditUsageMutation{
  15330. config: c,
  15331. op: op,
  15332. typ: TypeCreditUsage,
  15333. clearedFields: make(map[string]struct{}),
  15334. }
  15335. for _, opt := range opts {
  15336. opt(m)
  15337. }
  15338. return m
  15339. }
  15340. // withCreditUsageID sets the ID field of the mutation.
  15341. func withCreditUsageID(id uint64) creditusageOption {
  15342. return func(m *CreditUsageMutation) {
  15343. var (
  15344. err error
  15345. once sync.Once
  15346. value *CreditUsage
  15347. )
  15348. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  15349. once.Do(func() {
  15350. if m.done {
  15351. err = errors.New("querying old values post mutation is not allowed")
  15352. } else {
  15353. value, err = m.Client().CreditUsage.Get(ctx, id)
  15354. }
  15355. })
  15356. return value, err
  15357. }
  15358. m.id = &id
  15359. }
  15360. }
  15361. // withCreditUsage sets the old CreditUsage of the mutation.
  15362. func withCreditUsage(node *CreditUsage) creditusageOption {
  15363. return func(m *CreditUsageMutation) {
  15364. m.oldValue = func(context.Context) (*CreditUsage, error) {
  15365. return node, nil
  15366. }
  15367. m.id = &node.ID
  15368. }
  15369. }
  15370. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15371. // executed in a transaction (ent.Tx), a transactional client is returned.
  15372. func (m CreditUsageMutation) Client() *Client {
  15373. client := &Client{config: m.config}
  15374. client.init()
  15375. return client
  15376. }
  15377. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15378. // it returns an error otherwise.
  15379. func (m CreditUsageMutation) Tx() (*Tx, error) {
  15380. if _, ok := m.driver.(*txDriver); !ok {
  15381. return nil, errors.New("ent: mutation is not running in a transaction")
  15382. }
  15383. tx := &Tx{config: m.config}
  15384. tx.init()
  15385. return tx, nil
  15386. }
  15387. // SetID sets the value of the id field. Note that this
  15388. // operation is only accepted on creation of CreditUsage entities.
  15389. func (m *CreditUsageMutation) SetID(id uint64) {
  15390. m.id = &id
  15391. }
  15392. // ID returns the ID value in the mutation. Note that the ID is only available
  15393. // if it was provided to the builder or after it was returned from the database.
  15394. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  15395. if m.id == nil {
  15396. return
  15397. }
  15398. return *m.id, true
  15399. }
  15400. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15401. // That means, if the mutation is applied within a transaction with an isolation level such
  15402. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15403. // or updated by the mutation.
  15404. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  15405. switch {
  15406. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15407. id, exists := m.ID()
  15408. if exists {
  15409. return []uint64{id}, nil
  15410. }
  15411. fallthrough
  15412. case m.op.Is(OpUpdate | OpDelete):
  15413. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  15414. default:
  15415. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15416. }
  15417. }
  15418. // SetCreatedAt sets the "created_at" field.
  15419. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  15420. m.created_at = &t
  15421. }
  15422. // CreatedAt returns the value of the "created_at" field in the mutation.
  15423. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  15424. v := m.created_at
  15425. if v == nil {
  15426. return
  15427. }
  15428. return *v, true
  15429. }
  15430. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  15431. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15433. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15434. if !m.op.Is(OpUpdateOne) {
  15435. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15436. }
  15437. if m.id == nil || m.oldValue == nil {
  15438. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15439. }
  15440. oldValue, err := m.oldValue(ctx)
  15441. if err != nil {
  15442. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15443. }
  15444. return oldValue.CreatedAt, nil
  15445. }
  15446. // ResetCreatedAt resets all changes to the "created_at" field.
  15447. func (m *CreditUsageMutation) ResetCreatedAt() {
  15448. m.created_at = nil
  15449. }
  15450. // SetUpdatedAt sets the "updated_at" field.
  15451. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  15452. m.updated_at = &t
  15453. }
  15454. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15455. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  15456. v := m.updated_at
  15457. if v == nil {
  15458. return
  15459. }
  15460. return *v, true
  15461. }
  15462. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  15463. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15465. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15466. if !m.op.Is(OpUpdateOne) {
  15467. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15468. }
  15469. if m.id == nil || m.oldValue == nil {
  15470. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15471. }
  15472. oldValue, err := m.oldValue(ctx)
  15473. if err != nil {
  15474. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15475. }
  15476. return oldValue.UpdatedAt, nil
  15477. }
  15478. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15479. func (m *CreditUsageMutation) ResetUpdatedAt() {
  15480. m.updated_at = nil
  15481. }
  15482. // SetDeletedAt sets the "deleted_at" field.
  15483. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  15484. m.deleted_at = &t
  15485. }
  15486. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15487. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  15488. v := m.deleted_at
  15489. if v == nil {
  15490. return
  15491. }
  15492. return *v, true
  15493. }
  15494. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  15495. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15497. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15498. if !m.op.Is(OpUpdateOne) {
  15499. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15500. }
  15501. if m.id == nil || m.oldValue == nil {
  15502. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15503. }
  15504. oldValue, err := m.oldValue(ctx)
  15505. if err != nil {
  15506. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15507. }
  15508. return oldValue.DeletedAt, nil
  15509. }
  15510. // ClearDeletedAt clears the value of the "deleted_at" field.
  15511. func (m *CreditUsageMutation) ClearDeletedAt() {
  15512. m.deleted_at = nil
  15513. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  15514. }
  15515. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15516. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  15517. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  15518. return ok
  15519. }
  15520. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15521. func (m *CreditUsageMutation) ResetDeletedAt() {
  15522. m.deleted_at = nil
  15523. delete(m.clearedFields, creditusage.FieldDeletedAt)
  15524. }
  15525. // SetUserID sets the "user_id" field.
  15526. func (m *CreditUsageMutation) SetUserID(s string) {
  15527. m.user_id = &s
  15528. }
  15529. // UserID returns the value of the "user_id" field in the mutation.
  15530. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  15531. v := m.user_id
  15532. if v == nil {
  15533. return
  15534. }
  15535. return *v, true
  15536. }
  15537. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  15538. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15540. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  15541. if !m.op.Is(OpUpdateOne) {
  15542. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15543. }
  15544. if m.id == nil || m.oldValue == nil {
  15545. return v, errors.New("OldUserID requires an ID field in the mutation")
  15546. }
  15547. oldValue, err := m.oldValue(ctx)
  15548. if err != nil {
  15549. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15550. }
  15551. return oldValue.UserID, nil
  15552. }
  15553. // ClearUserID clears the value of the "user_id" field.
  15554. func (m *CreditUsageMutation) ClearUserID() {
  15555. m.user_id = nil
  15556. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  15557. }
  15558. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15559. func (m *CreditUsageMutation) UserIDCleared() bool {
  15560. _, ok := m.clearedFields[creditusage.FieldUserID]
  15561. return ok
  15562. }
  15563. // ResetUserID resets all changes to the "user_id" field.
  15564. func (m *CreditUsageMutation) ResetUserID() {
  15565. m.user_id = nil
  15566. delete(m.clearedFields, creditusage.FieldUserID)
  15567. }
  15568. // SetNumber sets the "number" field.
  15569. func (m *CreditUsageMutation) SetNumber(f float32) {
  15570. m.number = &f
  15571. m.addnumber = nil
  15572. }
  15573. // Number returns the value of the "number" field in the mutation.
  15574. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  15575. v := m.number
  15576. if v == nil {
  15577. return
  15578. }
  15579. return *v, true
  15580. }
  15581. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  15582. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15584. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  15585. if !m.op.Is(OpUpdateOne) {
  15586. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  15587. }
  15588. if m.id == nil || m.oldValue == nil {
  15589. return v, errors.New("OldNumber requires an ID field in the mutation")
  15590. }
  15591. oldValue, err := m.oldValue(ctx)
  15592. if err != nil {
  15593. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  15594. }
  15595. return oldValue.Number, nil
  15596. }
  15597. // AddNumber adds f to the "number" field.
  15598. func (m *CreditUsageMutation) AddNumber(f float32) {
  15599. if m.addnumber != nil {
  15600. *m.addnumber += f
  15601. } else {
  15602. m.addnumber = &f
  15603. }
  15604. }
  15605. // AddedNumber returns the value that was added to the "number" field in this mutation.
  15606. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  15607. v := m.addnumber
  15608. if v == nil {
  15609. return
  15610. }
  15611. return *v, true
  15612. }
  15613. // ResetNumber resets all changes to the "number" field.
  15614. func (m *CreditUsageMutation) ResetNumber() {
  15615. m.number = nil
  15616. m.addnumber = nil
  15617. }
  15618. // SetStatus sets the "status" field.
  15619. func (m *CreditUsageMutation) SetStatus(i int) {
  15620. m.status = &i
  15621. m.addstatus = nil
  15622. }
  15623. // Status returns the value of the "status" field in the mutation.
  15624. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  15625. v := m.status
  15626. if v == nil {
  15627. return
  15628. }
  15629. return *v, true
  15630. }
  15631. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  15632. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15634. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  15635. if !m.op.Is(OpUpdateOne) {
  15636. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15637. }
  15638. if m.id == nil || m.oldValue == nil {
  15639. return v, errors.New("OldStatus requires an ID field in the mutation")
  15640. }
  15641. oldValue, err := m.oldValue(ctx)
  15642. if err != nil {
  15643. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15644. }
  15645. return oldValue.Status, nil
  15646. }
  15647. // AddStatus adds i to the "status" field.
  15648. func (m *CreditUsageMutation) AddStatus(i int) {
  15649. if m.addstatus != nil {
  15650. *m.addstatus += i
  15651. } else {
  15652. m.addstatus = &i
  15653. }
  15654. }
  15655. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15656. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  15657. v := m.addstatus
  15658. if v == nil {
  15659. return
  15660. }
  15661. return *v, true
  15662. }
  15663. // ClearStatus clears the value of the "status" field.
  15664. func (m *CreditUsageMutation) ClearStatus() {
  15665. m.status = nil
  15666. m.addstatus = nil
  15667. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  15668. }
  15669. // StatusCleared returns if the "status" field was cleared in this mutation.
  15670. func (m *CreditUsageMutation) StatusCleared() bool {
  15671. _, ok := m.clearedFields[creditusage.FieldStatus]
  15672. return ok
  15673. }
  15674. // ResetStatus resets all changes to the "status" field.
  15675. func (m *CreditUsageMutation) ResetStatus() {
  15676. m.status = nil
  15677. m.addstatus = nil
  15678. delete(m.clearedFields, creditusage.FieldStatus)
  15679. }
  15680. // SetNtype sets the "ntype" field.
  15681. func (m *CreditUsageMutation) SetNtype(i int) {
  15682. m.ntype = &i
  15683. m.addntype = nil
  15684. }
  15685. // Ntype returns the value of the "ntype" field in the mutation.
  15686. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  15687. v := m.ntype
  15688. if v == nil {
  15689. return
  15690. }
  15691. return *v, true
  15692. }
  15693. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  15694. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15696. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  15697. if !m.op.Is(OpUpdateOne) {
  15698. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  15699. }
  15700. if m.id == nil || m.oldValue == nil {
  15701. return v, errors.New("OldNtype requires an ID field in the mutation")
  15702. }
  15703. oldValue, err := m.oldValue(ctx)
  15704. if err != nil {
  15705. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  15706. }
  15707. return oldValue.Ntype, nil
  15708. }
  15709. // AddNtype adds i to the "ntype" field.
  15710. func (m *CreditUsageMutation) AddNtype(i int) {
  15711. if m.addntype != nil {
  15712. *m.addntype += i
  15713. } else {
  15714. m.addntype = &i
  15715. }
  15716. }
  15717. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  15718. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  15719. v := m.addntype
  15720. if v == nil {
  15721. return
  15722. }
  15723. return *v, true
  15724. }
  15725. // ResetNtype resets all changes to the "ntype" field.
  15726. func (m *CreditUsageMutation) ResetNtype() {
  15727. m.ntype = nil
  15728. m.addntype = nil
  15729. }
  15730. // SetTable sets the "table" field.
  15731. func (m *CreditUsageMutation) SetTable(s string) {
  15732. m.table = &s
  15733. }
  15734. // Table returns the value of the "table" field in the mutation.
  15735. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  15736. v := m.table
  15737. if v == nil {
  15738. return
  15739. }
  15740. return *v, true
  15741. }
  15742. // OldTable returns the old "table" field's value of the CreditUsage entity.
  15743. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15745. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  15746. if !m.op.Is(OpUpdateOne) {
  15747. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  15748. }
  15749. if m.id == nil || m.oldValue == nil {
  15750. return v, errors.New("OldTable requires an ID field in the mutation")
  15751. }
  15752. oldValue, err := m.oldValue(ctx)
  15753. if err != nil {
  15754. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  15755. }
  15756. return oldValue.Table, nil
  15757. }
  15758. // ResetTable resets all changes to the "table" field.
  15759. func (m *CreditUsageMutation) ResetTable() {
  15760. m.table = nil
  15761. }
  15762. // SetOrganizationID sets the "organization_id" field.
  15763. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  15764. m.organization_id = &u
  15765. m.addorganization_id = nil
  15766. }
  15767. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15768. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  15769. v := m.organization_id
  15770. if v == nil {
  15771. return
  15772. }
  15773. return *v, true
  15774. }
  15775. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  15776. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15778. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15779. if !m.op.Is(OpUpdateOne) {
  15780. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15781. }
  15782. if m.id == nil || m.oldValue == nil {
  15783. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15784. }
  15785. oldValue, err := m.oldValue(ctx)
  15786. if err != nil {
  15787. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15788. }
  15789. return oldValue.OrganizationID, nil
  15790. }
  15791. // AddOrganizationID adds u to the "organization_id" field.
  15792. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  15793. if m.addorganization_id != nil {
  15794. *m.addorganization_id += u
  15795. } else {
  15796. m.addorganization_id = &u
  15797. }
  15798. }
  15799. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15800. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  15801. v := m.addorganization_id
  15802. if v == nil {
  15803. return
  15804. }
  15805. return *v, true
  15806. }
  15807. // ClearOrganizationID clears the value of the "organization_id" field.
  15808. func (m *CreditUsageMutation) ClearOrganizationID() {
  15809. m.organization_id = nil
  15810. m.addorganization_id = nil
  15811. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  15812. }
  15813. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15814. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  15815. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  15816. return ok
  15817. }
  15818. // ResetOrganizationID resets all changes to the "organization_id" field.
  15819. func (m *CreditUsageMutation) ResetOrganizationID() {
  15820. m.organization_id = nil
  15821. m.addorganization_id = nil
  15822. delete(m.clearedFields, creditusage.FieldOrganizationID)
  15823. }
  15824. // SetNid sets the "nid" field.
  15825. func (m *CreditUsageMutation) SetNid(u uint64) {
  15826. m.nid = &u
  15827. m.addnid = nil
  15828. }
  15829. // Nid returns the value of the "nid" field in the mutation.
  15830. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  15831. v := m.nid
  15832. if v == nil {
  15833. return
  15834. }
  15835. return *v, true
  15836. }
  15837. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  15838. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15840. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  15841. if !m.op.Is(OpUpdateOne) {
  15842. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  15843. }
  15844. if m.id == nil || m.oldValue == nil {
  15845. return v, errors.New("OldNid requires an ID field in the mutation")
  15846. }
  15847. oldValue, err := m.oldValue(ctx)
  15848. if err != nil {
  15849. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  15850. }
  15851. return oldValue.Nid, nil
  15852. }
  15853. // AddNid adds u to the "nid" field.
  15854. func (m *CreditUsageMutation) AddNid(u int64) {
  15855. if m.addnid != nil {
  15856. *m.addnid += u
  15857. } else {
  15858. m.addnid = &u
  15859. }
  15860. }
  15861. // AddedNid returns the value that was added to the "nid" field in this mutation.
  15862. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  15863. v := m.addnid
  15864. if v == nil {
  15865. return
  15866. }
  15867. return *v, true
  15868. }
  15869. // ResetNid resets all changes to the "nid" field.
  15870. func (m *CreditUsageMutation) ResetNid() {
  15871. m.nid = nil
  15872. m.addnid = nil
  15873. }
  15874. // SetReason sets the "reason" field.
  15875. func (m *CreditUsageMutation) SetReason(s string) {
  15876. m.reason = &s
  15877. }
  15878. // Reason returns the value of the "reason" field in the mutation.
  15879. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  15880. v := m.reason
  15881. if v == nil {
  15882. return
  15883. }
  15884. return *v, true
  15885. }
  15886. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  15887. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15889. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  15890. if !m.op.Is(OpUpdateOne) {
  15891. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  15892. }
  15893. if m.id == nil || m.oldValue == nil {
  15894. return v, errors.New("OldReason requires an ID field in the mutation")
  15895. }
  15896. oldValue, err := m.oldValue(ctx)
  15897. if err != nil {
  15898. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  15899. }
  15900. return oldValue.Reason, nil
  15901. }
  15902. // ResetReason resets all changes to the "reason" field.
  15903. func (m *CreditUsageMutation) ResetReason() {
  15904. m.reason = nil
  15905. }
  15906. // SetOperator sets the "operator" field.
  15907. func (m *CreditUsageMutation) SetOperator(s string) {
  15908. m.operator = &s
  15909. }
  15910. // Operator returns the value of the "operator" field in the mutation.
  15911. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  15912. v := m.operator
  15913. if v == nil {
  15914. return
  15915. }
  15916. return *v, true
  15917. }
  15918. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  15919. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15921. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  15922. if !m.op.Is(OpUpdateOne) {
  15923. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  15924. }
  15925. if m.id == nil || m.oldValue == nil {
  15926. return v, errors.New("OldOperator requires an ID field in the mutation")
  15927. }
  15928. oldValue, err := m.oldValue(ctx)
  15929. if err != nil {
  15930. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  15931. }
  15932. return oldValue.Operator, nil
  15933. }
  15934. // ResetOperator resets all changes to the "operator" field.
  15935. func (m *CreditUsageMutation) ResetOperator() {
  15936. m.operator = nil
  15937. }
  15938. // Where appends a list predicates to the CreditUsageMutation builder.
  15939. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  15940. m.predicates = append(m.predicates, ps...)
  15941. }
  15942. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  15943. // users can use type-assertion to append predicates that do not depend on any generated package.
  15944. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  15945. p := make([]predicate.CreditUsage, len(ps))
  15946. for i := range ps {
  15947. p[i] = ps[i]
  15948. }
  15949. m.Where(p...)
  15950. }
  15951. // Op returns the operation name.
  15952. func (m *CreditUsageMutation) Op() Op {
  15953. return m.op
  15954. }
  15955. // SetOp allows setting the mutation operation.
  15956. func (m *CreditUsageMutation) SetOp(op Op) {
  15957. m.op = op
  15958. }
  15959. // Type returns the node type of this mutation (CreditUsage).
  15960. func (m *CreditUsageMutation) Type() string {
  15961. return m.typ
  15962. }
  15963. // Fields returns all fields that were changed during this mutation. Note that in
  15964. // order to get all numeric fields that were incremented/decremented, call
  15965. // AddedFields().
  15966. func (m *CreditUsageMutation) Fields() []string {
  15967. fields := make([]string, 0, 12)
  15968. if m.created_at != nil {
  15969. fields = append(fields, creditusage.FieldCreatedAt)
  15970. }
  15971. if m.updated_at != nil {
  15972. fields = append(fields, creditusage.FieldUpdatedAt)
  15973. }
  15974. if m.deleted_at != nil {
  15975. fields = append(fields, creditusage.FieldDeletedAt)
  15976. }
  15977. if m.user_id != nil {
  15978. fields = append(fields, creditusage.FieldUserID)
  15979. }
  15980. if m.number != nil {
  15981. fields = append(fields, creditusage.FieldNumber)
  15982. }
  15983. if m.status != nil {
  15984. fields = append(fields, creditusage.FieldStatus)
  15985. }
  15986. if m.ntype != nil {
  15987. fields = append(fields, creditusage.FieldNtype)
  15988. }
  15989. if m.table != nil {
  15990. fields = append(fields, creditusage.FieldTable)
  15991. }
  15992. if m.organization_id != nil {
  15993. fields = append(fields, creditusage.FieldOrganizationID)
  15994. }
  15995. if m.nid != nil {
  15996. fields = append(fields, creditusage.FieldNid)
  15997. }
  15998. if m.reason != nil {
  15999. fields = append(fields, creditusage.FieldReason)
  16000. }
  16001. if m.operator != nil {
  16002. fields = append(fields, creditusage.FieldOperator)
  16003. }
  16004. return fields
  16005. }
  16006. // Field returns the value of a field with the given name. The second boolean
  16007. // return value indicates that this field was not set, or was not defined in the
  16008. // schema.
  16009. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  16010. switch name {
  16011. case creditusage.FieldCreatedAt:
  16012. return m.CreatedAt()
  16013. case creditusage.FieldUpdatedAt:
  16014. return m.UpdatedAt()
  16015. case creditusage.FieldDeletedAt:
  16016. return m.DeletedAt()
  16017. case creditusage.FieldUserID:
  16018. return m.UserID()
  16019. case creditusage.FieldNumber:
  16020. return m.Number()
  16021. case creditusage.FieldStatus:
  16022. return m.Status()
  16023. case creditusage.FieldNtype:
  16024. return m.Ntype()
  16025. case creditusage.FieldTable:
  16026. return m.Table()
  16027. case creditusage.FieldOrganizationID:
  16028. return m.OrganizationID()
  16029. case creditusage.FieldNid:
  16030. return m.Nid()
  16031. case creditusage.FieldReason:
  16032. return m.Reason()
  16033. case creditusage.FieldOperator:
  16034. return m.Operator()
  16035. }
  16036. return nil, false
  16037. }
  16038. // OldField returns the old value of the field from the database. An error is
  16039. // returned if the mutation operation is not UpdateOne, or the query to the
  16040. // database failed.
  16041. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16042. switch name {
  16043. case creditusage.FieldCreatedAt:
  16044. return m.OldCreatedAt(ctx)
  16045. case creditusage.FieldUpdatedAt:
  16046. return m.OldUpdatedAt(ctx)
  16047. case creditusage.FieldDeletedAt:
  16048. return m.OldDeletedAt(ctx)
  16049. case creditusage.FieldUserID:
  16050. return m.OldUserID(ctx)
  16051. case creditusage.FieldNumber:
  16052. return m.OldNumber(ctx)
  16053. case creditusage.FieldStatus:
  16054. return m.OldStatus(ctx)
  16055. case creditusage.FieldNtype:
  16056. return m.OldNtype(ctx)
  16057. case creditusage.FieldTable:
  16058. return m.OldTable(ctx)
  16059. case creditusage.FieldOrganizationID:
  16060. return m.OldOrganizationID(ctx)
  16061. case creditusage.FieldNid:
  16062. return m.OldNid(ctx)
  16063. case creditusage.FieldReason:
  16064. return m.OldReason(ctx)
  16065. case creditusage.FieldOperator:
  16066. return m.OldOperator(ctx)
  16067. }
  16068. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  16069. }
  16070. // SetField sets the value of a field with the given name. It returns an error if
  16071. // the field is not defined in the schema, or if the type mismatched the field
  16072. // type.
  16073. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  16074. switch name {
  16075. case creditusage.FieldCreatedAt:
  16076. v, ok := value.(time.Time)
  16077. if !ok {
  16078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16079. }
  16080. m.SetCreatedAt(v)
  16081. return nil
  16082. case creditusage.FieldUpdatedAt:
  16083. v, ok := value.(time.Time)
  16084. if !ok {
  16085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16086. }
  16087. m.SetUpdatedAt(v)
  16088. return nil
  16089. case creditusage.FieldDeletedAt:
  16090. v, ok := value.(time.Time)
  16091. if !ok {
  16092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16093. }
  16094. m.SetDeletedAt(v)
  16095. return nil
  16096. case creditusage.FieldUserID:
  16097. v, ok := value.(string)
  16098. if !ok {
  16099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16100. }
  16101. m.SetUserID(v)
  16102. return nil
  16103. case creditusage.FieldNumber:
  16104. v, ok := value.(float32)
  16105. if !ok {
  16106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16107. }
  16108. m.SetNumber(v)
  16109. return nil
  16110. case creditusage.FieldStatus:
  16111. v, ok := value.(int)
  16112. if !ok {
  16113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16114. }
  16115. m.SetStatus(v)
  16116. return nil
  16117. case creditusage.FieldNtype:
  16118. v, ok := value.(int)
  16119. if !ok {
  16120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16121. }
  16122. m.SetNtype(v)
  16123. return nil
  16124. case creditusage.FieldTable:
  16125. v, ok := value.(string)
  16126. if !ok {
  16127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16128. }
  16129. m.SetTable(v)
  16130. return nil
  16131. case creditusage.FieldOrganizationID:
  16132. v, ok := value.(uint64)
  16133. if !ok {
  16134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16135. }
  16136. m.SetOrganizationID(v)
  16137. return nil
  16138. case creditusage.FieldNid:
  16139. v, ok := value.(uint64)
  16140. if !ok {
  16141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16142. }
  16143. m.SetNid(v)
  16144. return nil
  16145. case creditusage.FieldReason:
  16146. v, ok := value.(string)
  16147. if !ok {
  16148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16149. }
  16150. m.SetReason(v)
  16151. return nil
  16152. case creditusage.FieldOperator:
  16153. v, ok := value.(string)
  16154. if !ok {
  16155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16156. }
  16157. m.SetOperator(v)
  16158. return nil
  16159. }
  16160. return fmt.Errorf("unknown CreditUsage field %s", name)
  16161. }
  16162. // AddedFields returns all numeric fields that were incremented/decremented during
  16163. // this mutation.
  16164. func (m *CreditUsageMutation) AddedFields() []string {
  16165. var fields []string
  16166. if m.addnumber != nil {
  16167. fields = append(fields, creditusage.FieldNumber)
  16168. }
  16169. if m.addstatus != nil {
  16170. fields = append(fields, creditusage.FieldStatus)
  16171. }
  16172. if m.addntype != nil {
  16173. fields = append(fields, creditusage.FieldNtype)
  16174. }
  16175. if m.addorganization_id != nil {
  16176. fields = append(fields, creditusage.FieldOrganizationID)
  16177. }
  16178. if m.addnid != nil {
  16179. fields = append(fields, creditusage.FieldNid)
  16180. }
  16181. return fields
  16182. }
  16183. // AddedField returns the numeric value that was incremented/decremented on a field
  16184. // with the given name. The second boolean return value indicates that this field
  16185. // was not set, or was not defined in the schema.
  16186. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  16187. switch name {
  16188. case creditusage.FieldNumber:
  16189. return m.AddedNumber()
  16190. case creditusage.FieldStatus:
  16191. return m.AddedStatus()
  16192. case creditusage.FieldNtype:
  16193. return m.AddedNtype()
  16194. case creditusage.FieldOrganizationID:
  16195. return m.AddedOrganizationID()
  16196. case creditusage.FieldNid:
  16197. return m.AddedNid()
  16198. }
  16199. return nil, false
  16200. }
  16201. // AddField adds the value to the field with the given name. It returns an error if
  16202. // the field is not defined in the schema, or if the type mismatched the field
  16203. // type.
  16204. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  16205. switch name {
  16206. case creditusage.FieldNumber:
  16207. v, ok := value.(float32)
  16208. if !ok {
  16209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16210. }
  16211. m.AddNumber(v)
  16212. return nil
  16213. case creditusage.FieldStatus:
  16214. v, ok := value.(int)
  16215. if !ok {
  16216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16217. }
  16218. m.AddStatus(v)
  16219. return nil
  16220. case creditusage.FieldNtype:
  16221. v, ok := value.(int)
  16222. if !ok {
  16223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16224. }
  16225. m.AddNtype(v)
  16226. return nil
  16227. case creditusage.FieldOrganizationID:
  16228. v, ok := value.(int64)
  16229. if !ok {
  16230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16231. }
  16232. m.AddOrganizationID(v)
  16233. return nil
  16234. case creditusage.FieldNid:
  16235. v, ok := value.(int64)
  16236. if !ok {
  16237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16238. }
  16239. m.AddNid(v)
  16240. return nil
  16241. }
  16242. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  16243. }
  16244. // ClearedFields returns all nullable fields that were cleared during this
  16245. // mutation.
  16246. func (m *CreditUsageMutation) ClearedFields() []string {
  16247. var fields []string
  16248. if m.FieldCleared(creditusage.FieldDeletedAt) {
  16249. fields = append(fields, creditusage.FieldDeletedAt)
  16250. }
  16251. if m.FieldCleared(creditusage.FieldUserID) {
  16252. fields = append(fields, creditusage.FieldUserID)
  16253. }
  16254. if m.FieldCleared(creditusage.FieldStatus) {
  16255. fields = append(fields, creditusage.FieldStatus)
  16256. }
  16257. if m.FieldCleared(creditusage.FieldOrganizationID) {
  16258. fields = append(fields, creditusage.FieldOrganizationID)
  16259. }
  16260. return fields
  16261. }
  16262. // FieldCleared returns a boolean indicating if a field with the given name was
  16263. // cleared in this mutation.
  16264. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  16265. _, ok := m.clearedFields[name]
  16266. return ok
  16267. }
  16268. // ClearField clears the value of the field with the given name. It returns an
  16269. // error if the field is not defined in the schema.
  16270. func (m *CreditUsageMutation) ClearField(name string) error {
  16271. switch name {
  16272. case creditusage.FieldDeletedAt:
  16273. m.ClearDeletedAt()
  16274. return nil
  16275. case creditusage.FieldUserID:
  16276. m.ClearUserID()
  16277. return nil
  16278. case creditusage.FieldStatus:
  16279. m.ClearStatus()
  16280. return nil
  16281. case creditusage.FieldOrganizationID:
  16282. m.ClearOrganizationID()
  16283. return nil
  16284. }
  16285. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  16286. }
  16287. // ResetField resets all changes in the mutation for the field with the given name.
  16288. // It returns an error if the field is not defined in the schema.
  16289. func (m *CreditUsageMutation) ResetField(name string) error {
  16290. switch name {
  16291. case creditusage.FieldCreatedAt:
  16292. m.ResetCreatedAt()
  16293. return nil
  16294. case creditusage.FieldUpdatedAt:
  16295. m.ResetUpdatedAt()
  16296. return nil
  16297. case creditusage.FieldDeletedAt:
  16298. m.ResetDeletedAt()
  16299. return nil
  16300. case creditusage.FieldUserID:
  16301. m.ResetUserID()
  16302. return nil
  16303. case creditusage.FieldNumber:
  16304. m.ResetNumber()
  16305. return nil
  16306. case creditusage.FieldStatus:
  16307. m.ResetStatus()
  16308. return nil
  16309. case creditusage.FieldNtype:
  16310. m.ResetNtype()
  16311. return nil
  16312. case creditusage.FieldTable:
  16313. m.ResetTable()
  16314. return nil
  16315. case creditusage.FieldOrganizationID:
  16316. m.ResetOrganizationID()
  16317. return nil
  16318. case creditusage.FieldNid:
  16319. m.ResetNid()
  16320. return nil
  16321. case creditusage.FieldReason:
  16322. m.ResetReason()
  16323. return nil
  16324. case creditusage.FieldOperator:
  16325. m.ResetOperator()
  16326. return nil
  16327. }
  16328. return fmt.Errorf("unknown CreditUsage field %s", name)
  16329. }
  16330. // AddedEdges returns all edge names that were set/added in this mutation.
  16331. func (m *CreditUsageMutation) AddedEdges() []string {
  16332. edges := make([]string, 0, 0)
  16333. return edges
  16334. }
  16335. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16336. // name in this mutation.
  16337. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  16338. return nil
  16339. }
  16340. // RemovedEdges returns all edge names that were removed in this mutation.
  16341. func (m *CreditUsageMutation) RemovedEdges() []string {
  16342. edges := make([]string, 0, 0)
  16343. return edges
  16344. }
  16345. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16346. // the given name in this mutation.
  16347. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  16348. return nil
  16349. }
  16350. // ClearedEdges returns all edge names that were cleared in this mutation.
  16351. func (m *CreditUsageMutation) ClearedEdges() []string {
  16352. edges := make([]string, 0, 0)
  16353. return edges
  16354. }
  16355. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16356. // was cleared in this mutation.
  16357. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  16358. return false
  16359. }
  16360. // ClearEdge clears the value of the edge with the given name. It returns an error
  16361. // if that edge is not defined in the schema.
  16362. func (m *CreditUsageMutation) ClearEdge(name string) error {
  16363. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  16364. }
  16365. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16366. // It returns an error if the edge is not defined in the schema.
  16367. func (m *CreditUsageMutation) ResetEdge(name string) error {
  16368. return fmt.Errorf("unknown CreditUsage edge %s", name)
  16369. }
  16370. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  16371. type EmployeeMutation struct {
  16372. config
  16373. op Op
  16374. typ string
  16375. id *uint64
  16376. created_at *time.Time
  16377. updated_at *time.Time
  16378. deleted_at *time.Time
  16379. title *string
  16380. avatar *string
  16381. tags *string
  16382. hire_count *int
  16383. addhire_count *int
  16384. service_count *int
  16385. addservice_count *int
  16386. achievement_count *int
  16387. addachievement_count *int
  16388. intro *string
  16389. estimate *string
  16390. skill *string
  16391. ability_type *string
  16392. scene *string
  16393. switch_in *string
  16394. video_url *string
  16395. organization_id *uint64
  16396. addorganization_id *int64
  16397. category_id *uint64
  16398. addcategory_id *int64
  16399. api_base *string
  16400. api_key *string
  16401. ai_info *string
  16402. is_vip *int
  16403. addis_vip *int
  16404. chat_url *string
  16405. clearedFields map[string]struct{}
  16406. em_work_experiences map[uint64]struct{}
  16407. removedem_work_experiences map[uint64]struct{}
  16408. clearedem_work_experiences bool
  16409. em_tutorial map[uint64]struct{}
  16410. removedem_tutorial map[uint64]struct{}
  16411. clearedem_tutorial bool
  16412. done bool
  16413. oldValue func(context.Context) (*Employee, error)
  16414. predicates []predicate.Employee
  16415. }
  16416. var _ ent.Mutation = (*EmployeeMutation)(nil)
  16417. // employeeOption allows management of the mutation configuration using functional options.
  16418. type employeeOption func(*EmployeeMutation)
  16419. // newEmployeeMutation creates new mutation for the Employee entity.
  16420. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  16421. m := &EmployeeMutation{
  16422. config: c,
  16423. op: op,
  16424. typ: TypeEmployee,
  16425. clearedFields: make(map[string]struct{}),
  16426. }
  16427. for _, opt := range opts {
  16428. opt(m)
  16429. }
  16430. return m
  16431. }
  16432. // withEmployeeID sets the ID field of the mutation.
  16433. func withEmployeeID(id uint64) employeeOption {
  16434. return func(m *EmployeeMutation) {
  16435. var (
  16436. err error
  16437. once sync.Once
  16438. value *Employee
  16439. )
  16440. m.oldValue = func(ctx context.Context) (*Employee, error) {
  16441. once.Do(func() {
  16442. if m.done {
  16443. err = errors.New("querying old values post mutation is not allowed")
  16444. } else {
  16445. value, err = m.Client().Employee.Get(ctx, id)
  16446. }
  16447. })
  16448. return value, err
  16449. }
  16450. m.id = &id
  16451. }
  16452. }
  16453. // withEmployee sets the old Employee of the mutation.
  16454. func withEmployee(node *Employee) employeeOption {
  16455. return func(m *EmployeeMutation) {
  16456. m.oldValue = func(context.Context) (*Employee, error) {
  16457. return node, nil
  16458. }
  16459. m.id = &node.ID
  16460. }
  16461. }
  16462. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16463. // executed in a transaction (ent.Tx), a transactional client is returned.
  16464. func (m EmployeeMutation) Client() *Client {
  16465. client := &Client{config: m.config}
  16466. client.init()
  16467. return client
  16468. }
  16469. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16470. // it returns an error otherwise.
  16471. func (m EmployeeMutation) Tx() (*Tx, error) {
  16472. if _, ok := m.driver.(*txDriver); !ok {
  16473. return nil, errors.New("ent: mutation is not running in a transaction")
  16474. }
  16475. tx := &Tx{config: m.config}
  16476. tx.init()
  16477. return tx, nil
  16478. }
  16479. // SetID sets the value of the id field. Note that this
  16480. // operation is only accepted on creation of Employee entities.
  16481. func (m *EmployeeMutation) SetID(id uint64) {
  16482. m.id = &id
  16483. }
  16484. // ID returns the ID value in the mutation. Note that the ID is only available
  16485. // if it was provided to the builder or after it was returned from the database.
  16486. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  16487. if m.id == nil {
  16488. return
  16489. }
  16490. return *m.id, true
  16491. }
  16492. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16493. // That means, if the mutation is applied within a transaction with an isolation level such
  16494. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16495. // or updated by the mutation.
  16496. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16497. switch {
  16498. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16499. id, exists := m.ID()
  16500. if exists {
  16501. return []uint64{id}, nil
  16502. }
  16503. fallthrough
  16504. case m.op.Is(OpUpdate | OpDelete):
  16505. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  16506. default:
  16507. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16508. }
  16509. }
  16510. // SetCreatedAt sets the "created_at" field.
  16511. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  16512. m.created_at = &t
  16513. }
  16514. // CreatedAt returns the value of the "created_at" field in the mutation.
  16515. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  16516. v := m.created_at
  16517. if v == nil {
  16518. return
  16519. }
  16520. return *v, true
  16521. }
  16522. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  16523. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16525. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16526. if !m.op.Is(OpUpdateOne) {
  16527. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16528. }
  16529. if m.id == nil || m.oldValue == nil {
  16530. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16531. }
  16532. oldValue, err := m.oldValue(ctx)
  16533. if err != nil {
  16534. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16535. }
  16536. return oldValue.CreatedAt, nil
  16537. }
  16538. // ResetCreatedAt resets all changes to the "created_at" field.
  16539. func (m *EmployeeMutation) ResetCreatedAt() {
  16540. m.created_at = nil
  16541. }
  16542. // SetUpdatedAt sets the "updated_at" field.
  16543. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  16544. m.updated_at = &t
  16545. }
  16546. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16547. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  16548. v := m.updated_at
  16549. if v == nil {
  16550. return
  16551. }
  16552. return *v, true
  16553. }
  16554. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  16555. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16557. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16558. if !m.op.Is(OpUpdateOne) {
  16559. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16560. }
  16561. if m.id == nil || m.oldValue == nil {
  16562. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16563. }
  16564. oldValue, err := m.oldValue(ctx)
  16565. if err != nil {
  16566. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16567. }
  16568. return oldValue.UpdatedAt, nil
  16569. }
  16570. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16571. func (m *EmployeeMutation) ResetUpdatedAt() {
  16572. m.updated_at = nil
  16573. }
  16574. // SetDeletedAt sets the "deleted_at" field.
  16575. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  16576. m.deleted_at = &t
  16577. }
  16578. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16579. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  16580. v := m.deleted_at
  16581. if v == nil {
  16582. return
  16583. }
  16584. return *v, true
  16585. }
  16586. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  16587. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16589. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16590. if !m.op.Is(OpUpdateOne) {
  16591. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16592. }
  16593. if m.id == nil || m.oldValue == nil {
  16594. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16595. }
  16596. oldValue, err := m.oldValue(ctx)
  16597. if err != nil {
  16598. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16599. }
  16600. return oldValue.DeletedAt, nil
  16601. }
  16602. // ClearDeletedAt clears the value of the "deleted_at" field.
  16603. func (m *EmployeeMutation) ClearDeletedAt() {
  16604. m.deleted_at = nil
  16605. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  16606. }
  16607. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16608. func (m *EmployeeMutation) DeletedAtCleared() bool {
  16609. _, ok := m.clearedFields[employee.FieldDeletedAt]
  16610. return ok
  16611. }
  16612. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16613. func (m *EmployeeMutation) ResetDeletedAt() {
  16614. m.deleted_at = nil
  16615. delete(m.clearedFields, employee.FieldDeletedAt)
  16616. }
  16617. // SetTitle sets the "title" field.
  16618. func (m *EmployeeMutation) SetTitle(s string) {
  16619. m.title = &s
  16620. }
  16621. // Title returns the value of the "title" field in the mutation.
  16622. func (m *EmployeeMutation) Title() (r string, exists bool) {
  16623. v := m.title
  16624. if v == nil {
  16625. return
  16626. }
  16627. return *v, true
  16628. }
  16629. // OldTitle returns the old "title" field's value of the Employee entity.
  16630. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16632. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  16633. if !m.op.Is(OpUpdateOne) {
  16634. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16635. }
  16636. if m.id == nil || m.oldValue == nil {
  16637. return v, errors.New("OldTitle requires an ID field in the mutation")
  16638. }
  16639. oldValue, err := m.oldValue(ctx)
  16640. if err != nil {
  16641. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16642. }
  16643. return oldValue.Title, nil
  16644. }
  16645. // ResetTitle resets all changes to the "title" field.
  16646. func (m *EmployeeMutation) ResetTitle() {
  16647. m.title = nil
  16648. }
  16649. // SetAvatar sets the "avatar" field.
  16650. func (m *EmployeeMutation) SetAvatar(s string) {
  16651. m.avatar = &s
  16652. }
  16653. // Avatar returns the value of the "avatar" field in the mutation.
  16654. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  16655. v := m.avatar
  16656. if v == nil {
  16657. return
  16658. }
  16659. return *v, true
  16660. }
  16661. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  16662. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16664. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  16665. if !m.op.Is(OpUpdateOne) {
  16666. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  16667. }
  16668. if m.id == nil || m.oldValue == nil {
  16669. return v, errors.New("OldAvatar requires an ID field in the mutation")
  16670. }
  16671. oldValue, err := m.oldValue(ctx)
  16672. if err != nil {
  16673. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  16674. }
  16675. return oldValue.Avatar, nil
  16676. }
  16677. // ResetAvatar resets all changes to the "avatar" field.
  16678. func (m *EmployeeMutation) ResetAvatar() {
  16679. m.avatar = nil
  16680. }
  16681. // SetTags sets the "tags" field.
  16682. func (m *EmployeeMutation) SetTags(s string) {
  16683. m.tags = &s
  16684. }
  16685. // Tags returns the value of the "tags" field in the mutation.
  16686. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  16687. v := m.tags
  16688. if v == nil {
  16689. return
  16690. }
  16691. return *v, true
  16692. }
  16693. // OldTags returns the old "tags" field's value of the Employee entity.
  16694. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16696. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  16697. if !m.op.Is(OpUpdateOne) {
  16698. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  16699. }
  16700. if m.id == nil || m.oldValue == nil {
  16701. return v, errors.New("OldTags requires an ID field in the mutation")
  16702. }
  16703. oldValue, err := m.oldValue(ctx)
  16704. if err != nil {
  16705. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  16706. }
  16707. return oldValue.Tags, nil
  16708. }
  16709. // ResetTags resets all changes to the "tags" field.
  16710. func (m *EmployeeMutation) ResetTags() {
  16711. m.tags = nil
  16712. }
  16713. // SetHireCount sets the "hire_count" field.
  16714. func (m *EmployeeMutation) SetHireCount(i int) {
  16715. m.hire_count = &i
  16716. m.addhire_count = nil
  16717. }
  16718. // HireCount returns the value of the "hire_count" field in the mutation.
  16719. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  16720. v := m.hire_count
  16721. if v == nil {
  16722. return
  16723. }
  16724. return *v, true
  16725. }
  16726. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  16727. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16729. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  16730. if !m.op.Is(OpUpdateOne) {
  16731. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  16732. }
  16733. if m.id == nil || m.oldValue == nil {
  16734. return v, errors.New("OldHireCount requires an ID field in the mutation")
  16735. }
  16736. oldValue, err := m.oldValue(ctx)
  16737. if err != nil {
  16738. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  16739. }
  16740. return oldValue.HireCount, nil
  16741. }
  16742. // AddHireCount adds i to the "hire_count" field.
  16743. func (m *EmployeeMutation) AddHireCount(i int) {
  16744. if m.addhire_count != nil {
  16745. *m.addhire_count += i
  16746. } else {
  16747. m.addhire_count = &i
  16748. }
  16749. }
  16750. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  16751. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  16752. v := m.addhire_count
  16753. if v == nil {
  16754. return
  16755. }
  16756. return *v, true
  16757. }
  16758. // ResetHireCount resets all changes to the "hire_count" field.
  16759. func (m *EmployeeMutation) ResetHireCount() {
  16760. m.hire_count = nil
  16761. m.addhire_count = nil
  16762. }
  16763. // SetServiceCount sets the "service_count" field.
  16764. func (m *EmployeeMutation) SetServiceCount(i int) {
  16765. m.service_count = &i
  16766. m.addservice_count = nil
  16767. }
  16768. // ServiceCount returns the value of the "service_count" field in the mutation.
  16769. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  16770. v := m.service_count
  16771. if v == nil {
  16772. return
  16773. }
  16774. return *v, true
  16775. }
  16776. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  16777. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16779. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  16780. if !m.op.Is(OpUpdateOne) {
  16781. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  16782. }
  16783. if m.id == nil || m.oldValue == nil {
  16784. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  16785. }
  16786. oldValue, err := m.oldValue(ctx)
  16787. if err != nil {
  16788. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  16789. }
  16790. return oldValue.ServiceCount, nil
  16791. }
  16792. // AddServiceCount adds i to the "service_count" field.
  16793. func (m *EmployeeMutation) AddServiceCount(i int) {
  16794. if m.addservice_count != nil {
  16795. *m.addservice_count += i
  16796. } else {
  16797. m.addservice_count = &i
  16798. }
  16799. }
  16800. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  16801. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  16802. v := m.addservice_count
  16803. if v == nil {
  16804. return
  16805. }
  16806. return *v, true
  16807. }
  16808. // ResetServiceCount resets all changes to the "service_count" field.
  16809. func (m *EmployeeMutation) ResetServiceCount() {
  16810. m.service_count = nil
  16811. m.addservice_count = nil
  16812. }
  16813. // SetAchievementCount sets the "achievement_count" field.
  16814. func (m *EmployeeMutation) SetAchievementCount(i int) {
  16815. m.achievement_count = &i
  16816. m.addachievement_count = nil
  16817. }
  16818. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  16819. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  16820. v := m.achievement_count
  16821. if v == nil {
  16822. return
  16823. }
  16824. return *v, true
  16825. }
  16826. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  16827. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16829. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  16830. if !m.op.Is(OpUpdateOne) {
  16831. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  16832. }
  16833. if m.id == nil || m.oldValue == nil {
  16834. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  16835. }
  16836. oldValue, err := m.oldValue(ctx)
  16837. if err != nil {
  16838. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  16839. }
  16840. return oldValue.AchievementCount, nil
  16841. }
  16842. // AddAchievementCount adds i to the "achievement_count" field.
  16843. func (m *EmployeeMutation) AddAchievementCount(i int) {
  16844. if m.addachievement_count != nil {
  16845. *m.addachievement_count += i
  16846. } else {
  16847. m.addachievement_count = &i
  16848. }
  16849. }
  16850. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  16851. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  16852. v := m.addachievement_count
  16853. if v == nil {
  16854. return
  16855. }
  16856. return *v, true
  16857. }
  16858. // ResetAchievementCount resets all changes to the "achievement_count" field.
  16859. func (m *EmployeeMutation) ResetAchievementCount() {
  16860. m.achievement_count = nil
  16861. m.addachievement_count = nil
  16862. }
  16863. // SetIntro sets the "intro" field.
  16864. func (m *EmployeeMutation) SetIntro(s string) {
  16865. m.intro = &s
  16866. }
  16867. // Intro returns the value of the "intro" field in the mutation.
  16868. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  16869. v := m.intro
  16870. if v == nil {
  16871. return
  16872. }
  16873. return *v, true
  16874. }
  16875. // OldIntro returns the old "intro" field's value of the Employee entity.
  16876. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16878. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  16879. if !m.op.Is(OpUpdateOne) {
  16880. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  16881. }
  16882. if m.id == nil || m.oldValue == nil {
  16883. return v, errors.New("OldIntro requires an ID field in the mutation")
  16884. }
  16885. oldValue, err := m.oldValue(ctx)
  16886. if err != nil {
  16887. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  16888. }
  16889. return oldValue.Intro, nil
  16890. }
  16891. // ResetIntro resets all changes to the "intro" field.
  16892. func (m *EmployeeMutation) ResetIntro() {
  16893. m.intro = nil
  16894. }
  16895. // SetEstimate sets the "estimate" field.
  16896. func (m *EmployeeMutation) SetEstimate(s string) {
  16897. m.estimate = &s
  16898. }
  16899. // Estimate returns the value of the "estimate" field in the mutation.
  16900. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  16901. v := m.estimate
  16902. if v == nil {
  16903. return
  16904. }
  16905. return *v, true
  16906. }
  16907. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  16908. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16910. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  16911. if !m.op.Is(OpUpdateOne) {
  16912. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  16913. }
  16914. if m.id == nil || m.oldValue == nil {
  16915. return v, errors.New("OldEstimate requires an ID field in the mutation")
  16916. }
  16917. oldValue, err := m.oldValue(ctx)
  16918. if err != nil {
  16919. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  16920. }
  16921. return oldValue.Estimate, nil
  16922. }
  16923. // ResetEstimate resets all changes to the "estimate" field.
  16924. func (m *EmployeeMutation) ResetEstimate() {
  16925. m.estimate = nil
  16926. }
  16927. // SetSkill sets the "skill" field.
  16928. func (m *EmployeeMutation) SetSkill(s string) {
  16929. m.skill = &s
  16930. }
  16931. // Skill returns the value of the "skill" field in the mutation.
  16932. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  16933. v := m.skill
  16934. if v == nil {
  16935. return
  16936. }
  16937. return *v, true
  16938. }
  16939. // OldSkill returns the old "skill" field's value of the Employee entity.
  16940. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16942. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  16943. if !m.op.Is(OpUpdateOne) {
  16944. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  16945. }
  16946. if m.id == nil || m.oldValue == nil {
  16947. return v, errors.New("OldSkill requires an ID field in the mutation")
  16948. }
  16949. oldValue, err := m.oldValue(ctx)
  16950. if err != nil {
  16951. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  16952. }
  16953. return oldValue.Skill, nil
  16954. }
  16955. // ResetSkill resets all changes to the "skill" field.
  16956. func (m *EmployeeMutation) ResetSkill() {
  16957. m.skill = nil
  16958. }
  16959. // SetAbilityType sets the "ability_type" field.
  16960. func (m *EmployeeMutation) SetAbilityType(s string) {
  16961. m.ability_type = &s
  16962. }
  16963. // AbilityType returns the value of the "ability_type" field in the mutation.
  16964. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  16965. v := m.ability_type
  16966. if v == nil {
  16967. return
  16968. }
  16969. return *v, true
  16970. }
  16971. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  16972. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16974. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  16975. if !m.op.Is(OpUpdateOne) {
  16976. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  16977. }
  16978. if m.id == nil || m.oldValue == nil {
  16979. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  16980. }
  16981. oldValue, err := m.oldValue(ctx)
  16982. if err != nil {
  16983. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  16984. }
  16985. return oldValue.AbilityType, nil
  16986. }
  16987. // ResetAbilityType resets all changes to the "ability_type" field.
  16988. func (m *EmployeeMutation) ResetAbilityType() {
  16989. m.ability_type = nil
  16990. }
  16991. // SetScene sets the "scene" field.
  16992. func (m *EmployeeMutation) SetScene(s string) {
  16993. m.scene = &s
  16994. }
  16995. // Scene returns the value of the "scene" field in the mutation.
  16996. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  16997. v := m.scene
  16998. if v == nil {
  16999. return
  17000. }
  17001. return *v, true
  17002. }
  17003. // OldScene returns the old "scene" field's value of the Employee entity.
  17004. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17006. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  17007. if !m.op.Is(OpUpdateOne) {
  17008. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  17009. }
  17010. if m.id == nil || m.oldValue == nil {
  17011. return v, errors.New("OldScene requires an ID field in the mutation")
  17012. }
  17013. oldValue, err := m.oldValue(ctx)
  17014. if err != nil {
  17015. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  17016. }
  17017. return oldValue.Scene, nil
  17018. }
  17019. // ResetScene resets all changes to the "scene" field.
  17020. func (m *EmployeeMutation) ResetScene() {
  17021. m.scene = nil
  17022. }
  17023. // SetSwitchIn sets the "switch_in" field.
  17024. func (m *EmployeeMutation) SetSwitchIn(s string) {
  17025. m.switch_in = &s
  17026. }
  17027. // SwitchIn returns the value of the "switch_in" field in the mutation.
  17028. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  17029. v := m.switch_in
  17030. if v == nil {
  17031. return
  17032. }
  17033. return *v, true
  17034. }
  17035. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  17036. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17038. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  17039. if !m.op.Is(OpUpdateOne) {
  17040. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  17041. }
  17042. if m.id == nil || m.oldValue == nil {
  17043. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  17044. }
  17045. oldValue, err := m.oldValue(ctx)
  17046. if err != nil {
  17047. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  17048. }
  17049. return oldValue.SwitchIn, nil
  17050. }
  17051. // ResetSwitchIn resets all changes to the "switch_in" field.
  17052. func (m *EmployeeMutation) ResetSwitchIn() {
  17053. m.switch_in = nil
  17054. }
  17055. // SetVideoURL sets the "video_url" field.
  17056. func (m *EmployeeMutation) SetVideoURL(s string) {
  17057. m.video_url = &s
  17058. }
  17059. // VideoURL returns the value of the "video_url" field in the mutation.
  17060. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  17061. v := m.video_url
  17062. if v == nil {
  17063. return
  17064. }
  17065. return *v, true
  17066. }
  17067. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  17068. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17070. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  17071. if !m.op.Is(OpUpdateOne) {
  17072. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  17073. }
  17074. if m.id == nil || m.oldValue == nil {
  17075. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  17076. }
  17077. oldValue, err := m.oldValue(ctx)
  17078. if err != nil {
  17079. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  17080. }
  17081. return oldValue.VideoURL, nil
  17082. }
  17083. // ResetVideoURL resets all changes to the "video_url" field.
  17084. func (m *EmployeeMutation) ResetVideoURL() {
  17085. m.video_url = nil
  17086. }
  17087. // SetOrganizationID sets the "organization_id" field.
  17088. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  17089. m.organization_id = &u
  17090. m.addorganization_id = nil
  17091. }
  17092. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17093. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  17094. v := m.organization_id
  17095. if v == nil {
  17096. return
  17097. }
  17098. return *v, true
  17099. }
  17100. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  17101. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17103. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17104. if !m.op.Is(OpUpdateOne) {
  17105. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17106. }
  17107. if m.id == nil || m.oldValue == nil {
  17108. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17109. }
  17110. oldValue, err := m.oldValue(ctx)
  17111. if err != nil {
  17112. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17113. }
  17114. return oldValue.OrganizationID, nil
  17115. }
  17116. // AddOrganizationID adds u to the "organization_id" field.
  17117. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  17118. if m.addorganization_id != nil {
  17119. *m.addorganization_id += u
  17120. } else {
  17121. m.addorganization_id = &u
  17122. }
  17123. }
  17124. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17125. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  17126. v := m.addorganization_id
  17127. if v == nil {
  17128. return
  17129. }
  17130. return *v, true
  17131. }
  17132. // ResetOrganizationID resets all changes to the "organization_id" field.
  17133. func (m *EmployeeMutation) ResetOrganizationID() {
  17134. m.organization_id = nil
  17135. m.addorganization_id = nil
  17136. }
  17137. // SetCategoryID sets the "category_id" field.
  17138. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  17139. m.category_id = &u
  17140. m.addcategory_id = nil
  17141. }
  17142. // CategoryID returns the value of the "category_id" field in the mutation.
  17143. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  17144. v := m.category_id
  17145. if v == nil {
  17146. return
  17147. }
  17148. return *v, true
  17149. }
  17150. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  17151. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17153. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  17154. if !m.op.Is(OpUpdateOne) {
  17155. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  17156. }
  17157. if m.id == nil || m.oldValue == nil {
  17158. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  17159. }
  17160. oldValue, err := m.oldValue(ctx)
  17161. if err != nil {
  17162. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  17163. }
  17164. return oldValue.CategoryID, nil
  17165. }
  17166. // AddCategoryID adds u to the "category_id" field.
  17167. func (m *EmployeeMutation) AddCategoryID(u int64) {
  17168. if m.addcategory_id != nil {
  17169. *m.addcategory_id += u
  17170. } else {
  17171. m.addcategory_id = &u
  17172. }
  17173. }
  17174. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  17175. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  17176. v := m.addcategory_id
  17177. if v == nil {
  17178. return
  17179. }
  17180. return *v, true
  17181. }
  17182. // ResetCategoryID resets all changes to the "category_id" field.
  17183. func (m *EmployeeMutation) ResetCategoryID() {
  17184. m.category_id = nil
  17185. m.addcategory_id = nil
  17186. }
  17187. // SetAPIBase sets the "api_base" field.
  17188. func (m *EmployeeMutation) SetAPIBase(s string) {
  17189. m.api_base = &s
  17190. }
  17191. // APIBase returns the value of the "api_base" field in the mutation.
  17192. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  17193. v := m.api_base
  17194. if v == nil {
  17195. return
  17196. }
  17197. return *v, true
  17198. }
  17199. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  17200. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17202. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  17203. if !m.op.Is(OpUpdateOne) {
  17204. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  17205. }
  17206. if m.id == nil || m.oldValue == nil {
  17207. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  17208. }
  17209. oldValue, err := m.oldValue(ctx)
  17210. if err != nil {
  17211. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  17212. }
  17213. return oldValue.APIBase, nil
  17214. }
  17215. // ResetAPIBase resets all changes to the "api_base" field.
  17216. func (m *EmployeeMutation) ResetAPIBase() {
  17217. m.api_base = nil
  17218. }
  17219. // SetAPIKey sets the "api_key" field.
  17220. func (m *EmployeeMutation) SetAPIKey(s string) {
  17221. m.api_key = &s
  17222. }
  17223. // APIKey returns the value of the "api_key" field in the mutation.
  17224. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  17225. v := m.api_key
  17226. if v == nil {
  17227. return
  17228. }
  17229. return *v, true
  17230. }
  17231. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  17232. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17234. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  17235. if !m.op.Is(OpUpdateOne) {
  17236. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  17237. }
  17238. if m.id == nil || m.oldValue == nil {
  17239. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  17240. }
  17241. oldValue, err := m.oldValue(ctx)
  17242. if err != nil {
  17243. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  17244. }
  17245. return oldValue.APIKey, nil
  17246. }
  17247. // ResetAPIKey resets all changes to the "api_key" field.
  17248. func (m *EmployeeMutation) ResetAPIKey() {
  17249. m.api_key = nil
  17250. }
  17251. // SetAiInfo sets the "ai_info" field.
  17252. func (m *EmployeeMutation) SetAiInfo(s string) {
  17253. m.ai_info = &s
  17254. }
  17255. // AiInfo returns the value of the "ai_info" field in the mutation.
  17256. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  17257. v := m.ai_info
  17258. if v == nil {
  17259. return
  17260. }
  17261. return *v, true
  17262. }
  17263. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  17264. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17266. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  17267. if !m.op.Is(OpUpdateOne) {
  17268. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  17269. }
  17270. if m.id == nil || m.oldValue == nil {
  17271. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  17272. }
  17273. oldValue, err := m.oldValue(ctx)
  17274. if err != nil {
  17275. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  17276. }
  17277. return oldValue.AiInfo, nil
  17278. }
  17279. // ClearAiInfo clears the value of the "ai_info" field.
  17280. func (m *EmployeeMutation) ClearAiInfo() {
  17281. m.ai_info = nil
  17282. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  17283. }
  17284. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  17285. func (m *EmployeeMutation) AiInfoCleared() bool {
  17286. _, ok := m.clearedFields[employee.FieldAiInfo]
  17287. return ok
  17288. }
  17289. // ResetAiInfo resets all changes to the "ai_info" field.
  17290. func (m *EmployeeMutation) ResetAiInfo() {
  17291. m.ai_info = nil
  17292. delete(m.clearedFields, employee.FieldAiInfo)
  17293. }
  17294. // SetIsVip sets the "is_vip" field.
  17295. func (m *EmployeeMutation) SetIsVip(i int) {
  17296. m.is_vip = &i
  17297. m.addis_vip = nil
  17298. }
  17299. // IsVip returns the value of the "is_vip" field in the mutation.
  17300. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  17301. v := m.is_vip
  17302. if v == nil {
  17303. return
  17304. }
  17305. return *v, true
  17306. }
  17307. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  17308. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17310. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  17311. if !m.op.Is(OpUpdateOne) {
  17312. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  17313. }
  17314. if m.id == nil || m.oldValue == nil {
  17315. return v, errors.New("OldIsVip requires an ID field in the mutation")
  17316. }
  17317. oldValue, err := m.oldValue(ctx)
  17318. if err != nil {
  17319. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  17320. }
  17321. return oldValue.IsVip, nil
  17322. }
  17323. // AddIsVip adds i to the "is_vip" field.
  17324. func (m *EmployeeMutation) AddIsVip(i int) {
  17325. if m.addis_vip != nil {
  17326. *m.addis_vip += i
  17327. } else {
  17328. m.addis_vip = &i
  17329. }
  17330. }
  17331. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  17332. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  17333. v := m.addis_vip
  17334. if v == nil {
  17335. return
  17336. }
  17337. return *v, true
  17338. }
  17339. // ResetIsVip resets all changes to the "is_vip" field.
  17340. func (m *EmployeeMutation) ResetIsVip() {
  17341. m.is_vip = nil
  17342. m.addis_vip = nil
  17343. }
  17344. // SetChatURL sets the "chat_url" field.
  17345. func (m *EmployeeMutation) SetChatURL(s string) {
  17346. m.chat_url = &s
  17347. }
  17348. // ChatURL returns the value of the "chat_url" field in the mutation.
  17349. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  17350. v := m.chat_url
  17351. if v == nil {
  17352. return
  17353. }
  17354. return *v, true
  17355. }
  17356. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  17357. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17359. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  17360. if !m.op.Is(OpUpdateOne) {
  17361. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  17362. }
  17363. if m.id == nil || m.oldValue == nil {
  17364. return v, errors.New("OldChatURL requires an ID field in the mutation")
  17365. }
  17366. oldValue, err := m.oldValue(ctx)
  17367. if err != nil {
  17368. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  17369. }
  17370. return oldValue.ChatURL, nil
  17371. }
  17372. // ResetChatURL resets all changes to the "chat_url" field.
  17373. func (m *EmployeeMutation) ResetChatURL() {
  17374. m.chat_url = nil
  17375. }
  17376. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  17377. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  17378. if m.em_work_experiences == nil {
  17379. m.em_work_experiences = make(map[uint64]struct{})
  17380. }
  17381. for i := range ids {
  17382. m.em_work_experiences[ids[i]] = struct{}{}
  17383. }
  17384. }
  17385. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  17386. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  17387. m.clearedem_work_experiences = true
  17388. }
  17389. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  17390. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  17391. return m.clearedem_work_experiences
  17392. }
  17393. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  17394. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  17395. if m.removedem_work_experiences == nil {
  17396. m.removedem_work_experiences = make(map[uint64]struct{})
  17397. }
  17398. for i := range ids {
  17399. delete(m.em_work_experiences, ids[i])
  17400. m.removedem_work_experiences[ids[i]] = struct{}{}
  17401. }
  17402. }
  17403. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  17404. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  17405. for id := range m.removedem_work_experiences {
  17406. ids = append(ids, id)
  17407. }
  17408. return
  17409. }
  17410. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  17411. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  17412. for id := range m.em_work_experiences {
  17413. ids = append(ids, id)
  17414. }
  17415. return
  17416. }
  17417. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  17418. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  17419. m.em_work_experiences = nil
  17420. m.clearedem_work_experiences = false
  17421. m.removedem_work_experiences = nil
  17422. }
  17423. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  17424. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  17425. if m.em_tutorial == nil {
  17426. m.em_tutorial = make(map[uint64]struct{})
  17427. }
  17428. for i := range ids {
  17429. m.em_tutorial[ids[i]] = struct{}{}
  17430. }
  17431. }
  17432. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  17433. func (m *EmployeeMutation) ClearEmTutorial() {
  17434. m.clearedem_tutorial = true
  17435. }
  17436. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  17437. func (m *EmployeeMutation) EmTutorialCleared() bool {
  17438. return m.clearedem_tutorial
  17439. }
  17440. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  17441. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  17442. if m.removedem_tutorial == nil {
  17443. m.removedem_tutorial = make(map[uint64]struct{})
  17444. }
  17445. for i := range ids {
  17446. delete(m.em_tutorial, ids[i])
  17447. m.removedem_tutorial[ids[i]] = struct{}{}
  17448. }
  17449. }
  17450. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  17451. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  17452. for id := range m.removedem_tutorial {
  17453. ids = append(ids, id)
  17454. }
  17455. return
  17456. }
  17457. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  17458. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  17459. for id := range m.em_tutorial {
  17460. ids = append(ids, id)
  17461. }
  17462. return
  17463. }
  17464. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  17465. func (m *EmployeeMutation) ResetEmTutorial() {
  17466. m.em_tutorial = nil
  17467. m.clearedem_tutorial = false
  17468. m.removedem_tutorial = nil
  17469. }
  17470. // Where appends a list predicates to the EmployeeMutation builder.
  17471. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  17472. m.predicates = append(m.predicates, ps...)
  17473. }
  17474. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  17475. // users can use type-assertion to append predicates that do not depend on any generated package.
  17476. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  17477. p := make([]predicate.Employee, len(ps))
  17478. for i := range ps {
  17479. p[i] = ps[i]
  17480. }
  17481. m.Where(p...)
  17482. }
  17483. // Op returns the operation name.
  17484. func (m *EmployeeMutation) Op() Op {
  17485. return m.op
  17486. }
  17487. // SetOp allows setting the mutation operation.
  17488. func (m *EmployeeMutation) SetOp(op Op) {
  17489. m.op = op
  17490. }
  17491. // Type returns the node type of this mutation (Employee).
  17492. func (m *EmployeeMutation) Type() string {
  17493. return m.typ
  17494. }
  17495. // Fields returns all fields that were changed during this mutation. Note that in
  17496. // order to get all numeric fields that were incremented/decremented, call
  17497. // AddedFields().
  17498. func (m *EmployeeMutation) Fields() []string {
  17499. fields := make([]string, 0, 23)
  17500. if m.created_at != nil {
  17501. fields = append(fields, employee.FieldCreatedAt)
  17502. }
  17503. if m.updated_at != nil {
  17504. fields = append(fields, employee.FieldUpdatedAt)
  17505. }
  17506. if m.deleted_at != nil {
  17507. fields = append(fields, employee.FieldDeletedAt)
  17508. }
  17509. if m.title != nil {
  17510. fields = append(fields, employee.FieldTitle)
  17511. }
  17512. if m.avatar != nil {
  17513. fields = append(fields, employee.FieldAvatar)
  17514. }
  17515. if m.tags != nil {
  17516. fields = append(fields, employee.FieldTags)
  17517. }
  17518. if m.hire_count != nil {
  17519. fields = append(fields, employee.FieldHireCount)
  17520. }
  17521. if m.service_count != nil {
  17522. fields = append(fields, employee.FieldServiceCount)
  17523. }
  17524. if m.achievement_count != nil {
  17525. fields = append(fields, employee.FieldAchievementCount)
  17526. }
  17527. if m.intro != nil {
  17528. fields = append(fields, employee.FieldIntro)
  17529. }
  17530. if m.estimate != nil {
  17531. fields = append(fields, employee.FieldEstimate)
  17532. }
  17533. if m.skill != nil {
  17534. fields = append(fields, employee.FieldSkill)
  17535. }
  17536. if m.ability_type != nil {
  17537. fields = append(fields, employee.FieldAbilityType)
  17538. }
  17539. if m.scene != nil {
  17540. fields = append(fields, employee.FieldScene)
  17541. }
  17542. if m.switch_in != nil {
  17543. fields = append(fields, employee.FieldSwitchIn)
  17544. }
  17545. if m.video_url != nil {
  17546. fields = append(fields, employee.FieldVideoURL)
  17547. }
  17548. if m.organization_id != nil {
  17549. fields = append(fields, employee.FieldOrganizationID)
  17550. }
  17551. if m.category_id != nil {
  17552. fields = append(fields, employee.FieldCategoryID)
  17553. }
  17554. if m.api_base != nil {
  17555. fields = append(fields, employee.FieldAPIBase)
  17556. }
  17557. if m.api_key != nil {
  17558. fields = append(fields, employee.FieldAPIKey)
  17559. }
  17560. if m.ai_info != nil {
  17561. fields = append(fields, employee.FieldAiInfo)
  17562. }
  17563. if m.is_vip != nil {
  17564. fields = append(fields, employee.FieldIsVip)
  17565. }
  17566. if m.chat_url != nil {
  17567. fields = append(fields, employee.FieldChatURL)
  17568. }
  17569. return fields
  17570. }
  17571. // Field returns the value of a field with the given name. The second boolean
  17572. // return value indicates that this field was not set, or was not defined in the
  17573. // schema.
  17574. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  17575. switch name {
  17576. case employee.FieldCreatedAt:
  17577. return m.CreatedAt()
  17578. case employee.FieldUpdatedAt:
  17579. return m.UpdatedAt()
  17580. case employee.FieldDeletedAt:
  17581. return m.DeletedAt()
  17582. case employee.FieldTitle:
  17583. return m.Title()
  17584. case employee.FieldAvatar:
  17585. return m.Avatar()
  17586. case employee.FieldTags:
  17587. return m.Tags()
  17588. case employee.FieldHireCount:
  17589. return m.HireCount()
  17590. case employee.FieldServiceCount:
  17591. return m.ServiceCount()
  17592. case employee.FieldAchievementCount:
  17593. return m.AchievementCount()
  17594. case employee.FieldIntro:
  17595. return m.Intro()
  17596. case employee.FieldEstimate:
  17597. return m.Estimate()
  17598. case employee.FieldSkill:
  17599. return m.Skill()
  17600. case employee.FieldAbilityType:
  17601. return m.AbilityType()
  17602. case employee.FieldScene:
  17603. return m.Scene()
  17604. case employee.FieldSwitchIn:
  17605. return m.SwitchIn()
  17606. case employee.FieldVideoURL:
  17607. return m.VideoURL()
  17608. case employee.FieldOrganizationID:
  17609. return m.OrganizationID()
  17610. case employee.FieldCategoryID:
  17611. return m.CategoryID()
  17612. case employee.FieldAPIBase:
  17613. return m.APIBase()
  17614. case employee.FieldAPIKey:
  17615. return m.APIKey()
  17616. case employee.FieldAiInfo:
  17617. return m.AiInfo()
  17618. case employee.FieldIsVip:
  17619. return m.IsVip()
  17620. case employee.FieldChatURL:
  17621. return m.ChatURL()
  17622. }
  17623. return nil, false
  17624. }
  17625. // OldField returns the old value of the field from the database. An error is
  17626. // returned if the mutation operation is not UpdateOne, or the query to the
  17627. // database failed.
  17628. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17629. switch name {
  17630. case employee.FieldCreatedAt:
  17631. return m.OldCreatedAt(ctx)
  17632. case employee.FieldUpdatedAt:
  17633. return m.OldUpdatedAt(ctx)
  17634. case employee.FieldDeletedAt:
  17635. return m.OldDeletedAt(ctx)
  17636. case employee.FieldTitle:
  17637. return m.OldTitle(ctx)
  17638. case employee.FieldAvatar:
  17639. return m.OldAvatar(ctx)
  17640. case employee.FieldTags:
  17641. return m.OldTags(ctx)
  17642. case employee.FieldHireCount:
  17643. return m.OldHireCount(ctx)
  17644. case employee.FieldServiceCount:
  17645. return m.OldServiceCount(ctx)
  17646. case employee.FieldAchievementCount:
  17647. return m.OldAchievementCount(ctx)
  17648. case employee.FieldIntro:
  17649. return m.OldIntro(ctx)
  17650. case employee.FieldEstimate:
  17651. return m.OldEstimate(ctx)
  17652. case employee.FieldSkill:
  17653. return m.OldSkill(ctx)
  17654. case employee.FieldAbilityType:
  17655. return m.OldAbilityType(ctx)
  17656. case employee.FieldScene:
  17657. return m.OldScene(ctx)
  17658. case employee.FieldSwitchIn:
  17659. return m.OldSwitchIn(ctx)
  17660. case employee.FieldVideoURL:
  17661. return m.OldVideoURL(ctx)
  17662. case employee.FieldOrganizationID:
  17663. return m.OldOrganizationID(ctx)
  17664. case employee.FieldCategoryID:
  17665. return m.OldCategoryID(ctx)
  17666. case employee.FieldAPIBase:
  17667. return m.OldAPIBase(ctx)
  17668. case employee.FieldAPIKey:
  17669. return m.OldAPIKey(ctx)
  17670. case employee.FieldAiInfo:
  17671. return m.OldAiInfo(ctx)
  17672. case employee.FieldIsVip:
  17673. return m.OldIsVip(ctx)
  17674. case employee.FieldChatURL:
  17675. return m.OldChatURL(ctx)
  17676. }
  17677. return nil, fmt.Errorf("unknown Employee field %s", name)
  17678. }
  17679. // SetField sets the value of a field with the given name. It returns an error if
  17680. // the field is not defined in the schema, or if the type mismatched the field
  17681. // type.
  17682. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  17683. switch name {
  17684. case employee.FieldCreatedAt:
  17685. v, ok := value.(time.Time)
  17686. if !ok {
  17687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17688. }
  17689. m.SetCreatedAt(v)
  17690. return nil
  17691. case employee.FieldUpdatedAt:
  17692. v, ok := value.(time.Time)
  17693. if !ok {
  17694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17695. }
  17696. m.SetUpdatedAt(v)
  17697. return nil
  17698. case employee.FieldDeletedAt:
  17699. v, ok := value.(time.Time)
  17700. if !ok {
  17701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17702. }
  17703. m.SetDeletedAt(v)
  17704. return nil
  17705. case employee.FieldTitle:
  17706. v, ok := value.(string)
  17707. if !ok {
  17708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17709. }
  17710. m.SetTitle(v)
  17711. return nil
  17712. case employee.FieldAvatar:
  17713. v, ok := value.(string)
  17714. if !ok {
  17715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17716. }
  17717. m.SetAvatar(v)
  17718. return nil
  17719. case employee.FieldTags:
  17720. v, ok := value.(string)
  17721. if !ok {
  17722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17723. }
  17724. m.SetTags(v)
  17725. return nil
  17726. case employee.FieldHireCount:
  17727. v, ok := value.(int)
  17728. if !ok {
  17729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17730. }
  17731. m.SetHireCount(v)
  17732. return nil
  17733. case employee.FieldServiceCount:
  17734. v, ok := value.(int)
  17735. if !ok {
  17736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17737. }
  17738. m.SetServiceCount(v)
  17739. return nil
  17740. case employee.FieldAchievementCount:
  17741. v, ok := value.(int)
  17742. if !ok {
  17743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17744. }
  17745. m.SetAchievementCount(v)
  17746. return nil
  17747. case employee.FieldIntro:
  17748. v, ok := value.(string)
  17749. if !ok {
  17750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17751. }
  17752. m.SetIntro(v)
  17753. return nil
  17754. case employee.FieldEstimate:
  17755. v, ok := value.(string)
  17756. if !ok {
  17757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17758. }
  17759. m.SetEstimate(v)
  17760. return nil
  17761. case employee.FieldSkill:
  17762. v, ok := value.(string)
  17763. if !ok {
  17764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17765. }
  17766. m.SetSkill(v)
  17767. return nil
  17768. case employee.FieldAbilityType:
  17769. v, ok := value.(string)
  17770. if !ok {
  17771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17772. }
  17773. m.SetAbilityType(v)
  17774. return nil
  17775. case employee.FieldScene:
  17776. v, ok := value.(string)
  17777. if !ok {
  17778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17779. }
  17780. m.SetScene(v)
  17781. return nil
  17782. case employee.FieldSwitchIn:
  17783. v, ok := value.(string)
  17784. if !ok {
  17785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17786. }
  17787. m.SetSwitchIn(v)
  17788. return nil
  17789. case employee.FieldVideoURL:
  17790. v, ok := value.(string)
  17791. if !ok {
  17792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17793. }
  17794. m.SetVideoURL(v)
  17795. return nil
  17796. case employee.FieldOrganizationID:
  17797. v, ok := value.(uint64)
  17798. if !ok {
  17799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17800. }
  17801. m.SetOrganizationID(v)
  17802. return nil
  17803. case employee.FieldCategoryID:
  17804. v, ok := value.(uint64)
  17805. if !ok {
  17806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17807. }
  17808. m.SetCategoryID(v)
  17809. return nil
  17810. case employee.FieldAPIBase:
  17811. v, ok := value.(string)
  17812. if !ok {
  17813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17814. }
  17815. m.SetAPIBase(v)
  17816. return nil
  17817. case employee.FieldAPIKey:
  17818. v, ok := value.(string)
  17819. if !ok {
  17820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17821. }
  17822. m.SetAPIKey(v)
  17823. return nil
  17824. case employee.FieldAiInfo:
  17825. v, ok := value.(string)
  17826. if !ok {
  17827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17828. }
  17829. m.SetAiInfo(v)
  17830. return nil
  17831. case employee.FieldIsVip:
  17832. v, ok := value.(int)
  17833. if !ok {
  17834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17835. }
  17836. m.SetIsVip(v)
  17837. return nil
  17838. case employee.FieldChatURL:
  17839. v, ok := value.(string)
  17840. if !ok {
  17841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17842. }
  17843. m.SetChatURL(v)
  17844. return nil
  17845. }
  17846. return fmt.Errorf("unknown Employee field %s", name)
  17847. }
  17848. // AddedFields returns all numeric fields that were incremented/decremented during
  17849. // this mutation.
  17850. func (m *EmployeeMutation) AddedFields() []string {
  17851. var fields []string
  17852. if m.addhire_count != nil {
  17853. fields = append(fields, employee.FieldHireCount)
  17854. }
  17855. if m.addservice_count != nil {
  17856. fields = append(fields, employee.FieldServiceCount)
  17857. }
  17858. if m.addachievement_count != nil {
  17859. fields = append(fields, employee.FieldAchievementCount)
  17860. }
  17861. if m.addorganization_id != nil {
  17862. fields = append(fields, employee.FieldOrganizationID)
  17863. }
  17864. if m.addcategory_id != nil {
  17865. fields = append(fields, employee.FieldCategoryID)
  17866. }
  17867. if m.addis_vip != nil {
  17868. fields = append(fields, employee.FieldIsVip)
  17869. }
  17870. return fields
  17871. }
  17872. // AddedField returns the numeric value that was incremented/decremented on a field
  17873. // with the given name. The second boolean return value indicates that this field
  17874. // was not set, or was not defined in the schema.
  17875. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  17876. switch name {
  17877. case employee.FieldHireCount:
  17878. return m.AddedHireCount()
  17879. case employee.FieldServiceCount:
  17880. return m.AddedServiceCount()
  17881. case employee.FieldAchievementCount:
  17882. return m.AddedAchievementCount()
  17883. case employee.FieldOrganizationID:
  17884. return m.AddedOrganizationID()
  17885. case employee.FieldCategoryID:
  17886. return m.AddedCategoryID()
  17887. case employee.FieldIsVip:
  17888. return m.AddedIsVip()
  17889. }
  17890. return nil, false
  17891. }
  17892. // AddField adds the value to the field with the given name. It returns an error if
  17893. // the field is not defined in the schema, or if the type mismatched the field
  17894. // type.
  17895. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  17896. switch name {
  17897. case employee.FieldHireCount:
  17898. v, ok := value.(int)
  17899. if !ok {
  17900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17901. }
  17902. m.AddHireCount(v)
  17903. return nil
  17904. case employee.FieldServiceCount:
  17905. v, ok := value.(int)
  17906. if !ok {
  17907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17908. }
  17909. m.AddServiceCount(v)
  17910. return nil
  17911. case employee.FieldAchievementCount:
  17912. v, ok := value.(int)
  17913. if !ok {
  17914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17915. }
  17916. m.AddAchievementCount(v)
  17917. return nil
  17918. case employee.FieldOrganizationID:
  17919. v, ok := value.(int64)
  17920. if !ok {
  17921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17922. }
  17923. m.AddOrganizationID(v)
  17924. return nil
  17925. case employee.FieldCategoryID:
  17926. v, ok := value.(int64)
  17927. if !ok {
  17928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17929. }
  17930. m.AddCategoryID(v)
  17931. return nil
  17932. case employee.FieldIsVip:
  17933. v, ok := value.(int)
  17934. if !ok {
  17935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17936. }
  17937. m.AddIsVip(v)
  17938. return nil
  17939. }
  17940. return fmt.Errorf("unknown Employee numeric field %s", name)
  17941. }
  17942. // ClearedFields returns all nullable fields that were cleared during this
  17943. // mutation.
  17944. func (m *EmployeeMutation) ClearedFields() []string {
  17945. var fields []string
  17946. if m.FieldCleared(employee.FieldDeletedAt) {
  17947. fields = append(fields, employee.FieldDeletedAt)
  17948. }
  17949. if m.FieldCleared(employee.FieldAiInfo) {
  17950. fields = append(fields, employee.FieldAiInfo)
  17951. }
  17952. return fields
  17953. }
  17954. // FieldCleared returns a boolean indicating if a field with the given name was
  17955. // cleared in this mutation.
  17956. func (m *EmployeeMutation) FieldCleared(name string) bool {
  17957. _, ok := m.clearedFields[name]
  17958. return ok
  17959. }
  17960. // ClearField clears the value of the field with the given name. It returns an
  17961. // error if the field is not defined in the schema.
  17962. func (m *EmployeeMutation) ClearField(name string) error {
  17963. switch name {
  17964. case employee.FieldDeletedAt:
  17965. m.ClearDeletedAt()
  17966. return nil
  17967. case employee.FieldAiInfo:
  17968. m.ClearAiInfo()
  17969. return nil
  17970. }
  17971. return fmt.Errorf("unknown Employee nullable field %s", name)
  17972. }
  17973. // ResetField resets all changes in the mutation for the field with the given name.
  17974. // It returns an error if the field is not defined in the schema.
  17975. func (m *EmployeeMutation) ResetField(name string) error {
  17976. switch name {
  17977. case employee.FieldCreatedAt:
  17978. m.ResetCreatedAt()
  17979. return nil
  17980. case employee.FieldUpdatedAt:
  17981. m.ResetUpdatedAt()
  17982. return nil
  17983. case employee.FieldDeletedAt:
  17984. m.ResetDeletedAt()
  17985. return nil
  17986. case employee.FieldTitle:
  17987. m.ResetTitle()
  17988. return nil
  17989. case employee.FieldAvatar:
  17990. m.ResetAvatar()
  17991. return nil
  17992. case employee.FieldTags:
  17993. m.ResetTags()
  17994. return nil
  17995. case employee.FieldHireCount:
  17996. m.ResetHireCount()
  17997. return nil
  17998. case employee.FieldServiceCount:
  17999. m.ResetServiceCount()
  18000. return nil
  18001. case employee.FieldAchievementCount:
  18002. m.ResetAchievementCount()
  18003. return nil
  18004. case employee.FieldIntro:
  18005. m.ResetIntro()
  18006. return nil
  18007. case employee.FieldEstimate:
  18008. m.ResetEstimate()
  18009. return nil
  18010. case employee.FieldSkill:
  18011. m.ResetSkill()
  18012. return nil
  18013. case employee.FieldAbilityType:
  18014. m.ResetAbilityType()
  18015. return nil
  18016. case employee.FieldScene:
  18017. m.ResetScene()
  18018. return nil
  18019. case employee.FieldSwitchIn:
  18020. m.ResetSwitchIn()
  18021. return nil
  18022. case employee.FieldVideoURL:
  18023. m.ResetVideoURL()
  18024. return nil
  18025. case employee.FieldOrganizationID:
  18026. m.ResetOrganizationID()
  18027. return nil
  18028. case employee.FieldCategoryID:
  18029. m.ResetCategoryID()
  18030. return nil
  18031. case employee.FieldAPIBase:
  18032. m.ResetAPIBase()
  18033. return nil
  18034. case employee.FieldAPIKey:
  18035. m.ResetAPIKey()
  18036. return nil
  18037. case employee.FieldAiInfo:
  18038. m.ResetAiInfo()
  18039. return nil
  18040. case employee.FieldIsVip:
  18041. m.ResetIsVip()
  18042. return nil
  18043. case employee.FieldChatURL:
  18044. m.ResetChatURL()
  18045. return nil
  18046. }
  18047. return fmt.Errorf("unknown Employee field %s", name)
  18048. }
  18049. // AddedEdges returns all edge names that were set/added in this mutation.
  18050. func (m *EmployeeMutation) AddedEdges() []string {
  18051. edges := make([]string, 0, 2)
  18052. if m.em_work_experiences != nil {
  18053. edges = append(edges, employee.EdgeEmWorkExperiences)
  18054. }
  18055. if m.em_tutorial != nil {
  18056. edges = append(edges, employee.EdgeEmTutorial)
  18057. }
  18058. return edges
  18059. }
  18060. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18061. // name in this mutation.
  18062. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  18063. switch name {
  18064. case employee.EdgeEmWorkExperiences:
  18065. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  18066. for id := range m.em_work_experiences {
  18067. ids = append(ids, id)
  18068. }
  18069. return ids
  18070. case employee.EdgeEmTutorial:
  18071. ids := make([]ent.Value, 0, len(m.em_tutorial))
  18072. for id := range m.em_tutorial {
  18073. ids = append(ids, id)
  18074. }
  18075. return ids
  18076. }
  18077. return nil
  18078. }
  18079. // RemovedEdges returns all edge names that were removed in this mutation.
  18080. func (m *EmployeeMutation) RemovedEdges() []string {
  18081. edges := make([]string, 0, 2)
  18082. if m.removedem_work_experiences != nil {
  18083. edges = append(edges, employee.EdgeEmWorkExperiences)
  18084. }
  18085. if m.removedem_tutorial != nil {
  18086. edges = append(edges, employee.EdgeEmTutorial)
  18087. }
  18088. return edges
  18089. }
  18090. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18091. // the given name in this mutation.
  18092. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  18093. switch name {
  18094. case employee.EdgeEmWorkExperiences:
  18095. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  18096. for id := range m.removedem_work_experiences {
  18097. ids = append(ids, id)
  18098. }
  18099. return ids
  18100. case employee.EdgeEmTutorial:
  18101. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  18102. for id := range m.removedem_tutorial {
  18103. ids = append(ids, id)
  18104. }
  18105. return ids
  18106. }
  18107. return nil
  18108. }
  18109. // ClearedEdges returns all edge names that were cleared in this mutation.
  18110. func (m *EmployeeMutation) ClearedEdges() []string {
  18111. edges := make([]string, 0, 2)
  18112. if m.clearedem_work_experiences {
  18113. edges = append(edges, employee.EdgeEmWorkExperiences)
  18114. }
  18115. if m.clearedem_tutorial {
  18116. edges = append(edges, employee.EdgeEmTutorial)
  18117. }
  18118. return edges
  18119. }
  18120. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18121. // was cleared in this mutation.
  18122. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  18123. switch name {
  18124. case employee.EdgeEmWorkExperiences:
  18125. return m.clearedem_work_experiences
  18126. case employee.EdgeEmTutorial:
  18127. return m.clearedem_tutorial
  18128. }
  18129. return false
  18130. }
  18131. // ClearEdge clears the value of the edge with the given name. It returns an error
  18132. // if that edge is not defined in the schema.
  18133. func (m *EmployeeMutation) ClearEdge(name string) error {
  18134. switch name {
  18135. }
  18136. return fmt.Errorf("unknown Employee unique edge %s", name)
  18137. }
  18138. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18139. // It returns an error if the edge is not defined in the schema.
  18140. func (m *EmployeeMutation) ResetEdge(name string) error {
  18141. switch name {
  18142. case employee.EdgeEmWorkExperiences:
  18143. m.ResetEmWorkExperiences()
  18144. return nil
  18145. case employee.EdgeEmTutorial:
  18146. m.ResetEmTutorial()
  18147. return nil
  18148. }
  18149. return fmt.Errorf("unknown Employee edge %s", name)
  18150. }
  18151. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  18152. type EmployeeConfigMutation struct {
  18153. config
  18154. op Op
  18155. typ string
  18156. id *uint64
  18157. created_at *time.Time
  18158. updated_at *time.Time
  18159. deleted_at *time.Time
  18160. stype *string
  18161. title *string
  18162. photo *string
  18163. organization_id *uint64
  18164. addorganization_id *int64
  18165. clearedFields map[string]struct{}
  18166. done bool
  18167. oldValue func(context.Context) (*EmployeeConfig, error)
  18168. predicates []predicate.EmployeeConfig
  18169. }
  18170. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  18171. // employeeconfigOption allows management of the mutation configuration using functional options.
  18172. type employeeconfigOption func(*EmployeeConfigMutation)
  18173. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  18174. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  18175. m := &EmployeeConfigMutation{
  18176. config: c,
  18177. op: op,
  18178. typ: TypeEmployeeConfig,
  18179. clearedFields: make(map[string]struct{}),
  18180. }
  18181. for _, opt := range opts {
  18182. opt(m)
  18183. }
  18184. return m
  18185. }
  18186. // withEmployeeConfigID sets the ID field of the mutation.
  18187. func withEmployeeConfigID(id uint64) employeeconfigOption {
  18188. return func(m *EmployeeConfigMutation) {
  18189. var (
  18190. err error
  18191. once sync.Once
  18192. value *EmployeeConfig
  18193. )
  18194. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  18195. once.Do(func() {
  18196. if m.done {
  18197. err = errors.New("querying old values post mutation is not allowed")
  18198. } else {
  18199. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  18200. }
  18201. })
  18202. return value, err
  18203. }
  18204. m.id = &id
  18205. }
  18206. }
  18207. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  18208. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  18209. return func(m *EmployeeConfigMutation) {
  18210. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  18211. return node, nil
  18212. }
  18213. m.id = &node.ID
  18214. }
  18215. }
  18216. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18217. // executed in a transaction (ent.Tx), a transactional client is returned.
  18218. func (m EmployeeConfigMutation) Client() *Client {
  18219. client := &Client{config: m.config}
  18220. client.init()
  18221. return client
  18222. }
  18223. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18224. // it returns an error otherwise.
  18225. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  18226. if _, ok := m.driver.(*txDriver); !ok {
  18227. return nil, errors.New("ent: mutation is not running in a transaction")
  18228. }
  18229. tx := &Tx{config: m.config}
  18230. tx.init()
  18231. return tx, nil
  18232. }
  18233. // SetID sets the value of the id field. Note that this
  18234. // operation is only accepted on creation of EmployeeConfig entities.
  18235. func (m *EmployeeConfigMutation) SetID(id uint64) {
  18236. m.id = &id
  18237. }
  18238. // ID returns the ID value in the mutation. Note that the ID is only available
  18239. // if it was provided to the builder or after it was returned from the database.
  18240. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  18241. if m.id == nil {
  18242. return
  18243. }
  18244. return *m.id, true
  18245. }
  18246. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18247. // That means, if the mutation is applied within a transaction with an isolation level such
  18248. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18249. // or updated by the mutation.
  18250. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  18251. switch {
  18252. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18253. id, exists := m.ID()
  18254. if exists {
  18255. return []uint64{id}, nil
  18256. }
  18257. fallthrough
  18258. case m.op.Is(OpUpdate | OpDelete):
  18259. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  18260. default:
  18261. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18262. }
  18263. }
  18264. // SetCreatedAt sets the "created_at" field.
  18265. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  18266. m.created_at = &t
  18267. }
  18268. // CreatedAt returns the value of the "created_at" field in the mutation.
  18269. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  18270. v := m.created_at
  18271. if v == nil {
  18272. return
  18273. }
  18274. return *v, true
  18275. }
  18276. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  18277. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18279. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18280. if !m.op.Is(OpUpdateOne) {
  18281. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18282. }
  18283. if m.id == nil || m.oldValue == nil {
  18284. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18285. }
  18286. oldValue, err := m.oldValue(ctx)
  18287. if err != nil {
  18288. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18289. }
  18290. return oldValue.CreatedAt, nil
  18291. }
  18292. // ResetCreatedAt resets all changes to the "created_at" field.
  18293. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  18294. m.created_at = nil
  18295. }
  18296. // SetUpdatedAt sets the "updated_at" field.
  18297. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  18298. m.updated_at = &t
  18299. }
  18300. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18301. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  18302. v := m.updated_at
  18303. if v == nil {
  18304. return
  18305. }
  18306. return *v, true
  18307. }
  18308. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  18309. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18311. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18312. if !m.op.Is(OpUpdateOne) {
  18313. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18314. }
  18315. if m.id == nil || m.oldValue == nil {
  18316. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18317. }
  18318. oldValue, err := m.oldValue(ctx)
  18319. if err != nil {
  18320. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18321. }
  18322. return oldValue.UpdatedAt, nil
  18323. }
  18324. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18325. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  18326. m.updated_at = nil
  18327. }
  18328. // SetDeletedAt sets the "deleted_at" field.
  18329. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  18330. m.deleted_at = &t
  18331. }
  18332. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18333. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  18334. v := m.deleted_at
  18335. if v == nil {
  18336. return
  18337. }
  18338. return *v, true
  18339. }
  18340. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  18341. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18343. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18344. if !m.op.Is(OpUpdateOne) {
  18345. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18346. }
  18347. if m.id == nil || m.oldValue == nil {
  18348. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18349. }
  18350. oldValue, err := m.oldValue(ctx)
  18351. if err != nil {
  18352. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18353. }
  18354. return oldValue.DeletedAt, nil
  18355. }
  18356. // ClearDeletedAt clears the value of the "deleted_at" field.
  18357. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  18358. m.deleted_at = nil
  18359. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  18360. }
  18361. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18362. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  18363. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  18364. return ok
  18365. }
  18366. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18367. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  18368. m.deleted_at = nil
  18369. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  18370. }
  18371. // SetStype sets the "stype" field.
  18372. func (m *EmployeeConfigMutation) SetStype(s string) {
  18373. m.stype = &s
  18374. }
  18375. // Stype returns the value of the "stype" field in the mutation.
  18376. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  18377. v := m.stype
  18378. if v == nil {
  18379. return
  18380. }
  18381. return *v, true
  18382. }
  18383. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  18384. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18386. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  18387. if !m.op.Is(OpUpdateOne) {
  18388. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  18389. }
  18390. if m.id == nil || m.oldValue == nil {
  18391. return v, errors.New("OldStype requires an ID field in the mutation")
  18392. }
  18393. oldValue, err := m.oldValue(ctx)
  18394. if err != nil {
  18395. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  18396. }
  18397. return oldValue.Stype, nil
  18398. }
  18399. // ResetStype resets all changes to the "stype" field.
  18400. func (m *EmployeeConfigMutation) ResetStype() {
  18401. m.stype = nil
  18402. }
  18403. // SetTitle sets the "title" field.
  18404. func (m *EmployeeConfigMutation) SetTitle(s string) {
  18405. m.title = &s
  18406. }
  18407. // Title returns the value of the "title" field in the mutation.
  18408. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  18409. v := m.title
  18410. if v == nil {
  18411. return
  18412. }
  18413. return *v, true
  18414. }
  18415. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  18416. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18418. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  18419. if !m.op.Is(OpUpdateOne) {
  18420. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18421. }
  18422. if m.id == nil || m.oldValue == nil {
  18423. return v, errors.New("OldTitle requires an ID field in the mutation")
  18424. }
  18425. oldValue, err := m.oldValue(ctx)
  18426. if err != nil {
  18427. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18428. }
  18429. return oldValue.Title, nil
  18430. }
  18431. // ResetTitle resets all changes to the "title" field.
  18432. func (m *EmployeeConfigMutation) ResetTitle() {
  18433. m.title = nil
  18434. }
  18435. // SetPhoto sets the "photo" field.
  18436. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  18437. m.photo = &s
  18438. }
  18439. // Photo returns the value of the "photo" field in the mutation.
  18440. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  18441. v := m.photo
  18442. if v == nil {
  18443. return
  18444. }
  18445. return *v, true
  18446. }
  18447. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  18448. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18450. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  18451. if !m.op.Is(OpUpdateOne) {
  18452. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  18453. }
  18454. if m.id == nil || m.oldValue == nil {
  18455. return v, errors.New("OldPhoto requires an ID field in the mutation")
  18456. }
  18457. oldValue, err := m.oldValue(ctx)
  18458. if err != nil {
  18459. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  18460. }
  18461. return oldValue.Photo, nil
  18462. }
  18463. // ResetPhoto resets all changes to the "photo" field.
  18464. func (m *EmployeeConfigMutation) ResetPhoto() {
  18465. m.photo = nil
  18466. }
  18467. // SetOrganizationID sets the "organization_id" field.
  18468. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  18469. m.organization_id = &u
  18470. m.addorganization_id = nil
  18471. }
  18472. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18473. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  18474. v := m.organization_id
  18475. if v == nil {
  18476. return
  18477. }
  18478. return *v, true
  18479. }
  18480. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  18481. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18483. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18484. if !m.op.Is(OpUpdateOne) {
  18485. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18486. }
  18487. if m.id == nil || m.oldValue == nil {
  18488. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18489. }
  18490. oldValue, err := m.oldValue(ctx)
  18491. if err != nil {
  18492. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18493. }
  18494. return oldValue.OrganizationID, nil
  18495. }
  18496. // AddOrganizationID adds u to the "organization_id" field.
  18497. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  18498. if m.addorganization_id != nil {
  18499. *m.addorganization_id += u
  18500. } else {
  18501. m.addorganization_id = &u
  18502. }
  18503. }
  18504. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18505. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  18506. v := m.addorganization_id
  18507. if v == nil {
  18508. return
  18509. }
  18510. return *v, true
  18511. }
  18512. // ClearOrganizationID clears the value of the "organization_id" field.
  18513. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  18514. m.organization_id = nil
  18515. m.addorganization_id = nil
  18516. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  18517. }
  18518. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18519. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  18520. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  18521. return ok
  18522. }
  18523. // ResetOrganizationID resets all changes to the "organization_id" field.
  18524. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  18525. m.organization_id = nil
  18526. m.addorganization_id = nil
  18527. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  18528. }
  18529. // Where appends a list predicates to the EmployeeConfigMutation builder.
  18530. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  18531. m.predicates = append(m.predicates, ps...)
  18532. }
  18533. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  18534. // users can use type-assertion to append predicates that do not depend on any generated package.
  18535. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  18536. p := make([]predicate.EmployeeConfig, len(ps))
  18537. for i := range ps {
  18538. p[i] = ps[i]
  18539. }
  18540. m.Where(p...)
  18541. }
  18542. // Op returns the operation name.
  18543. func (m *EmployeeConfigMutation) Op() Op {
  18544. return m.op
  18545. }
  18546. // SetOp allows setting the mutation operation.
  18547. func (m *EmployeeConfigMutation) SetOp(op Op) {
  18548. m.op = op
  18549. }
  18550. // Type returns the node type of this mutation (EmployeeConfig).
  18551. func (m *EmployeeConfigMutation) Type() string {
  18552. return m.typ
  18553. }
  18554. // Fields returns all fields that were changed during this mutation. Note that in
  18555. // order to get all numeric fields that were incremented/decremented, call
  18556. // AddedFields().
  18557. func (m *EmployeeConfigMutation) Fields() []string {
  18558. fields := make([]string, 0, 7)
  18559. if m.created_at != nil {
  18560. fields = append(fields, employeeconfig.FieldCreatedAt)
  18561. }
  18562. if m.updated_at != nil {
  18563. fields = append(fields, employeeconfig.FieldUpdatedAt)
  18564. }
  18565. if m.deleted_at != nil {
  18566. fields = append(fields, employeeconfig.FieldDeletedAt)
  18567. }
  18568. if m.stype != nil {
  18569. fields = append(fields, employeeconfig.FieldStype)
  18570. }
  18571. if m.title != nil {
  18572. fields = append(fields, employeeconfig.FieldTitle)
  18573. }
  18574. if m.photo != nil {
  18575. fields = append(fields, employeeconfig.FieldPhoto)
  18576. }
  18577. if m.organization_id != nil {
  18578. fields = append(fields, employeeconfig.FieldOrganizationID)
  18579. }
  18580. return fields
  18581. }
  18582. // Field returns the value of a field with the given name. The second boolean
  18583. // return value indicates that this field was not set, or was not defined in the
  18584. // schema.
  18585. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  18586. switch name {
  18587. case employeeconfig.FieldCreatedAt:
  18588. return m.CreatedAt()
  18589. case employeeconfig.FieldUpdatedAt:
  18590. return m.UpdatedAt()
  18591. case employeeconfig.FieldDeletedAt:
  18592. return m.DeletedAt()
  18593. case employeeconfig.FieldStype:
  18594. return m.Stype()
  18595. case employeeconfig.FieldTitle:
  18596. return m.Title()
  18597. case employeeconfig.FieldPhoto:
  18598. return m.Photo()
  18599. case employeeconfig.FieldOrganizationID:
  18600. return m.OrganizationID()
  18601. }
  18602. return nil, false
  18603. }
  18604. // OldField returns the old value of the field from the database. An error is
  18605. // returned if the mutation operation is not UpdateOne, or the query to the
  18606. // database failed.
  18607. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18608. switch name {
  18609. case employeeconfig.FieldCreatedAt:
  18610. return m.OldCreatedAt(ctx)
  18611. case employeeconfig.FieldUpdatedAt:
  18612. return m.OldUpdatedAt(ctx)
  18613. case employeeconfig.FieldDeletedAt:
  18614. return m.OldDeletedAt(ctx)
  18615. case employeeconfig.FieldStype:
  18616. return m.OldStype(ctx)
  18617. case employeeconfig.FieldTitle:
  18618. return m.OldTitle(ctx)
  18619. case employeeconfig.FieldPhoto:
  18620. return m.OldPhoto(ctx)
  18621. case employeeconfig.FieldOrganizationID:
  18622. return m.OldOrganizationID(ctx)
  18623. }
  18624. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  18625. }
  18626. // SetField sets the value of a field with the given name. It returns an error if
  18627. // the field is not defined in the schema, or if the type mismatched the field
  18628. // type.
  18629. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  18630. switch name {
  18631. case employeeconfig.FieldCreatedAt:
  18632. v, ok := value.(time.Time)
  18633. if !ok {
  18634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18635. }
  18636. m.SetCreatedAt(v)
  18637. return nil
  18638. case employeeconfig.FieldUpdatedAt:
  18639. v, ok := value.(time.Time)
  18640. if !ok {
  18641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18642. }
  18643. m.SetUpdatedAt(v)
  18644. return nil
  18645. case employeeconfig.FieldDeletedAt:
  18646. v, ok := value.(time.Time)
  18647. if !ok {
  18648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18649. }
  18650. m.SetDeletedAt(v)
  18651. return nil
  18652. case employeeconfig.FieldStype:
  18653. v, ok := value.(string)
  18654. if !ok {
  18655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18656. }
  18657. m.SetStype(v)
  18658. return nil
  18659. case employeeconfig.FieldTitle:
  18660. v, ok := value.(string)
  18661. if !ok {
  18662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18663. }
  18664. m.SetTitle(v)
  18665. return nil
  18666. case employeeconfig.FieldPhoto:
  18667. v, ok := value.(string)
  18668. if !ok {
  18669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18670. }
  18671. m.SetPhoto(v)
  18672. return nil
  18673. case employeeconfig.FieldOrganizationID:
  18674. v, ok := value.(uint64)
  18675. if !ok {
  18676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18677. }
  18678. m.SetOrganizationID(v)
  18679. return nil
  18680. }
  18681. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  18682. }
  18683. // AddedFields returns all numeric fields that were incremented/decremented during
  18684. // this mutation.
  18685. func (m *EmployeeConfigMutation) AddedFields() []string {
  18686. var fields []string
  18687. if m.addorganization_id != nil {
  18688. fields = append(fields, employeeconfig.FieldOrganizationID)
  18689. }
  18690. return fields
  18691. }
  18692. // AddedField returns the numeric value that was incremented/decremented on a field
  18693. // with the given name. The second boolean return value indicates that this field
  18694. // was not set, or was not defined in the schema.
  18695. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  18696. switch name {
  18697. case employeeconfig.FieldOrganizationID:
  18698. return m.AddedOrganizationID()
  18699. }
  18700. return nil, false
  18701. }
  18702. // AddField adds the value to the field with the given name. It returns an error if
  18703. // the field is not defined in the schema, or if the type mismatched the field
  18704. // type.
  18705. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  18706. switch name {
  18707. case employeeconfig.FieldOrganizationID:
  18708. v, ok := value.(int64)
  18709. if !ok {
  18710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18711. }
  18712. m.AddOrganizationID(v)
  18713. return nil
  18714. }
  18715. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  18716. }
  18717. // ClearedFields returns all nullable fields that were cleared during this
  18718. // mutation.
  18719. func (m *EmployeeConfigMutation) ClearedFields() []string {
  18720. var fields []string
  18721. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  18722. fields = append(fields, employeeconfig.FieldDeletedAt)
  18723. }
  18724. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  18725. fields = append(fields, employeeconfig.FieldOrganizationID)
  18726. }
  18727. return fields
  18728. }
  18729. // FieldCleared returns a boolean indicating if a field with the given name was
  18730. // cleared in this mutation.
  18731. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  18732. _, ok := m.clearedFields[name]
  18733. return ok
  18734. }
  18735. // ClearField clears the value of the field with the given name. It returns an
  18736. // error if the field is not defined in the schema.
  18737. func (m *EmployeeConfigMutation) ClearField(name string) error {
  18738. switch name {
  18739. case employeeconfig.FieldDeletedAt:
  18740. m.ClearDeletedAt()
  18741. return nil
  18742. case employeeconfig.FieldOrganizationID:
  18743. m.ClearOrganizationID()
  18744. return nil
  18745. }
  18746. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  18747. }
  18748. // ResetField resets all changes in the mutation for the field with the given name.
  18749. // It returns an error if the field is not defined in the schema.
  18750. func (m *EmployeeConfigMutation) ResetField(name string) error {
  18751. switch name {
  18752. case employeeconfig.FieldCreatedAt:
  18753. m.ResetCreatedAt()
  18754. return nil
  18755. case employeeconfig.FieldUpdatedAt:
  18756. m.ResetUpdatedAt()
  18757. return nil
  18758. case employeeconfig.FieldDeletedAt:
  18759. m.ResetDeletedAt()
  18760. return nil
  18761. case employeeconfig.FieldStype:
  18762. m.ResetStype()
  18763. return nil
  18764. case employeeconfig.FieldTitle:
  18765. m.ResetTitle()
  18766. return nil
  18767. case employeeconfig.FieldPhoto:
  18768. m.ResetPhoto()
  18769. return nil
  18770. case employeeconfig.FieldOrganizationID:
  18771. m.ResetOrganizationID()
  18772. return nil
  18773. }
  18774. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  18775. }
  18776. // AddedEdges returns all edge names that were set/added in this mutation.
  18777. func (m *EmployeeConfigMutation) AddedEdges() []string {
  18778. edges := make([]string, 0, 0)
  18779. return edges
  18780. }
  18781. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18782. // name in this mutation.
  18783. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  18784. return nil
  18785. }
  18786. // RemovedEdges returns all edge names that were removed in this mutation.
  18787. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  18788. edges := make([]string, 0, 0)
  18789. return edges
  18790. }
  18791. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18792. // the given name in this mutation.
  18793. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  18794. return nil
  18795. }
  18796. // ClearedEdges returns all edge names that were cleared in this mutation.
  18797. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  18798. edges := make([]string, 0, 0)
  18799. return edges
  18800. }
  18801. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18802. // was cleared in this mutation.
  18803. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  18804. return false
  18805. }
  18806. // ClearEdge clears the value of the edge with the given name. It returns an error
  18807. // if that edge is not defined in the schema.
  18808. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  18809. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  18810. }
  18811. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18812. // It returns an error if the edge is not defined in the schema.
  18813. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  18814. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  18815. }
  18816. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  18817. type LabelMutation struct {
  18818. config
  18819. op Op
  18820. typ string
  18821. id *uint64
  18822. created_at *time.Time
  18823. updated_at *time.Time
  18824. status *uint8
  18825. addstatus *int8
  18826. _type *int
  18827. add_type *int
  18828. name *string
  18829. from *int
  18830. addfrom *int
  18831. mode *int
  18832. addmode *int
  18833. conditions *string
  18834. organization_id *uint64
  18835. addorganization_id *int64
  18836. clearedFields map[string]struct{}
  18837. label_relationships map[uint64]struct{}
  18838. removedlabel_relationships map[uint64]struct{}
  18839. clearedlabel_relationships bool
  18840. done bool
  18841. oldValue func(context.Context) (*Label, error)
  18842. predicates []predicate.Label
  18843. }
  18844. var _ ent.Mutation = (*LabelMutation)(nil)
  18845. // labelOption allows management of the mutation configuration using functional options.
  18846. type labelOption func(*LabelMutation)
  18847. // newLabelMutation creates new mutation for the Label entity.
  18848. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  18849. m := &LabelMutation{
  18850. config: c,
  18851. op: op,
  18852. typ: TypeLabel,
  18853. clearedFields: make(map[string]struct{}),
  18854. }
  18855. for _, opt := range opts {
  18856. opt(m)
  18857. }
  18858. return m
  18859. }
  18860. // withLabelID sets the ID field of the mutation.
  18861. func withLabelID(id uint64) labelOption {
  18862. return func(m *LabelMutation) {
  18863. var (
  18864. err error
  18865. once sync.Once
  18866. value *Label
  18867. )
  18868. m.oldValue = func(ctx context.Context) (*Label, error) {
  18869. once.Do(func() {
  18870. if m.done {
  18871. err = errors.New("querying old values post mutation is not allowed")
  18872. } else {
  18873. value, err = m.Client().Label.Get(ctx, id)
  18874. }
  18875. })
  18876. return value, err
  18877. }
  18878. m.id = &id
  18879. }
  18880. }
  18881. // withLabel sets the old Label of the mutation.
  18882. func withLabel(node *Label) labelOption {
  18883. return func(m *LabelMutation) {
  18884. m.oldValue = func(context.Context) (*Label, error) {
  18885. return node, nil
  18886. }
  18887. m.id = &node.ID
  18888. }
  18889. }
  18890. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18891. // executed in a transaction (ent.Tx), a transactional client is returned.
  18892. func (m LabelMutation) Client() *Client {
  18893. client := &Client{config: m.config}
  18894. client.init()
  18895. return client
  18896. }
  18897. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18898. // it returns an error otherwise.
  18899. func (m LabelMutation) Tx() (*Tx, error) {
  18900. if _, ok := m.driver.(*txDriver); !ok {
  18901. return nil, errors.New("ent: mutation is not running in a transaction")
  18902. }
  18903. tx := &Tx{config: m.config}
  18904. tx.init()
  18905. return tx, nil
  18906. }
  18907. // SetID sets the value of the id field. Note that this
  18908. // operation is only accepted on creation of Label entities.
  18909. func (m *LabelMutation) SetID(id uint64) {
  18910. m.id = &id
  18911. }
  18912. // ID returns the ID value in the mutation. Note that the ID is only available
  18913. // if it was provided to the builder or after it was returned from the database.
  18914. func (m *LabelMutation) ID() (id uint64, exists bool) {
  18915. if m.id == nil {
  18916. return
  18917. }
  18918. return *m.id, true
  18919. }
  18920. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18921. // That means, if the mutation is applied within a transaction with an isolation level such
  18922. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18923. // or updated by the mutation.
  18924. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  18925. switch {
  18926. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18927. id, exists := m.ID()
  18928. if exists {
  18929. return []uint64{id}, nil
  18930. }
  18931. fallthrough
  18932. case m.op.Is(OpUpdate | OpDelete):
  18933. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  18934. default:
  18935. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18936. }
  18937. }
  18938. // SetCreatedAt sets the "created_at" field.
  18939. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  18940. m.created_at = &t
  18941. }
  18942. // CreatedAt returns the value of the "created_at" field in the mutation.
  18943. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  18944. v := m.created_at
  18945. if v == nil {
  18946. return
  18947. }
  18948. return *v, true
  18949. }
  18950. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  18951. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18953. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18954. if !m.op.Is(OpUpdateOne) {
  18955. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18956. }
  18957. if m.id == nil || m.oldValue == nil {
  18958. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18959. }
  18960. oldValue, err := m.oldValue(ctx)
  18961. if err != nil {
  18962. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18963. }
  18964. return oldValue.CreatedAt, nil
  18965. }
  18966. // ResetCreatedAt resets all changes to the "created_at" field.
  18967. func (m *LabelMutation) ResetCreatedAt() {
  18968. m.created_at = nil
  18969. }
  18970. // SetUpdatedAt sets the "updated_at" field.
  18971. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  18972. m.updated_at = &t
  18973. }
  18974. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18975. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  18976. v := m.updated_at
  18977. if v == nil {
  18978. return
  18979. }
  18980. return *v, true
  18981. }
  18982. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  18983. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  18984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18985. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18986. if !m.op.Is(OpUpdateOne) {
  18987. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18988. }
  18989. if m.id == nil || m.oldValue == nil {
  18990. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18991. }
  18992. oldValue, err := m.oldValue(ctx)
  18993. if err != nil {
  18994. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18995. }
  18996. return oldValue.UpdatedAt, nil
  18997. }
  18998. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18999. func (m *LabelMutation) ResetUpdatedAt() {
  19000. m.updated_at = nil
  19001. }
  19002. // SetStatus sets the "status" field.
  19003. func (m *LabelMutation) SetStatus(u uint8) {
  19004. m.status = &u
  19005. m.addstatus = nil
  19006. }
  19007. // Status returns the value of the "status" field in the mutation.
  19008. func (m *LabelMutation) Status() (r uint8, exists bool) {
  19009. v := m.status
  19010. if v == nil {
  19011. return
  19012. }
  19013. return *v, true
  19014. }
  19015. // OldStatus returns the old "status" field's value of the Label entity.
  19016. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19018. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19019. if !m.op.Is(OpUpdateOne) {
  19020. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19021. }
  19022. if m.id == nil || m.oldValue == nil {
  19023. return v, errors.New("OldStatus requires an ID field in the mutation")
  19024. }
  19025. oldValue, err := m.oldValue(ctx)
  19026. if err != nil {
  19027. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19028. }
  19029. return oldValue.Status, nil
  19030. }
  19031. // AddStatus adds u to the "status" field.
  19032. func (m *LabelMutation) AddStatus(u int8) {
  19033. if m.addstatus != nil {
  19034. *m.addstatus += u
  19035. } else {
  19036. m.addstatus = &u
  19037. }
  19038. }
  19039. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19040. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  19041. v := m.addstatus
  19042. if v == nil {
  19043. return
  19044. }
  19045. return *v, true
  19046. }
  19047. // ClearStatus clears the value of the "status" field.
  19048. func (m *LabelMutation) ClearStatus() {
  19049. m.status = nil
  19050. m.addstatus = nil
  19051. m.clearedFields[label.FieldStatus] = struct{}{}
  19052. }
  19053. // StatusCleared returns if the "status" field was cleared in this mutation.
  19054. func (m *LabelMutation) StatusCleared() bool {
  19055. _, ok := m.clearedFields[label.FieldStatus]
  19056. return ok
  19057. }
  19058. // ResetStatus resets all changes to the "status" field.
  19059. func (m *LabelMutation) ResetStatus() {
  19060. m.status = nil
  19061. m.addstatus = nil
  19062. delete(m.clearedFields, label.FieldStatus)
  19063. }
  19064. // SetType sets the "type" field.
  19065. func (m *LabelMutation) SetType(i int) {
  19066. m._type = &i
  19067. m.add_type = nil
  19068. }
  19069. // GetType returns the value of the "type" field in the mutation.
  19070. func (m *LabelMutation) GetType() (r int, exists bool) {
  19071. v := m._type
  19072. if v == nil {
  19073. return
  19074. }
  19075. return *v, true
  19076. }
  19077. // OldType returns the old "type" field's value of the Label entity.
  19078. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19080. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  19081. if !m.op.Is(OpUpdateOne) {
  19082. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19083. }
  19084. if m.id == nil || m.oldValue == nil {
  19085. return v, errors.New("OldType requires an ID field in the mutation")
  19086. }
  19087. oldValue, err := m.oldValue(ctx)
  19088. if err != nil {
  19089. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19090. }
  19091. return oldValue.Type, nil
  19092. }
  19093. // AddType adds i to the "type" field.
  19094. func (m *LabelMutation) AddType(i int) {
  19095. if m.add_type != nil {
  19096. *m.add_type += i
  19097. } else {
  19098. m.add_type = &i
  19099. }
  19100. }
  19101. // AddedType returns the value that was added to the "type" field in this mutation.
  19102. func (m *LabelMutation) AddedType() (r int, exists bool) {
  19103. v := m.add_type
  19104. if v == nil {
  19105. return
  19106. }
  19107. return *v, true
  19108. }
  19109. // ResetType resets all changes to the "type" field.
  19110. func (m *LabelMutation) ResetType() {
  19111. m._type = nil
  19112. m.add_type = nil
  19113. }
  19114. // SetName sets the "name" field.
  19115. func (m *LabelMutation) SetName(s string) {
  19116. m.name = &s
  19117. }
  19118. // Name returns the value of the "name" field in the mutation.
  19119. func (m *LabelMutation) Name() (r string, exists bool) {
  19120. v := m.name
  19121. if v == nil {
  19122. return
  19123. }
  19124. return *v, true
  19125. }
  19126. // OldName returns the old "name" field's value of the Label entity.
  19127. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19129. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  19130. if !m.op.Is(OpUpdateOne) {
  19131. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19132. }
  19133. if m.id == nil || m.oldValue == nil {
  19134. return v, errors.New("OldName requires an ID field in the mutation")
  19135. }
  19136. oldValue, err := m.oldValue(ctx)
  19137. if err != nil {
  19138. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19139. }
  19140. return oldValue.Name, nil
  19141. }
  19142. // ResetName resets all changes to the "name" field.
  19143. func (m *LabelMutation) ResetName() {
  19144. m.name = nil
  19145. }
  19146. // SetFrom sets the "from" field.
  19147. func (m *LabelMutation) SetFrom(i int) {
  19148. m.from = &i
  19149. m.addfrom = nil
  19150. }
  19151. // From returns the value of the "from" field in the mutation.
  19152. func (m *LabelMutation) From() (r int, exists bool) {
  19153. v := m.from
  19154. if v == nil {
  19155. return
  19156. }
  19157. return *v, true
  19158. }
  19159. // OldFrom returns the old "from" field's value of the Label entity.
  19160. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19162. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  19163. if !m.op.Is(OpUpdateOne) {
  19164. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  19165. }
  19166. if m.id == nil || m.oldValue == nil {
  19167. return v, errors.New("OldFrom requires an ID field in the mutation")
  19168. }
  19169. oldValue, err := m.oldValue(ctx)
  19170. if err != nil {
  19171. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  19172. }
  19173. return oldValue.From, nil
  19174. }
  19175. // AddFrom adds i to the "from" field.
  19176. func (m *LabelMutation) AddFrom(i int) {
  19177. if m.addfrom != nil {
  19178. *m.addfrom += i
  19179. } else {
  19180. m.addfrom = &i
  19181. }
  19182. }
  19183. // AddedFrom returns the value that was added to the "from" field in this mutation.
  19184. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  19185. v := m.addfrom
  19186. if v == nil {
  19187. return
  19188. }
  19189. return *v, true
  19190. }
  19191. // ResetFrom resets all changes to the "from" field.
  19192. func (m *LabelMutation) ResetFrom() {
  19193. m.from = nil
  19194. m.addfrom = nil
  19195. }
  19196. // SetMode sets the "mode" field.
  19197. func (m *LabelMutation) SetMode(i int) {
  19198. m.mode = &i
  19199. m.addmode = nil
  19200. }
  19201. // Mode returns the value of the "mode" field in the mutation.
  19202. func (m *LabelMutation) Mode() (r int, exists bool) {
  19203. v := m.mode
  19204. if v == nil {
  19205. return
  19206. }
  19207. return *v, true
  19208. }
  19209. // OldMode returns the old "mode" field's value of the Label entity.
  19210. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19212. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  19213. if !m.op.Is(OpUpdateOne) {
  19214. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  19215. }
  19216. if m.id == nil || m.oldValue == nil {
  19217. return v, errors.New("OldMode requires an ID field in the mutation")
  19218. }
  19219. oldValue, err := m.oldValue(ctx)
  19220. if err != nil {
  19221. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  19222. }
  19223. return oldValue.Mode, nil
  19224. }
  19225. // AddMode adds i to the "mode" field.
  19226. func (m *LabelMutation) AddMode(i int) {
  19227. if m.addmode != nil {
  19228. *m.addmode += i
  19229. } else {
  19230. m.addmode = &i
  19231. }
  19232. }
  19233. // AddedMode returns the value that was added to the "mode" field in this mutation.
  19234. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  19235. v := m.addmode
  19236. if v == nil {
  19237. return
  19238. }
  19239. return *v, true
  19240. }
  19241. // ResetMode resets all changes to the "mode" field.
  19242. func (m *LabelMutation) ResetMode() {
  19243. m.mode = nil
  19244. m.addmode = nil
  19245. }
  19246. // SetConditions sets the "conditions" field.
  19247. func (m *LabelMutation) SetConditions(s string) {
  19248. m.conditions = &s
  19249. }
  19250. // Conditions returns the value of the "conditions" field in the mutation.
  19251. func (m *LabelMutation) Conditions() (r string, exists bool) {
  19252. v := m.conditions
  19253. if v == nil {
  19254. return
  19255. }
  19256. return *v, true
  19257. }
  19258. // OldConditions returns the old "conditions" field's value of the Label entity.
  19259. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19261. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  19262. if !m.op.Is(OpUpdateOne) {
  19263. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19264. }
  19265. if m.id == nil || m.oldValue == nil {
  19266. return v, errors.New("OldConditions requires an ID field in the mutation")
  19267. }
  19268. oldValue, err := m.oldValue(ctx)
  19269. if err != nil {
  19270. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19271. }
  19272. return oldValue.Conditions, nil
  19273. }
  19274. // ClearConditions clears the value of the "conditions" field.
  19275. func (m *LabelMutation) ClearConditions() {
  19276. m.conditions = nil
  19277. m.clearedFields[label.FieldConditions] = struct{}{}
  19278. }
  19279. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  19280. func (m *LabelMutation) ConditionsCleared() bool {
  19281. _, ok := m.clearedFields[label.FieldConditions]
  19282. return ok
  19283. }
  19284. // ResetConditions resets all changes to the "conditions" field.
  19285. func (m *LabelMutation) ResetConditions() {
  19286. m.conditions = nil
  19287. delete(m.clearedFields, label.FieldConditions)
  19288. }
  19289. // SetOrganizationID sets the "organization_id" field.
  19290. func (m *LabelMutation) SetOrganizationID(u uint64) {
  19291. m.organization_id = &u
  19292. m.addorganization_id = nil
  19293. }
  19294. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19295. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  19296. v := m.organization_id
  19297. if v == nil {
  19298. return
  19299. }
  19300. return *v, true
  19301. }
  19302. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  19303. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19305. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19306. if !m.op.Is(OpUpdateOne) {
  19307. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19308. }
  19309. if m.id == nil || m.oldValue == nil {
  19310. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19311. }
  19312. oldValue, err := m.oldValue(ctx)
  19313. if err != nil {
  19314. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19315. }
  19316. return oldValue.OrganizationID, nil
  19317. }
  19318. // AddOrganizationID adds u to the "organization_id" field.
  19319. func (m *LabelMutation) AddOrganizationID(u int64) {
  19320. if m.addorganization_id != nil {
  19321. *m.addorganization_id += u
  19322. } else {
  19323. m.addorganization_id = &u
  19324. }
  19325. }
  19326. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19327. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  19328. v := m.addorganization_id
  19329. if v == nil {
  19330. return
  19331. }
  19332. return *v, true
  19333. }
  19334. // ClearOrganizationID clears the value of the "organization_id" field.
  19335. func (m *LabelMutation) ClearOrganizationID() {
  19336. m.organization_id = nil
  19337. m.addorganization_id = nil
  19338. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  19339. }
  19340. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19341. func (m *LabelMutation) OrganizationIDCleared() bool {
  19342. _, ok := m.clearedFields[label.FieldOrganizationID]
  19343. return ok
  19344. }
  19345. // ResetOrganizationID resets all changes to the "organization_id" field.
  19346. func (m *LabelMutation) ResetOrganizationID() {
  19347. m.organization_id = nil
  19348. m.addorganization_id = nil
  19349. delete(m.clearedFields, label.FieldOrganizationID)
  19350. }
  19351. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  19352. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  19353. if m.label_relationships == nil {
  19354. m.label_relationships = make(map[uint64]struct{})
  19355. }
  19356. for i := range ids {
  19357. m.label_relationships[ids[i]] = struct{}{}
  19358. }
  19359. }
  19360. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  19361. func (m *LabelMutation) ClearLabelRelationships() {
  19362. m.clearedlabel_relationships = true
  19363. }
  19364. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  19365. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  19366. return m.clearedlabel_relationships
  19367. }
  19368. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  19369. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  19370. if m.removedlabel_relationships == nil {
  19371. m.removedlabel_relationships = make(map[uint64]struct{})
  19372. }
  19373. for i := range ids {
  19374. delete(m.label_relationships, ids[i])
  19375. m.removedlabel_relationships[ids[i]] = struct{}{}
  19376. }
  19377. }
  19378. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  19379. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  19380. for id := range m.removedlabel_relationships {
  19381. ids = append(ids, id)
  19382. }
  19383. return
  19384. }
  19385. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  19386. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  19387. for id := range m.label_relationships {
  19388. ids = append(ids, id)
  19389. }
  19390. return
  19391. }
  19392. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  19393. func (m *LabelMutation) ResetLabelRelationships() {
  19394. m.label_relationships = nil
  19395. m.clearedlabel_relationships = false
  19396. m.removedlabel_relationships = nil
  19397. }
  19398. // Where appends a list predicates to the LabelMutation builder.
  19399. func (m *LabelMutation) Where(ps ...predicate.Label) {
  19400. m.predicates = append(m.predicates, ps...)
  19401. }
  19402. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  19403. // users can use type-assertion to append predicates that do not depend on any generated package.
  19404. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  19405. p := make([]predicate.Label, len(ps))
  19406. for i := range ps {
  19407. p[i] = ps[i]
  19408. }
  19409. m.Where(p...)
  19410. }
  19411. // Op returns the operation name.
  19412. func (m *LabelMutation) Op() Op {
  19413. return m.op
  19414. }
  19415. // SetOp allows setting the mutation operation.
  19416. func (m *LabelMutation) SetOp(op Op) {
  19417. m.op = op
  19418. }
  19419. // Type returns the node type of this mutation (Label).
  19420. func (m *LabelMutation) Type() string {
  19421. return m.typ
  19422. }
  19423. // Fields returns all fields that were changed during this mutation. Note that in
  19424. // order to get all numeric fields that were incremented/decremented, call
  19425. // AddedFields().
  19426. func (m *LabelMutation) Fields() []string {
  19427. fields := make([]string, 0, 9)
  19428. if m.created_at != nil {
  19429. fields = append(fields, label.FieldCreatedAt)
  19430. }
  19431. if m.updated_at != nil {
  19432. fields = append(fields, label.FieldUpdatedAt)
  19433. }
  19434. if m.status != nil {
  19435. fields = append(fields, label.FieldStatus)
  19436. }
  19437. if m._type != nil {
  19438. fields = append(fields, label.FieldType)
  19439. }
  19440. if m.name != nil {
  19441. fields = append(fields, label.FieldName)
  19442. }
  19443. if m.from != nil {
  19444. fields = append(fields, label.FieldFrom)
  19445. }
  19446. if m.mode != nil {
  19447. fields = append(fields, label.FieldMode)
  19448. }
  19449. if m.conditions != nil {
  19450. fields = append(fields, label.FieldConditions)
  19451. }
  19452. if m.organization_id != nil {
  19453. fields = append(fields, label.FieldOrganizationID)
  19454. }
  19455. return fields
  19456. }
  19457. // Field returns the value of a field with the given name. The second boolean
  19458. // return value indicates that this field was not set, or was not defined in the
  19459. // schema.
  19460. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  19461. switch name {
  19462. case label.FieldCreatedAt:
  19463. return m.CreatedAt()
  19464. case label.FieldUpdatedAt:
  19465. return m.UpdatedAt()
  19466. case label.FieldStatus:
  19467. return m.Status()
  19468. case label.FieldType:
  19469. return m.GetType()
  19470. case label.FieldName:
  19471. return m.Name()
  19472. case label.FieldFrom:
  19473. return m.From()
  19474. case label.FieldMode:
  19475. return m.Mode()
  19476. case label.FieldConditions:
  19477. return m.Conditions()
  19478. case label.FieldOrganizationID:
  19479. return m.OrganizationID()
  19480. }
  19481. return nil, false
  19482. }
  19483. // OldField returns the old value of the field from the database. An error is
  19484. // returned if the mutation operation is not UpdateOne, or the query to the
  19485. // database failed.
  19486. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19487. switch name {
  19488. case label.FieldCreatedAt:
  19489. return m.OldCreatedAt(ctx)
  19490. case label.FieldUpdatedAt:
  19491. return m.OldUpdatedAt(ctx)
  19492. case label.FieldStatus:
  19493. return m.OldStatus(ctx)
  19494. case label.FieldType:
  19495. return m.OldType(ctx)
  19496. case label.FieldName:
  19497. return m.OldName(ctx)
  19498. case label.FieldFrom:
  19499. return m.OldFrom(ctx)
  19500. case label.FieldMode:
  19501. return m.OldMode(ctx)
  19502. case label.FieldConditions:
  19503. return m.OldConditions(ctx)
  19504. case label.FieldOrganizationID:
  19505. return m.OldOrganizationID(ctx)
  19506. }
  19507. return nil, fmt.Errorf("unknown Label field %s", name)
  19508. }
  19509. // SetField sets the value of a field with the given name. It returns an error if
  19510. // the field is not defined in the schema, or if the type mismatched the field
  19511. // type.
  19512. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  19513. switch name {
  19514. case label.FieldCreatedAt:
  19515. v, ok := value.(time.Time)
  19516. if !ok {
  19517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19518. }
  19519. m.SetCreatedAt(v)
  19520. return nil
  19521. case label.FieldUpdatedAt:
  19522. v, ok := value.(time.Time)
  19523. if !ok {
  19524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19525. }
  19526. m.SetUpdatedAt(v)
  19527. return nil
  19528. case label.FieldStatus:
  19529. v, ok := value.(uint8)
  19530. if !ok {
  19531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19532. }
  19533. m.SetStatus(v)
  19534. return nil
  19535. case label.FieldType:
  19536. v, ok := value.(int)
  19537. if !ok {
  19538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19539. }
  19540. m.SetType(v)
  19541. return nil
  19542. case label.FieldName:
  19543. v, ok := value.(string)
  19544. if !ok {
  19545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19546. }
  19547. m.SetName(v)
  19548. return nil
  19549. case label.FieldFrom:
  19550. v, ok := value.(int)
  19551. if !ok {
  19552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19553. }
  19554. m.SetFrom(v)
  19555. return nil
  19556. case label.FieldMode:
  19557. v, ok := value.(int)
  19558. if !ok {
  19559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19560. }
  19561. m.SetMode(v)
  19562. return nil
  19563. case label.FieldConditions:
  19564. v, ok := value.(string)
  19565. if !ok {
  19566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19567. }
  19568. m.SetConditions(v)
  19569. return nil
  19570. case label.FieldOrganizationID:
  19571. v, ok := value.(uint64)
  19572. if !ok {
  19573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19574. }
  19575. m.SetOrganizationID(v)
  19576. return nil
  19577. }
  19578. return fmt.Errorf("unknown Label field %s", name)
  19579. }
  19580. // AddedFields returns all numeric fields that were incremented/decremented during
  19581. // this mutation.
  19582. func (m *LabelMutation) AddedFields() []string {
  19583. var fields []string
  19584. if m.addstatus != nil {
  19585. fields = append(fields, label.FieldStatus)
  19586. }
  19587. if m.add_type != nil {
  19588. fields = append(fields, label.FieldType)
  19589. }
  19590. if m.addfrom != nil {
  19591. fields = append(fields, label.FieldFrom)
  19592. }
  19593. if m.addmode != nil {
  19594. fields = append(fields, label.FieldMode)
  19595. }
  19596. if m.addorganization_id != nil {
  19597. fields = append(fields, label.FieldOrganizationID)
  19598. }
  19599. return fields
  19600. }
  19601. // AddedField returns the numeric value that was incremented/decremented on a field
  19602. // with the given name. The second boolean return value indicates that this field
  19603. // was not set, or was not defined in the schema.
  19604. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  19605. switch name {
  19606. case label.FieldStatus:
  19607. return m.AddedStatus()
  19608. case label.FieldType:
  19609. return m.AddedType()
  19610. case label.FieldFrom:
  19611. return m.AddedFrom()
  19612. case label.FieldMode:
  19613. return m.AddedMode()
  19614. case label.FieldOrganizationID:
  19615. return m.AddedOrganizationID()
  19616. }
  19617. return nil, false
  19618. }
  19619. // AddField adds the value to the field with the given name. It returns an error if
  19620. // the field is not defined in the schema, or if the type mismatched the field
  19621. // type.
  19622. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  19623. switch name {
  19624. case label.FieldStatus:
  19625. v, ok := value.(int8)
  19626. if !ok {
  19627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19628. }
  19629. m.AddStatus(v)
  19630. return nil
  19631. case label.FieldType:
  19632. v, ok := value.(int)
  19633. if !ok {
  19634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19635. }
  19636. m.AddType(v)
  19637. return nil
  19638. case label.FieldFrom:
  19639. v, ok := value.(int)
  19640. if !ok {
  19641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19642. }
  19643. m.AddFrom(v)
  19644. return nil
  19645. case label.FieldMode:
  19646. v, ok := value.(int)
  19647. if !ok {
  19648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19649. }
  19650. m.AddMode(v)
  19651. return nil
  19652. case label.FieldOrganizationID:
  19653. v, ok := value.(int64)
  19654. if !ok {
  19655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19656. }
  19657. m.AddOrganizationID(v)
  19658. return nil
  19659. }
  19660. return fmt.Errorf("unknown Label numeric field %s", name)
  19661. }
  19662. // ClearedFields returns all nullable fields that were cleared during this
  19663. // mutation.
  19664. func (m *LabelMutation) ClearedFields() []string {
  19665. var fields []string
  19666. if m.FieldCleared(label.FieldStatus) {
  19667. fields = append(fields, label.FieldStatus)
  19668. }
  19669. if m.FieldCleared(label.FieldConditions) {
  19670. fields = append(fields, label.FieldConditions)
  19671. }
  19672. if m.FieldCleared(label.FieldOrganizationID) {
  19673. fields = append(fields, label.FieldOrganizationID)
  19674. }
  19675. return fields
  19676. }
  19677. // FieldCleared returns a boolean indicating if a field with the given name was
  19678. // cleared in this mutation.
  19679. func (m *LabelMutation) FieldCleared(name string) bool {
  19680. _, ok := m.clearedFields[name]
  19681. return ok
  19682. }
  19683. // ClearField clears the value of the field with the given name. It returns an
  19684. // error if the field is not defined in the schema.
  19685. func (m *LabelMutation) ClearField(name string) error {
  19686. switch name {
  19687. case label.FieldStatus:
  19688. m.ClearStatus()
  19689. return nil
  19690. case label.FieldConditions:
  19691. m.ClearConditions()
  19692. return nil
  19693. case label.FieldOrganizationID:
  19694. m.ClearOrganizationID()
  19695. return nil
  19696. }
  19697. return fmt.Errorf("unknown Label nullable field %s", name)
  19698. }
  19699. // ResetField resets all changes in the mutation for the field with the given name.
  19700. // It returns an error if the field is not defined in the schema.
  19701. func (m *LabelMutation) ResetField(name string) error {
  19702. switch name {
  19703. case label.FieldCreatedAt:
  19704. m.ResetCreatedAt()
  19705. return nil
  19706. case label.FieldUpdatedAt:
  19707. m.ResetUpdatedAt()
  19708. return nil
  19709. case label.FieldStatus:
  19710. m.ResetStatus()
  19711. return nil
  19712. case label.FieldType:
  19713. m.ResetType()
  19714. return nil
  19715. case label.FieldName:
  19716. m.ResetName()
  19717. return nil
  19718. case label.FieldFrom:
  19719. m.ResetFrom()
  19720. return nil
  19721. case label.FieldMode:
  19722. m.ResetMode()
  19723. return nil
  19724. case label.FieldConditions:
  19725. m.ResetConditions()
  19726. return nil
  19727. case label.FieldOrganizationID:
  19728. m.ResetOrganizationID()
  19729. return nil
  19730. }
  19731. return fmt.Errorf("unknown Label field %s", name)
  19732. }
  19733. // AddedEdges returns all edge names that were set/added in this mutation.
  19734. func (m *LabelMutation) AddedEdges() []string {
  19735. edges := make([]string, 0, 1)
  19736. if m.label_relationships != nil {
  19737. edges = append(edges, label.EdgeLabelRelationships)
  19738. }
  19739. return edges
  19740. }
  19741. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19742. // name in this mutation.
  19743. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  19744. switch name {
  19745. case label.EdgeLabelRelationships:
  19746. ids := make([]ent.Value, 0, len(m.label_relationships))
  19747. for id := range m.label_relationships {
  19748. ids = append(ids, id)
  19749. }
  19750. return ids
  19751. }
  19752. return nil
  19753. }
  19754. // RemovedEdges returns all edge names that were removed in this mutation.
  19755. func (m *LabelMutation) RemovedEdges() []string {
  19756. edges := make([]string, 0, 1)
  19757. if m.removedlabel_relationships != nil {
  19758. edges = append(edges, label.EdgeLabelRelationships)
  19759. }
  19760. return edges
  19761. }
  19762. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19763. // the given name in this mutation.
  19764. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  19765. switch name {
  19766. case label.EdgeLabelRelationships:
  19767. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  19768. for id := range m.removedlabel_relationships {
  19769. ids = append(ids, id)
  19770. }
  19771. return ids
  19772. }
  19773. return nil
  19774. }
  19775. // ClearedEdges returns all edge names that were cleared in this mutation.
  19776. func (m *LabelMutation) ClearedEdges() []string {
  19777. edges := make([]string, 0, 1)
  19778. if m.clearedlabel_relationships {
  19779. edges = append(edges, label.EdgeLabelRelationships)
  19780. }
  19781. return edges
  19782. }
  19783. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19784. // was cleared in this mutation.
  19785. func (m *LabelMutation) EdgeCleared(name string) bool {
  19786. switch name {
  19787. case label.EdgeLabelRelationships:
  19788. return m.clearedlabel_relationships
  19789. }
  19790. return false
  19791. }
  19792. // ClearEdge clears the value of the edge with the given name. It returns an error
  19793. // if that edge is not defined in the schema.
  19794. func (m *LabelMutation) ClearEdge(name string) error {
  19795. switch name {
  19796. }
  19797. return fmt.Errorf("unknown Label unique edge %s", name)
  19798. }
  19799. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19800. // It returns an error if the edge is not defined in the schema.
  19801. func (m *LabelMutation) ResetEdge(name string) error {
  19802. switch name {
  19803. case label.EdgeLabelRelationships:
  19804. m.ResetLabelRelationships()
  19805. return nil
  19806. }
  19807. return fmt.Errorf("unknown Label edge %s", name)
  19808. }
  19809. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  19810. type LabelLogMutation struct {
  19811. config
  19812. op Op
  19813. typ string
  19814. id *uint64
  19815. created_at *time.Time
  19816. updated_at *time.Time
  19817. label_name *string
  19818. label_id *int
  19819. addlabel_id *int
  19820. wx_id *string
  19821. organization_id *uint64
  19822. addorganization_id *int64
  19823. clearedFields map[string]struct{}
  19824. done bool
  19825. oldValue func(context.Context) (*LabelLog, error)
  19826. predicates []predicate.LabelLog
  19827. }
  19828. var _ ent.Mutation = (*LabelLogMutation)(nil)
  19829. // labellogOption allows management of the mutation configuration using functional options.
  19830. type labellogOption func(*LabelLogMutation)
  19831. // newLabelLogMutation creates new mutation for the LabelLog entity.
  19832. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  19833. m := &LabelLogMutation{
  19834. config: c,
  19835. op: op,
  19836. typ: TypeLabelLog,
  19837. clearedFields: make(map[string]struct{}),
  19838. }
  19839. for _, opt := range opts {
  19840. opt(m)
  19841. }
  19842. return m
  19843. }
  19844. // withLabelLogID sets the ID field of the mutation.
  19845. func withLabelLogID(id uint64) labellogOption {
  19846. return func(m *LabelLogMutation) {
  19847. var (
  19848. err error
  19849. once sync.Once
  19850. value *LabelLog
  19851. )
  19852. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  19853. once.Do(func() {
  19854. if m.done {
  19855. err = errors.New("querying old values post mutation is not allowed")
  19856. } else {
  19857. value, err = m.Client().LabelLog.Get(ctx, id)
  19858. }
  19859. })
  19860. return value, err
  19861. }
  19862. m.id = &id
  19863. }
  19864. }
  19865. // withLabelLog sets the old LabelLog of the mutation.
  19866. func withLabelLog(node *LabelLog) labellogOption {
  19867. return func(m *LabelLogMutation) {
  19868. m.oldValue = func(context.Context) (*LabelLog, error) {
  19869. return node, nil
  19870. }
  19871. m.id = &node.ID
  19872. }
  19873. }
  19874. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19875. // executed in a transaction (ent.Tx), a transactional client is returned.
  19876. func (m LabelLogMutation) Client() *Client {
  19877. client := &Client{config: m.config}
  19878. client.init()
  19879. return client
  19880. }
  19881. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19882. // it returns an error otherwise.
  19883. func (m LabelLogMutation) Tx() (*Tx, error) {
  19884. if _, ok := m.driver.(*txDriver); !ok {
  19885. return nil, errors.New("ent: mutation is not running in a transaction")
  19886. }
  19887. tx := &Tx{config: m.config}
  19888. tx.init()
  19889. return tx, nil
  19890. }
  19891. // SetID sets the value of the id field. Note that this
  19892. // operation is only accepted on creation of LabelLog entities.
  19893. func (m *LabelLogMutation) SetID(id uint64) {
  19894. m.id = &id
  19895. }
  19896. // ID returns the ID value in the mutation. Note that the ID is only available
  19897. // if it was provided to the builder or after it was returned from the database.
  19898. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  19899. if m.id == nil {
  19900. return
  19901. }
  19902. return *m.id, true
  19903. }
  19904. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19905. // That means, if the mutation is applied within a transaction with an isolation level such
  19906. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19907. // or updated by the mutation.
  19908. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  19909. switch {
  19910. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19911. id, exists := m.ID()
  19912. if exists {
  19913. return []uint64{id}, nil
  19914. }
  19915. fallthrough
  19916. case m.op.Is(OpUpdate | OpDelete):
  19917. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  19918. default:
  19919. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19920. }
  19921. }
  19922. // SetCreatedAt sets the "created_at" field.
  19923. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  19924. m.created_at = &t
  19925. }
  19926. // CreatedAt returns the value of the "created_at" field in the mutation.
  19927. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  19928. v := m.created_at
  19929. if v == nil {
  19930. return
  19931. }
  19932. return *v, true
  19933. }
  19934. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  19935. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  19936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19937. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19938. if !m.op.Is(OpUpdateOne) {
  19939. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19940. }
  19941. if m.id == nil || m.oldValue == nil {
  19942. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19943. }
  19944. oldValue, err := m.oldValue(ctx)
  19945. if err != nil {
  19946. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19947. }
  19948. return oldValue.CreatedAt, nil
  19949. }
  19950. // ResetCreatedAt resets all changes to the "created_at" field.
  19951. func (m *LabelLogMutation) ResetCreatedAt() {
  19952. m.created_at = nil
  19953. }
  19954. // SetUpdatedAt sets the "updated_at" field.
  19955. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  19956. m.updated_at = &t
  19957. }
  19958. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19959. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  19960. v := m.updated_at
  19961. if v == nil {
  19962. return
  19963. }
  19964. return *v, true
  19965. }
  19966. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  19967. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  19968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19969. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19970. if !m.op.Is(OpUpdateOne) {
  19971. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19972. }
  19973. if m.id == nil || m.oldValue == nil {
  19974. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19975. }
  19976. oldValue, err := m.oldValue(ctx)
  19977. if err != nil {
  19978. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19979. }
  19980. return oldValue.UpdatedAt, nil
  19981. }
  19982. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19983. func (m *LabelLogMutation) ResetUpdatedAt() {
  19984. m.updated_at = nil
  19985. }
  19986. // SetLabelName sets the "label_name" field.
  19987. func (m *LabelLogMutation) SetLabelName(s string) {
  19988. m.label_name = &s
  19989. }
  19990. // LabelName returns the value of the "label_name" field in the mutation.
  19991. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  19992. v := m.label_name
  19993. if v == nil {
  19994. return
  19995. }
  19996. return *v, true
  19997. }
  19998. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  19999. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20001. func (m *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  20002. if !m.op.Is(OpUpdateOne) {
  20003. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  20004. }
  20005. if m.id == nil || m.oldValue == nil {
  20006. return v, errors.New("OldLabelName requires an ID field in the mutation")
  20007. }
  20008. oldValue, err := m.oldValue(ctx)
  20009. if err != nil {
  20010. return v, fmt.Errorf("querying old value for OldLabelName: %w", err)
  20011. }
  20012. return oldValue.LabelName, nil
  20013. }
  20014. // ResetLabelName resets all changes to the "label_name" field.
  20015. func (m *LabelLogMutation) ResetLabelName() {
  20016. m.label_name = nil
  20017. }
  20018. // SetLabelID sets the "label_id" field.
  20019. func (m *LabelLogMutation) SetLabelID(i int) {
  20020. m.label_id = &i
  20021. m.addlabel_id = nil
  20022. }
  20023. // LabelID returns the value of the "label_id" field in the mutation.
  20024. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  20025. v := m.label_id
  20026. if v == nil {
  20027. return
  20028. }
  20029. return *v, true
  20030. }
  20031. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  20032. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20034. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  20035. if !m.op.Is(OpUpdateOne) {
  20036. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  20037. }
  20038. if m.id == nil || m.oldValue == nil {
  20039. return v, errors.New("OldLabelID requires an ID field in the mutation")
  20040. }
  20041. oldValue, err := m.oldValue(ctx)
  20042. if err != nil {
  20043. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  20044. }
  20045. return oldValue.LabelID, nil
  20046. }
  20047. // AddLabelID adds i to the "label_id" field.
  20048. func (m *LabelLogMutation) AddLabelID(i int) {
  20049. if m.addlabel_id != nil {
  20050. *m.addlabel_id += i
  20051. } else {
  20052. m.addlabel_id = &i
  20053. }
  20054. }
  20055. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  20056. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  20057. v := m.addlabel_id
  20058. if v == nil {
  20059. return
  20060. }
  20061. return *v, true
  20062. }
  20063. // ResetLabelID resets all changes to the "label_id" field.
  20064. func (m *LabelLogMutation) ResetLabelID() {
  20065. m.label_id = nil
  20066. m.addlabel_id = nil
  20067. }
  20068. // SetWxID sets the "wx_id" field.
  20069. func (m *LabelLogMutation) SetWxID(s string) {
  20070. m.wx_id = &s
  20071. }
  20072. // WxID returns the value of the "wx_id" field in the mutation.
  20073. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  20074. v := m.wx_id
  20075. if v == nil {
  20076. return
  20077. }
  20078. return *v, true
  20079. }
  20080. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  20081. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20083. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  20084. if !m.op.Is(OpUpdateOne) {
  20085. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  20086. }
  20087. if m.id == nil || m.oldValue == nil {
  20088. return v, errors.New("OldWxID requires an ID field in the mutation")
  20089. }
  20090. oldValue, err := m.oldValue(ctx)
  20091. if err != nil {
  20092. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  20093. }
  20094. return oldValue.WxID, nil
  20095. }
  20096. // ResetWxID resets all changes to the "wx_id" field.
  20097. func (m *LabelLogMutation) ResetWxID() {
  20098. m.wx_id = nil
  20099. }
  20100. // SetOrganizationID sets the "organization_id" field.
  20101. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  20102. m.organization_id = &u
  20103. m.addorganization_id = nil
  20104. }
  20105. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20106. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  20107. v := m.organization_id
  20108. if v == nil {
  20109. return
  20110. }
  20111. return *v, true
  20112. }
  20113. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  20114. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  20115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20116. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20117. if !m.op.Is(OpUpdateOne) {
  20118. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20119. }
  20120. if m.id == nil || m.oldValue == nil {
  20121. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20122. }
  20123. oldValue, err := m.oldValue(ctx)
  20124. if err != nil {
  20125. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20126. }
  20127. return oldValue.OrganizationID, nil
  20128. }
  20129. // AddOrganizationID adds u to the "organization_id" field.
  20130. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  20131. if m.addorganization_id != nil {
  20132. *m.addorganization_id += u
  20133. } else {
  20134. m.addorganization_id = &u
  20135. }
  20136. }
  20137. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20138. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  20139. v := m.addorganization_id
  20140. if v == nil {
  20141. return
  20142. }
  20143. return *v, true
  20144. }
  20145. // ClearOrganizationID clears the value of the "organization_id" field.
  20146. func (m *LabelLogMutation) ClearOrganizationID() {
  20147. m.organization_id = nil
  20148. m.addorganization_id = nil
  20149. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  20150. }
  20151. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20152. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  20153. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  20154. return ok
  20155. }
  20156. // ResetOrganizationID resets all changes to the "organization_id" field.
  20157. func (m *LabelLogMutation) ResetOrganizationID() {
  20158. m.organization_id = nil
  20159. m.addorganization_id = nil
  20160. delete(m.clearedFields, labellog.FieldOrganizationID)
  20161. }
  20162. // Where appends a list predicates to the LabelLogMutation builder.
  20163. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  20164. m.predicates = append(m.predicates, ps...)
  20165. }
  20166. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  20167. // users can use type-assertion to append predicates that do not depend on any generated package.
  20168. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  20169. p := make([]predicate.LabelLog, len(ps))
  20170. for i := range ps {
  20171. p[i] = ps[i]
  20172. }
  20173. m.Where(p...)
  20174. }
  20175. // Op returns the operation name.
  20176. func (m *LabelLogMutation) Op() Op {
  20177. return m.op
  20178. }
  20179. // SetOp allows setting the mutation operation.
  20180. func (m *LabelLogMutation) SetOp(op Op) {
  20181. m.op = op
  20182. }
  20183. // Type returns the node type of this mutation (LabelLog).
  20184. func (m *LabelLogMutation) Type() string {
  20185. return m.typ
  20186. }
  20187. // Fields returns all fields that were changed during this mutation. Note that in
  20188. // order to get all numeric fields that were incremented/decremented, call
  20189. // AddedFields().
  20190. func (m *LabelLogMutation) Fields() []string {
  20191. fields := make([]string, 0, 6)
  20192. if m.created_at != nil {
  20193. fields = append(fields, labellog.FieldCreatedAt)
  20194. }
  20195. if m.updated_at != nil {
  20196. fields = append(fields, labellog.FieldUpdatedAt)
  20197. }
  20198. if m.label_name != nil {
  20199. fields = append(fields, labellog.FieldLabelName)
  20200. }
  20201. if m.label_id != nil {
  20202. fields = append(fields, labellog.FieldLabelID)
  20203. }
  20204. if m.wx_id != nil {
  20205. fields = append(fields, labellog.FieldWxID)
  20206. }
  20207. if m.organization_id != nil {
  20208. fields = append(fields, labellog.FieldOrganizationID)
  20209. }
  20210. return fields
  20211. }
  20212. // Field returns the value of a field with the given name. The second boolean
  20213. // return value indicates that this field was not set, or was not defined in the
  20214. // schema.
  20215. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  20216. switch name {
  20217. case labellog.FieldCreatedAt:
  20218. return m.CreatedAt()
  20219. case labellog.FieldUpdatedAt:
  20220. return m.UpdatedAt()
  20221. case labellog.FieldLabelName:
  20222. return m.LabelName()
  20223. case labellog.FieldLabelID:
  20224. return m.LabelID()
  20225. case labellog.FieldWxID:
  20226. return m.WxID()
  20227. case labellog.FieldOrganizationID:
  20228. return m.OrganizationID()
  20229. }
  20230. return nil, false
  20231. }
  20232. // OldField returns the old value of the field from the database. An error is
  20233. // returned if the mutation operation is not UpdateOne, or the query to the
  20234. // database failed.
  20235. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20236. switch name {
  20237. case labellog.FieldCreatedAt:
  20238. return m.OldCreatedAt(ctx)
  20239. case labellog.FieldUpdatedAt:
  20240. return m.OldUpdatedAt(ctx)
  20241. case labellog.FieldLabelName:
  20242. return m.OldLabelName(ctx)
  20243. case labellog.FieldLabelID:
  20244. return m.OldLabelID(ctx)
  20245. case labellog.FieldWxID:
  20246. return m.OldWxID(ctx)
  20247. case labellog.FieldOrganizationID:
  20248. return m.OldOrganizationID(ctx)
  20249. }
  20250. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  20251. }
  20252. // SetField sets the value of a field with the given name. It returns an error if
  20253. // the field is not defined in the schema, or if the type mismatched the field
  20254. // type.
  20255. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  20256. switch name {
  20257. case labellog.FieldCreatedAt:
  20258. v, ok := value.(time.Time)
  20259. if !ok {
  20260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20261. }
  20262. m.SetCreatedAt(v)
  20263. return nil
  20264. case labellog.FieldUpdatedAt:
  20265. v, ok := value.(time.Time)
  20266. if !ok {
  20267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20268. }
  20269. m.SetUpdatedAt(v)
  20270. return nil
  20271. case labellog.FieldLabelName:
  20272. v, ok := value.(string)
  20273. if !ok {
  20274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20275. }
  20276. m.SetLabelName(v)
  20277. return nil
  20278. case labellog.FieldLabelID:
  20279. v, ok := value.(int)
  20280. if !ok {
  20281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20282. }
  20283. m.SetLabelID(v)
  20284. return nil
  20285. case labellog.FieldWxID:
  20286. v, ok := value.(string)
  20287. if !ok {
  20288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20289. }
  20290. m.SetWxID(v)
  20291. return nil
  20292. case labellog.FieldOrganizationID:
  20293. v, ok := value.(uint64)
  20294. if !ok {
  20295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20296. }
  20297. m.SetOrganizationID(v)
  20298. return nil
  20299. }
  20300. return fmt.Errorf("unknown LabelLog field %s", name)
  20301. }
  20302. // AddedFields returns all numeric fields that were incremented/decremented during
  20303. // this mutation.
  20304. func (m *LabelLogMutation) AddedFields() []string {
  20305. var fields []string
  20306. if m.addlabel_id != nil {
  20307. fields = append(fields, labellog.FieldLabelID)
  20308. }
  20309. if m.addorganization_id != nil {
  20310. fields = append(fields, labellog.FieldOrganizationID)
  20311. }
  20312. return fields
  20313. }
  20314. // AddedField returns the numeric value that was incremented/decremented on a field
  20315. // with the given name. The second boolean return value indicates that this field
  20316. // was not set, or was not defined in the schema.
  20317. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  20318. switch name {
  20319. case labellog.FieldLabelID:
  20320. return m.AddedLabelID()
  20321. case labellog.FieldOrganizationID:
  20322. return m.AddedOrganizationID()
  20323. }
  20324. return nil, false
  20325. }
  20326. // AddField adds the value to the field with the given name. It returns an error if
  20327. // the field is not defined in the schema, or if the type mismatched the field
  20328. // type.
  20329. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  20330. switch name {
  20331. case labellog.FieldLabelID:
  20332. v, ok := value.(int)
  20333. if !ok {
  20334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20335. }
  20336. m.AddLabelID(v)
  20337. return nil
  20338. case labellog.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 LabelLog numeric field %s", name)
  20347. }
  20348. // ClearedFields returns all nullable fields that were cleared during this
  20349. // mutation.
  20350. func (m *LabelLogMutation) ClearedFields() []string {
  20351. var fields []string
  20352. if m.FieldCleared(labellog.FieldOrganizationID) {
  20353. fields = append(fields, labellog.FieldOrganizationID)
  20354. }
  20355. return fields
  20356. }
  20357. // FieldCleared returns a boolean indicating if a field with the given name was
  20358. // cleared in this mutation.
  20359. func (m *LabelLogMutation) FieldCleared(name string) bool {
  20360. _, ok := m.clearedFields[name]
  20361. return ok
  20362. }
  20363. // ClearField clears the value of the field with the given name. It returns an
  20364. // error if the field is not defined in the schema.
  20365. func (m *LabelLogMutation) ClearField(name string) error {
  20366. switch name {
  20367. case labellog.FieldOrganizationID:
  20368. m.ClearOrganizationID()
  20369. return nil
  20370. }
  20371. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  20372. }
  20373. // ResetField resets all changes in the mutation for the field with the given name.
  20374. // It returns an error if the field is not defined in the schema.
  20375. func (m *LabelLogMutation) ResetField(name string) error {
  20376. switch name {
  20377. case labellog.FieldCreatedAt:
  20378. m.ResetCreatedAt()
  20379. return nil
  20380. case labellog.FieldUpdatedAt:
  20381. m.ResetUpdatedAt()
  20382. return nil
  20383. case labellog.FieldLabelName:
  20384. m.ResetLabelName()
  20385. return nil
  20386. case labellog.FieldLabelID:
  20387. m.ResetLabelID()
  20388. return nil
  20389. case labellog.FieldWxID:
  20390. m.ResetWxID()
  20391. return nil
  20392. case labellog.FieldOrganizationID:
  20393. m.ResetOrganizationID()
  20394. return nil
  20395. }
  20396. return fmt.Errorf("unknown LabelLog field %s", name)
  20397. }
  20398. // AddedEdges returns all edge names that were set/added in this mutation.
  20399. func (m *LabelLogMutation) AddedEdges() []string {
  20400. edges := make([]string, 0, 0)
  20401. return edges
  20402. }
  20403. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20404. // name in this mutation.
  20405. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  20406. return nil
  20407. }
  20408. // RemovedEdges returns all edge names that were removed in this mutation.
  20409. func (m *LabelLogMutation) RemovedEdges() []string {
  20410. edges := make([]string, 0, 0)
  20411. return edges
  20412. }
  20413. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20414. // the given name in this mutation.
  20415. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  20416. return nil
  20417. }
  20418. // ClearedEdges returns all edge names that were cleared in this mutation.
  20419. func (m *LabelLogMutation) ClearedEdges() []string {
  20420. edges := make([]string, 0, 0)
  20421. return edges
  20422. }
  20423. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20424. // was cleared in this mutation.
  20425. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  20426. return false
  20427. }
  20428. // ClearEdge clears the value of the edge with the given name. It returns an error
  20429. // if that edge is not defined in the schema.
  20430. func (m *LabelLogMutation) ClearEdge(name string) error {
  20431. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  20432. }
  20433. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20434. // It returns an error if the edge is not defined in the schema.
  20435. func (m *LabelLogMutation) ResetEdge(name string) error {
  20436. return fmt.Errorf("unknown LabelLog edge %s", name)
  20437. }
  20438. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  20439. type LabelRelationshipMutation struct {
  20440. config
  20441. op Op
  20442. typ string
  20443. id *uint64
  20444. created_at *time.Time
  20445. updated_at *time.Time
  20446. status *uint8
  20447. addstatus *int8
  20448. organization_id *uint64
  20449. addorganization_id *int64
  20450. clearedFields map[string]struct{}
  20451. contacts *uint64
  20452. clearedcontacts bool
  20453. labels *uint64
  20454. clearedlabels bool
  20455. done bool
  20456. oldValue func(context.Context) (*LabelRelationship, error)
  20457. predicates []predicate.LabelRelationship
  20458. }
  20459. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  20460. // labelrelationshipOption allows management of the mutation configuration using functional options.
  20461. type labelrelationshipOption func(*LabelRelationshipMutation)
  20462. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  20463. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  20464. m := &LabelRelationshipMutation{
  20465. config: c,
  20466. op: op,
  20467. typ: TypeLabelRelationship,
  20468. clearedFields: make(map[string]struct{}),
  20469. }
  20470. for _, opt := range opts {
  20471. opt(m)
  20472. }
  20473. return m
  20474. }
  20475. // withLabelRelationshipID sets the ID field of the mutation.
  20476. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  20477. return func(m *LabelRelationshipMutation) {
  20478. var (
  20479. err error
  20480. once sync.Once
  20481. value *LabelRelationship
  20482. )
  20483. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  20484. once.Do(func() {
  20485. if m.done {
  20486. err = errors.New("querying old values post mutation is not allowed")
  20487. } else {
  20488. value, err = m.Client().LabelRelationship.Get(ctx, id)
  20489. }
  20490. })
  20491. return value, err
  20492. }
  20493. m.id = &id
  20494. }
  20495. }
  20496. // withLabelRelationship sets the old LabelRelationship of the mutation.
  20497. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  20498. return func(m *LabelRelationshipMutation) {
  20499. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  20500. return node, nil
  20501. }
  20502. m.id = &node.ID
  20503. }
  20504. }
  20505. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20506. // executed in a transaction (ent.Tx), a transactional client is returned.
  20507. func (m LabelRelationshipMutation) Client() *Client {
  20508. client := &Client{config: m.config}
  20509. client.init()
  20510. return client
  20511. }
  20512. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20513. // it returns an error otherwise.
  20514. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  20515. if _, ok := m.driver.(*txDriver); !ok {
  20516. return nil, errors.New("ent: mutation is not running in a transaction")
  20517. }
  20518. tx := &Tx{config: m.config}
  20519. tx.init()
  20520. return tx, nil
  20521. }
  20522. // SetID sets the value of the id field. Note that this
  20523. // operation is only accepted on creation of LabelRelationship entities.
  20524. func (m *LabelRelationshipMutation) SetID(id uint64) {
  20525. m.id = &id
  20526. }
  20527. // ID returns the ID value in the mutation. Note that the ID is only available
  20528. // if it was provided to the builder or after it was returned from the database.
  20529. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  20530. if m.id == nil {
  20531. return
  20532. }
  20533. return *m.id, true
  20534. }
  20535. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20536. // That means, if the mutation is applied within a transaction with an isolation level such
  20537. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20538. // or updated by the mutation.
  20539. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  20540. switch {
  20541. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20542. id, exists := m.ID()
  20543. if exists {
  20544. return []uint64{id}, nil
  20545. }
  20546. fallthrough
  20547. case m.op.Is(OpUpdate | OpDelete):
  20548. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  20549. default:
  20550. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20551. }
  20552. }
  20553. // SetCreatedAt sets the "created_at" field.
  20554. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  20555. m.created_at = &t
  20556. }
  20557. // CreatedAt returns the value of the "created_at" field in the mutation.
  20558. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  20559. v := m.created_at
  20560. if v == nil {
  20561. return
  20562. }
  20563. return *v, true
  20564. }
  20565. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  20566. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20568. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20569. if !m.op.Is(OpUpdateOne) {
  20570. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20571. }
  20572. if m.id == nil || m.oldValue == nil {
  20573. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20574. }
  20575. oldValue, err := m.oldValue(ctx)
  20576. if err != nil {
  20577. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20578. }
  20579. return oldValue.CreatedAt, nil
  20580. }
  20581. // ResetCreatedAt resets all changes to the "created_at" field.
  20582. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  20583. m.created_at = nil
  20584. }
  20585. // SetUpdatedAt sets the "updated_at" field.
  20586. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  20587. m.updated_at = &t
  20588. }
  20589. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20590. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  20591. v := m.updated_at
  20592. if v == nil {
  20593. return
  20594. }
  20595. return *v, true
  20596. }
  20597. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  20598. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20600. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20601. if !m.op.Is(OpUpdateOne) {
  20602. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20603. }
  20604. if m.id == nil || m.oldValue == nil {
  20605. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20606. }
  20607. oldValue, err := m.oldValue(ctx)
  20608. if err != nil {
  20609. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20610. }
  20611. return oldValue.UpdatedAt, nil
  20612. }
  20613. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20614. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  20615. m.updated_at = nil
  20616. }
  20617. // SetStatus sets the "status" field.
  20618. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  20619. m.status = &u
  20620. m.addstatus = nil
  20621. }
  20622. // Status returns the value of the "status" field in the mutation.
  20623. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  20624. v := m.status
  20625. if v == nil {
  20626. return
  20627. }
  20628. return *v, true
  20629. }
  20630. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  20631. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20633. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20634. if !m.op.Is(OpUpdateOne) {
  20635. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20636. }
  20637. if m.id == nil || m.oldValue == nil {
  20638. return v, errors.New("OldStatus requires an ID field in the mutation")
  20639. }
  20640. oldValue, err := m.oldValue(ctx)
  20641. if err != nil {
  20642. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20643. }
  20644. return oldValue.Status, nil
  20645. }
  20646. // AddStatus adds u to the "status" field.
  20647. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  20648. if m.addstatus != nil {
  20649. *m.addstatus += u
  20650. } else {
  20651. m.addstatus = &u
  20652. }
  20653. }
  20654. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20655. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  20656. v := m.addstatus
  20657. if v == nil {
  20658. return
  20659. }
  20660. return *v, true
  20661. }
  20662. // ClearStatus clears the value of the "status" field.
  20663. func (m *LabelRelationshipMutation) ClearStatus() {
  20664. m.status = nil
  20665. m.addstatus = nil
  20666. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  20667. }
  20668. // StatusCleared returns if the "status" field was cleared in this mutation.
  20669. func (m *LabelRelationshipMutation) StatusCleared() bool {
  20670. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  20671. return ok
  20672. }
  20673. // ResetStatus resets all changes to the "status" field.
  20674. func (m *LabelRelationshipMutation) ResetStatus() {
  20675. m.status = nil
  20676. m.addstatus = nil
  20677. delete(m.clearedFields, labelrelationship.FieldStatus)
  20678. }
  20679. // SetLabelID sets the "label_id" field.
  20680. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  20681. m.labels = &u
  20682. }
  20683. // LabelID returns the value of the "label_id" field in the mutation.
  20684. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  20685. v := m.labels
  20686. if v == nil {
  20687. return
  20688. }
  20689. return *v, true
  20690. }
  20691. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  20692. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20694. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  20695. if !m.op.Is(OpUpdateOne) {
  20696. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  20697. }
  20698. if m.id == nil || m.oldValue == nil {
  20699. return v, errors.New("OldLabelID requires an ID field in the mutation")
  20700. }
  20701. oldValue, err := m.oldValue(ctx)
  20702. if err != nil {
  20703. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  20704. }
  20705. return oldValue.LabelID, nil
  20706. }
  20707. // ResetLabelID resets all changes to the "label_id" field.
  20708. func (m *LabelRelationshipMutation) ResetLabelID() {
  20709. m.labels = nil
  20710. }
  20711. // SetContactID sets the "contact_id" field.
  20712. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  20713. m.contacts = &u
  20714. }
  20715. // ContactID returns the value of the "contact_id" field in the mutation.
  20716. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  20717. v := m.contacts
  20718. if v == nil {
  20719. return
  20720. }
  20721. return *v, true
  20722. }
  20723. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  20724. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20726. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20727. if !m.op.Is(OpUpdateOne) {
  20728. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20729. }
  20730. if m.id == nil || m.oldValue == nil {
  20731. return v, errors.New("OldContactID requires an ID field in the mutation")
  20732. }
  20733. oldValue, err := m.oldValue(ctx)
  20734. if err != nil {
  20735. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20736. }
  20737. return oldValue.ContactID, nil
  20738. }
  20739. // ResetContactID resets all changes to the "contact_id" field.
  20740. func (m *LabelRelationshipMutation) ResetContactID() {
  20741. m.contacts = nil
  20742. }
  20743. // SetOrganizationID sets the "organization_id" field.
  20744. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  20745. m.organization_id = &u
  20746. m.addorganization_id = nil
  20747. }
  20748. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20749. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  20750. v := m.organization_id
  20751. if v == nil {
  20752. return
  20753. }
  20754. return *v, true
  20755. }
  20756. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  20757. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20759. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20760. if !m.op.Is(OpUpdateOne) {
  20761. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20762. }
  20763. if m.id == nil || m.oldValue == nil {
  20764. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20765. }
  20766. oldValue, err := m.oldValue(ctx)
  20767. if err != nil {
  20768. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20769. }
  20770. return oldValue.OrganizationID, nil
  20771. }
  20772. // AddOrganizationID adds u to the "organization_id" field.
  20773. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  20774. if m.addorganization_id != nil {
  20775. *m.addorganization_id += u
  20776. } else {
  20777. m.addorganization_id = &u
  20778. }
  20779. }
  20780. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20781. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  20782. v := m.addorganization_id
  20783. if v == nil {
  20784. return
  20785. }
  20786. return *v, true
  20787. }
  20788. // ClearOrganizationID clears the value of the "organization_id" field.
  20789. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  20790. m.organization_id = nil
  20791. m.addorganization_id = nil
  20792. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  20793. }
  20794. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20795. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  20796. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  20797. return ok
  20798. }
  20799. // ResetOrganizationID resets all changes to the "organization_id" field.
  20800. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  20801. m.organization_id = nil
  20802. m.addorganization_id = nil
  20803. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  20804. }
  20805. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  20806. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  20807. m.contacts = &id
  20808. }
  20809. // ClearContacts clears the "contacts" edge to the Contact entity.
  20810. func (m *LabelRelationshipMutation) ClearContacts() {
  20811. m.clearedcontacts = true
  20812. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  20813. }
  20814. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  20815. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  20816. return m.clearedcontacts
  20817. }
  20818. // ContactsID returns the "contacts" edge ID in the mutation.
  20819. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  20820. if m.contacts != nil {
  20821. return *m.contacts, true
  20822. }
  20823. return
  20824. }
  20825. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  20826. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20827. // ContactsID instead. It exists only for internal usage by the builders.
  20828. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  20829. if id := m.contacts; id != nil {
  20830. ids = append(ids, *id)
  20831. }
  20832. return
  20833. }
  20834. // ResetContacts resets all changes to the "contacts" edge.
  20835. func (m *LabelRelationshipMutation) ResetContacts() {
  20836. m.contacts = nil
  20837. m.clearedcontacts = false
  20838. }
  20839. // SetLabelsID sets the "labels" edge to the Label entity by id.
  20840. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  20841. m.labels = &id
  20842. }
  20843. // ClearLabels clears the "labels" edge to the Label entity.
  20844. func (m *LabelRelationshipMutation) ClearLabels() {
  20845. m.clearedlabels = true
  20846. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  20847. }
  20848. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  20849. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  20850. return m.clearedlabels
  20851. }
  20852. // LabelsID returns the "labels" edge ID in the mutation.
  20853. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  20854. if m.labels != nil {
  20855. return *m.labels, true
  20856. }
  20857. return
  20858. }
  20859. // LabelsIDs returns the "labels" edge IDs in the mutation.
  20860. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20861. // LabelsID instead. It exists only for internal usage by the builders.
  20862. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  20863. if id := m.labels; id != nil {
  20864. ids = append(ids, *id)
  20865. }
  20866. return
  20867. }
  20868. // ResetLabels resets all changes to the "labels" edge.
  20869. func (m *LabelRelationshipMutation) ResetLabels() {
  20870. m.labels = nil
  20871. m.clearedlabels = false
  20872. }
  20873. // Where appends a list predicates to the LabelRelationshipMutation builder.
  20874. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  20875. m.predicates = append(m.predicates, ps...)
  20876. }
  20877. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  20878. // users can use type-assertion to append predicates that do not depend on any generated package.
  20879. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  20880. p := make([]predicate.LabelRelationship, len(ps))
  20881. for i := range ps {
  20882. p[i] = ps[i]
  20883. }
  20884. m.Where(p...)
  20885. }
  20886. // Op returns the operation name.
  20887. func (m *LabelRelationshipMutation) Op() Op {
  20888. return m.op
  20889. }
  20890. // SetOp allows setting the mutation operation.
  20891. func (m *LabelRelationshipMutation) SetOp(op Op) {
  20892. m.op = op
  20893. }
  20894. // Type returns the node type of this mutation (LabelRelationship).
  20895. func (m *LabelRelationshipMutation) Type() string {
  20896. return m.typ
  20897. }
  20898. // Fields returns all fields that were changed during this mutation. Note that in
  20899. // order to get all numeric fields that were incremented/decremented, call
  20900. // AddedFields().
  20901. func (m *LabelRelationshipMutation) Fields() []string {
  20902. fields := make([]string, 0, 6)
  20903. if m.created_at != nil {
  20904. fields = append(fields, labelrelationship.FieldCreatedAt)
  20905. }
  20906. if m.updated_at != nil {
  20907. fields = append(fields, labelrelationship.FieldUpdatedAt)
  20908. }
  20909. if m.status != nil {
  20910. fields = append(fields, labelrelationship.FieldStatus)
  20911. }
  20912. if m.labels != nil {
  20913. fields = append(fields, labelrelationship.FieldLabelID)
  20914. }
  20915. if m.contacts != nil {
  20916. fields = append(fields, labelrelationship.FieldContactID)
  20917. }
  20918. if m.organization_id != nil {
  20919. fields = append(fields, labelrelationship.FieldOrganizationID)
  20920. }
  20921. return fields
  20922. }
  20923. // Field returns the value of a field with the given name. The second boolean
  20924. // return value indicates that this field was not set, or was not defined in the
  20925. // schema.
  20926. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  20927. switch name {
  20928. case labelrelationship.FieldCreatedAt:
  20929. return m.CreatedAt()
  20930. case labelrelationship.FieldUpdatedAt:
  20931. return m.UpdatedAt()
  20932. case labelrelationship.FieldStatus:
  20933. return m.Status()
  20934. case labelrelationship.FieldLabelID:
  20935. return m.LabelID()
  20936. case labelrelationship.FieldContactID:
  20937. return m.ContactID()
  20938. case labelrelationship.FieldOrganizationID:
  20939. return m.OrganizationID()
  20940. }
  20941. return nil, false
  20942. }
  20943. // OldField returns the old value of the field from the database. An error is
  20944. // returned if the mutation operation is not UpdateOne, or the query to the
  20945. // database failed.
  20946. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20947. switch name {
  20948. case labelrelationship.FieldCreatedAt:
  20949. return m.OldCreatedAt(ctx)
  20950. case labelrelationship.FieldUpdatedAt:
  20951. return m.OldUpdatedAt(ctx)
  20952. case labelrelationship.FieldStatus:
  20953. return m.OldStatus(ctx)
  20954. case labelrelationship.FieldLabelID:
  20955. return m.OldLabelID(ctx)
  20956. case labelrelationship.FieldContactID:
  20957. return m.OldContactID(ctx)
  20958. case labelrelationship.FieldOrganizationID:
  20959. return m.OldOrganizationID(ctx)
  20960. }
  20961. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  20962. }
  20963. // SetField sets the value of a field with the given name. It returns an error if
  20964. // the field is not defined in the schema, or if the type mismatched the field
  20965. // type.
  20966. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  20967. switch name {
  20968. case labelrelationship.FieldCreatedAt:
  20969. v, ok := value.(time.Time)
  20970. if !ok {
  20971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20972. }
  20973. m.SetCreatedAt(v)
  20974. return nil
  20975. case labelrelationship.FieldUpdatedAt:
  20976. v, ok := value.(time.Time)
  20977. if !ok {
  20978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20979. }
  20980. m.SetUpdatedAt(v)
  20981. return nil
  20982. case labelrelationship.FieldStatus:
  20983. v, ok := value.(uint8)
  20984. if !ok {
  20985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20986. }
  20987. m.SetStatus(v)
  20988. return nil
  20989. case labelrelationship.FieldLabelID:
  20990. v, ok := value.(uint64)
  20991. if !ok {
  20992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20993. }
  20994. m.SetLabelID(v)
  20995. return nil
  20996. case labelrelationship.FieldContactID:
  20997. v, ok := value.(uint64)
  20998. if !ok {
  20999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21000. }
  21001. m.SetContactID(v)
  21002. return nil
  21003. case labelrelationship.FieldOrganizationID:
  21004. v, ok := value.(uint64)
  21005. if !ok {
  21006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21007. }
  21008. m.SetOrganizationID(v)
  21009. return nil
  21010. }
  21011. return fmt.Errorf("unknown LabelRelationship field %s", name)
  21012. }
  21013. // AddedFields returns all numeric fields that were incremented/decremented during
  21014. // this mutation.
  21015. func (m *LabelRelationshipMutation) AddedFields() []string {
  21016. var fields []string
  21017. if m.addstatus != nil {
  21018. fields = append(fields, labelrelationship.FieldStatus)
  21019. }
  21020. if m.addorganization_id != nil {
  21021. fields = append(fields, labelrelationship.FieldOrganizationID)
  21022. }
  21023. return fields
  21024. }
  21025. // AddedField returns the numeric value that was incremented/decremented on a field
  21026. // with the given name. The second boolean return value indicates that this field
  21027. // was not set, or was not defined in the schema.
  21028. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  21029. switch name {
  21030. case labelrelationship.FieldStatus:
  21031. return m.AddedStatus()
  21032. case labelrelationship.FieldOrganizationID:
  21033. return m.AddedOrganizationID()
  21034. }
  21035. return nil, false
  21036. }
  21037. // AddField adds the value to the field with the given name. It returns an error if
  21038. // the field is not defined in the schema, or if the type mismatched the field
  21039. // type.
  21040. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  21041. switch name {
  21042. case labelrelationship.FieldStatus:
  21043. v, ok := value.(int8)
  21044. if !ok {
  21045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21046. }
  21047. m.AddStatus(v)
  21048. return nil
  21049. case labelrelationship.FieldOrganizationID:
  21050. v, ok := value.(int64)
  21051. if !ok {
  21052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21053. }
  21054. m.AddOrganizationID(v)
  21055. return nil
  21056. }
  21057. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  21058. }
  21059. // ClearedFields returns all nullable fields that were cleared during this
  21060. // mutation.
  21061. func (m *LabelRelationshipMutation) ClearedFields() []string {
  21062. var fields []string
  21063. if m.FieldCleared(labelrelationship.FieldStatus) {
  21064. fields = append(fields, labelrelationship.FieldStatus)
  21065. }
  21066. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  21067. fields = append(fields, labelrelationship.FieldOrganizationID)
  21068. }
  21069. return fields
  21070. }
  21071. // FieldCleared returns a boolean indicating if a field with the given name was
  21072. // cleared in this mutation.
  21073. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  21074. _, ok := m.clearedFields[name]
  21075. return ok
  21076. }
  21077. // ClearField clears the value of the field with the given name. It returns an
  21078. // error if the field is not defined in the schema.
  21079. func (m *LabelRelationshipMutation) ClearField(name string) error {
  21080. switch name {
  21081. case labelrelationship.FieldStatus:
  21082. m.ClearStatus()
  21083. return nil
  21084. case labelrelationship.FieldOrganizationID:
  21085. m.ClearOrganizationID()
  21086. return nil
  21087. }
  21088. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  21089. }
  21090. // ResetField resets all changes in the mutation for the field with the given name.
  21091. // It returns an error if the field is not defined in the schema.
  21092. func (m *LabelRelationshipMutation) ResetField(name string) error {
  21093. switch name {
  21094. case labelrelationship.FieldCreatedAt:
  21095. m.ResetCreatedAt()
  21096. return nil
  21097. case labelrelationship.FieldUpdatedAt:
  21098. m.ResetUpdatedAt()
  21099. return nil
  21100. case labelrelationship.FieldStatus:
  21101. m.ResetStatus()
  21102. return nil
  21103. case labelrelationship.FieldLabelID:
  21104. m.ResetLabelID()
  21105. return nil
  21106. case labelrelationship.FieldContactID:
  21107. m.ResetContactID()
  21108. return nil
  21109. case labelrelationship.FieldOrganizationID:
  21110. m.ResetOrganizationID()
  21111. return nil
  21112. }
  21113. return fmt.Errorf("unknown LabelRelationship field %s", name)
  21114. }
  21115. // AddedEdges returns all edge names that were set/added in this mutation.
  21116. func (m *LabelRelationshipMutation) AddedEdges() []string {
  21117. edges := make([]string, 0, 2)
  21118. if m.contacts != nil {
  21119. edges = append(edges, labelrelationship.EdgeContacts)
  21120. }
  21121. if m.labels != nil {
  21122. edges = append(edges, labelrelationship.EdgeLabels)
  21123. }
  21124. return edges
  21125. }
  21126. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21127. // name in this mutation.
  21128. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  21129. switch name {
  21130. case labelrelationship.EdgeContacts:
  21131. if id := m.contacts; id != nil {
  21132. return []ent.Value{*id}
  21133. }
  21134. case labelrelationship.EdgeLabels:
  21135. if id := m.labels; id != nil {
  21136. return []ent.Value{*id}
  21137. }
  21138. }
  21139. return nil
  21140. }
  21141. // RemovedEdges returns all edge names that were removed in this mutation.
  21142. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  21143. edges := make([]string, 0, 2)
  21144. return edges
  21145. }
  21146. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21147. // the given name in this mutation.
  21148. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  21149. return nil
  21150. }
  21151. // ClearedEdges returns all edge names that were cleared in this mutation.
  21152. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  21153. edges := make([]string, 0, 2)
  21154. if m.clearedcontacts {
  21155. edges = append(edges, labelrelationship.EdgeContacts)
  21156. }
  21157. if m.clearedlabels {
  21158. edges = append(edges, labelrelationship.EdgeLabels)
  21159. }
  21160. return edges
  21161. }
  21162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21163. // was cleared in this mutation.
  21164. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  21165. switch name {
  21166. case labelrelationship.EdgeContacts:
  21167. return m.clearedcontacts
  21168. case labelrelationship.EdgeLabels:
  21169. return m.clearedlabels
  21170. }
  21171. return false
  21172. }
  21173. // ClearEdge clears the value of the edge with the given name. It returns an error
  21174. // if that edge is not defined in the schema.
  21175. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  21176. switch name {
  21177. case labelrelationship.EdgeContacts:
  21178. m.ClearContacts()
  21179. return nil
  21180. case labelrelationship.EdgeLabels:
  21181. m.ClearLabels()
  21182. return nil
  21183. }
  21184. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  21185. }
  21186. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21187. // It returns an error if the edge is not defined in the schema.
  21188. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  21189. switch name {
  21190. case labelrelationship.EdgeContacts:
  21191. m.ResetContacts()
  21192. return nil
  21193. case labelrelationship.EdgeLabels:
  21194. m.ResetLabels()
  21195. return nil
  21196. }
  21197. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  21198. }
  21199. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  21200. type LabelTaggingMutation struct {
  21201. config
  21202. op Op
  21203. typ string
  21204. id *uint64
  21205. created_at *time.Time
  21206. updated_at *time.Time
  21207. status *uint8
  21208. addstatus *int8
  21209. deleted_at *time.Time
  21210. organization_id *uint64
  21211. addorganization_id *int64
  21212. _type *int
  21213. add_type *int
  21214. conditions *string
  21215. action_label_add *[]uint64
  21216. appendaction_label_add []uint64
  21217. action_label_del *[]uint64
  21218. appendaction_label_del []uint64
  21219. clearedFields map[string]struct{}
  21220. done bool
  21221. oldValue func(context.Context) (*LabelTagging, error)
  21222. predicates []predicate.LabelTagging
  21223. }
  21224. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  21225. // labeltaggingOption allows management of the mutation configuration using functional options.
  21226. type labeltaggingOption func(*LabelTaggingMutation)
  21227. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  21228. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  21229. m := &LabelTaggingMutation{
  21230. config: c,
  21231. op: op,
  21232. typ: TypeLabelTagging,
  21233. clearedFields: make(map[string]struct{}),
  21234. }
  21235. for _, opt := range opts {
  21236. opt(m)
  21237. }
  21238. return m
  21239. }
  21240. // withLabelTaggingID sets the ID field of the mutation.
  21241. func withLabelTaggingID(id uint64) labeltaggingOption {
  21242. return func(m *LabelTaggingMutation) {
  21243. var (
  21244. err error
  21245. once sync.Once
  21246. value *LabelTagging
  21247. )
  21248. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  21249. once.Do(func() {
  21250. if m.done {
  21251. err = errors.New("querying old values post mutation is not allowed")
  21252. } else {
  21253. value, err = m.Client().LabelTagging.Get(ctx, id)
  21254. }
  21255. })
  21256. return value, err
  21257. }
  21258. m.id = &id
  21259. }
  21260. }
  21261. // withLabelTagging sets the old LabelTagging of the mutation.
  21262. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  21263. return func(m *LabelTaggingMutation) {
  21264. m.oldValue = func(context.Context) (*LabelTagging, error) {
  21265. return node, nil
  21266. }
  21267. m.id = &node.ID
  21268. }
  21269. }
  21270. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21271. // executed in a transaction (ent.Tx), a transactional client is returned.
  21272. func (m LabelTaggingMutation) Client() *Client {
  21273. client := &Client{config: m.config}
  21274. client.init()
  21275. return client
  21276. }
  21277. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21278. // it returns an error otherwise.
  21279. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  21280. if _, ok := m.driver.(*txDriver); !ok {
  21281. return nil, errors.New("ent: mutation is not running in a transaction")
  21282. }
  21283. tx := &Tx{config: m.config}
  21284. tx.init()
  21285. return tx, nil
  21286. }
  21287. // SetID sets the value of the id field. Note that this
  21288. // operation is only accepted on creation of LabelTagging entities.
  21289. func (m *LabelTaggingMutation) SetID(id uint64) {
  21290. m.id = &id
  21291. }
  21292. // ID returns the ID value in the mutation. Note that the ID is only available
  21293. // if it was provided to the builder or after it was returned from the database.
  21294. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  21295. if m.id == nil {
  21296. return
  21297. }
  21298. return *m.id, true
  21299. }
  21300. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21301. // That means, if the mutation is applied within a transaction with an isolation level such
  21302. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21303. // or updated by the mutation.
  21304. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  21305. switch {
  21306. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21307. id, exists := m.ID()
  21308. if exists {
  21309. return []uint64{id}, nil
  21310. }
  21311. fallthrough
  21312. case m.op.Is(OpUpdate | OpDelete):
  21313. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  21314. default:
  21315. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21316. }
  21317. }
  21318. // SetCreatedAt sets the "created_at" field.
  21319. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  21320. m.created_at = &t
  21321. }
  21322. // CreatedAt returns the value of the "created_at" field in the mutation.
  21323. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  21324. v := m.created_at
  21325. if v == nil {
  21326. return
  21327. }
  21328. return *v, true
  21329. }
  21330. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  21331. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21333. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21334. if !m.op.Is(OpUpdateOne) {
  21335. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21336. }
  21337. if m.id == nil || m.oldValue == nil {
  21338. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21339. }
  21340. oldValue, err := m.oldValue(ctx)
  21341. if err != nil {
  21342. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21343. }
  21344. return oldValue.CreatedAt, nil
  21345. }
  21346. // ResetCreatedAt resets all changes to the "created_at" field.
  21347. func (m *LabelTaggingMutation) ResetCreatedAt() {
  21348. m.created_at = nil
  21349. }
  21350. // SetUpdatedAt sets the "updated_at" field.
  21351. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  21352. m.updated_at = &t
  21353. }
  21354. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21355. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  21356. v := m.updated_at
  21357. if v == nil {
  21358. return
  21359. }
  21360. return *v, true
  21361. }
  21362. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  21363. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21365. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21366. if !m.op.Is(OpUpdateOne) {
  21367. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21368. }
  21369. if m.id == nil || m.oldValue == nil {
  21370. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21371. }
  21372. oldValue, err := m.oldValue(ctx)
  21373. if err != nil {
  21374. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21375. }
  21376. return oldValue.UpdatedAt, nil
  21377. }
  21378. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21379. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  21380. m.updated_at = nil
  21381. }
  21382. // SetStatus sets the "status" field.
  21383. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  21384. m.status = &u
  21385. m.addstatus = nil
  21386. }
  21387. // Status returns the value of the "status" field in the mutation.
  21388. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  21389. v := m.status
  21390. if v == nil {
  21391. return
  21392. }
  21393. return *v, true
  21394. }
  21395. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  21396. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21398. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21399. if !m.op.Is(OpUpdateOne) {
  21400. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21401. }
  21402. if m.id == nil || m.oldValue == nil {
  21403. return v, errors.New("OldStatus requires an ID field in the mutation")
  21404. }
  21405. oldValue, err := m.oldValue(ctx)
  21406. if err != nil {
  21407. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21408. }
  21409. return oldValue.Status, nil
  21410. }
  21411. // AddStatus adds u to the "status" field.
  21412. func (m *LabelTaggingMutation) AddStatus(u int8) {
  21413. if m.addstatus != nil {
  21414. *m.addstatus += u
  21415. } else {
  21416. m.addstatus = &u
  21417. }
  21418. }
  21419. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21420. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  21421. v := m.addstatus
  21422. if v == nil {
  21423. return
  21424. }
  21425. return *v, true
  21426. }
  21427. // ClearStatus clears the value of the "status" field.
  21428. func (m *LabelTaggingMutation) ClearStatus() {
  21429. m.status = nil
  21430. m.addstatus = nil
  21431. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  21432. }
  21433. // StatusCleared returns if the "status" field was cleared in this mutation.
  21434. func (m *LabelTaggingMutation) StatusCleared() bool {
  21435. _, ok := m.clearedFields[labeltagging.FieldStatus]
  21436. return ok
  21437. }
  21438. // ResetStatus resets all changes to the "status" field.
  21439. func (m *LabelTaggingMutation) ResetStatus() {
  21440. m.status = nil
  21441. m.addstatus = nil
  21442. delete(m.clearedFields, labeltagging.FieldStatus)
  21443. }
  21444. // SetDeletedAt sets the "deleted_at" field.
  21445. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  21446. m.deleted_at = &t
  21447. }
  21448. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21449. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  21450. v := m.deleted_at
  21451. if v == nil {
  21452. return
  21453. }
  21454. return *v, true
  21455. }
  21456. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  21457. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21459. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21460. if !m.op.Is(OpUpdateOne) {
  21461. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21462. }
  21463. if m.id == nil || m.oldValue == nil {
  21464. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21465. }
  21466. oldValue, err := m.oldValue(ctx)
  21467. if err != nil {
  21468. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21469. }
  21470. return oldValue.DeletedAt, nil
  21471. }
  21472. // ClearDeletedAt clears the value of the "deleted_at" field.
  21473. func (m *LabelTaggingMutation) ClearDeletedAt() {
  21474. m.deleted_at = nil
  21475. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  21476. }
  21477. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21478. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  21479. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  21480. return ok
  21481. }
  21482. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21483. func (m *LabelTaggingMutation) ResetDeletedAt() {
  21484. m.deleted_at = nil
  21485. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  21486. }
  21487. // SetOrganizationID sets the "organization_id" field.
  21488. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  21489. m.organization_id = &u
  21490. m.addorganization_id = nil
  21491. }
  21492. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21493. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  21494. v := m.organization_id
  21495. if v == nil {
  21496. return
  21497. }
  21498. return *v, true
  21499. }
  21500. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  21501. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21503. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21504. if !m.op.Is(OpUpdateOne) {
  21505. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21506. }
  21507. if m.id == nil || m.oldValue == nil {
  21508. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21509. }
  21510. oldValue, err := m.oldValue(ctx)
  21511. if err != nil {
  21512. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21513. }
  21514. return oldValue.OrganizationID, nil
  21515. }
  21516. // AddOrganizationID adds u to the "organization_id" field.
  21517. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  21518. if m.addorganization_id != nil {
  21519. *m.addorganization_id += u
  21520. } else {
  21521. m.addorganization_id = &u
  21522. }
  21523. }
  21524. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21525. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  21526. v := m.addorganization_id
  21527. if v == nil {
  21528. return
  21529. }
  21530. return *v, true
  21531. }
  21532. // ResetOrganizationID resets all changes to the "organization_id" field.
  21533. func (m *LabelTaggingMutation) ResetOrganizationID() {
  21534. m.organization_id = nil
  21535. m.addorganization_id = nil
  21536. }
  21537. // SetType sets the "type" field.
  21538. func (m *LabelTaggingMutation) SetType(i int) {
  21539. m._type = &i
  21540. m.add_type = nil
  21541. }
  21542. // GetType returns the value of the "type" field in the mutation.
  21543. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  21544. v := m._type
  21545. if v == nil {
  21546. return
  21547. }
  21548. return *v, true
  21549. }
  21550. // OldType returns the old "type" field's value of the LabelTagging entity.
  21551. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21553. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  21554. if !m.op.Is(OpUpdateOne) {
  21555. return v, errors.New("OldType is only allowed on UpdateOne operations")
  21556. }
  21557. if m.id == nil || m.oldValue == nil {
  21558. return v, errors.New("OldType requires an ID field in the mutation")
  21559. }
  21560. oldValue, err := m.oldValue(ctx)
  21561. if err != nil {
  21562. return v, fmt.Errorf("querying old value for OldType: %w", err)
  21563. }
  21564. return oldValue.Type, nil
  21565. }
  21566. // AddType adds i to the "type" field.
  21567. func (m *LabelTaggingMutation) AddType(i int) {
  21568. if m.add_type != nil {
  21569. *m.add_type += i
  21570. } else {
  21571. m.add_type = &i
  21572. }
  21573. }
  21574. // AddedType returns the value that was added to the "type" field in this mutation.
  21575. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  21576. v := m.add_type
  21577. if v == nil {
  21578. return
  21579. }
  21580. return *v, true
  21581. }
  21582. // ResetType resets all changes to the "type" field.
  21583. func (m *LabelTaggingMutation) ResetType() {
  21584. m._type = nil
  21585. m.add_type = nil
  21586. }
  21587. // SetConditions sets the "conditions" field.
  21588. func (m *LabelTaggingMutation) SetConditions(s string) {
  21589. m.conditions = &s
  21590. }
  21591. // Conditions returns the value of the "conditions" field in the mutation.
  21592. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  21593. v := m.conditions
  21594. if v == nil {
  21595. return
  21596. }
  21597. return *v, true
  21598. }
  21599. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  21600. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21602. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  21603. if !m.op.Is(OpUpdateOne) {
  21604. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  21605. }
  21606. if m.id == nil || m.oldValue == nil {
  21607. return v, errors.New("OldConditions requires an ID field in the mutation")
  21608. }
  21609. oldValue, err := m.oldValue(ctx)
  21610. if err != nil {
  21611. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  21612. }
  21613. return oldValue.Conditions, nil
  21614. }
  21615. // ResetConditions resets all changes to the "conditions" field.
  21616. func (m *LabelTaggingMutation) ResetConditions() {
  21617. m.conditions = nil
  21618. }
  21619. // SetActionLabelAdd sets the "action_label_add" field.
  21620. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  21621. m.action_label_add = &u
  21622. m.appendaction_label_add = nil
  21623. }
  21624. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21625. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21626. v := m.action_label_add
  21627. if v == nil {
  21628. return
  21629. }
  21630. return *v, true
  21631. }
  21632. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  21633. // If the LabelTagging 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 *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21636. if !m.op.Is(OpUpdateOne) {
  21637. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21638. }
  21639. if m.id == nil || m.oldValue == nil {
  21640. return v, errors.New("OldActionLabelAdd 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 OldActionLabelAdd: %w", err)
  21645. }
  21646. return oldValue.ActionLabelAdd, nil
  21647. }
  21648. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21649. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  21650. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21651. }
  21652. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21653. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21654. if len(m.appendaction_label_add) == 0 {
  21655. return nil, false
  21656. }
  21657. return m.appendaction_label_add, true
  21658. }
  21659. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21660. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  21661. m.action_label_add = nil
  21662. m.appendaction_label_add = nil
  21663. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  21664. }
  21665. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21666. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  21667. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  21668. return ok
  21669. }
  21670. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21671. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  21672. m.action_label_add = nil
  21673. m.appendaction_label_add = nil
  21674. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  21675. }
  21676. // SetActionLabelDel sets the "action_label_del" field.
  21677. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  21678. m.action_label_del = &u
  21679. m.appendaction_label_del = nil
  21680. }
  21681. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21682. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  21683. v := m.action_label_del
  21684. if v == nil {
  21685. return
  21686. }
  21687. return *v, true
  21688. }
  21689. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  21690. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21692. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21693. if !m.op.Is(OpUpdateOne) {
  21694. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21695. }
  21696. if m.id == nil || m.oldValue == nil {
  21697. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21698. }
  21699. oldValue, err := m.oldValue(ctx)
  21700. if err != nil {
  21701. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21702. }
  21703. return oldValue.ActionLabelDel, nil
  21704. }
  21705. // AppendActionLabelDel adds u to the "action_label_del" field.
  21706. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  21707. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21708. }
  21709. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21710. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21711. if len(m.appendaction_label_del) == 0 {
  21712. return nil, false
  21713. }
  21714. return m.appendaction_label_del, true
  21715. }
  21716. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21717. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  21718. m.action_label_del = nil
  21719. m.appendaction_label_del = nil
  21720. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  21721. }
  21722. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21723. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  21724. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  21725. return ok
  21726. }
  21727. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21728. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  21729. m.action_label_del = nil
  21730. m.appendaction_label_del = nil
  21731. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  21732. }
  21733. // Where appends a list predicates to the LabelTaggingMutation builder.
  21734. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  21735. m.predicates = append(m.predicates, ps...)
  21736. }
  21737. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  21738. // users can use type-assertion to append predicates that do not depend on any generated package.
  21739. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  21740. p := make([]predicate.LabelTagging, len(ps))
  21741. for i := range ps {
  21742. p[i] = ps[i]
  21743. }
  21744. m.Where(p...)
  21745. }
  21746. // Op returns the operation name.
  21747. func (m *LabelTaggingMutation) Op() Op {
  21748. return m.op
  21749. }
  21750. // SetOp allows setting the mutation operation.
  21751. func (m *LabelTaggingMutation) SetOp(op Op) {
  21752. m.op = op
  21753. }
  21754. // Type returns the node type of this mutation (LabelTagging).
  21755. func (m *LabelTaggingMutation) Type() string {
  21756. return m.typ
  21757. }
  21758. // Fields returns all fields that were changed during this mutation. Note that in
  21759. // order to get all numeric fields that were incremented/decremented, call
  21760. // AddedFields().
  21761. func (m *LabelTaggingMutation) Fields() []string {
  21762. fields := make([]string, 0, 9)
  21763. if m.created_at != nil {
  21764. fields = append(fields, labeltagging.FieldCreatedAt)
  21765. }
  21766. if m.updated_at != nil {
  21767. fields = append(fields, labeltagging.FieldUpdatedAt)
  21768. }
  21769. if m.status != nil {
  21770. fields = append(fields, labeltagging.FieldStatus)
  21771. }
  21772. if m.deleted_at != nil {
  21773. fields = append(fields, labeltagging.FieldDeletedAt)
  21774. }
  21775. if m.organization_id != nil {
  21776. fields = append(fields, labeltagging.FieldOrganizationID)
  21777. }
  21778. if m._type != nil {
  21779. fields = append(fields, labeltagging.FieldType)
  21780. }
  21781. if m.conditions != nil {
  21782. fields = append(fields, labeltagging.FieldConditions)
  21783. }
  21784. if m.action_label_add != nil {
  21785. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21786. }
  21787. if m.action_label_del != nil {
  21788. fields = append(fields, labeltagging.FieldActionLabelDel)
  21789. }
  21790. return fields
  21791. }
  21792. // Field returns the value of a field with the given name. The second boolean
  21793. // return value indicates that this field was not set, or was not defined in the
  21794. // schema.
  21795. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  21796. switch name {
  21797. case labeltagging.FieldCreatedAt:
  21798. return m.CreatedAt()
  21799. case labeltagging.FieldUpdatedAt:
  21800. return m.UpdatedAt()
  21801. case labeltagging.FieldStatus:
  21802. return m.Status()
  21803. case labeltagging.FieldDeletedAt:
  21804. return m.DeletedAt()
  21805. case labeltagging.FieldOrganizationID:
  21806. return m.OrganizationID()
  21807. case labeltagging.FieldType:
  21808. return m.GetType()
  21809. case labeltagging.FieldConditions:
  21810. return m.Conditions()
  21811. case labeltagging.FieldActionLabelAdd:
  21812. return m.ActionLabelAdd()
  21813. case labeltagging.FieldActionLabelDel:
  21814. return m.ActionLabelDel()
  21815. }
  21816. return nil, false
  21817. }
  21818. // OldField returns the old value of the field from the database. An error is
  21819. // returned if the mutation operation is not UpdateOne, or the query to the
  21820. // database failed.
  21821. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21822. switch name {
  21823. case labeltagging.FieldCreatedAt:
  21824. return m.OldCreatedAt(ctx)
  21825. case labeltagging.FieldUpdatedAt:
  21826. return m.OldUpdatedAt(ctx)
  21827. case labeltagging.FieldStatus:
  21828. return m.OldStatus(ctx)
  21829. case labeltagging.FieldDeletedAt:
  21830. return m.OldDeletedAt(ctx)
  21831. case labeltagging.FieldOrganizationID:
  21832. return m.OldOrganizationID(ctx)
  21833. case labeltagging.FieldType:
  21834. return m.OldType(ctx)
  21835. case labeltagging.FieldConditions:
  21836. return m.OldConditions(ctx)
  21837. case labeltagging.FieldActionLabelAdd:
  21838. return m.OldActionLabelAdd(ctx)
  21839. case labeltagging.FieldActionLabelDel:
  21840. return m.OldActionLabelDel(ctx)
  21841. }
  21842. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  21843. }
  21844. // SetField sets the value of a field with the given name. It returns an error if
  21845. // the field is not defined in the schema, or if the type mismatched the field
  21846. // type.
  21847. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  21848. switch name {
  21849. case labeltagging.FieldCreatedAt:
  21850. v, ok := value.(time.Time)
  21851. if !ok {
  21852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21853. }
  21854. m.SetCreatedAt(v)
  21855. return nil
  21856. case labeltagging.FieldUpdatedAt:
  21857. v, ok := value.(time.Time)
  21858. if !ok {
  21859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21860. }
  21861. m.SetUpdatedAt(v)
  21862. return nil
  21863. case labeltagging.FieldStatus:
  21864. v, ok := value.(uint8)
  21865. if !ok {
  21866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21867. }
  21868. m.SetStatus(v)
  21869. return nil
  21870. case labeltagging.FieldDeletedAt:
  21871. v, ok := value.(time.Time)
  21872. if !ok {
  21873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21874. }
  21875. m.SetDeletedAt(v)
  21876. return nil
  21877. case labeltagging.FieldOrganizationID:
  21878. v, ok := value.(uint64)
  21879. if !ok {
  21880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21881. }
  21882. m.SetOrganizationID(v)
  21883. return nil
  21884. case labeltagging.FieldType:
  21885. v, ok := value.(int)
  21886. if !ok {
  21887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21888. }
  21889. m.SetType(v)
  21890. return nil
  21891. case labeltagging.FieldConditions:
  21892. v, ok := value.(string)
  21893. if !ok {
  21894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21895. }
  21896. m.SetConditions(v)
  21897. return nil
  21898. case labeltagging.FieldActionLabelAdd:
  21899. v, ok := value.([]uint64)
  21900. if !ok {
  21901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21902. }
  21903. m.SetActionLabelAdd(v)
  21904. return nil
  21905. case labeltagging.FieldActionLabelDel:
  21906. v, ok := value.([]uint64)
  21907. if !ok {
  21908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21909. }
  21910. m.SetActionLabelDel(v)
  21911. return nil
  21912. }
  21913. return fmt.Errorf("unknown LabelTagging field %s", name)
  21914. }
  21915. // AddedFields returns all numeric fields that were incremented/decremented during
  21916. // this mutation.
  21917. func (m *LabelTaggingMutation) AddedFields() []string {
  21918. var fields []string
  21919. if m.addstatus != nil {
  21920. fields = append(fields, labeltagging.FieldStatus)
  21921. }
  21922. if m.addorganization_id != nil {
  21923. fields = append(fields, labeltagging.FieldOrganizationID)
  21924. }
  21925. if m.add_type != nil {
  21926. fields = append(fields, labeltagging.FieldType)
  21927. }
  21928. return fields
  21929. }
  21930. // AddedField returns the numeric value that was incremented/decremented on a field
  21931. // with the given name. The second boolean return value indicates that this field
  21932. // was not set, or was not defined in the schema.
  21933. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  21934. switch name {
  21935. case labeltagging.FieldStatus:
  21936. return m.AddedStatus()
  21937. case labeltagging.FieldOrganizationID:
  21938. return m.AddedOrganizationID()
  21939. case labeltagging.FieldType:
  21940. return m.AddedType()
  21941. }
  21942. return nil, false
  21943. }
  21944. // AddField adds the value to the field with the given name. It returns an error if
  21945. // the field is not defined in the schema, or if the type mismatched the field
  21946. // type.
  21947. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  21948. switch name {
  21949. case labeltagging.FieldStatus:
  21950. v, ok := value.(int8)
  21951. if !ok {
  21952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21953. }
  21954. m.AddStatus(v)
  21955. return nil
  21956. case labeltagging.FieldOrganizationID:
  21957. v, ok := value.(int64)
  21958. if !ok {
  21959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21960. }
  21961. m.AddOrganizationID(v)
  21962. return nil
  21963. case labeltagging.FieldType:
  21964. v, ok := value.(int)
  21965. if !ok {
  21966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21967. }
  21968. m.AddType(v)
  21969. return nil
  21970. }
  21971. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  21972. }
  21973. // ClearedFields returns all nullable fields that were cleared during this
  21974. // mutation.
  21975. func (m *LabelTaggingMutation) ClearedFields() []string {
  21976. var fields []string
  21977. if m.FieldCleared(labeltagging.FieldStatus) {
  21978. fields = append(fields, labeltagging.FieldStatus)
  21979. }
  21980. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  21981. fields = append(fields, labeltagging.FieldDeletedAt)
  21982. }
  21983. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  21984. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21985. }
  21986. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  21987. fields = append(fields, labeltagging.FieldActionLabelDel)
  21988. }
  21989. return fields
  21990. }
  21991. // FieldCleared returns a boolean indicating if a field with the given name was
  21992. // cleared in this mutation.
  21993. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  21994. _, ok := m.clearedFields[name]
  21995. return ok
  21996. }
  21997. // ClearField clears the value of the field with the given name. It returns an
  21998. // error if the field is not defined in the schema.
  21999. func (m *LabelTaggingMutation) ClearField(name string) error {
  22000. switch name {
  22001. case labeltagging.FieldStatus:
  22002. m.ClearStatus()
  22003. return nil
  22004. case labeltagging.FieldDeletedAt:
  22005. m.ClearDeletedAt()
  22006. return nil
  22007. case labeltagging.FieldActionLabelAdd:
  22008. m.ClearActionLabelAdd()
  22009. return nil
  22010. case labeltagging.FieldActionLabelDel:
  22011. m.ClearActionLabelDel()
  22012. return nil
  22013. }
  22014. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  22015. }
  22016. // ResetField resets all changes in the mutation for the field with the given name.
  22017. // It returns an error if the field is not defined in the schema.
  22018. func (m *LabelTaggingMutation) ResetField(name string) error {
  22019. switch name {
  22020. case labeltagging.FieldCreatedAt:
  22021. m.ResetCreatedAt()
  22022. return nil
  22023. case labeltagging.FieldUpdatedAt:
  22024. m.ResetUpdatedAt()
  22025. return nil
  22026. case labeltagging.FieldStatus:
  22027. m.ResetStatus()
  22028. return nil
  22029. case labeltagging.FieldDeletedAt:
  22030. m.ResetDeletedAt()
  22031. return nil
  22032. case labeltagging.FieldOrganizationID:
  22033. m.ResetOrganizationID()
  22034. return nil
  22035. case labeltagging.FieldType:
  22036. m.ResetType()
  22037. return nil
  22038. case labeltagging.FieldConditions:
  22039. m.ResetConditions()
  22040. return nil
  22041. case labeltagging.FieldActionLabelAdd:
  22042. m.ResetActionLabelAdd()
  22043. return nil
  22044. case labeltagging.FieldActionLabelDel:
  22045. m.ResetActionLabelDel()
  22046. return nil
  22047. }
  22048. return fmt.Errorf("unknown LabelTagging field %s", name)
  22049. }
  22050. // AddedEdges returns all edge names that were set/added in this mutation.
  22051. func (m *LabelTaggingMutation) AddedEdges() []string {
  22052. edges := make([]string, 0, 0)
  22053. return edges
  22054. }
  22055. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22056. // name in this mutation.
  22057. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  22058. return nil
  22059. }
  22060. // RemovedEdges returns all edge names that were removed in this mutation.
  22061. func (m *LabelTaggingMutation) RemovedEdges() []string {
  22062. edges := make([]string, 0, 0)
  22063. return edges
  22064. }
  22065. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22066. // the given name in this mutation.
  22067. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  22068. return nil
  22069. }
  22070. // ClearedEdges returns all edge names that were cleared in this mutation.
  22071. func (m *LabelTaggingMutation) ClearedEdges() []string {
  22072. edges := make([]string, 0, 0)
  22073. return edges
  22074. }
  22075. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22076. // was cleared in this mutation.
  22077. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  22078. return false
  22079. }
  22080. // ClearEdge clears the value of the edge with the given name. It returns an error
  22081. // if that edge is not defined in the schema.
  22082. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  22083. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  22084. }
  22085. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22086. // It returns an error if the edge is not defined in the schema.
  22087. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  22088. return fmt.Errorf("unknown LabelTagging edge %s", name)
  22089. }
  22090. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  22091. type MessageMutation struct {
  22092. config
  22093. op Op
  22094. typ string
  22095. id *int
  22096. wx_wxid *string
  22097. wxid *string
  22098. content *string
  22099. clearedFields map[string]struct{}
  22100. done bool
  22101. oldValue func(context.Context) (*Message, error)
  22102. predicates []predicate.Message
  22103. }
  22104. var _ ent.Mutation = (*MessageMutation)(nil)
  22105. // messageOption allows management of the mutation configuration using functional options.
  22106. type messageOption func(*MessageMutation)
  22107. // newMessageMutation creates new mutation for the Message entity.
  22108. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  22109. m := &MessageMutation{
  22110. config: c,
  22111. op: op,
  22112. typ: TypeMessage,
  22113. clearedFields: make(map[string]struct{}),
  22114. }
  22115. for _, opt := range opts {
  22116. opt(m)
  22117. }
  22118. return m
  22119. }
  22120. // withMessageID sets the ID field of the mutation.
  22121. func withMessageID(id int) messageOption {
  22122. return func(m *MessageMutation) {
  22123. var (
  22124. err error
  22125. once sync.Once
  22126. value *Message
  22127. )
  22128. m.oldValue = func(ctx context.Context) (*Message, error) {
  22129. once.Do(func() {
  22130. if m.done {
  22131. err = errors.New("querying old values post mutation is not allowed")
  22132. } else {
  22133. value, err = m.Client().Message.Get(ctx, id)
  22134. }
  22135. })
  22136. return value, err
  22137. }
  22138. m.id = &id
  22139. }
  22140. }
  22141. // withMessage sets the old Message of the mutation.
  22142. func withMessage(node *Message) messageOption {
  22143. return func(m *MessageMutation) {
  22144. m.oldValue = func(context.Context) (*Message, error) {
  22145. return node, nil
  22146. }
  22147. m.id = &node.ID
  22148. }
  22149. }
  22150. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22151. // executed in a transaction (ent.Tx), a transactional client is returned.
  22152. func (m MessageMutation) Client() *Client {
  22153. client := &Client{config: m.config}
  22154. client.init()
  22155. return client
  22156. }
  22157. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22158. // it returns an error otherwise.
  22159. func (m MessageMutation) Tx() (*Tx, error) {
  22160. if _, ok := m.driver.(*txDriver); !ok {
  22161. return nil, errors.New("ent: mutation is not running in a transaction")
  22162. }
  22163. tx := &Tx{config: m.config}
  22164. tx.init()
  22165. return tx, nil
  22166. }
  22167. // ID returns the ID value in the mutation. Note that the ID is only available
  22168. // if it was provided to the builder or after it was returned from the database.
  22169. func (m *MessageMutation) ID() (id int, exists bool) {
  22170. if m.id == nil {
  22171. return
  22172. }
  22173. return *m.id, true
  22174. }
  22175. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22176. // That means, if the mutation is applied within a transaction with an isolation level such
  22177. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22178. // or updated by the mutation.
  22179. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  22180. switch {
  22181. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22182. id, exists := m.ID()
  22183. if exists {
  22184. return []int{id}, nil
  22185. }
  22186. fallthrough
  22187. case m.op.Is(OpUpdate | OpDelete):
  22188. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  22189. default:
  22190. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22191. }
  22192. }
  22193. // SetWxWxid sets the "wx_wxid" field.
  22194. func (m *MessageMutation) SetWxWxid(s string) {
  22195. m.wx_wxid = &s
  22196. }
  22197. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  22198. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  22199. v := m.wx_wxid
  22200. if v == nil {
  22201. return
  22202. }
  22203. return *v, true
  22204. }
  22205. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  22206. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22208. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  22209. if !m.op.Is(OpUpdateOne) {
  22210. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  22211. }
  22212. if m.id == nil || m.oldValue == nil {
  22213. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  22214. }
  22215. oldValue, err := m.oldValue(ctx)
  22216. if err != nil {
  22217. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  22218. }
  22219. return oldValue.WxWxid, nil
  22220. }
  22221. // ClearWxWxid clears the value of the "wx_wxid" field.
  22222. func (m *MessageMutation) ClearWxWxid() {
  22223. m.wx_wxid = nil
  22224. m.clearedFields[message.FieldWxWxid] = struct{}{}
  22225. }
  22226. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  22227. func (m *MessageMutation) WxWxidCleared() bool {
  22228. _, ok := m.clearedFields[message.FieldWxWxid]
  22229. return ok
  22230. }
  22231. // ResetWxWxid resets all changes to the "wx_wxid" field.
  22232. func (m *MessageMutation) ResetWxWxid() {
  22233. m.wx_wxid = nil
  22234. delete(m.clearedFields, message.FieldWxWxid)
  22235. }
  22236. // SetWxid sets the "wxid" field.
  22237. func (m *MessageMutation) SetWxid(s string) {
  22238. m.wxid = &s
  22239. }
  22240. // Wxid returns the value of the "wxid" field in the mutation.
  22241. func (m *MessageMutation) Wxid() (r string, exists bool) {
  22242. v := m.wxid
  22243. if v == nil {
  22244. return
  22245. }
  22246. return *v, true
  22247. }
  22248. // OldWxid returns the old "wxid" field's value of the Message entity.
  22249. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22251. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  22252. if !m.op.Is(OpUpdateOne) {
  22253. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  22254. }
  22255. if m.id == nil || m.oldValue == nil {
  22256. return v, errors.New("OldWxid requires an ID field in the mutation")
  22257. }
  22258. oldValue, err := m.oldValue(ctx)
  22259. if err != nil {
  22260. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  22261. }
  22262. return oldValue.Wxid, nil
  22263. }
  22264. // ResetWxid resets all changes to the "wxid" field.
  22265. func (m *MessageMutation) ResetWxid() {
  22266. m.wxid = nil
  22267. }
  22268. // SetContent sets the "content" field.
  22269. func (m *MessageMutation) SetContent(s string) {
  22270. m.content = &s
  22271. }
  22272. // Content returns the value of the "content" field in the mutation.
  22273. func (m *MessageMutation) Content() (r string, exists bool) {
  22274. v := m.content
  22275. if v == nil {
  22276. return
  22277. }
  22278. return *v, true
  22279. }
  22280. // OldContent returns the old "content" field's value of the Message entity.
  22281. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22283. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  22284. if !m.op.Is(OpUpdateOne) {
  22285. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22286. }
  22287. if m.id == nil || m.oldValue == nil {
  22288. return v, errors.New("OldContent requires an ID field in the mutation")
  22289. }
  22290. oldValue, err := m.oldValue(ctx)
  22291. if err != nil {
  22292. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22293. }
  22294. return oldValue.Content, nil
  22295. }
  22296. // ResetContent resets all changes to the "content" field.
  22297. func (m *MessageMutation) ResetContent() {
  22298. m.content = nil
  22299. }
  22300. // Where appends a list predicates to the MessageMutation builder.
  22301. func (m *MessageMutation) Where(ps ...predicate.Message) {
  22302. m.predicates = append(m.predicates, ps...)
  22303. }
  22304. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  22305. // users can use type-assertion to append predicates that do not depend on any generated package.
  22306. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  22307. p := make([]predicate.Message, len(ps))
  22308. for i := range ps {
  22309. p[i] = ps[i]
  22310. }
  22311. m.Where(p...)
  22312. }
  22313. // Op returns the operation name.
  22314. func (m *MessageMutation) Op() Op {
  22315. return m.op
  22316. }
  22317. // SetOp allows setting the mutation operation.
  22318. func (m *MessageMutation) SetOp(op Op) {
  22319. m.op = op
  22320. }
  22321. // Type returns the node type of this mutation (Message).
  22322. func (m *MessageMutation) Type() string {
  22323. return m.typ
  22324. }
  22325. // Fields returns all fields that were changed during this mutation. Note that in
  22326. // order to get all numeric fields that were incremented/decremented, call
  22327. // AddedFields().
  22328. func (m *MessageMutation) Fields() []string {
  22329. fields := make([]string, 0, 3)
  22330. if m.wx_wxid != nil {
  22331. fields = append(fields, message.FieldWxWxid)
  22332. }
  22333. if m.wxid != nil {
  22334. fields = append(fields, message.FieldWxid)
  22335. }
  22336. if m.content != nil {
  22337. fields = append(fields, message.FieldContent)
  22338. }
  22339. return fields
  22340. }
  22341. // Field returns the value of a field with the given name. The second boolean
  22342. // return value indicates that this field was not set, or was not defined in the
  22343. // schema.
  22344. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  22345. switch name {
  22346. case message.FieldWxWxid:
  22347. return m.WxWxid()
  22348. case message.FieldWxid:
  22349. return m.Wxid()
  22350. case message.FieldContent:
  22351. return m.Content()
  22352. }
  22353. return nil, false
  22354. }
  22355. // OldField returns the old value of the field from the database. An error is
  22356. // returned if the mutation operation is not UpdateOne, or the query to the
  22357. // database failed.
  22358. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22359. switch name {
  22360. case message.FieldWxWxid:
  22361. return m.OldWxWxid(ctx)
  22362. case message.FieldWxid:
  22363. return m.OldWxid(ctx)
  22364. case message.FieldContent:
  22365. return m.OldContent(ctx)
  22366. }
  22367. return nil, fmt.Errorf("unknown Message field %s", name)
  22368. }
  22369. // SetField sets the value of a field with the given name. It returns an error if
  22370. // the field is not defined in the schema, or if the type mismatched the field
  22371. // type.
  22372. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  22373. switch name {
  22374. case message.FieldWxWxid:
  22375. v, ok := value.(string)
  22376. if !ok {
  22377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22378. }
  22379. m.SetWxWxid(v)
  22380. return nil
  22381. case message.FieldWxid:
  22382. v, ok := value.(string)
  22383. if !ok {
  22384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22385. }
  22386. m.SetWxid(v)
  22387. return nil
  22388. case message.FieldContent:
  22389. v, ok := value.(string)
  22390. if !ok {
  22391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22392. }
  22393. m.SetContent(v)
  22394. return nil
  22395. }
  22396. return fmt.Errorf("unknown Message field %s", name)
  22397. }
  22398. // AddedFields returns all numeric fields that were incremented/decremented during
  22399. // this mutation.
  22400. func (m *MessageMutation) AddedFields() []string {
  22401. return nil
  22402. }
  22403. // AddedField returns the numeric value that was incremented/decremented on a field
  22404. // with the given name. The second boolean return value indicates that this field
  22405. // was not set, or was not defined in the schema.
  22406. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  22407. return nil, false
  22408. }
  22409. // AddField adds the value to the field with the given name. It returns an error if
  22410. // the field is not defined in the schema, or if the type mismatched the field
  22411. // type.
  22412. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  22413. switch name {
  22414. }
  22415. return fmt.Errorf("unknown Message numeric field %s", name)
  22416. }
  22417. // ClearedFields returns all nullable fields that were cleared during this
  22418. // mutation.
  22419. func (m *MessageMutation) ClearedFields() []string {
  22420. var fields []string
  22421. if m.FieldCleared(message.FieldWxWxid) {
  22422. fields = append(fields, message.FieldWxWxid)
  22423. }
  22424. return fields
  22425. }
  22426. // FieldCleared returns a boolean indicating if a field with the given name was
  22427. // cleared in this mutation.
  22428. func (m *MessageMutation) FieldCleared(name string) bool {
  22429. _, ok := m.clearedFields[name]
  22430. return ok
  22431. }
  22432. // ClearField clears the value of the field with the given name. It returns an
  22433. // error if the field is not defined in the schema.
  22434. func (m *MessageMutation) ClearField(name string) error {
  22435. switch name {
  22436. case message.FieldWxWxid:
  22437. m.ClearWxWxid()
  22438. return nil
  22439. }
  22440. return fmt.Errorf("unknown Message nullable field %s", name)
  22441. }
  22442. // ResetField resets all changes in the mutation for the field with the given name.
  22443. // It returns an error if the field is not defined in the schema.
  22444. func (m *MessageMutation) ResetField(name string) error {
  22445. switch name {
  22446. case message.FieldWxWxid:
  22447. m.ResetWxWxid()
  22448. return nil
  22449. case message.FieldWxid:
  22450. m.ResetWxid()
  22451. return nil
  22452. case message.FieldContent:
  22453. m.ResetContent()
  22454. return nil
  22455. }
  22456. return fmt.Errorf("unknown Message field %s", name)
  22457. }
  22458. // AddedEdges returns all edge names that were set/added in this mutation.
  22459. func (m *MessageMutation) AddedEdges() []string {
  22460. edges := make([]string, 0, 0)
  22461. return edges
  22462. }
  22463. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22464. // name in this mutation.
  22465. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  22466. return nil
  22467. }
  22468. // RemovedEdges returns all edge names that were removed in this mutation.
  22469. func (m *MessageMutation) RemovedEdges() []string {
  22470. edges := make([]string, 0, 0)
  22471. return edges
  22472. }
  22473. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22474. // the given name in this mutation.
  22475. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  22476. return nil
  22477. }
  22478. // ClearedEdges returns all edge names that were cleared in this mutation.
  22479. func (m *MessageMutation) ClearedEdges() []string {
  22480. edges := make([]string, 0, 0)
  22481. return edges
  22482. }
  22483. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22484. // was cleared in this mutation.
  22485. func (m *MessageMutation) EdgeCleared(name string) bool {
  22486. return false
  22487. }
  22488. // ClearEdge clears the value of the edge with the given name. It returns an error
  22489. // if that edge is not defined in the schema.
  22490. func (m *MessageMutation) ClearEdge(name string) error {
  22491. return fmt.Errorf("unknown Message unique edge %s", name)
  22492. }
  22493. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22494. // It returns an error if the edge is not defined in the schema.
  22495. func (m *MessageMutation) ResetEdge(name string) error {
  22496. return fmt.Errorf("unknown Message edge %s", name)
  22497. }
  22498. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  22499. type MessageRecordsMutation struct {
  22500. config
  22501. op Op
  22502. typ string
  22503. id *uint64
  22504. created_at *time.Time
  22505. updated_at *time.Time
  22506. status *uint8
  22507. addstatus *int8
  22508. bot_wxid *string
  22509. contact_type *int
  22510. addcontact_type *int
  22511. contact_wxid *string
  22512. content_type *int
  22513. addcontent_type *int
  22514. content *string
  22515. meta *custom_types.Meta
  22516. error_detail *string
  22517. send_time *time.Time
  22518. source_type *int
  22519. addsource_type *int
  22520. organization_id *uint64
  22521. addorganization_id *int64
  22522. clearedFields map[string]struct{}
  22523. sop_stage *uint64
  22524. clearedsop_stage bool
  22525. sop_node *uint64
  22526. clearedsop_node bool
  22527. message_contact *uint64
  22528. clearedmessage_contact bool
  22529. done bool
  22530. oldValue func(context.Context) (*MessageRecords, error)
  22531. predicates []predicate.MessageRecords
  22532. }
  22533. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  22534. // messagerecordsOption allows management of the mutation configuration using functional options.
  22535. type messagerecordsOption func(*MessageRecordsMutation)
  22536. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  22537. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  22538. m := &MessageRecordsMutation{
  22539. config: c,
  22540. op: op,
  22541. typ: TypeMessageRecords,
  22542. clearedFields: make(map[string]struct{}),
  22543. }
  22544. for _, opt := range opts {
  22545. opt(m)
  22546. }
  22547. return m
  22548. }
  22549. // withMessageRecordsID sets the ID field of the mutation.
  22550. func withMessageRecordsID(id uint64) messagerecordsOption {
  22551. return func(m *MessageRecordsMutation) {
  22552. var (
  22553. err error
  22554. once sync.Once
  22555. value *MessageRecords
  22556. )
  22557. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  22558. once.Do(func() {
  22559. if m.done {
  22560. err = errors.New("querying old values post mutation is not allowed")
  22561. } else {
  22562. value, err = m.Client().MessageRecords.Get(ctx, id)
  22563. }
  22564. })
  22565. return value, err
  22566. }
  22567. m.id = &id
  22568. }
  22569. }
  22570. // withMessageRecords sets the old MessageRecords of the mutation.
  22571. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  22572. return func(m *MessageRecordsMutation) {
  22573. m.oldValue = func(context.Context) (*MessageRecords, error) {
  22574. return node, nil
  22575. }
  22576. m.id = &node.ID
  22577. }
  22578. }
  22579. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22580. // executed in a transaction (ent.Tx), a transactional client is returned.
  22581. func (m MessageRecordsMutation) Client() *Client {
  22582. client := &Client{config: m.config}
  22583. client.init()
  22584. return client
  22585. }
  22586. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22587. // it returns an error otherwise.
  22588. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  22589. if _, ok := m.driver.(*txDriver); !ok {
  22590. return nil, errors.New("ent: mutation is not running in a transaction")
  22591. }
  22592. tx := &Tx{config: m.config}
  22593. tx.init()
  22594. return tx, nil
  22595. }
  22596. // SetID sets the value of the id field. Note that this
  22597. // operation is only accepted on creation of MessageRecords entities.
  22598. func (m *MessageRecordsMutation) SetID(id uint64) {
  22599. m.id = &id
  22600. }
  22601. // ID returns the ID value in the mutation. Note that the ID is only available
  22602. // if it was provided to the builder or after it was returned from the database.
  22603. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  22604. if m.id == nil {
  22605. return
  22606. }
  22607. return *m.id, true
  22608. }
  22609. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22610. // That means, if the mutation is applied within a transaction with an isolation level such
  22611. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22612. // or updated by the mutation.
  22613. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  22614. switch {
  22615. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22616. id, exists := m.ID()
  22617. if exists {
  22618. return []uint64{id}, nil
  22619. }
  22620. fallthrough
  22621. case m.op.Is(OpUpdate | OpDelete):
  22622. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  22623. default:
  22624. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22625. }
  22626. }
  22627. // SetCreatedAt sets the "created_at" field.
  22628. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  22629. m.created_at = &t
  22630. }
  22631. // CreatedAt returns the value of the "created_at" field in the mutation.
  22632. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  22633. v := m.created_at
  22634. if v == nil {
  22635. return
  22636. }
  22637. return *v, true
  22638. }
  22639. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  22640. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22642. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22643. if !m.op.Is(OpUpdateOne) {
  22644. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22645. }
  22646. if m.id == nil || m.oldValue == nil {
  22647. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22648. }
  22649. oldValue, err := m.oldValue(ctx)
  22650. if err != nil {
  22651. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22652. }
  22653. return oldValue.CreatedAt, nil
  22654. }
  22655. // ResetCreatedAt resets all changes to the "created_at" field.
  22656. func (m *MessageRecordsMutation) ResetCreatedAt() {
  22657. m.created_at = nil
  22658. }
  22659. // SetUpdatedAt sets the "updated_at" field.
  22660. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  22661. m.updated_at = &t
  22662. }
  22663. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22664. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  22665. v := m.updated_at
  22666. if v == nil {
  22667. return
  22668. }
  22669. return *v, true
  22670. }
  22671. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  22672. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22674. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22675. if !m.op.Is(OpUpdateOne) {
  22676. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22677. }
  22678. if m.id == nil || m.oldValue == nil {
  22679. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22680. }
  22681. oldValue, err := m.oldValue(ctx)
  22682. if err != nil {
  22683. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22684. }
  22685. return oldValue.UpdatedAt, nil
  22686. }
  22687. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22688. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  22689. m.updated_at = nil
  22690. }
  22691. // SetStatus sets the "status" field.
  22692. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  22693. m.status = &u
  22694. m.addstatus = nil
  22695. }
  22696. // Status returns the value of the "status" field in the mutation.
  22697. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  22698. v := m.status
  22699. if v == nil {
  22700. return
  22701. }
  22702. return *v, true
  22703. }
  22704. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  22705. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22707. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22708. if !m.op.Is(OpUpdateOne) {
  22709. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22710. }
  22711. if m.id == nil || m.oldValue == nil {
  22712. return v, errors.New("OldStatus requires an ID field in the mutation")
  22713. }
  22714. oldValue, err := m.oldValue(ctx)
  22715. if err != nil {
  22716. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22717. }
  22718. return oldValue.Status, nil
  22719. }
  22720. // AddStatus adds u to the "status" field.
  22721. func (m *MessageRecordsMutation) AddStatus(u int8) {
  22722. if m.addstatus != nil {
  22723. *m.addstatus += u
  22724. } else {
  22725. m.addstatus = &u
  22726. }
  22727. }
  22728. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22729. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  22730. v := m.addstatus
  22731. if v == nil {
  22732. return
  22733. }
  22734. return *v, true
  22735. }
  22736. // ClearStatus clears the value of the "status" field.
  22737. func (m *MessageRecordsMutation) ClearStatus() {
  22738. m.status = nil
  22739. m.addstatus = nil
  22740. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  22741. }
  22742. // StatusCleared returns if the "status" field was cleared in this mutation.
  22743. func (m *MessageRecordsMutation) StatusCleared() bool {
  22744. _, ok := m.clearedFields[messagerecords.FieldStatus]
  22745. return ok
  22746. }
  22747. // ResetStatus resets all changes to the "status" field.
  22748. func (m *MessageRecordsMutation) ResetStatus() {
  22749. m.status = nil
  22750. m.addstatus = nil
  22751. delete(m.clearedFields, messagerecords.FieldStatus)
  22752. }
  22753. // SetBotWxid sets the "bot_wxid" field.
  22754. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  22755. m.bot_wxid = &s
  22756. }
  22757. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  22758. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  22759. v := m.bot_wxid
  22760. if v == nil {
  22761. return
  22762. }
  22763. return *v, true
  22764. }
  22765. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  22766. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22768. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  22769. if !m.op.Is(OpUpdateOne) {
  22770. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  22771. }
  22772. if m.id == nil || m.oldValue == nil {
  22773. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  22774. }
  22775. oldValue, err := m.oldValue(ctx)
  22776. if err != nil {
  22777. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  22778. }
  22779. return oldValue.BotWxid, nil
  22780. }
  22781. // ResetBotWxid resets all changes to the "bot_wxid" field.
  22782. func (m *MessageRecordsMutation) ResetBotWxid() {
  22783. m.bot_wxid = nil
  22784. }
  22785. // SetContactID sets the "contact_id" field.
  22786. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  22787. m.message_contact = &u
  22788. }
  22789. // ContactID returns the value of the "contact_id" field in the mutation.
  22790. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  22791. v := m.message_contact
  22792. if v == nil {
  22793. return
  22794. }
  22795. return *v, true
  22796. }
  22797. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  22798. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22800. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22801. if !m.op.Is(OpUpdateOne) {
  22802. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22803. }
  22804. if m.id == nil || m.oldValue == nil {
  22805. return v, errors.New("OldContactID requires an ID field in the mutation")
  22806. }
  22807. oldValue, err := m.oldValue(ctx)
  22808. if err != nil {
  22809. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22810. }
  22811. return oldValue.ContactID, nil
  22812. }
  22813. // ClearContactID clears the value of the "contact_id" field.
  22814. func (m *MessageRecordsMutation) ClearContactID() {
  22815. m.message_contact = nil
  22816. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  22817. }
  22818. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  22819. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  22820. _, ok := m.clearedFields[messagerecords.FieldContactID]
  22821. return ok
  22822. }
  22823. // ResetContactID resets all changes to the "contact_id" field.
  22824. func (m *MessageRecordsMutation) ResetContactID() {
  22825. m.message_contact = nil
  22826. delete(m.clearedFields, messagerecords.FieldContactID)
  22827. }
  22828. // SetContactType sets the "contact_type" field.
  22829. func (m *MessageRecordsMutation) SetContactType(i int) {
  22830. m.contact_type = &i
  22831. m.addcontact_type = nil
  22832. }
  22833. // ContactType returns the value of the "contact_type" field in the mutation.
  22834. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  22835. v := m.contact_type
  22836. if v == nil {
  22837. return
  22838. }
  22839. return *v, true
  22840. }
  22841. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  22842. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22844. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  22845. if !m.op.Is(OpUpdateOne) {
  22846. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  22847. }
  22848. if m.id == nil || m.oldValue == nil {
  22849. return v, errors.New("OldContactType requires an ID field in the mutation")
  22850. }
  22851. oldValue, err := m.oldValue(ctx)
  22852. if err != nil {
  22853. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  22854. }
  22855. return oldValue.ContactType, nil
  22856. }
  22857. // AddContactType adds i to the "contact_type" field.
  22858. func (m *MessageRecordsMutation) AddContactType(i int) {
  22859. if m.addcontact_type != nil {
  22860. *m.addcontact_type += i
  22861. } else {
  22862. m.addcontact_type = &i
  22863. }
  22864. }
  22865. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  22866. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  22867. v := m.addcontact_type
  22868. if v == nil {
  22869. return
  22870. }
  22871. return *v, true
  22872. }
  22873. // ResetContactType resets all changes to the "contact_type" field.
  22874. func (m *MessageRecordsMutation) ResetContactType() {
  22875. m.contact_type = nil
  22876. m.addcontact_type = nil
  22877. }
  22878. // SetContactWxid sets the "contact_wxid" field.
  22879. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  22880. m.contact_wxid = &s
  22881. }
  22882. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  22883. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  22884. v := m.contact_wxid
  22885. if v == nil {
  22886. return
  22887. }
  22888. return *v, true
  22889. }
  22890. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  22891. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22893. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  22894. if !m.op.Is(OpUpdateOne) {
  22895. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  22896. }
  22897. if m.id == nil || m.oldValue == nil {
  22898. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  22899. }
  22900. oldValue, err := m.oldValue(ctx)
  22901. if err != nil {
  22902. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  22903. }
  22904. return oldValue.ContactWxid, nil
  22905. }
  22906. // ResetContactWxid resets all changes to the "contact_wxid" field.
  22907. func (m *MessageRecordsMutation) ResetContactWxid() {
  22908. m.contact_wxid = nil
  22909. }
  22910. // SetContentType sets the "content_type" field.
  22911. func (m *MessageRecordsMutation) SetContentType(i int) {
  22912. m.content_type = &i
  22913. m.addcontent_type = nil
  22914. }
  22915. // ContentType returns the value of the "content_type" field in the mutation.
  22916. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  22917. v := m.content_type
  22918. if v == nil {
  22919. return
  22920. }
  22921. return *v, true
  22922. }
  22923. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  22924. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22926. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  22927. if !m.op.Is(OpUpdateOne) {
  22928. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  22929. }
  22930. if m.id == nil || m.oldValue == nil {
  22931. return v, errors.New("OldContentType requires an ID field in the mutation")
  22932. }
  22933. oldValue, err := m.oldValue(ctx)
  22934. if err != nil {
  22935. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  22936. }
  22937. return oldValue.ContentType, nil
  22938. }
  22939. // AddContentType adds i to the "content_type" field.
  22940. func (m *MessageRecordsMutation) AddContentType(i int) {
  22941. if m.addcontent_type != nil {
  22942. *m.addcontent_type += i
  22943. } else {
  22944. m.addcontent_type = &i
  22945. }
  22946. }
  22947. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  22948. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  22949. v := m.addcontent_type
  22950. if v == nil {
  22951. return
  22952. }
  22953. return *v, true
  22954. }
  22955. // ResetContentType resets all changes to the "content_type" field.
  22956. func (m *MessageRecordsMutation) ResetContentType() {
  22957. m.content_type = nil
  22958. m.addcontent_type = nil
  22959. }
  22960. // SetContent sets the "content" field.
  22961. func (m *MessageRecordsMutation) SetContent(s string) {
  22962. m.content = &s
  22963. }
  22964. // Content returns the value of the "content" field in the mutation.
  22965. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  22966. v := m.content
  22967. if v == nil {
  22968. return
  22969. }
  22970. return *v, true
  22971. }
  22972. // OldContent returns the old "content" field's value of the MessageRecords entity.
  22973. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22975. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  22976. if !m.op.Is(OpUpdateOne) {
  22977. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22978. }
  22979. if m.id == nil || m.oldValue == nil {
  22980. return v, errors.New("OldContent requires an ID field in the mutation")
  22981. }
  22982. oldValue, err := m.oldValue(ctx)
  22983. if err != nil {
  22984. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22985. }
  22986. return oldValue.Content, nil
  22987. }
  22988. // ResetContent resets all changes to the "content" field.
  22989. func (m *MessageRecordsMutation) ResetContent() {
  22990. m.content = nil
  22991. }
  22992. // SetMeta sets the "meta" field.
  22993. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  22994. m.meta = &ct
  22995. }
  22996. // Meta returns the value of the "meta" field in the mutation.
  22997. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  22998. v := m.meta
  22999. if v == nil {
  23000. return
  23001. }
  23002. return *v, true
  23003. }
  23004. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  23005. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23007. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  23008. if !m.op.Is(OpUpdateOne) {
  23009. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  23010. }
  23011. if m.id == nil || m.oldValue == nil {
  23012. return v, errors.New("OldMeta requires an ID field in the mutation")
  23013. }
  23014. oldValue, err := m.oldValue(ctx)
  23015. if err != nil {
  23016. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  23017. }
  23018. return oldValue.Meta, nil
  23019. }
  23020. // ClearMeta clears the value of the "meta" field.
  23021. func (m *MessageRecordsMutation) ClearMeta() {
  23022. m.meta = nil
  23023. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  23024. }
  23025. // MetaCleared returns if the "meta" field was cleared in this mutation.
  23026. func (m *MessageRecordsMutation) MetaCleared() bool {
  23027. _, ok := m.clearedFields[messagerecords.FieldMeta]
  23028. return ok
  23029. }
  23030. // ResetMeta resets all changes to the "meta" field.
  23031. func (m *MessageRecordsMutation) ResetMeta() {
  23032. m.meta = nil
  23033. delete(m.clearedFields, messagerecords.FieldMeta)
  23034. }
  23035. // SetErrorDetail sets the "error_detail" field.
  23036. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  23037. m.error_detail = &s
  23038. }
  23039. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  23040. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  23041. v := m.error_detail
  23042. if v == nil {
  23043. return
  23044. }
  23045. return *v, true
  23046. }
  23047. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  23048. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23050. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  23051. if !m.op.Is(OpUpdateOne) {
  23052. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  23053. }
  23054. if m.id == nil || m.oldValue == nil {
  23055. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  23056. }
  23057. oldValue, err := m.oldValue(ctx)
  23058. if err != nil {
  23059. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  23060. }
  23061. return oldValue.ErrorDetail, nil
  23062. }
  23063. // ResetErrorDetail resets all changes to the "error_detail" field.
  23064. func (m *MessageRecordsMutation) ResetErrorDetail() {
  23065. m.error_detail = nil
  23066. }
  23067. // SetSendTime sets the "send_time" field.
  23068. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  23069. m.send_time = &t
  23070. }
  23071. // SendTime returns the value of the "send_time" field in the mutation.
  23072. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  23073. v := m.send_time
  23074. if v == nil {
  23075. return
  23076. }
  23077. return *v, true
  23078. }
  23079. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  23080. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23082. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  23083. if !m.op.Is(OpUpdateOne) {
  23084. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  23085. }
  23086. if m.id == nil || m.oldValue == nil {
  23087. return v, errors.New("OldSendTime requires an ID field in the mutation")
  23088. }
  23089. oldValue, err := m.oldValue(ctx)
  23090. if err != nil {
  23091. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  23092. }
  23093. return oldValue.SendTime, nil
  23094. }
  23095. // ClearSendTime clears the value of the "send_time" field.
  23096. func (m *MessageRecordsMutation) ClearSendTime() {
  23097. m.send_time = nil
  23098. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  23099. }
  23100. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  23101. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  23102. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  23103. return ok
  23104. }
  23105. // ResetSendTime resets all changes to the "send_time" field.
  23106. func (m *MessageRecordsMutation) ResetSendTime() {
  23107. m.send_time = nil
  23108. delete(m.clearedFields, messagerecords.FieldSendTime)
  23109. }
  23110. // SetSourceType sets the "source_type" field.
  23111. func (m *MessageRecordsMutation) SetSourceType(i int) {
  23112. m.source_type = &i
  23113. m.addsource_type = nil
  23114. }
  23115. // SourceType returns the value of the "source_type" field in the mutation.
  23116. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  23117. v := m.source_type
  23118. if v == nil {
  23119. return
  23120. }
  23121. return *v, true
  23122. }
  23123. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  23124. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23126. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  23127. if !m.op.Is(OpUpdateOne) {
  23128. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  23129. }
  23130. if m.id == nil || m.oldValue == nil {
  23131. return v, errors.New("OldSourceType requires an ID field in the mutation")
  23132. }
  23133. oldValue, err := m.oldValue(ctx)
  23134. if err != nil {
  23135. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  23136. }
  23137. return oldValue.SourceType, nil
  23138. }
  23139. // AddSourceType adds i to the "source_type" field.
  23140. func (m *MessageRecordsMutation) AddSourceType(i int) {
  23141. if m.addsource_type != nil {
  23142. *m.addsource_type += i
  23143. } else {
  23144. m.addsource_type = &i
  23145. }
  23146. }
  23147. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  23148. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  23149. v := m.addsource_type
  23150. if v == nil {
  23151. return
  23152. }
  23153. return *v, true
  23154. }
  23155. // ResetSourceType resets all changes to the "source_type" field.
  23156. func (m *MessageRecordsMutation) ResetSourceType() {
  23157. m.source_type = nil
  23158. m.addsource_type = nil
  23159. }
  23160. // SetSourceID sets the "source_id" field.
  23161. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  23162. m.sop_stage = &u
  23163. }
  23164. // SourceID returns the value of the "source_id" field in the mutation.
  23165. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  23166. v := m.sop_stage
  23167. if v == nil {
  23168. return
  23169. }
  23170. return *v, true
  23171. }
  23172. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  23173. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23175. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  23176. if !m.op.Is(OpUpdateOne) {
  23177. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  23178. }
  23179. if m.id == nil || m.oldValue == nil {
  23180. return v, errors.New("OldSourceID requires an ID field in the mutation")
  23181. }
  23182. oldValue, err := m.oldValue(ctx)
  23183. if err != nil {
  23184. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  23185. }
  23186. return oldValue.SourceID, nil
  23187. }
  23188. // ClearSourceID clears the value of the "source_id" field.
  23189. func (m *MessageRecordsMutation) ClearSourceID() {
  23190. m.sop_stage = nil
  23191. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23192. }
  23193. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  23194. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  23195. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  23196. return ok
  23197. }
  23198. // ResetSourceID resets all changes to the "source_id" field.
  23199. func (m *MessageRecordsMutation) ResetSourceID() {
  23200. m.sop_stage = nil
  23201. delete(m.clearedFields, messagerecords.FieldSourceID)
  23202. }
  23203. // SetSubSourceID sets the "sub_source_id" field.
  23204. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  23205. m.sop_node = &u
  23206. }
  23207. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  23208. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  23209. v := m.sop_node
  23210. if v == nil {
  23211. return
  23212. }
  23213. return *v, true
  23214. }
  23215. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  23216. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23218. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  23219. if !m.op.Is(OpUpdateOne) {
  23220. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  23221. }
  23222. if m.id == nil || m.oldValue == nil {
  23223. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  23224. }
  23225. oldValue, err := m.oldValue(ctx)
  23226. if err != nil {
  23227. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  23228. }
  23229. return oldValue.SubSourceID, nil
  23230. }
  23231. // ClearSubSourceID clears the value of the "sub_source_id" field.
  23232. func (m *MessageRecordsMutation) ClearSubSourceID() {
  23233. m.sop_node = nil
  23234. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23235. }
  23236. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  23237. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  23238. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  23239. return ok
  23240. }
  23241. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  23242. func (m *MessageRecordsMutation) ResetSubSourceID() {
  23243. m.sop_node = nil
  23244. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  23245. }
  23246. // SetOrganizationID sets the "organization_id" field.
  23247. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  23248. m.organization_id = &u
  23249. m.addorganization_id = nil
  23250. }
  23251. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23252. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  23253. v := m.organization_id
  23254. if v == nil {
  23255. return
  23256. }
  23257. return *v, true
  23258. }
  23259. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  23260. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23262. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23263. if !m.op.Is(OpUpdateOne) {
  23264. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23265. }
  23266. if m.id == nil || m.oldValue == nil {
  23267. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23268. }
  23269. oldValue, err := m.oldValue(ctx)
  23270. if err != nil {
  23271. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23272. }
  23273. return oldValue.OrganizationID, nil
  23274. }
  23275. // AddOrganizationID adds u to the "organization_id" field.
  23276. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  23277. if m.addorganization_id != nil {
  23278. *m.addorganization_id += u
  23279. } else {
  23280. m.addorganization_id = &u
  23281. }
  23282. }
  23283. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23284. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  23285. v := m.addorganization_id
  23286. if v == nil {
  23287. return
  23288. }
  23289. return *v, true
  23290. }
  23291. // ClearOrganizationID clears the value of the "organization_id" field.
  23292. func (m *MessageRecordsMutation) ClearOrganizationID() {
  23293. m.organization_id = nil
  23294. m.addorganization_id = nil
  23295. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  23296. }
  23297. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23298. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  23299. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  23300. return ok
  23301. }
  23302. // ResetOrganizationID resets all changes to the "organization_id" field.
  23303. func (m *MessageRecordsMutation) ResetOrganizationID() {
  23304. m.organization_id = nil
  23305. m.addorganization_id = nil
  23306. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  23307. }
  23308. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23309. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  23310. m.sop_stage = &id
  23311. }
  23312. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23313. func (m *MessageRecordsMutation) ClearSopStage() {
  23314. m.clearedsop_stage = true
  23315. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23316. }
  23317. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23318. func (m *MessageRecordsMutation) SopStageCleared() bool {
  23319. return m.SourceIDCleared() || m.clearedsop_stage
  23320. }
  23321. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23322. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  23323. if m.sop_stage != nil {
  23324. return *m.sop_stage, true
  23325. }
  23326. return
  23327. }
  23328. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23329. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23330. // SopStageID instead. It exists only for internal usage by the builders.
  23331. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  23332. if id := m.sop_stage; id != nil {
  23333. ids = append(ids, *id)
  23334. }
  23335. return
  23336. }
  23337. // ResetSopStage resets all changes to the "sop_stage" edge.
  23338. func (m *MessageRecordsMutation) ResetSopStage() {
  23339. m.sop_stage = nil
  23340. m.clearedsop_stage = false
  23341. }
  23342. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  23343. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  23344. m.sop_node = &id
  23345. }
  23346. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  23347. func (m *MessageRecordsMutation) ClearSopNode() {
  23348. m.clearedsop_node = true
  23349. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23350. }
  23351. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  23352. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  23353. return m.SubSourceIDCleared() || m.clearedsop_node
  23354. }
  23355. // SopNodeID returns the "sop_node" edge ID in the mutation.
  23356. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  23357. if m.sop_node != nil {
  23358. return *m.sop_node, true
  23359. }
  23360. return
  23361. }
  23362. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  23363. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23364. // SopNodeID instead. It exists only for internal usage by the builders.
  23365. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  23366. if id := m.sop_node; id != nil {
  23367. ids = append(ids, *id)
  23368. }
  23369. return
  23370. }
  23371. // ResetSopNode resets all changes to the "sop_node" edge.
  23372. func (m *MessageRecordsMutation) ResetSopNode() {
  23373. m.sop_node = nil
  23374. m.clearedsop_node = false
  23375. }
  23376. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  23377. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  23378. m.message_contact = &id
  23379. }
  23380. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  23381. func (m *MessageRecordsMutation) ClearMessageContact() {
  23382. m.clearedmessage_contact = true
  23383. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  23384. }
  23385. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  23386. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  23387. return m.ContactIDCleared() || m.clearedmessage_contact
  23388. }
  23389. // MessageContactID returns the "message_contact" edge ID in the mutation.
  23390. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  23391. if m.message_contact != nil {
  23392. return *m.message_contact, true
  23393. }
  23394. return
  23395. }
  23396. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  23397. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23398. // MessageContactID instead. It exists only for internal usage by the builders.
  23399. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  23400. if id := m.message_contact; id != nil {
  23401. ids = append(ids, *id)
  23402. }
  23403. return
  23404. }
  23405. // ResetMessageContact resets all changes to the "message_contact" edge.
  23406. func (m *MessageRecordsMutation) ResetMessageContact() {
  23407. m.message_contact = nil
  23408. m.clearedmessage_contact = false
  23409. }
  23410. // Where appends a list predicates to the MessageRecordsMutation builder.
  23411. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  23412. m.predicates = append(m.predicates, ps...)
  23413. }
  23414. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  23415. // users can use type-assertion to append predicates that do not depend on any generated package.
  23416. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  23417. p := make([]predicate.MessageRecords, len(ps))
  23418. for i := range ps {
  23419. p[i] = ps[i]
  23420. }
  23421. m.Where(p...)
  23422. }
  23423. // Op returns the operation name.
  23424. func (m *MessageRecordsMutation) Op() Op {
  23425. return m.op
  23426. }
  23427. // SetOp allows setting the mutation operation.
  23428. func (m *MessageRecordsMutation) SetOp(op Op) {
  23429. m.op = op
  23430. }
  23431. // Type returns the node type of this mutation (MessageRecords).
  23432. func (m *MessageRecordsMutation) Type() string {
  23433. return m.typ
  23434. }
  23435. // Fields returns all fields that were changed during this mutation. Note that in
  23436. // order to get all numeric fields that were incremented/decremented, call
  23437. // AddedFields().
  23438. func (m *MessageRecordsMutation) Fields() []string {
  23439. fields := make([]string, 0, 16)
  23440. if m.created_at != nil {
  23441. fields = append(fields, messagerecords.FieldCreatedAt)
  23442. }
  23443. if m.updated_at != nil {
  23444. fields = append(fields, messagerecords.FieldUpdatedAt)
  23445. }
  23446. if m.status != nil {
  23447. fields = append(fields, messagerecords.FieldStatus)
  23448. }
  23449. if m.bot_wxid != nil {
  23450. fields = append(fields, messagerecords.FieldBotWxid)
  23451. }
  23452. if m.message_contact != nil {
  23453. fields = append(fields, messagerecords.FieldContactID)
  23454. }
  23455. if m.contact_type != nil {
  23456. fields = append(fields, messagerecords.FieldContactType)
  23457. }
  23458. if m.contact_wxid != nil {
  23459. fields = append(fields, messagerecords.FieldContactWxid)
  23460. }
  23461. if m.content_type != nil {
  23462. fields = append(fields, messagerecords.FieldContentType)
  23463. }
  23464. if m.content != nil {
  23465. fields = append(fields, messagerecords.FieldContent)
  23466. }
  23467. if m.meta != nil {
  23468. fields = append(fields, messagerecords.FieldMeta)
  23469. }
  23470. if m.error_detail != nil {
  23471. fields = append(fields, messagerecords.FieldErrorDetail)
  23472. }
  23473. if m.send_time != nil {
  23474. fields = append(fields, messagerecords.FieldSendTime)
  23475. }
  23476. if m.source_type != nil {
  23477. fields = append(fields, messagerecords.FieldSourceType)
  23478. }
  23479. if m.sop_stage != nil {
  23480. fields = append(fields, messagerecords.FieldSourceID)
  23481. }
  23482. if m.sop_node != nil {
  23483. fields = append(fields, messagerecords.FieldSubSourceID)
  23484. }
  23485. if m.organization_id != nil {
  23486. fields = append(fields, messagerecords.FieldOrganizationID)
  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 *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  23494. switch name {
  23495. case messagerecords.FieldCreatedAt:
  23496. return m.CreatedAt()
  23497. case messagerecords.FieldUpdatedAt:
  23498. return m.UpdatedAt()
  23499. case messagerecords.FieldStatus:
  23500. return m.Status()
  23501. case messagerecords.FieldBotWxid:
  23502. return m.BotWxid()
  23503. case messagerecords.FieldContactID:
  23504. return m.ContactID()
  23505. case messagerecords.FieldContactType:
  23506. return m.ContactType()
  23507. case messagerecords.FieldContactWxid:
  23508. return m.ContactWxid()
  23509. case messagerecords.FieldContentType:
  23510. return m.ContentType()
  23511. case messagerecords.FieldContent:
  23512. return m.Content()
  23513. case messagerecords.FieldMeta:
  23514. return m.Meta()
  23515. case messagerecords.FieldErrorDetail:
  23516. return m.ErrorDetail()
  23517. case messagerecords.FieldSendTime:
  23518. return m.SendTime()
  23519. case messagerecords.FieldSourceType:
  23520. return m.SourceType()
  23521. case messagerecords.FieldSourceID:
  23522. return m.SourceID()
  23523. case messagerecords.FieldSubSourceID:
  23524. return m.SubSourceID()
  23525. case messagerecords.FieldOrganizationID:
  23526. return m.OrganizationID()
  23527. }
  23528. return nil, false
  23529. }
  23530. // OldField returns the old value of the field from the database. An error is
  23531. // returned if the mutation operation is not UpdateOne, or the query to the
  23532. // database failed.
  23533. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23534. switch name {
  23535. case messagerecords.FieldCreatedAt:
  23536. return m.OldCreatedAt(ctx)
  23537. case messagerecords.FieldUpdatedAt:
  23538. return m.OldUpdatedAt(ctx)
  23539. case messagerecords.FieldStatus:
  23540. return m.OldStatus(ctx)
  23541. case messagerecords.FieldBotWxid:
  23542. return m.OldBotWxid(ctx)
  23543. case messagerecords.FieldContactID:
  23544. return m.OldContactID(ctx)
  23545. case messagerecords.FieldContactType:
  23546. return m.OldContactType(ctx)
  23547. case messagerecords.FieldContactWxid:
  23548. return m.OldContactWxid(ctx)
  23549. case messagerecords.FieldContentType:
  23550. return m.OldContentType(ctx)
  23551. case messagerecords.FieldContent:
  23552. return m.OldContent(ctx)
  23553. case messagerecords.FieldMeta:
  23554. return m.OldMeta(ctx)
  23555. case messagerecords.FieldErrorDetail:
  23556. return m.OldErrorDetail(ctx)
  23557. case messagerecords.FieldSendTime:
  23558. return m.OldSendTime(ctx)
  23559. case messagerecords.FieldSourceType:
  23560. return m.OldSourceType(ctx)
  23561. case messagerecords.FieldSourceID:
  23562. return m.OldSourceID(ctx)
  23563. case messagerecords.FieldSubSourceID:
  23564. return m.OldSubSourceID(ctx)
  23565. case messagerecords.FieldOrganizationID:
  23566. return m.OldOrganizationID(ctx)
  23567. }
  23568. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  23569. }
  23570. // SetField sets the value of a field with the given name. It returns an error if
  23571. // the field is not defined in the schema, or if the type mismatched the field
  23572. // type.
  23573. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  23574. switch name {
  23575. case messagerecords.FieldCreatedAt:
  23576. v, ok := value.(time.Time)
  23577. if !ok {
  23578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23579. }
  23580. m.SetCreatedAt(v)
  23581. return nil
  23582. case messagerecords.FieldUpdatedAt:
  23583. v, ok := value.(time.Time)
  23584. if !ok {
  23585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23586. }
  23587. m.SetUpdatedAt(v)
  23588. return nil
  23589. case messagerecords.FieldStatus:
  23590. v, ok := value.(uint8)
  23591. if !ok {
  23592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23593. }
  23594. m.SetStatus(v)
  23595. return nil
  23596. case messagerecords.FieldBotWxid:
  23597. v, ok := value.(string)
  23598. if !ok {
  23599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23600. }
  23601. m.SetBotWxid(v)
  23602. return nil
  23603. case messagerecords.FieldContactID:
  23604. v, ok := value.(uint64)
  23605. if !ok {
  23606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23607. }
  23608. m.SetContactID(v)
  23609. return nil
  23610. case messagerecords.FieldContactType:
  23611. v, ok := value.(int)
  23612. if !ok {
  23613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23614. }
  23615. m.SetContactType(v)
  23616. return nil
  23617. case messagerecords.FieldContactWxid:
  23618. v, ok := value.(string)
  23619. if !ok {
  23620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23621. }
  23622. m.SetContactWxid(v)
  23623. return nil
  23624. case messagerecords.FieldContentType:
  23625. v, ok := value.(int)
  23626. if !ok {
  23627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23628. }
  23629. m.SetContentType(v)
  23630. return nil
  23631. case messagerecords.FieldContent:
  23632. v, ok := value.(string)
  23633. if !ok {
  23634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23635. }
  23636. m.SetContent(v)
  23637. return nil
  23638. case messagerecords.FieldMeta:
  23639. v, ok := value.(custom_types.Meta)
  23640. if !ok {
  23641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23642. }
  23643. m.SetMeta(v)
  23644. return nil
  23645. case messagerecords.FieldErrorDetail:
  23646. v, ok := value.(string)
  23647. if !ok {
  23648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23649. }
  23650. m.SetErrorDetail(v)
  23651. return nil
  23652. case messagerecords.FieldSendTime:
  23653. v, ok := value.(time.Time)
  23654. if !ok {
  23655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23656. }
  23657. m.SetSendTime(v)
  23658. return nil
  23659. case messagerecords.FieldSourceType:
  23660. v, ok := value.(int)
  23661. if !ok {
  23662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23663. }
  23664. m.SetSourceType(v)
  23665. return nil
  23666. case messagerecords.FieldSourceID:
  23667. v, ok := value.(uint64)
  23668. if !ok {
  23669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23670. }
  23671. m.SetSourceID(v)
  23672. return nil
  23673. case messagerecords.FieldSubSourceID:
  23674. v, ok := value.(uint64)
  23675. if !ok {
  23676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23677. }
  23678. m.SetSubSourceID(v)
  23679. return nil
  23680. case messagerecords.FieldOrganizationID:
  23681. v, ok := value.(uint64)
  23682. if !ok {
  23683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23684. }
  23685. m.SetOrganizationID(v)
  23686. return nil
  23687. }
  23688. return fmt.Errorf("unknown MessageRecords field %s", name)
  23689. }
  23690. // AddedFields returns all numeric fields that were incremented/decremented during
  23691. // this mutation.
  23692. func (m *MessageRecordsMutation) AddedFields() []string {
  23693. var fields []string
  23694. if m.addstatus != nil {
  23695. fields = append(fields, messagerecords.FieldStatus)
  23696. }
  23697. if m.addcontact_type != nil {
  23698. fields = append(fields, messagerecords.FieldContactType)
  23699. }
  23700. if m.addcontent_type != nil {
  23701. fields = append(fields, messagerecords.FieldContentType)
  23702. }
  23703. if m.addsource_type != nil {
  23704. fields = append(fields, messagerecords.FieldSourceType)
  23705. }
  23706. if m.addorganization_id != nil {
  23707. fields = append(fields, messagerecords.FieldOrganizationID)
  23708. }
  23709. return fields
  23710. }
  23711. // AddedField returns the numeric value that was incremented/decremented on a field
  23712. // with the given name. The second boolean return value indicates that this field
  23713. // was not set, or was not defined in the schema.
  23714. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  23715. switch name {
  23716. case messagerecords.FieldStatus:
  23717. return m.AddedStatus()
  23718. case messagerecords.FieldContactType:
  23719. return m.AddedContactType()
  23720. case messagerecords.FieldContentType:
  23721. return m.AddedContentType()
  23722. case messagerecords.FieldSourceType:
  23723. return m.AddedSourceType()
  23724. case messagerecords.FieldOrganizationID:
  23725. return m.AddedOrganizationID()
  23726. }
  23727. return nil, false
  23728. }
  23729. // AddField adds the value to the field with the given name. It returns an error if
  23730. // the field is not defined in the schema, or if the type mismatched the field
  23731. // type.
  23732. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  23733. switch name {
  23734. case messagerecords.FieldStatus:
  23735. v, ok := value.(int8)
  23736. if !ok {
  23737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23738. }
  23739. m.AddStatus(v)
  23740. return nil
  23741. case messagerecords.FieldContactType:
  23742. v, ok := value.(int)
  23743. if !ok {
  23744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23745. }
  23746. m.AddContactType(v)
  23747. return nil
  23748. case messagerecords.FieldContentType:
  23749. v, ok := value.(int)
  23750. if !ok {
  23751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23752. }
  23753. m.AddContentType(v)
  23754. return nil
  23755. case messagerecords.FieldSourceType:
  23756. v, ok := value.(int)
  23757. if !ok {
  23758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23759. }
  23760. m.AddSourceType(v)
  23761. return nil
  23762. case messagerecords.FieldOrganizationID:
  23763. v, ok := value.(int64)
  23764. if !ok {
  23765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23766. }
  23767. m.AddOrganizationID(v)
  23768. return nil
  23769. }
  23770. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  23771. }
  23772. // ClearedFields returns all nullable fields that were cleared during this
  23773. // mutation.
  23774. func (m *MessageRecordsMutation) ClearedFields() []string {
  23775. var fields []string
  23776. if m.FieldCleared(messagerecords.FieldStatus) {
  23777. fields = append(fields, messagerecords.FieldStatus)
  23778. }
  23779. if m.FieldCleared(messagerecords.FieldContactID) {
  23780. fields = append(fields, messagerecords.FieldContactID)
  23781. }
  23782. if m.FieldCleared(messagerecords.FieldMeta) {
  23783. fields = append(fields, messagerecords.FieldMeta)
  23784. }
  23785. if m.FieldCleared(messagerecords.FieldSendTime) {
  23786. fields = append(fields, messagerecords.FieldSendTime)
  23787. }
  23788. if m.FieldCleared(messagerecords.FieldSourceID) {
  23789. fields = append(fields, messagerecords.FieldSourceID)
  23790. }
  23791. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  23792. fields = append(fields, messagerecords.FieldSubSourceID)
  23793. }
  23794. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  23795. fields = append(fields, messagerecords.FieldOrganizationID)
  23796. }
  23797. return fields
  23798. }
  23799. // FieldCleared returns a boolean indicating if a field with the given name was
  23800. // cleared in this mutation.
  23801. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  23802. _, ok := m.clearedFields[name]
  23803. return ok
  23804. }
  23805. // ClearField clears the value of the field with the given name. It returns an
  23806. // error if the field is not defined in the schema.
  23807. func (m *MessageRecordsMutation) ClearField(name string) error {
  23808. switch name {
  23809. case messagerecords.FieldStatus:
  23810. m.ClearStatus()
  23811. return nil
  23812. case messagerecords.FieldContactID:
  23813. m.ClearContactID()
  23814. return nil
  23815. case messagerecords.FieldMeta:
  23816. m.ClearMeta()
  23817. return nil
  23818. case messagerecords.FieldSendTime:
  23819. m.ClearSendTime()
  23820. return nil
  23821. case messagerecords.FieldSourceID:
  23822. m.ClearSourceID()
  23823. return nil
  23824. case messagerecords.FieldSubSourceID:
  23825. m.ClearSubSourceID()
  23826. return nil
  23827. case messagerecords.FieldOrganizationID:
  23828. m.ClearOrganizationID()
  23829. return nil
  23830. }
  23831. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  23832. }
  23833. // ResetField resets all changes in the mutation for the field with the given name.
  23834. // It returns an error if the field is not defined in the schema.
  23835. func (m *MessageRecordsMutation) ResetField(name string) error {
  23836. switch name {
  23837. case messagerecords.FieldCreatedAt:
  23838. m.ResetCreatedAt()
  23839. return nil
  23840. case messagerecords.FieldUpdatedAt:
  23841. m.ResetUpdatedAt()
  23842. return nil
  23843. case messagerecords.FieldStatus:
  23844. m.ResetStatus()
  23845. return nil
  23846. case messagerecords.FieldBotWxid:
  23847. m.ResetBotWxid()
  23848. return nil
  23849. case messagerecords.FieldContactID:
  23850. m.ResetContactID()
  23851. return nil
  23852. case messagerecords.FieldContactType:
  23853. m.ResetContactType()
  23854. return nil
  23855. case messagerecords.FieldContactWxid:
  23856. m.ResetContactWxid()
  23857. return nil
  23858. case messagerecords.FieldContentType:
  23859. m.ResetContentType()
  23860. return nil
  23861. case messagerecords.FieldContent:
  23862. m.ResetContent()
  23863. return nil
  23864. case messagerecords.FieldMeta:
  23865. m.ResetMeta()
  23866. return nil
  23867. case messagerecords.FieldErrorDetail:
  23868. m.ResetErrorDetail()
  23869. return nil
  23870. case messagerecords.FieldSendTime:
  23871. m.ResetSendTime()
  23872. return nil
  23873. case messagerecords.FieldSourceType:
  23874. m.ResetSourceType()
  23875. return nil
  23876. case messagerecords.FieldSourceID:
  23877. m.ResetSourceID()
  23878. return nil
  23879. case messagerecords.FieldSubSourceID:
  23880. m.ResetSubSourceID()
  23881. return nil
  23882. case messagerecords.FieldOrganizationID:
  23883. m.ResetOrganizationID()
  23884. return nil
  23885. }
  23886. return fmt.Errorf("unknown MessageRecords field %s", name)
  23887. }
  23888. // AddedEdges returns all edge names that were set/added in this mutation.
  23889. func (m *MessageRecordsMutation) AddedEdges() []string {
  23890. edges := make([]string, 0, 3)
  23891. if m.sop_stage != nil {
  23892. edges = append(edges, messagerecords.EdgeSopStage)
  23893. }
  23894. if m.sop_node != nil {
  23895. edges = append(edges, messagerecords.EdgeSopNode)
  23896. }
  23897. if m.message_contact != nil {
  23898. edges = append(edges, messagerecords.EdgeMessageContact)
  23899. }
  23900. return edges
  23901. }
  23902. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23903. // name in this mutation.
  23904. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  23905. switch name {
  23906. case messagerecords.EdgeSopStage:
  23907. if id := m.sop_stage; id != nil {
  23908. return []ent.Value{*id}
  23909. }
  23910. case messagerecords.EdgeSopNode:
  23911. if id := m.sop_node; id != nil {
  23912. return []ent.Value{*id}
  23913. }
  23914. case messagerecords.EdgeMessageContact:
  23915. if id := m.message_contact; id != nil {
  23916. return []ent.Value{*id}
  23917. }
  23918. }
  23919. return nil
  23920. }
  23921. // RemovedEdges returns all edge names that were removed in this mutation.
  23922. func (m *MessageRecordsMutation) RemovedEdges() []string {
  23923. edges := make([]string, 0, 3)
  23924. return edges
  23925. }
  23926. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23927. // the given name in this mutation.
  23928. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  23929. return nil
  23930. }
  23931. // ClearedEdges returns all edge names that were cleared in this mutation.
  23932. func (m *MessageRecordsMutation) ClearedEdges() []string {
  23933. edges := make([]string, 0, 3)
  23934. if m.clearedsop_stage {
  23935. edges = append(edges, messagerecords.EdgeSopStage)
  23936. }
  23937. if m.clearedsop_node {
  23938. edges = append(edges, messagerecords.EdgeSopNode)
  23939. }
  23940. if m.clearedmessage_contact {
  23941. edges = append(edges, messagerecords.EdgeMessageContact)
  23942. }
  23943. return edges
  23944. }
  23945. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23946. // was cleared in this mutation.
  23947. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  23948. switch name {
  23949. case messagerecords.EdgeSopStage:
  23950. return m.clearedsop_stage
  23951. case messagerecords.EdgeSopNode:
  23952. return m.clearedsop_node
  23953. case messagerecords.EdgeMessageContact:
  23954. return m.clearedmessage_contact
  23955. }
  23956. return false
  23957. }
  23958. // ClearEdge clears the value of the edge with the given name. It returns an error
  23959. // if that edge is not defined in the schema.
  23960. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  23961. switch name {
  23962. case messagerecords.EdgeSopStage:
  23963. m.ClearSopStage()
  23964. return nil
  23965. case messagerecords.EdgeSopNode:
  23966. m.ClearSopNode()
  23967. return nil
  23968. case messagerecords.EdgeMessageContact:
  23969. m.ClearMessageContact()
  23970. return nil
  23971. }
  23972. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  23973. }
  23974. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23975. // It returns an error if the edge is not defined in the schema.
  23976. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  23977. switch name {
  23978. case messagerecords.EdgeSopStage:
  23979. m.ResetSopStage()
  23980. return nil
  23981. case messagerecords.EdgeSopNode:
  23982. m.ResetSopNode()
  23983. return nil
  23984. case messagerecords.EdgeMessageContact:
  23985. m.ResetMessageContact()
  23986. return nil
  23987. }
  23988. return fmt.Errorf("unknown MessageRecords edge %s", name)
  23989. }
  23990. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  23991. type MsgMutation struct {
  23992. config
  23993. op Op
  23994. typ string
  23995. id *uint64
  23996. created_at *time.Time
  23997. updated_at *time.Time
  23998. deleted_at *time.Time
  23999. status *uint8
  24000. addstatus *int8
  24001. fromwxid *string
  24002. toid *string
  24003. msgtype *int32
  24004. addmsgtype *int32
  24005. msg *string
  24006. batch_no *string
  24007. cc *string
  24008. phone *string
  24009. clearedFields map[string]struct{}
  24010. done bool
  24011. oldValue func(context.Context) (*Msg, error)
  24012. predicates []predicate.Msg
  24013. }
  24014. var _ ent.Mutation = (*MsgMutation)(nil)
  24015. // msgOption allows management of the mutation configuration using functional options.
  24016. type msgOption func(*MsgMutation)
  24017. // newMsgMutation creates new mutation for the Msg entity.
  24018. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  24019. m := &MsgMutation{
  24020. config: c,
  24021. op: op,
  24022. typ: TypeMsg,
  24023. clearedFields: make(map[string]struct{}),
  24024. }
  24025. for _, opt := range opts {
  24026. opt(m)
  24027. }
  24028. return m
  24029. }
  24030. // withMsgID sets the ID field of the mutation.
  24031. func withMsgID(id uint64) msgOption {
  24032. return func(m *MsgMutation) {
  24033. var (
  24034. err error
  24035. once sync.Once
  24036. value *Msg
  24037. )
  24038. m.oldValue = func(ctx context.Context) (*Msg, error) {
  24039. once.Do(func() {
  24040. if m.done {
  24041. err = errors.New("querying old values post mutation is not allowed")
  24042. } else {
  24043. value, err = m.Client().Msg.Get(ctx, id)
  24044. }
  24045. })
  24046. return value, err
  24047. }
  24048. m.id = &id
  24049. }
  24050. }
  24051. // withMsg sets the old Msg of the mutation.
  24052. func withMsg(node *Msg) msgOption {
  24053. return func(m *MsgMutation) {
  24054. m.oldValue = func(context.Context) (*Msg, error) {
  24055. return node, nil
  24056. }
  24057. m.id = &node.ID
  24058. }
  24059. }
  24060. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24061. // executed in a transaction (ent.Tx), a transactional client is returned.
  24062. func (m MsgMutation) Client() *Client {
  24063. client := &Client{config: m.config}
  24064. client.init()
  24065. return client
  24066. }
  24067. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24068. // it returns an error otherwise.
  24069. func (m MsgMutation) Tx() (*Tx, error) {
  24070. if _, ok := m.driver.(*txDriver); !ok {
  24071. return nil, errors.New("ent: mutation is not running in a transaction")
  24072. }
  24073. tx := &Tx{config: m.config}
  24074. tx.init()
  24075. return tx, nil
  24076. }
  24077. // SetID sets the value of the id field. Note that this
  24078. // operation is only accepted on creation of Msg entities.
  24079. func (m *MsgMutation) SetID(id uint64) {
  24080. m.id = &id
  24081. }
  24082. // ID returns the ID value in the mutation. Note that the ID is only available
  24083. // if it was provided to the builder or after it was returned from the database.
  24084. func (m *MsgMutation) ID() (id uint64, exists bool) {
  24085. if m.id == nil {
  24086. return
  24087. }
  24088. return *m.id, true
  24089. }
  24090. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24091. // That means, if the mutation is applied within a transaction with an isolation level such
  24092. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24093. // or updated by the mutation.
  24094. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  24095. switch {
  24096. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24097. id, exists := m.ID()
  24098. if exists {
  24099. return []uint64{id}, nil
  24100. }
  24101. fallthrough
  24102. case m.op.Is(OpUpdate | OpDelete):
  24103. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  24104. default:
  24105. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24106. }
  24107. }
  24108. // SetCreatedAt sets the "created_at" field.
  24109. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  24110. m.created_at = &t
  24111. }
  24112. // CreatedAt returns the value of the "created_at" field in the mutation.
  24113. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  24114. v := m.created_at
  24115. if v == nil {
  24116. return
  24117. }
  24118. return *v, true
  24119. }
  24120. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  24121. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24123. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24124. if !m.op.Is(OpUpdateOne) {
  24125. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24126. }
  24127. if m.id == nil || m.oldValue == nil {
  24128. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24129. }
  24130. oldValue, err := m.oldValue(ctx)
  24131. if err != nil {
  24132. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24133. }
  24134. return oldValue.CreatedAt, nil
  24135. }
  24136. // ResetCreatedAt resets all changes to the "created_at" field.
  24137. func (m *MsgMutation) ResetCreatedAt() {
  24138. m.created_at = nil
  24139. }
  24140. // SetUpdatedAt sets the "updated_at" field.
  24141. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  24142. m.updated_at = &t
  24143. }
  24144. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24145. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  24146. v := m.updated_at
  24147. if v == nil {
  24148. return
  24149. }
  24150. return *v, true
  24151. }
  24152. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  24153. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24155. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24156. if !m.op.Is(OpUpdateOne) {
  24157. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24158. }
  24159. if m.id == nil || m.oldValue == nil {
  24160. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24161. }
  24162. oldValue, err := m.oldValue(ctx)
  24163. if err != nil {
  24164. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24165. }
  24166. return oldValue.UpdatedAt, nil
  24167. }
  24168. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24169. func (m *MsgMutation) ResetUpdatedAt() {
  24170. m.updated_at = nil
  24171. }
  24172. // SetDeletedAt sets the "deleted_at" field.
  24173. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  24174. m.deleted_at = &t
  24175. }
  24176. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24177. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  24178. v := m.deleted_at
  24179. if v == nil {
  24180. return
  24181. }
  24182. return *v, true
  24183. }
  24184. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  24185. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24187. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24188. if !m.op.Is(OpUpdateOne) {
  24189. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24190. }
  24191. if m.id == nil || m.oldValue == nil {
  24192. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24193. }
  24194. oldValue, err := m.oldValue(ctx)
  24195. if err != nil {
  24196. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24197. }
  24198. return oldValue.DeletedAt, nil
  24199. }
  24200. // ClearDeletedAt clears the value of the "deleted_at" field.
  24201. func (m *MsgMutation) ClearDeletedAt() {
  24202. m.deleted_at = nil
  24203. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  24204. }
  24205. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24206. func (m *MsgMutation) DeletedAtCleared() bool {
  24207. _, ok := m.clearedFields[msg.FieldDeletedAt]
  24208. return ok
  24209. }
  24210. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24211. func (m *MsgMutation) ResetDeletedAt() {
  24212. m.deleted_at = nil
  24213. delete(m.clearedFields, msg.FieldDeletedAt)
  24214. }
  24215. // SetStatus sets the "status" field.
  24216. func (m *MsgMutation) SetStatus(u uint8) {
  24217. m.status = &u
  24218. m.addstatus = nil
  24219. }
  24220. // Status returns the value of the "status" field in the mutation.
  24221. func (m *MsgMutation) Status() (r uint8, exists bool) {
  24222. v := m.status
  24223. if v == nil {
  24224. return
  24225. }
  24226. return *v, true
  24227. }
  24228. // OldStatus returns the old "status" field's value of the Msg entity.
  24229. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24231. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24232. if !m.op.Is(OpUpdateOne) {
  24233. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24234. }
  24235. if m.id == nil || m.oldValue == nil {
  24236. return v, errors.New("OldStatus requires an ID field in the mutation")
  24237. }
  24238. oldValue, err := m.oldValue(ctx)
  24239. if err != nil {
  24240. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24241. }
  24242. return oldValue.Status, nil
  24243. }
  24244. // AddStatus adds u to the "status" field.
  24245. func (m *MsgMutation) AddStatus(u int8) {
  24246. if m.addstatus != nil {
  24247. *m.addstatus += u
  24248. } else {
  24249. m.addstatus = &u
  24250. }
  24251. }
  24252. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24253. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  24254. v := m.addstatus
  24255. if v == nil {
  24256. return
  24257. }
  24258. return *v, true
  24259. }
  24260. // ClearStatus clears the value of the "status" field.
  24261. func (m *MsgMutation) ClearStatus() {
  24262. m.status = nil
  24263. m.addstatus = nil
  24264. m.clearedFields[msg.FieldStatus] = struct{}{}
  24265. }
  24266. // StatusCleared returns if the "status" field was cleared in this mutation.
  24267. func (m *MsgMutation) StatusCleared() bool {
  24268. _, ok := m.clearedFields[msg.FieldStatus]
  24269. return ok
  24270. }
  24271. // ResetStatus resets all changes to the "status" field.
  24272. func (m *MsgMutation) ResetStatus() {
  24273. m.status = nil
  24274. m.addstatus = nil
  24275. delete(m.clearedFields, msg.FieldStatus)
  24276. }
  24277. // SetFromwxid sets the "fromwxid" field.
  24278. func (m *MsgMutation) SetFromwxid(s string) {
  24279. m.fromwxid = &s
  24280. }
  24281. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  24282. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  24283. v := m.fromwxid
  24284. if v == nil {
  24285. return
  24286. }
  24287. return *v, true
  24288. }
  24289. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  24290. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24292. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  24293. if !m.op.Is(OpUpdateOne) {
  24294. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  24295. }
  24296. if m.id == nil || m.oldValue == nil {
  24297. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  24298. }
  24299. oldValue, err := m.oldValue(ctx)
  24300. if err != nil {
  24301. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  24302. }
  24303. return oldValue.Fromwxid, nil
  24304. }
  24305. // ClearFromwxid clears the value of the "fromwxid" field.
  24306. func (m *MsgMutation) ClearFromwxid() {
  24307. m.fromwxid = nil
  24308. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  24309. }
  24310. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  24311. func (m *MsgMutation) FromwxidCleared() bool {
  24312. _, ok := m.clearedFields[msg.FieldFromwxid]
  24313. return ok
  24314. }
  24315. // ResetFromwxid resets all changes to the "fromwxid" field.
  24316. func (m *MsgMutation) ResetFromwxid() {
  24317. m.fromwxid = nil
  24318. delete(m.clearedFields, msg.FieldFromwxid)
  24319. }
  24320. // SetToid sets the "toid" field.
  24321. func (m *MsgMutation) SetToid(s string) {
  24322. m.toid = &s
  24323. }
  24324. // Toid returns the value of the "toid" field in the mutation.
  24325. func (m *MsgMutation) Toid() (r string, exists bool) {
  24326. v := m.toid
  24327. if v == nil {
  24328. return
  24329. }
  24330. return *v, true
  24331. }
  24332. // OldToid returns the old "toid" field's value of the Msg entity.
  24333. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24335. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  24336. if !m.op.Is(OpUpdateOne) {
  24337. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  24338. }
  24339. if m.id == nil || m.oldValue == nil {
  24340. return v, errors.New("OldToid requires an ID field in the mutation")
  24341. }
  24342. oldValue, err := m.oldValue(ctx)
  24343. if err != nil {
  24344. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  24345. }
  24346. return oldValue.Toid, nil
  24347. }
  24348. // ClearToid clears the value of the "toid" field.
  24349. func (m *MsgMutation) ClearToid() {
  24350. m.toid = nil
  24351. m.clearedFields[msg.FieldToid] = struct{}{}
  24352. }
  24353. // ToidCleared returns if the "toid" field was cleared in this mutation.
  24354. func (m *MsgMutation) ToidCleared() bool {
  24355. _, ok := m.clearedFields[msg.FieldToid]
  24356. return ok
  24357. }
  24358. // ResetToid resets all changes to the "toid" field.
  24359. func (m *MsgMutation) ResetToid() {
  24360. m.toid = nil
  24361. delete(m.clearedFields, msg.FieldToid)
  24362. }
  24363. // SetMsgtype sets the "msgtype" field.
  24364. func (m *MsgMutation) SetMsgtype(i int32) {
  24365. m.msgtype = &i
  24366. m.addmsgtype = nil
  24367. }
  24368. // Msgtype returns the value of the "msgtype" field in the mutation.
  24369. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  24370. v := m.msgtype
  24371. if v == nil {
  24372. return
  24373. }
  24374. return *v, true
  24375. }
  24376. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  24377. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24379. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  24380. if !m.op.Is(OpUpdateOne) {
  24381. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  24382. }
  24383. if m.id == nil || m.oldValue == nil {
  24384. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  24385. }
  24386. oldValue, err := m.oldValue(ctx)
  24387. if err != nil {
  24388. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  24389. }
  24390. return oldValue.Msgtype, nil
  24391. }
  24392. // AddMsgtype adds i to the "msgtype" field.
  24393. func (m *MsgMutation) AddMsgtype(i int32) {
  24394. if m.addmsgtype != nil {
  24395. *m.addmsgtype += i
  24396. } else {
  24397. m.addmsgtype = &i
  24398. }
  24399. }
  24400. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  24401. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  24402. v := m.addmsgtype
  24403. if v == nil {
  24404. return
  24405. }
  24406. return *v, true
  24407. }
  24408. // ClearMsgtype clears the value of the "msgtype" field.
  24409. func (m *MsgMutation) ClearMsgtype() {
  24410. m.msgtype = nil
  24411. m.addmsgtype = nil
  24412. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  24413. }
  24414. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  24415. func (m *MsgMutation) MsgtypeCleared() bool {
  24416. _, ok := m.clearedFields[msg.FieldMsgtype]
  24417. return ok
  24418. }
  24419. // ResetMsgtype resets all changes to the "msgtype" field.
  24420. func (m *MsgMutation) ResetMsgtype() {
  24421. m.msgtype = nil
  24422. m.addmsgtype = nil
  24423. delete(m.clearedFields, msg.FieldMsgtype)
  24424. }
  24425. // SetMsg sets the "msg" field.
  24426. func (m *MsgMutation) SetMsg(s string) {
  24427. m.msg = &s
  24428. }
  24429. // Msg returns the value of the "msg" field in the mutation.
  24430. func (m *MsgMutation) Msg() (r string, exists bool) {
  24431. v := m.msg
  24432. if v == nil {
  24433. return
  24434. }
  24435. return *v, true
  24436. }
  24437. // OldMsg returns the old "msg" field's value of the Msg entity.
  24438. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24440. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  24441. if !m.op.Is(OpUpdateOne) {
  24442. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  24443. }
  24444. if m.id == nil || m.oldValue == nil {
  24445. return v, errors.New("OldMsg requires an ID field in the mutation")
  24446. }
  24447. oldValue, err := m.oldValue(ctx)
  24448. if err != nil {
  24449. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  24450. }
  24451. return oldValue.Msg, nil
  24452. }
  24453. // ClearMsg clears the value of the "msg" field.
  24454. func (m *MsgMutation) ClearMsg() {
  24455. m.msg = nil
  24456. m.clearedFields[msg.FieldMsg] = struct{}{}
  24457. }
  24458. // MsgCleared returns if the "msg" field was cleared in this mutation.
  24459. func (m *MsgMutation) MsgCleared() bool {
  24460. _, ok := m.clearedFields[msg.FieldMsg]
  24461. return ok
  24462. }
  24463. // ResetMsg resets all changes to the "msg" field.
  24464. func (m *MsgMutation) ResetMsg() {
  24465. m.msg = nil
  24466. delete(m.clearedFields, msg.FieldMsg)
  24467. }
  24468. // SetBatchNo sets the "batch_no" field.
  24469. func (m *MsgMutation) SetBatchNo(s string) {
  24470. m.batch_no = &s
  24471. }
  24472. // BatchNo returns the value of the "batch_no" field in the mutation.
  24473. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  24474. v := m.batch_no
  24475. if v == nil {
  24476. return
  24477. }
  24478. return *v, true
  24479. }
  24480. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  24481. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24483. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  24484. if !m.op.Is(OpUpdateOne) {
  24485. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  24486. }
  24487. if m.id == nil || m.oldValue == nil {
  24488. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  24489. }
  24490. oldValue, err := m.oldValue(ctx)
  24491. if err != nil {
  24492. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  24493. }
  24494. return oldValue.BatchNo, nil
  24495. }
  24496. // ClearBatchNo clears the value of the "batch_no" field.
  24497. func (m *MsgMutation) ClearBatchNo() {
  24498. m.batch_no = nil
  24499. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  24500. }
  24501. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  24502. func (m *MsgMutation) BatchNoCleared() bool {
  24503. _, ok := m.clearedFields[msg.FieldBatchNo]
  24504. return ok
  24505. }
  24506. // ResetBatchNo resets all changes to the "batch_no" field.
  24507. func (m *MsgMutation) ResetBatchNo() {
  24508. m.batch_no = nil
  24509. delete(m.clearedFields, msg.FieldBatchNo)
  24510. }
  24511. // SetCc sets the "cc" field.
  24512. func (m *MsgMutation) SetCc(s string) {
  24513. m.cc = &s
  24514. }
  24515. // Cc returns the value of the "cc" field in the mutation.
  24516. func (m *MsgMutation) Cc() (r string, exists bool) {
  24517. v := m.cc
  24518. if v == nil {
  24519. return
  24520. }
  24521. return *v, true
  24522. }
  24523. // OldCc returns the old "cc" field's value of the Msg entity.
  24524. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24526. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  24527. if !m.op.Is(OpUpdateOne) {
  24528. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  24529. }
  24530. if m.id == nil || m.oldValue == nil {
  24531. return v, errors.New("OldCc requires an ID field in the mutation")
  24532. }
  24533. oldValue, err := m.oldValue(ctx)
  24534. if err != nil {
  24535. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  24536. }
  24537. return oldValue.Cc, nil
  24538. }
  24539. // ResetCc resets all changes to the "cc" field.
  24540. func (m *MsgMutation) ResetCc() {
  24541. m.cc = nil
  24542. }
  24543. // SetPhone sets the "phone" field.
  24544. func (m *MsgMutation) SetPhone(s string) {
  24545. m.phone = &s
  24546. }
  24547. // Phone returns the value of the "phone" field in the mutation.
  24548. func (m *MsgMutation) Phone() (r string, exists bool) {
  24549. v := m.phone
  24550. if v == nil {
  24551. return
  24552. }
  24553. return *v, true
  24554. }
  24555. // OldPhone returns the old "phone" field's value of the Msg entity.
  24556. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24558. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  24559. if !m.op.Is(OpUpdateOne) {
  24560. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24561. }
  24562. if m.id == nil || m.oldValue == nil {
  24563. return v, errors.New("OldPhone requires an ID field in the mutation")
  24564. }
  24565. oldValue, err := m.oldValue(ctx)
  24566. if err != nil {
  24567. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  24568. }
  24569. return oldValue.Phone, nil
  24570. }
  24571. // ResetPhone resets all changes to the "phone" field.
  24572. func (m *MsgMutation) ResetPhone() {
  24573. m.phone = nil
  24574. }
  24575. // Where appends a list predicates to the MsgMutation builder.
  24576. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  24577. m.predicates = append(m.predicates, ps...)
  24578. }
  24579. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  24580. // users can use type-assertion to append predicates that do not depend on any generated package.
  24581. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  24582. p := make([]predicate.Msg, len(ps))
  24583. for i := range ps {
  24584. p[i] = ps[i]
  24585. }
  24586. m.Where(p...)
  24587. }
  24588. // Op returns the operation name.
  24589. func (m *MsgMutation) Op() Op {
  24590. return m.op
  24591. }
  24592. // SetOp allows setting the mutation operation.
  24593. func (m *MsgMutation) SetOp(op Op) {
  24594. m.op = op
  24595. }
  24596. // Type returns the node type of this mutation (Msg).
  24597. func (m *MsgMutation) Type() string {
  24598. return m.typ
  24599. }
  24600. // Fields returns all fields that were changed during this mutation. Note that in
  24601. // order to get all numeric fields that were incremented/decremented, call
  24602. // AddedFields().
  24603. func (m *MsgMutation) Fields() []string {
  24604. fields := make([]string, 0, 11)
  24605. if m.created_at != nil {
  24606. fields = append(fields, msg.FieldCreatedAt)
  24607. }
  24608. if m.updated_at != nil {
  24609. fields = append(fields, msg.FieldUpdatedAt)
  24610. }
  24611. if m.deleted_at != nil {
  24612. fields = append(fields, msg.FieldDeletedAt)
  24613. }
  24614. if m.status != nil {
  24615. fields = append(fields, msg.FieldStatus)
  24616. }
  24617. if m.fromwxid != nil {
  24618. fields = append(fields, msg.FieldFromwxid)
  24619. }
  24620. if m.toid != nil {
  24621. fields = append(fields, msg.FieldToid)
  24622. }
  24623. if m.msgtype != nil {
  24624. fields = append(fields, msg.FieldMsgtype)
  24625. }
  24626. if m.msg != nil {
  24627. fields = append(fields, msg.FieldMsg)
  24628. }
  24629. if m.batch_no != nil {
  24630. fields = append(fields, msg.FieldBatchNo)
  24631. }
  24632. if m.cc != nil {
  24633. fields = append(fields, msg.FieldCc)
  24634. }
  24635. if m.phone != nil {
  24636. fields = append(fields, msg.FieldPhone)
  24637. }
  24638. return fields
  24639. }
  24640. // Field returns the value of a field with the given name. The second boolean
  24641. // return value indicates that this field was not set, or was not defined in the
  24642. // schema.
  24643. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  24644. switch name {
  24645. case msg.FieldCreatedAt:
  24646. return m.CreatedAt()
  24647. case msg.FieldUpdatedAt:
  24648. return m.UpdatedAt()
  24649. case msg.FieldDeletedAt:
  24650. return m.DeletedAt()
  24651. case msg.FieldStatus:
  24652. return m.Status()
  24653. case msg.FieldFromwxid:
  24654. return m.Fromwxid()
  24655. case msg.FieldToid:
  24656. return m.Toid()
  24657. case msg.FieldMsgtype:
  24658. return m.Msgtype()
  24659. case msg.FieldMsg:
  24660. return m.Msg()
  24661. case msg.FieldBatchNo:
  24662. return m.BatchNo()
  24663. case msg.FieldCc:
  24664. return m.Cc()
  24665. case msg.FieldPhone:
  24666. return m.Phone()
  24667. }
  24668. return nil, false
  24669. }
  24670. // OldField returns the old value of the field from the database. An error is
  24671. // returned if the mutation operation is not UpdateOne, or the query to the
  24672. // database failed.
  24673. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24674. switch name {
  24675. case msg.FieldCreatedAt:
  24676. return m.OldCreatedAt(ctx)
  24677. case msg.FieldUpdatedAt:
  24678. return m.OldUpdatedAt(ctx)
  24679. case msg.FieldDeletedAt:
  24680. return m.OldDeletedAt(ctx)
  24681. case msg.FieldStatus:
  24682. return m.OldStatus(ctx)
  24683. case msg.FieldFromwxid:
  24684. return m.OldFromwxid(ctx)
  24685. case msg.FieldToid:
  24686. return m.OldToid(ctx)
  24687. case msg.FieldMsgtype:
  24688. return m.OldMsgtype(ctx)
  24689. case msg.FieldMsg:
  24690. return m.OldMsg(ctx)
  24691. case msg.FieldBatchNo:
  24692. return m.OldBatchNo(ctx)
  24693. case msg.FieldCc:
  24694. return m.OldCc(ctx)
  24695. case msg.FieldPhone:
  24696. return m.OldPhone(ctx)
  24697. }
  24698. return nil, fmt.Errorf("unknown Msg field %s", name)
  24699. }
  24700. // SetField sets the value of a field with the given name. It returns an error if
  24701. // the field is not defined in the schema, or if the type mismatched the field
  24702. // type.
  24703. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  24704. switch name {
  24705. case msg.FieldCreatedAt:
  24706. v, ok := value.(time.Time)
  24707. if !ok {
  24708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24709. }
  24710. m.SetCreatedAt(v)
  24711. return nil
  24712. case msg.FieldUpdatedAt:
  24713. v, ok := value.(time.Time)
  24714. if !ok {
  24715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24716. }
  24717. m.SetUpdatedAt(v)
  24718. return nil
  24719. case msg.FieldDeletedAt:
  24720. v, ok := value.(time.Time)
  24721. if !ok {
  24722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24723. }
  24724. m.SetDeletedAt(v)
  24725. return nil
  24726. case msg.FieldStatus:
  24727. v, ok := value.(uint8)
  24728. if !ok {
  24729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24730. }
  24731. m.SetStatus(v)
  24732. return nil
  24733. case msg.FieldFromwxid:
  24734. v, ok := value.(string)
  24735. if !ok {
  24736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24737. }
  24738. m.SetFromwxid(v)
  24739. return nil
  24740. case msg.FieldToid:
  24741. v, ok := value.(string)
  24742. if !ok {
  24743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24744. }
  24745. m.SetToid(v)
  24746. return nil
  24747. case msg.FieldMsgtype:
  24748. v, ok := value.(int32)
  24749. if !ok {
  24750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24751. }
  24752. m.SetMsgtype(v)
  24753. return nil
  24754. case msg.FieldMsg:
  24755. v, ok := value.(string)
  24756. if !ok {
  24757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24758. }
  24759. m.SetMsg(v)
  24760. return nil
  24761. case msg.FieldBatchNo:
  24762. v, ok := value.(string)
  24763. if !ok {
  24764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24765. }
  24766. m.SetBatchNo(v)
  24767. return nil
  24768. case msg.FieldCc:
  24769. v, ok := value.(string)
  24770. if !ok {
  24771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24772. }
  24773. m.SetCc(v)
  24774. return nil
  24775. case msg.FieldPhone:
  24776. v, ok := value.(string)
  24777. if !ok {
  24778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24779. }
  24780. m.SetPhone(v)
  24781. return nil
  24782. }
  24783. return fmt.Errorf("unknown Msg field %s", name)
  24784. }
  24785. // AddedFields returns all numeric fields that were incremented/decremented during
  24786. // this mutation.
  24787. func (m *MsgMutation) AddedFields() []string {
  24788. var fields []string
  24789. if m.addstatus != nil {
  24790. fields = append(fields, msg.FieldStatus)
  24791. }
  24792. if m.addmsgtype != nil {
  24793. fields = append(fields, msg.FieldMsgtype)
  24794. }
  24795. return fields
  24796. }
  24797. // AddedField returns the numeric value that was incremented/decremented on a field
  24798. // with the given name. The second boolean return value indicates that this field
  24799. // was not set, or was not defined in the schema.
  24800. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  24801. switch name {
  24802. case msg.FieldStatus:
  24803. return m.AddedStatus()
  24804. case msg.FieldMsgtype:
  24805. return m.AddedMsgtype()
  24806. }
  24807. return nil, false
  24808. }
  24809. // AddField adds the value to the field with the given name. It returns an error if
  24810. // the field is not defined in the schema, or if the type mismatched the field
  24811. // type.
  24812. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  24813. switch name {
  24814. case msg.FieldStatus:
  24815. v, ok := value.(int8)
  24816. if !ok {
  24817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24818. }
  24819. m.AddStatus(v)
  24820. return nil
  24821. case msg.FieldMsgtype:
  24822. v, ok := value.(int32)
  24823. if !ok {
  24824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24825. }
  24826. m.AddMsgtype(v)
  24827. return nil
  24828. }
  24829. return fmt.Errorf("unknown Msg numeric field %s", name)
  24830. }
  24831. // ClearedFields returns all nullable fields that were cleared during this
  24832. // mutation.
  24833. func (m *MsgMutation) ClearedFields() []string {
  24834. var fields []string
  24835. if m.FieldCleared(msg.FieldDeletedAt) {
  24836. fields = append(fields, msg.FieldDeletedAt)
  24837. }
  24838. if m.FieldCleared(msg.FieldStatus) {
  24839. fields = append(fields, msg.FieldStatus)
  24840. }
  24841. if m.FieldCleared(msg.FieldFromwxid) {
  24842. fields = append(fields, msg.FieldFromwxid)
  24843. }
  24844. if m.FieldCleared(msg.FieldToid) {
  24845. fields = append(fields, msg.FieldToid)
  24846. }
  24847. if m.FieldCleared(msg.FieldMsgtype) {
  24848. fields = append(fields, msg.FieldMsgtype)
  24849. }
  24850. if m.FieldCleared(msg.FieldMsg) {
  24851. fields = append(fields, msg.FieldMsg)
  24852. }
  24853. if m.FieldCleared(msg.FieldBatchNo) {
  24854. fields = append(fields, msg.FieldBatchNo)
  24855. }
  24856. return fields
  24857. }
  24858. // FieldCleared returns a boolean indicating if a field with the given name was
  24859. // cleared in this mutation.
  24860. func (m *MsgMutation) FieldCleared(name string) bool {
  24861. _, ok := m.clearedFields[name]
  24862. return ok
  24863. }
  24864. // ClearField clears the value of the field with the given name. It returns an
  24865. // error if the field is not defined in the schema.
  24866. func (m *MsgMutation) ClearField(name string) error {
  24867. switch name {
  24868. case msg.FieldDeletedAt:
  24869. m.ClearDeletedAt()
  24870. return nil
  24871. case msg.FieldStatus:
  24872. m.ClearStatus()
  24873. return nil
  24874. case msg.FieldFromwxid:
  24875. m.ClearFromwxid()
  24876. return nil
  24877. case msg.FieldToid:
  24878. m.ClearToid()
  24879. return nil
  24880. case msg.FieldMsgtype:
  24881. m.ClearMsgtype()
  24882. return nil
  24883. case msg.FieldMsg:
  24884. m.ClearMsg()
  24885. return nil
  24886. case msg.FieldBatchNo:
  24887. m.ClearBatchNo()
  24888. return nil
  24889. }
  24890. return fmt.Errorf("unknown Msg nullable field %s", name)
  24891. }
  24892. // ResetField resets all changes in the mutation for the field with the given name.
  24893. // It returns an error if the field is not defined in the schema.
  24894. func (m *MsgMutation) ResetField(name string) error {
  24895. switch name {
  24896. case msg.FieldCreatedAt:
  24897. m.ResetCreatedAt()
  24898. return nil
  24899. case msg.FieldUpdatedAt:
  24900. m.ResetUpdatedAt()
  24901. return nil
  24902. case msg.FieldDeletedAt:
  24903. m.ResetDeletedAt()
  24904. return nil
  24905. case msg.FieldStatus:
  24906. m.ResetStatus()
  24907. return nil
  24908. case msg.FieldFromwxid:
  24909. m.ResetFromwxid()
  24910. return nil
  24911. case msg.FieldToid:
  24912. m.ResetToid()
  24913. return nil
  24914. case msg.FieldMsgtype:
  24915. m.ResetMsgtype()
  24916. return nil
  24917. case msg.FieldMsg:
  24918. m.ResetMsg()
  24919. return nil
  24920. case msg.FieldBatchNo:
  24921. m.ResetBatchNo()
  24922. return nil
  24923. case msg.FieldCc:
  24924. m.ResetCc()
  24925. return nil
  24926. case msg.FieldPhone:
  24927. m.ResetPhone()
  24928. return nil
  24929. }
  24930. return fmt.Errorf("unknown Msg field %s", name)
  24931. }
  24932. // AddedEdges returns all edge names that were set/added in this mutation.
  24933. func (m *MsgMutation) AddedEdges() []string {
  24934. edges := make([]string, 0, 0)
  24935. return edges
  24936. }
  24937. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24938. // name in this mutation.
  24939. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  24940. return nil
  24941. }
  24942. // RemovedEdges returns all edge names that were removed in this mutation.
  24943. func (m *MsgMutation) RemovedEdges() []string {
  24944. edges := make([]string, 0, 0)
  24945. return edges
  24946. }
  24947. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24948. // the given name in this mutation.
  24949. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  24950. return nil
  24951. }
  24952. // ClearedEdges returns all edge names that were cleared in this mutation.
  24953. func (m *MsgMutation) ClearedEdges() []string {
  24954. edges := make([]string, 0, 0)
  24955. return edges
  24956. }
  24957. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24958. // was cleared in this mutation.
  24959. func (m *MsgMutation) EdgeCleared(name string) bool {
  24960. return false
  24961. }
  24962. // ClearEdge clears the value of the edge with the given name. It returns an error
  24963. // if that edge is not defined in the schema.
  24964. func (m *MsgMutation) ClearEdge(name string) error {
  24965. return fmt.Errorf("unknown Msg unique edge %s", name)
  24966. }
  24967. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24968. // It returns an error if the edge is not defined in the schema.
  24969. func (m *MsgMutation) ResetEdge(name string) error {
  24970. return fmt.Errorf("unknown Msg edge %s", name)
  24971. }
  24972. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  24973. type PayRechargeMutation struct {
  24974. config
  24975. op Op
  24976. typ string
  24977. id *uint64
  24978. created_at *time.Time
  24979. updated_at *time.Time
  24980. deleted_at *time.Time
  24981. user_id *string
  24982. number *float32
  24983. addnumber *float32
  24984. status *int
  24985. addstatus *int
  24986. money *float32
  24987. addmoney *float32
  24988. out_trade_no *string
  24989. organization_id *uint64
  24990. addorganization_id *int64
  24991. clearedFields map[string]struct{}
  24992. done bool
  24993. oldValue func(context.Context) (*PayRecharge, error)
  24994. predicates []predicate.PayRecharge
  24995. }
  24996. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  24997. // payrechargeOption allows management of the mutation configuration using functional options.
  24998. type payrechargeOption func(*PayRechargeMutation)
  24999. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  25000. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  25001. m := &PayRechargeMutation{
  25002. config: c,
  25003. op: op,
  25004. typ: TypePayRecharge,
  25005. clearedFields: make(map[string]struct{}),
  25006. }
  25007. for _, opt := range opts {
  25008. opt(m)
  25009. }
  25010. return m
  25011. }
  25012. // withPayRechargeID sets the ID field of the mutation.
  25013. func withPayRechargeID(id uint64) payrechargeOption {
  25014. return func(m *PayRechargeMutation) {
  25015. var (
  25016. err error
  25017. once sync.Once
  25018. value *PayRecharge
  25019. )
  25020. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  25021. once.Do(func() {
  25022. if m.done {
  25023. err = errors.New("querying old values post mutation is not allowed")
  25024. } else {
  25025. value, err = m.Client().PayRecharge.Get(ctx, id)
  25026. }
  25027. })
  25028. return value, err
  25029. }
  25030. m.id = &id
  25031. }
  25032. }
  25033. // withPayRecharge sets the old PayRecharge of the mutation.
  25034. func withPayRecharge(node *PayRecharge) payrechargeOption {
  25035. return func(m *PayRechargeMutation) {
  25036. m.oldValue = func(context.Context) (*PayRecharge, error) {
  25037. return node, nil
  25038. }
  25039. m.id = &node.ID
  25040. }
  25041. }
  25042. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25043. // executed in a transaction (ent.Tx), a transactional client is returned.
  25044. func (m PayRechargeMutation) Client() *Client {
  25045. client := &Client{config: m.config}
  25046. client.init()
  25047. return client
  25048. }
  25049. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25050. // it returns an error otherwise.
  25051. func (m PayRechargeMutation) Tx() (*Tx, error) {
  25052. if _, ok := m.driver.(*txDriver); !ok {
  25053. return nil, errors.New("ent: mutation is not running in a transaction")
  25054. }
  25055. tx := &Tx{config: m.config}
  25056. tx.init()
  25057. return tx, nil
  25058. }
  25059. // SetID sets the value of the id field. Note that this
  25060. // operation is only accepted on creation of PayRecharge entities.
  25061. func (m *PayRechargeMutation) SetID(id uint64) {
  25062. m.id = &id
  25063. }
  25064. // ID returns the ID value in the mutation. Note that the ID is only available
  25065. // if it was provided to the builder or after it was returned from the database.
  25066. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  25067. if m.id == nil {
  25068. return
  25069. }
  25070. return *m.id, true
  25071. }
  25072. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25073. // That means, if the mutation is applied within a transaction with an isolation level such
  25074. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25075. // or updated by the mutation.
  25076. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  25077. switch {
  25078. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25079. id, exists := m.ID()
  25080. if exists {
  25081. return []uint64{id}, nil
  25082. }
  25083. fallthrough
  25084. case m.op.Is(OpUpdate | OpDelete):
  25085. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  25086. default:
  25087. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25088. }
  25089. }
  25090. // SetCreatedAt sets the "created_at" field.
  25091. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  25092. m.created_at = &t
  25093. }
  25094. // CreatedAt returns the value of the "created_at" field in the mutation.
  25095. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  25096. v := m.created_at
  25097. if v == nil {
  25098. return
  25099. }
  25100. return *v, true
  25101. }
  25102. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  25103. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25105. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25106. if !m.op.Is(OpUpdateOne) {
  25107. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25108. }
  25109. if m.id == nil || m.oldValue == nil {
  25110. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25111. }
  25112. oldValue, err := m.oldValue(ctx)
  25113. if err != nil {
  25114. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25115. }
  25116. return oldValue.CreatedAt, nil
  25117. }
  25118. // ResetCreatedAt resets all changes to the "created_at" field.
  25119. func (m *PayRechargeMutation) ResetCreatedAt() {
  25120. m.created_at = nil
  25121. }
  25122. // SetUpdatedAt sets the "updated_at" field.
  25123. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  25124. m.updated_at = &t
  25125. }
  25126. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25127. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  25128. v := m.updated_at
  25129. if v == nil {
  25130. return
  25131. }
  25132. return *v, true
  25133. }
  25134. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  25135. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25137. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25138. if !m.op.Is(OpUpdateOne) {
  25139. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25140. }
  25141. if m.id == nil || m.oldValue == nil {
  25142. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25143. }
  25144. oldValue, err := m.oldValue(ctx)
  25145. if err != nil {
  25146. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25147. }
  25148. return oldValue.UpdatedAt, nil
  25149. }
  25150. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25151. func (m *PayRechargeMutation) ResetUpdatedAt() {
  25152. m.updated_at = nil
  25153. }
  25154. // SetDeletedAt sets the "deleted_at" field.
  25155. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  25156. m.deleted_at = &t
  25157. }
  25158. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25159. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  25160. v := m.deleted_at
  25161. if v == nil {
  25162. return
  25163. }
  25164. return *v, true
  25165. }
  25166. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  25167. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25169. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25170. if !m.op.Is(OpUpdateOne) {
  25171. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25172. }
  25173. if m.id == nil || m.oldValue == nil {
  25174. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25175. }
  25176. oldValue, err := m.oldValue(ctx)
  25177. if err != nil {
  25178. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25179. }
  25180. return oldValue.DeletedAt, nil
  25181. }
  25182. // ClearDeletedAt clears the value of the "deleted_at" field.
  25183. func (m *PayRechargeMutation) ClearDeletedAt() {
  25184. m.deleted_at = nil
  25185. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  25186. }
  25187. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25188. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  25189. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  25190. return ok
  25191. }
  25192. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25193. func (m *PayRechargeMutation) ResetDeletedAt() {
  25194. m.deleted_at = nil
  25195. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  25196. }
  25197. // SetUserID sets the "user_id" field.
  25198. func (m *PayRechargeMutation) SetUserID(s string) {
  25199. m.user_id = &s
  25200. }
  25201. // UserID returns the value of the "user_id" field in the mutation.
  25202. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  25203. v := m.user_id
  25204. if v == nil {
  25205. return
  25206. }
  25207. return *v, true
  25208. }
  25209. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  25210. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25212. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  25213. if !m.op.Is(OpUpdateOne) {
  25214. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25215. }
  25216. if m.id == nil || m.oldValue == nil {
  25217. return v, errors.New("OldUserID requires an ID field in the mutation")
  25218. }
  25219. oldValue, err := m.oldValue(ctx)
  25220. if err != nil {
  25221. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25222. }
  25223. return oldValue.UserID, nil
  25224. }
  25225. // ResetUserID resets all changes to the "user_id" field.
  25226. func (m *PayRechargeMutation) ResetUserID() {
  25227. m.user_id = nil
  25228. }
  25229. // SetNumber sets the "number" field.
  25230. func (m *PayRechargeMutation) SetNumber(f float32) {
  25231. m.number = &f
  25232. m.addnumber = nil
  25233. }
  25234. // Number returns the value of the "number" field in the mutation.
  25235. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  25236. v := m.number
  25237. if v == nil {
  25238. return
  25239. }
  25240. return *v, true
  25241. }
  25242. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  25243. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25245. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  25246. if !m.op.Is(OpUpdateOne) {
  25247. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  25248. }
  25249. if m.id == nil || m.oldValue == nil {
  25250. return v, errors.New("OldNumber requires an ID field in the mutation")
  25251. }
  25252. oldValue, err := m.oldValue(ctx)
  25253. if err != nil {
  25254. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  25255. }
  25256. return oldValue.Number, nil
  25257. }
  25258. // AddNumber adds f to the "number" field.
  25259. func (m *PayRechargeMutation) AddNumber(f float32) {
  25260. if m.addnumber != nil {
  25261. *m.addnumber += f
  25262. } else {
  25263. m.addnumber = &f
  25264. }
  25265. }
  25266. // AddedNumber returns the value that was added to the "number" field in this mutation.
  25267. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  25268. v := m.addnumber
  25269. if v == nil {
  25270. return
  25271. }
  25272. return *v, true
  25273. }
  25274. // ResetNumber resets all changes to the "number" field.
  25275. func (m *PayRechargeMutation) ResetNumber() {
  25276. m.number = nil
  25277. m.addnumber = nil
  25278. }
  25279. // SetStatus sets the "status" field.
  25280. func (m *PayRechargeMutation) SetStatus(i int) {
  25281. m.status = &i
  25282. m.addstatus = nil
  25283. }
  25284. // Status returns the value of the "status" field in the mutation.
  25285. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  25286. v := m.status
  25287. if v == nil {
  25288. return
  25289. }
  25290. return *v, true
  25291. }
  25292. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  25293. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25295. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  25296. if !m.op.Is(OpUpdateOne) {
  25297. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25298. }
  25299. if m.id == nil || m.oldValue == nil {
  25300. return v, errors.New("OldStatus requires an ID field in the mutation")
  25301. }
  25302. oldValue, err := m.oldValue(ctx)
  25303. if err != nil {
  25304. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25305. }
  25306. return oldValue.Status, nil
  25307. }
  25308. // AddStatus adds i to the "status" field.
  25309. func (m *PayRechargeMutation) AddStatus(i int) {
  25310. if m.addstatus != nil {
  25311. *m.addstatus += i
  25312. } else {
  25313. m.addstatus = &i
  25314. }
  25315. }
  25316. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25317. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  25318. v := m.addstatus
  25319. if v == nil {
  25320. return
  25321. }
  25322. return *v, true
  25323. }
  25324. // ClearStatus clears the value of the "status" field.
  25325. func (m *PayRechargeMutation) ClearStatus() {
  25326. m.status = nil
  25327. m.addstatus = nil
  25328. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  25329. }
  25330. // StatusCleared returns if the "status" field was cleared in this mutation.
  25331. func (m *PayRechargeMutation) StatusCleared() bool {
  25332. _, ok := m.clearedFields[payrecharge.FieldStatus]
  25333. return ok
  25334. }
  25335. // ResetStatus resets all changes to the "status" field.
  25336. func (m *PayRechargeMutation) ResetStatus() {
  25337. m.status = nil
  25338. m.addstatus = nil
  25339. delete(m.clearedFields, payrecharge.FieldStatus)
  25340. }
  25341. // SetMoney sets the "money" field.
  25342. func (m *PayRechargeMutation) SetMoney(f float32) {
  25343. m.money = &f
  25344. m.addmoney = nil
  25345. }
  25346. // Money returns the value of the "money" field in the mutation.
  25347. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  25348. v := m.money
  25349. if v == nil {
  25350. return
  25351. }
  25352. return *v, true
  25353. }
  25354. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  25355. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25357. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  25358. if !m.op.Is(OpUpdateOne) {
  25359. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  25360. }
  25361. if m.id == nil || m.oldValue == nil {
  25362. return v, errors.New("OldMoney requires an ID field in the mutation")
  25363. }
  25364. oldValue, err := m.oldValue(ctx)
  25365. if err != nil {
  25366. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  25367. }
  25368. return oldValue.Money, nil
  25369. }
  25370. // AddMoney adds f to the "money" field.
  25371. func (m *PayRechargeMutation) AddMoney(f float32) {
  25372. if m.addmoney != nil {
  25373. *m.addmoney += f
  25374. } else {
  25375. m.addmoney = &f
  25376. }
  25377. }
  25378. // AddedMoney returns the value that was added to the "money" field in this mutation.
  25379. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  25380. v := m.addmoney
  25381. if v == nil {
  25382. return
  25383. }
  25384. return *v, true
  25385. }
  25386. // ClearMoney clears the value of the "money" field.
  25387. func (m *PayRechargeMutation) ClearMoney() {
  25388. m.money = nil
  25389. m.addmoney = nil
  25390. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  25391. }
  25392. // MoneyCleared returns if the "money" field was cleared in this mutation.
  25393. func (m *PayRechargeMutation) MoneyCleared() bool {
  25394. _, ok := m.clearedFields[payrecharge.FieldMoney]
  25395. return ok
  25396. }
  25397. // ResetMoney resets all changes to the "money" field.
  25398. func (m *PayRechargeMutation) ResetMoney() {
  25399. m.money = nil
  25400. m.addmoney = nil
  25401. delete(m.clearedFields, payrecharge.FieldMoney)
  25402. }
  25403. // SetOutTradeNo sets the "out_trade_no" field.
  25404. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  25405. m.out_trade_no = &s
  25406. }
  25407. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  25408. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  25409. v := m.out_trade_no
  25410. if v == nil {
  25411. return
  25412. }
  25413. return *v, true
  25414. }
  25415. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  25416. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25418. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  25419. if !m.op.Is(OpUpdateOne) {
  25420. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  25421. }
  25422. if m.id == nil || m.oldValue == nil {
  25423. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  25424. }
  25425. oldValue, err := m.oldValue(ctx)
  25426. if err != nil {
  25427. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  25428. }
  25429. return oldValue.OutTradeNo, nil
  25430. }
  25431. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  25432. func (m *PayRechargeMutation) ClearOutTradeNo() {
  25433. m.out_trade_no = nil
  25434. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  25435. }
  25436. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  25437. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  25438. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  25439. return ok
  25440. }
  25441. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  25442. func (m *PayRechargeMutation) ResetOutTradeNo() {
  25443. m.out_trade_no = nil
  25444. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  25445. }
  25446. // SetOrganizationID sets the "organization_id" field.
  25447. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  25448. m.organization_id = &u
  25449. m.addorganization_id = nil
  25450. }
  25451. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25452. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  25453. v := m.organization_id
  25454. if v == nil {
  25455. return
  25456. }
  25457. return *v, true
  25458. }
  25459. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  25460. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25462. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25463. if !m.op.Is(OpUpdateOne) {
  25464. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25465. }
  25466. if m.id == nil || m.oldValue == nil {
  25467. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25468. }
  25469. oldValue, err := m.oldValue(ctx)
  25470. if err != nil {
  25471. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25472. }
  25473. return oldValue.OrganizationID, nil
  25474. }
  25475. // AddOrganizationID adds u to the "organization_id" field.
  25476. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  25477. if m.addorganization_id != nil {
  25478. *m.addorganization_id += u
  25479. } else {
  25480. m.addorganization_id = &u
  25481. }
  25482. }
  25483. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25484. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  25485. v := m.addorganization_id
  25486. if v == nil {
  25487. return
  25488. }
  25489. return *v, true
  25490. }
  25491. // ResetOrganizationID resets all changes to the "organization_id" field.
  25492. func (m *PayRechargeMutation) ResetOrganizationID() {
  25493. m.organization_id = nil
  25494. m.addorganization_id = nil
  25495. }
  25496. // Where appends a list predicates to the PayRechargeMutation builder.
  25497. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  25498. m.predicates = append(m.predicates, ps...)
  25499. }
  25500. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  25501. // users can use type-assertion to append predicates that do not depend on any generated package.
  25502. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  25503. p := make([]predicate.PayRecharge, len(ps))
  25504. for i := range ps {
  25505. p[i] = ps[i]
  25506. }
  25507. m.Where(p...)
  25508. }
  25509. // Op returns the operation name.
  25510. func (m *PayRechargeMutation) Op() Op {
  25511. return m.op
  25512. }
  25513. // SetOp allows setting the mutation operation.
  25514. func (m *PayRechargeMutation) SetOp(op Op) {
  25515. m.op = op
  25516. }
  25517. // Type returns the node type of this mutation (PayRecharge).
  25518. func (m *PayRechargeMutation) Type() string {
  25519. return m.typ
  25520. }
  25521. // Fields returns all fields that were changed during this mutation. Note that in
  25522. // order to get all numeric fields that were incremented/decremented, call
  25523. // AddedFields().
  25524. func (m *PayRechargeMutation) Fields() []string {
  25525. fields := make([]string, 0, 9)
  25526. if m.created_at != nil {
  25527. fields = append(fields, payrecharge.FieldCreatedAt)
  25528. }
  25529. if m.updated_at != nil {
  25530. fields = append(fields, payrecharge.FieldUpdatedAt)
  25531. }
  25532. if m.deleted_at != nil {
  25533. fields = append(fields, payrecharge.FieldDeletedAt)
  25534. }
  25535. if m.user_id != nil {
  25536. fields = append(fields, payrecharge.FieldUserID)
  25537. }
  25538. if m.number != nil {
  25539. fields = append(fields, payrecharge.FieldNumber)
  25540. }
  25541. if m.status != nil {
  25542. fields = append(fields, payrecharge.FieldStatus)
  25543. }
  25544. if m.money != nil {
  25545. fields = append(fields, payrecharge.FieldMoney)
  25546. }
  25547. if m.out_trade_no != nil {
  25548. fields = append(fields, payrecharge.FieldOutTradeNo)
  25549. }
  25550. if m.organization_id != nil {
  25551. fields = append(fields, payrecharge.FieldOrganizationID)
  25552. }
  25553. return fields
  25554. }
  25555. // Field returns the value of a field with the given name. The second boolean
  25556. // return value indicates that this field was not set, or was not defined in the
  25557. // schema.
  25558. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  25559. switch name {
  25560. case payrecharge.FieldCreatedAt:
  25561. return m.CreatedAt()
  25562. case payrecharge.FieldUpdatedAt:
  25563. return m.UpdatedAt()
  25564. case payrecharge.FieldDeletedAt:
  25565. return m.DeletedAt()
  25566. case payrecharge.FieldUserID:
  25567. return m.UserID()
  25568. case payrecharge.FieldNumber:
  25569. return m.Number()
  25570. case payrecharge.FieldStatus:
  25571. return m.Status()
  25572. case payrecharge.FieldMoney:
  25573. return m.Money()
  25574. case payrecharge.FieldOutTradeNo:
  25575. return m.OutTradeNo()
  25576. case payrecharge.FieldOrganizationID:
  25577. return m.OrganizationID()
  25578. }
  25579. return nil, false
  25580. }
  25581. // OldField returns the old value of the field from the database. An error is
  25582. // returned if the mutation operation is not UpdateOne, or the query to the
  25583. // database failed.
  25584. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25585. switch name {
  25586. case payrecharge.FieldCreatedAt:
  25587. return m.OldCreatedAt(ctx)
  25588. case payrecharge.FieldUpdatedAt:
  25589. return m.OldUpdatedAt(ctx)
  25590. case payrecharge.FieldDeletedAt:
  25591. return m.OldDeletedAt(ctx)
  25592. case payrecharge.FieldUserID:
  25593. return m.OldUserID(ctx)
  25594. case payrecharge.FieldNumber:
  25595. return m.OldNumber(ctx)
  25596. case payrecharge.FieldStatus:
  25597. return m.OldStatus(ctx)
  25598. case payrecharge.FieldMoney:
  25599. return m.OldMoney(ctx)
  25600. case payrecharge.FieldOutTradeNo:
  25601. return m.OldOutTradeNo(ctx)
  25602. case payrecharge.FieldOrganizationID:
  25603. return m.OldOrganizationID(ctx)
  25604. }
  25605. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  25606. }
  25607. // SetField sets the value of a field with the given name. It returns an error if
  25608. // the field is not defined in the schema, or if the type mismatched the field
  25609. // type.
  25610. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  25611. switch name {
  25612. case payrecharge.FieldCreatedAt:
  25613. v, ok := value.(time.Time)
  25614. if !ok {
  25615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25616. }
  25617. m.SetCreatedAt(v)
  25618. return nil
  25619. case payrecharge.FieldUpdatedAt:
  25620. v, ok := value.(time.Time)
  25621. if !ok {
  25622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25623. }
  25624. m.SetUpdatedAt(v)
  25625. return nil
  25626. case payrecharge.FieldDeletedAt:
  25627. v, ok := value.(time.Time)
  25628. if !ok {
  25629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25630. }
  25631. m.SetDeletedAt(v)
  25632. return nil
  25633. case payrecharge.FieldUserID:
  25634. v, ok := value.(string)
  25635. if !ok {
  25636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25637. }
  25638. m.SetUserID(v)
  25639. return nil
  25640. case payrecharge.FieldNumber:
  25641. v, ok := value.(float32)
  25642. if !ok {
  25643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25644. }
  25645. m.SetNumber(v)
  25646. return nil
  25647. case payrecharge.FieldStatus:
  25648. v, ok := value.(int)
  25649. if !ok {
  25650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25651. }
  25652. m.SetStatus(v)
  25653. return nil
  25654. case payrecharge.FieldMoney:
  25655. v, ok := value.(float32)
  25656. if !ok {
  25657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25658. }
  25659. m.SetMoney(v)
  25660. return nil
  25661. case payrecharge.FieldOutTradeNo:
  25662. v, ok := value.(string)
  25663. if !ok {
  25664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25665. }
  25666. m.SetOutTradeNo(v)
  25667. return nil
  25668. case payrecharge.FieldOrganizationID:
  25669. v, ok := value.(uint64)
  25670. if !ok {
  25671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25672. }
  25673. m.SetOrganizationID(v)
  25674. return nil
  25675. }
  25676. return fmt.Errorf("unknown PayRecharge field %s", name)
  25677. }
  25678. // AddedFields returns all numeric fields that were incremented/decremented during
  25679. // this mutation.
  25680. func (m *PayRechargeMutation) AddedFields() []string {
  25681. var fields []string
  25682. if m.addnumber != nil {
  25683. fields = append(fields, payrecharge.FieldNumber)
  25684. }
  25685. if m.addstatus != nil {
  25686. fields = append(fields, payrecharge.FieldStatus)
  25687. }
  25688. if m.addmoney != nil {
  25689. fields = append(fields, payrecharge.FieldMoney)
  25690. }
  25691. if m.addorganization_id != nil {
  25692. fields = append(fields, payrecharge.FieldOrganizationID)
  25693. }
  25694. return fields
  25695. }
  25696. // AddedField returns the numeric value that was incremented/decremented on a field
  25697. // with the given name. The second boolean return value indicates that this field
  25698. // was not set, or was not defined in the schema.
  25699. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  25700. switch name {
  25701. case payrecharge.FieldNumber:
  25702. return m.AddedNumber()
  25703. case payrecharge.FieldStatus:
  25704. return m.AddedStatus()
  25705. case payrecharge.FieldMoney:
  25706. return m.AddedMoney()
  25707. case payrecharge.FieldOrganizationID:
  25708. return m.AddedOrganizationID()
  25709. }
  25710. return nil, false
  25711. }
  25712. // AddField adds the value to the field with the given name. It returns an error if
  25713. // the field is not defined in the schema, or if the type mismatched the field
  25714. // type.
  25715. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  25716. switch name {
  25717. case payrecharge.FieldNumber:
  25718. v, ok := value.(float32)
  25719. if !ok {
  25720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25721. }
  25722. m.AddNumber(v)
  25723. return nil
  25724. case payrecharge.FieldStatus:
  25725. v, ok := value.(int)
  25726. if !ok {
  25727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25728. }
  25729. m.AddStatus(v)
  25730. return nil
  25731. case payrecharge.FieldMoney:
  25732. v, ok := value.(float32)
  25733. if !ok {
  25734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25735. }
  25736. m.AddMoney(v)
  25737. return nil
  25738. case payrecharge.FieldOrganizationID:
  25739. v, ok := value.(int64)
  25740. if !ok {
  25741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25742. }
  25743. m.AddOrganizationID(v)
  25744. return nil
  25745. }
  25746. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  25747. }
  25748. // ClearedFields returns all nullable fields that were cleared during this
  25749. // mutation.
  25750. func (m *PayRechargeMutation) ClearedFields() []string {
  25751. var fields []string
  25752. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  25753. fields = append(fields, payrecharge.FieldDeletedAt)
  25754. }
  25755. if m.FieldCleared(payrecharge.FieldStatus) {
  25756. fields = append(fields, payrecharge.FieldStatus)
  25757. }
  25758. if m.FieldCleared(payrecharge.FieldMoney) {
  25759. fields = append(fields, payrecharge.FieldMoney)
  25760. }
  25761. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  25762. fields = append(fields, payrecharge.FieldOutTradeNo)
  25763. }
  25764. return fields
  25765. }
  25766. // FieldCleared returns a boolean indicating if a field with the given name was
  25767. // cleared in this mutation.
  25768. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  25769. _, ok := m.clearedFields[name]
  25770. return ok
  25771. }
  25772. // ClearField clears the value of the field with the given name. It returns an
  25773. // error if the field is not defined in the schema.
  25774. func (m *PayRechargeMutation) ClearField(name string) error {
  25775. switch name {
  25776. case payrecharge.FieldDeletedAt:
  25777. m.ClearDeletedAt()
  25778. return nil
  25779. case payrecharge.FieldStatus:
  25780. m.ClearStatus()
  25781. return nil
  25782. case payrecharge.FieldMoney:
  25783. m.ClearMoney()
  25784. return nil
  25785. case payrecharge.FieldOutTradeNo:
  25786. m.ClearOutTradeNo()
  25787. return nil
  25788. }
  25789. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  25790. }
  25791. // ResetField resets all changes in the mutation for the field with the given name.
  25792. // It returns an error if the field is not defined in the schema.
  25793. func (m *PayRechargeMutation) ResetField(name string) error {
  25794. switch name {
  25795. case payrecharge.FieldCreatedAt:
  25796. m.ResetCreatedAt()
  25797. return nil
  25798. case payrecharge.FieldUpdatedAt:
  25799. m.ResetUpdatedAt()
  25800. return nil
  25801. case payrecharge.FieldDeletedAt:
  25802. m.ResetDeletedAt()
  25803. return nil
  25804. case payrecharge.FieldUserID:
  25805. m.ResetUserID()
  25806. return nil
  25807. case payrecharge.FieldNumber:
  25808. m.ResetNumber()
  25809. return nil
  25810. case payrecharge.FieldStatus:
  25811. m.ResetStatus()
  25812. return nil
  25813. case payrecharge.FieldMoney:
  25814. m.ResetMoney()
  25815. return nil
  25816. case payrecharge.FieldOutTradeNo:
  25817. m.ResetOutTradeNo()
  25818. return nil
  25819. case payrecharge.FieldOrganizationID:
  25820. m.ResetOrganizationID()
  25821. return nil
  25822. }
  25823. return fmt.Errorf("unknown PayRecharge field %s", name)
  25824. }
  25825. // AddedEdges returns all edge names that were set/added in this mutation.
  25826. func (m *PayRechargeMutation) AddedEdges() []string {
  25827. edges := make([]string, 0, 0)
  25828. return edges
  25829. }
  25830. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25831. // name in this mutation.
  25832. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  25833. return nil
  25834. }
  25835. // RemovedEdges returns all edge names that were removed in this mutation.
  25836. func (m *PayRechargeMutation) RemovedEdges() []string {
  25837. edges := make([]string, 0, 0)
  25838. return edges
  25839. }
  25840. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25841. // the given name in this mutation.
  25842. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  25843. return nil
  25844. }
  25845. // ClearedEdges returns all edge names that were cleared in this mutation.
  25846. func (m *PayRechargeMutation) ClearedEdges() []string {
  25847. edges := make([]string, 0, 0)
  25848. return edges
  25849. }
  25850. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25851. // was cleared in this mutation.
  25852. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  25853. return false
  25854. }
  25855. // ClearEdge clears the value of the edge with the given name. It returns an error
  25856. // if that edge is not defined in the schema.
  25857. func (m *PayRechargeMutation) ClearEdge(name string) error {
  25858. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  25859. }
  25860. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25861. // It returns an error if the edge is not defined in the schema.
  25862. func (m *PayRechargeMutation) ResetEdge(name string) error {
  25863. return fmt.Errorf("unknown PayRecharge edge %s", name)
  25864. }
  25865. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  25866. type ServerMutation struct {
  25867. config
  25868. op Op
  25869. typ string
  25870. id *uint64
  25871. created_at *time.Time
  25872. updated_at *time.Time
  25873. status *uint8
  25874. addstatus *int8
  25875. deleted_at *time.Time
  25876. name *string
  25877. public_ip *string
  25878. private_ip *string
  25879. admin_port *string
  25880. clearedFields map[string]struct{}
  25881. wxs map[uint64]struct{}
  25882. removedwxs map[uint64]struct{}
  25883. clearedwxs bool
  25884. done bool
  25885. oldValue func(context.Context) (*Server, error)
  25886. predicates []predicate.Server
  25887. }
  25888. var _ ent.Mutation = (*ServerMutation)(nil)
  25889. // serverOption allows management of the mutation configuration using functional options.
  25890. type serverOption func(*ServerMutation)
  25891. // newServerMutation creates new mutation for the Server entity.
  25892. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  25893. m := &ServerMutation{
  25894. config: c,
  25895. op: op,
  25896. typ: TypeServer,
  25897. clearedFields: make(map[string]struct{}),
  25898. }
  25899. for _, opt := range opts {
  25900. opt(m)
  25901. }
  25902. return m
  25903. }
  25904. // withServerID sets the ID field of the mutation.
  25905. func withServerID(id uint64) serverOption {
  25906. return func(m *ServerMutation) {
  25907. var (
  25908. err error
  25909. once sync.Once
  25910. value *Server
  25911. )
  25912. m.oldValue = func(ctx context.Context) (*Server, error) {
  25913. once.Do(func() {
  25914. if m.done {
  25915. err = errors.New("querying old values post mutation is not allowed")
  25916. } else {
  25917. value, err = m.Client().Server.Get(ctx, id)
  25918. }
  25919. })
  25920. return value, err
  25921. }
  25922. m.id = &id
  25923. }
  25924. }
  25925. // withServer sets the old Server of the mutation.
  25926. func withServer(node *Server) serverOption {
  25927. return func(m *ServerMutation) {
  25928. m.oldValue = func(context.Context) (*Server, error) {
  25929. return node, nil
  25930. }
  25931. m.id = &node.ID
  25932. }
  25933. }
  25934. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25935. // executed in a transaction (ent.Tx), a transactional client is returned.
  25936. func (m ServerMutation) Client() *Client {
  25937. client := &Client{config: m.config}
  25938. client.init()
  25939. return client
  25940. }
  25941. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25942. // it returns an error otherwise.
  25943. func (m ServerMutation) Tx() (*Tx, error) {
  25944. if _, ok := m.driver.(*txDriver); !ok {
  25945. return nil, errors.New("ent: mutation is not running in a transaction")
  25946. }
  25947. tx := &Tx{config: m.config}
  25948. tx.init()
  25949. return tx, nil
  25950. }
  25951. // SetID sets the value of the id field. Note that this
  25952. // operation is only accepted on creation of Server entities.
  25953. func (m *ServerMutation) SetID(id uint64) {
  25954. m.id = &id
  25955. }
  25956. // ID returns the ID value in the mutation. Note that the ID is only available
  25957. // if it was provided to the builder or after it was returned from the database.
  25958. func (m *ServerMutation) ID() (id uint64, exists bool) {
  25959. if m.id == nil {
  25960. return
  25961. }
  25962. return *m.id, true
  25963. }
  25964. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25965. // That means, if the mutation is applied within a transaction with an isolation level such
  25966. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25967. // or updated by the mutation.
  25968. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  25969. switch {
  25970. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25971. id, exists := m.ID()
  25972. if exists {
  25973. return []uint64{id}, nil
  25974. }
  25975. fallthrough
  25976. case m.op.Is(OpUpdate | OpDelete):
  25977. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  25978. default:
  25979. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25980. }
  25981. }
  25982. // SetCreatedAt sets the "created_at" field.
  25983. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  25984. m.created_at = &t
  25985. }
  25986. // CreatedAt returns the value of the "created_at" field in the mutation.
  25987. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  25988. v := m.created_at
  25989. if v == nil {
  25990. return
  25991. }
  25992. return *v, true
  25993. }
  25994. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  25995. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25997. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25998. if !m.op.Is(OpUpdateOne) {
  25999. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26000. }
  26001. if m.id == nil || m.oldValue == nil {
  26002. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26003. }
  26004. oldValue, err := m.oldValue(ctx)
  26005. if err != nil {
  26006. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26007. }
  26008. return oldValue.CreatedAt, nil
  26009. }
  26010. // ResetCreatedAt resets all changes to the "created_at" field.
  26011. func (m *ServerMutation) ResetCreatedAt() {
  26012. m.created_at = nil
  26013. }
  26014. // SetUpdatedAt sets the "updated_at" field.
  26015. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  26016. m.updated_at = &t
  26017. }
  26018. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26019. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  26020. v := m.updated_at
  26021. if v == nil {
  26022. return
  26023. }
  26024. return *v, true
  26025. }
  26026. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  26027. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26029. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26030. if !m.op.Is(OpUpdateOne) {
  26031. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26032. }
  26033. if m.id == nil || m.oldValue == nil {
  26034. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26035. }
  26036. oldValue, err := m.oldValue(ctx)
  26037. if err != nil {
  26038. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26039. }
  26040. return oldValue.UpdatedAt, nil
  26041. }
  26042. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26043. func (m *ServerMutation) ResetUpdatedAt() {
  26044. m.updated_at = nil
  26045. }
  26046. // SetStatus sets the "status" field.
  26047. func (m *ServerMutation) SetStatus(u uint8) {
  26048. m.status = &u
  26049. m.addstatus = nil
  26050. }
  26051. // Status returns the value of the "status" field in the mutation.
  26052. func (m *ServerMutation) Status() (r uint8, exists bool) {
  26053. v := m.status
  26054. if v == nil {
  26055. return
  26056. }
  26057. return *v, true
  26058. }
  26059. // OldStatus returns the old "status" field's value of the Server entity.
  26060. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26062. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26063. if !m.op.Is(OpUpdateOne) {
  26064. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26065. }
  26066. if m.id == nil || m.oldValue == nil {
  26067. return v, errors.New("OldStatus requires an ID field in the mutation")
  26068. }
  26069. oldValue, err := m.oldValue(ctx)
  26070. if err != nil {
  26071. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26072. }
  26073. return oldValue.Status, nil
  26074. }
  26075. // AddStatus adds u to the "status" field.
  26076. func (m *ServerMutation) AddStatus(u int8) {
  26077. if m.addstatus != nil {
  26078. *m.addstatus += u
  26079. } else {
  26080. m.addstatus = &u
  26081. }
  26082. }
  26083. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26084. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  26085. v := m.addstatus
  26086. if v == nil {
  26087. return
  26088. }
  26089. return *v, true
  26090. }
  26091. // ClearStatus clears the value of the "status" field.
  26092. func (m *ServerMutation) ClearStatus() {
  26093. m.status = nil
  26094. m.addstatus = nil
  26095. m.clearedFields[server.FieldStatus] = struct{}{}
  26096. }
  26097. // StatusCleared returns if the "status" field was cleared in this mutation.
  26098. func (m *ServerMutation) StatusCleared() bool {
  26099. _, ok := m.clearedFields[server.FieldStatus]
  26100. return ok
  26101. }
  26102. // ResetStatus resets all changes to the "status" field.
  26103. func (m *ServerMutation) ResetStatus() {
  26104. m.status = nil
  26105. m.addstatus = nil
  26106. delete(m.clearedFields, server.FieldStatus)
  26107. }
  26108. // SetDeletedAt sets the "deleted_at" field.
  26109. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  26110. m.deleted_at = &t
  26111. }
  26112. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26113. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  26114. v := m.deleted_at
  26115. if v == nil {
  26116. return
  26117. }
  26118. return *v, true
  26119. }
  26120. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  26121. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26123. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26124. if !m.op.Is(OpUpdateOne) {
  26125. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26126. }
  26127. if m.id == nil || m.oldValue == nil {
  26128. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26129. }
  26130. oldValue, err := m.oldValue(ctx)
  26131. if err != nil {
  26132. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26133. }
  26134. return oldValue.DeletedAt, nil
  26135. }
  26136. // ClearDeletedAt clears the value of the "deleted_at" field.
  26137. func (m *ServerMutation) ClearDeletedAt() {
  26138. m.deleted_at = nil
  26139. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  26140. }
  26141. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26142. func (m *ServerMutation) DeletedAtCleared() bool {
  26143. _, ok := m.clearedFields[server.FieldDeletedAt]
  26144. return ok
  26145. }
  26146. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26147. func (m *ServerMutation) ResetDeletedAt() {
  26148. m.deleted_at = nil
  26149. delete(m.clearedFields, server.FieldDeletedAt)
  26150. }
  26151. // SetName sets the "name" field.
  26152. func (m *ServerMutation) SetName(s string) {
  26153. m.name = &s
  26154. }
  26155. // Name returns the value of the "name" field in the mutation.
  26156. func (m *ServerMutation) Name() (r string, exists bool) {
  26157. v := m.name
  26158. if v == nil {
  26159. return
  26160. }
  26161. return *v, true
  26162. }
  26163. // OldName returns the old "name" field's value of the Server entity.
  26164. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26166. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  26167. if !m.op.Is(OpUpdateOne) {
  26168. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26169. }
  26170. if m.id == nil || m.oldValue == nil {
  26171. return v, errors.New("OldName requires an ID field in the mutation")
  26172. }
  26173. oldValue, err := m.oldValue(ctx)
  26174. if err != nil {
  26175. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26176. }
  26177. return oldValue.Name, nil
  26178. }
  26179. // ResetName resets all changes to the "name" field.
  26180. func (m *ServerMutation) ResetName() {
  26181. m.name = nil
  26182. }
  26183. // SetPublicIP sets the "public_ip" field.
  26184. func (m *ServerMutation) SetPublicIP(s string) {
  26185. m.public_ip = &s
  26186. }
  26187. // PublicIP returns the value of the "public_ip" field in the mutation.
  26188. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  26189. v := m.public_ip
  26190. if v == nil {
  26191. return
  26192. }
  26193. return *v, true
  26194. }
  26195. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  26196. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26198. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  26199. if !m.op.Is(OpUpdateOne) {
  26200. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  26201. }
  26202. if m.id == nil || m.oldValue == nil {
  26203. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  26204. }
  26205. oldValue, err := m.oldValue(ctx)
  26206. if err != nil {
  26207. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  26208. }
  26209. return oldValue.PublicIP, nil
  26210. }
  26211. // ResetPublicIP resets all changes to the "public_ip" field.
  26212. func (m *ServerMutation) ResetPublicIP() {
  26213. m.public_ip = nil
  26214. }
  26215. // SetPrivateIP sets the "private_ip" field.
  26216. func (m *ServerMutation) SetPrivateIP(s string) {
  26217. m.private_ip = &s
  26218. }
  26219. // PrivateIP returns the value of the "private_ip" field in the mutation.
  26220. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  26221. v := m.private_ip
  26222. if v == nil {
  26223. return
  26224. }
  26225. return *v, true
  26226. }
  26227. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  26228. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26230. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  26231. if !m.op.Is(OpUpdateOne) {
  26232. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  26233. }
  26234. if m.id == nil || m.oldValue == nil {
  26235. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  26236. }
  26237. oldValue, err := m.oldValue(ctx)
  26238. if err != nil {
  26239. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  26240. }
  26241. return oldValue.PrivateIP, nil
  26242. }
  26243. // ResetPrivateIP resets all changes to the "private_ip" field.
  26244. func (m *ServerMutation) ResetPrivateIP() {
  26245. m.private_ip = nil
  26246. }
  26247. // SetAdminPort sets the "admin_port" field.
  26248. func (m *ServerMutation) SetAdminPort(s string) {
  26249. m.admin_port = &s
  26250. }
  26251. // AdminPort returns the value of the "admin_port" field in the mutation.
  26252. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  26253. v := m.admin_port
  26254. if v == nil {
  26255. return
  26256. }
  26257. return *v, true
  26258. }
  26259. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  26260. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26262. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  26263. if !m.op.Is(OpUpdateOne) {
  26264. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  26265. }
  26266. if m.id == nil || m.oldValue == nil {
  26267. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  26268. }
  26269. oldValue, err := m.oldValue(ctx)
  26270. if err != nil {
  26271. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  26272. }
  26273. return oldValue.AdminPort, nil
  26274. }
  26275. // ResetAdminPort resets all changes to the "admin_port" field.
  26276. func (m *ServerMutation) ResetAdminPort() {
  26277. m.admin_port = nil
  26278. }
  26279. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  26280. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  26281. if m.wxs == nil {
  26282. m.wxs = make(map[uint64]struct{})
  26283. }
  26284. for i := range ids {
  26285. m.wxs[ids[i]] = struct{}{}
  26286. }
  26287. }
  26288. // ClearWxs clears the "wxs" edge to the Wx entity.
  26289. func (m *ServerMutation) ClearWxs() {
  26290. m.clearedwxs = true
  26291. }
  26292. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  26293. func (m *ServerMutation) WxsCleared() bool {
  26294. return m.clearedwxs
  26295. }
  26296. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  26297. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  26298. if m.removedwxs == nil {
  26299. m.removedwxs = make(map[uint64]struct{})
  26300. }
  26301. for i := range ids {
  26302. delete(m.wxs, ids[i])
  26303. m.removedwxs[ids[i]] = struct{}{}
  26304. }
  26305. }
  26306. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  26307. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  26308. for id := range m.removedwxs {
  26309. ids = append(ids, id)
  26310. }
  26311. return
  26312. }
  26313. // WxsIDs returns the "wxs" edge IDs in the mutation.
  26314. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  26315. for id := range m.wxs {
  26316. ids = append(ids, id)
  26317. }
  26318. return
  26319. }
  26320. // ResetWxs resets all changes to the "wxs" edge.
  26321. func (m *ServerMutation) ResetWxs() {
  26322. m.wxs = nil
  26323. m.clearedwxs = false
  26324. m.removedwxs = nil
  26325. }
  26326. // Where appends a list predicates to the ServerMutation builder.
  26327. func (m *ServerMutation) Where(ps ...predicate.Server) {
  26328. m.predicates = append(m.predicates, ps...)
  26329. }
  26330. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  26331. // users can use type-assertion to append predicates that do not depend on any generated package.
  26332. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  26333. p := make([]predicate.Server, len(ps))
  26334. for i := range ps {
  26335. p[i] = ps[i]
  26336. }
  26337. m.Where(p...)
  26338. }
  26339. // Op returns the operation name.
  26340. func (m *ServerMutation) Op() Op {
  26341. return m.op
  26342. }
  26343. // SetOp allows setting the mutation operation.
  26344. func (m *ServerMutation) SetOp(op Op) {
  26345. m.op = op
  26346. }
  26347. // Type returns the node type of this mutation (Server).
  26348. func (m *ServerMutation) Type() string {
  26349. return m.typ
  26350. }
  26351. // Fields returns all fields that were changed during this mutation. Note that in
  26352. // order to get all numeric fields that were incremented/decremented, call
  26353. // AddedFields().
  26354. func (m *ServerMutation) Fields() []string {
  26355. fields := make([]string, 0, 8)
  26356. if m.created_at != nil {
  26357. fields = append(fields, server.FieldCreatedAt)
  26358. }
  26359. if m.updated_at != nil {
  26360. fields = append(fields, server.FieldUpdatedAt)
  26361. }
  26362. if m.status != nil {
  26363. fields = append(fields, server.FieldStatus)
  26364. }
  26365. if m.deleted_at != nil {
  26366. fields = append(fields, server.FieldDeletedAt)
  26367. }
  26368. if m.name != nil {
  26369. fields = append(fields, server.FieldName)
  26370. }
  26371. if m.public_ip != nil {
  26372. fields = append(fields, server.FieldPublicIP)
  26373. }
  26374. if m.private_ip != nil {
  26375. fields = append(fields, server.FieldPrivateIP)
  26376. }
  26377. if m.admin_port != nil {
  26378. fields = append(fields, server.FieldAdminPort)
  26379. }
  26380. return fields
  26381. }
  26382. // Field returns the value of a field with the given name. The second boolean
  26383. // return value indicates that this field was not set, or was not defined in the
  26384. // schema.
  26385. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  26386. switch name {
  26387. case server.FieldCreatedAt:
  26388. return m.CreatedAt()
  26389. case server.FieldUpdatedAt:
  26390. return m.UpdatedAt()
  26391. case server.FieldStatus:
  26392. return m.Status()
  26393. case server.FieldDeletedAt:
  26394. return m.DeletedAt()
  26395. case server.FieldName:
  26396. return m.Name()
  26397. case server.FieldPublicIP:
  26398. return m.PublicIP()
  26399. case server.FieldPrivateIP:
  26400. return m.PrivateIP()
  26401. case server.FieldAdminPort:
  26402. return m.AdminPort()
  26403. }
  26404. return nil, false
  26405. }
  26406. // OldField returns the old value of the field from the database. An error is
  26407. // returned if the mutation operation is not UpdateOne, or the query to the
  26408. // database failed.
  26409. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26410. switch name {
  26411. case server.FieldCreatedAt:
  26412. return m.OldCreatedAt(ctx)
  26413. case server.FieldUpdatedAt:
  26414. return m.OldUpdatedAt(ctx)
  26415. case server.FieldStatus:
  26416. return m.OldStatus(ctx)
  26417. case server.FieldDeletedAt:
  26418. return m.OldDeletedAt(ctx)
  26419. case server.FieldName:
  26420. return m.OldName(ctx)
  26421. case server.FieldPublicIP:
  26422. return m.OldPublicIP(ctx)
  26423. case server.FieldPrivateIP:
  26424. return m.OldPrivateIP(ctx)
  26425. case server.FieldAdminPort:
  26426. return m.OldAdminPort(ctx)
  26427. }
  26428. return nil, fmt.Errorf("unknown Server field %s", name)
  26429. }
  26430. // SetField sets the value of a field with the given name. It returns an error if
  26431. // the field is not defined in the schema, or if the type mismatched the field
  26432. // type.
  26433. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  26434. switch name {
  26435. case server.FieldCreatedAt:
  26436. v, ok := value.(time.Time)
  26437. if !ok {
  26438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26439. }
  26440. m.SetCreatedAt(v)
  26441. return nil
  26442. case server.FieldUpdatedAt:
  26443. v, ok := value.(time.Time)
  26444. if !ok {
  26445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26446. }
  26447. m.SetUpdatedAt(v)
  26448. return nil
  26449. case server.FieldStatus:
  26450. v, ok := value.(uint8)
  26451. if !ok {
  26452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26453. }
  26454. m.SetStatus(v)
  26455. return nil
  26456. case server.FieldDeletedAt:
  26457. v, ok := value.(time.Time)
  26458. if !ok {
  26459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26460. }
  26461. m.SetDeletedAt(v)
  26462. return nil
  26463. case server.FieldName:
  26464. v, ok := value.(string)
  26465. if !ok {
  26466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26467. }
  26468. m.SetName(v)
  26469. return nil
  26470. case server.FieldPublicIP:
  26471. v, ok := value.(string)
  26472. if !ok {
  26473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26474. }
  26475. m.SetPublicIP(v)
  26476. return nil
  26477. case server.FieldPrivateIP:
  26478. v, ok := value.(string)
  26479. if !ok {
  26480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26481. }
  26482. m.SetPrivateIP(v)
  26483. return nil
  26484. case server.FieldAdminPort:
  26485. v, ok := value.(string)
  26486. if !ok {
  26487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26488. }
  26489. m.SetAdminPort(v)
  26490. return nil
  26491. }
  26492. return fmt.Errorf("unknown Server field %s", name)
  26493. }
  26494. // AddedFields returns all numeric fields that were incremented/decremented during
  26495. // this mutation.
  26496. func (m *ServerMutation) AddedFields() []string {
  26497. var fields []string
  26498. if m.addstatus != nil {
  26499. fields = append(fields, server.FieldStatus)
  26500. }
  26501. return fields
  26502. }
  26503. // AddedField returns the numeric value that was incremented/decremented on a field
  26504. // with the given name. The second boolean return value indicates that this field
  26505. // was not set, or was not defined in the schema.
  26506. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  26507. switch name {
  26508. case server.FieldStatus:
  26509. return m.AddedStatus()
  26510. }
  26511. return nil, false
  26512. }
  26513. // AddField adds the value to the field with the given name. It returns an error if
  26514. // the field is not defined in the schema, or if the type mismatched the field
  26515. // type.
  26516. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  26517. switch name {
  26518. case server.FieldStatus:
  26519. v, ok := value.(int8)
  26520. if !ok {
  26521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26522. }
  26523. m.AddStatus(v)
  26524. return nil
  26525. }
  26526. return fmt.Errorf("unknown Server numeric field %s", name)
  26527. }
  26528. // ClearedFields returns all nullable fields that were cleared during this
  26529. // mutation.
  26530. func (m *ServerMutation) ClearedFields() []string {
  26531. var fields []string
  26532. if m.FieldCleared(server.FieldStatus) {
  26533. fields = append(fields, server.FieldStatus)
  26534. }
  26535. if m.FieldCleared(server.FieldDeletedAt) {
  26536. fields = append(fields, server.FieldDeletedAt)
  26537. }
  26538. return fields
  26539. }
  26540. // FieldCleared returns a boolean indicating if a field with the given name was
  26541. // cleared in this mutation.
  26542. func (m *ServerMutation) FieldCleared(name string) bool {
  26543. _, ok := m.clearedFields[name]
  26544. return ok
  26545. }
  26546. // ClearField clears the value of the field with the given name. It returns an
  26547. // error if the field is not defined in the schema.
  26548. func (m *ServerMutation) ClearField(name string) error {
  26549. switch name {
  26550. case server.FieldStatus:
  26551. m.ClearStatus()
  26552. return nil
  26553. case server.FieldDeletedAt:
  26554. m.ClearDeletedAt()
  26555. return nil
  26556. }
  26557. return fmt.Errorf("unknown Server nullable field %s", name)
  26558. }
  26559. // ResetField resets all changes in the mutation for the field with the given name.
  26560. // It returns an error if the field is not defined in the schema.
  26561. func (m *ServerMutation) ResetField(name string) error {
  26562. switch name {
  26563. case server.FieldCreatedAt:
  26564. m.ResetCreatedAt()
  26565. return nil
  26566. case server.FieldUpdatedAt:
  26567. m.ResetUpdatedAt()
  26568. return nil
  26569. case server.FieldStatus:
  26570. m.ResetStatus()
  26571. return nil
  26572. case server.FieldDeletedAt:
  26573. m.ResetDeletedAt()
  26574. return nil
  26575. case server.FieldName:
  26576. m.ResetName()
  26577. return nil
  26578. case server.FieldPublicIP:
  26579. m.ResetPublicIP()
  26580. return nil
  26581. case server.FieldPrivateIP:
  26582. m.ResetPrivateIP()
  26583. return nil
  26584. case server.FieldAdminPort:
  26585. m.ResetAdminPort()
  26586. return nil
  26587. }
  26588. return fmt.Errorf("unknown Server field %s", name)
  26589. }
  26590. // AddedEdges returns all edge names that were set/added in this mutation.
  26591. func (m *ServerMutation) AddedEdges() []string {
  26592. edges := make([]string, 0, 1)
  26593. if m.wxs != nil {
  26594. edges = append(edges, server.EdgeWxs)
  26595. }
  26596. return edges
  26597. }
  26598. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26599. // name in this mutation.
  26600. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  26601. switch name {
  26602. case server.EdgeWxs:
  26603. ids := make([]ent.Value, 0, len(m.wxs))
  26604. for id := range m.wxs {
  26605. ids = append(ids, id)
  26606. }
  26607. return ids
  26608. }
  26609. return nil
  26610. }
  26611. // RemovedEdges returns all edge names that were removed in this mutation.
  26612. func (m *ServerMutation) RemovedEdges() []string {
  26613. edges := make([]string, 0, 1)
  26614. if m.removedwxs != nil {
  26615. edges = append(edges, server.EdgeWxs)
  26616. }
  26617. return edges
  26618. }
  26619. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26620. // the given name in this mutation.
  26621. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  26622. switch name {
  26623. case server.EdgeWxs:
  26624. ids := make([]ent.Value, 0, len(m.removedwxs))
  26625. for id := range m.removedwxs {
  26626. ids = append(ids, id)
  26627. }
  26628. return ids
  26629. }
  26630. return nil
  26631. }
  26632. // ClearedEdges returns all edge names that were cleared in this mutation.
  26633. func (m *ServerMutation) ClearedEdges() []string {
  26634. edges := make([]string, 0, 1)
  26635. if m.clearedwxs {
  26636. edges = append(edges, server.EdgeWxs)
  26637. }
  26638. return edges
  26639. }
  26640. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26641. // was cleared in this mutation.
  26642. func (m *ServerMutation) EdgeCleared(name string) bool {
  26643. switch name {
  26644. case server.EdgeWxs:
  26645. return m.clearedwxs
  26646. }
  26647. return false
  26648. }
  26649. // ClearEdge clears the value of the edge with the given name. It returns an error
  26650. // if that edge is not defined in the schema.
  26651. func (m *ServerMutation) ClearEdge(name string) error {
  26652. switch name {
  26653. }
  26654. return fmt.Errorf("unknown Server unique edge %s", name)
  26655. }
  26656. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26657. // It returns an error if the edge is not defined in the schema.
  26658. func (m *ServerMutation) ResetEdge(name string) error {
  26659. switch name {
  26660. case server.EdgeWxs:
  26661. m.ResetWxs()
  26662. return nil
  26663. }
  26664. return fmt.Errorf("unknown Server edge %s", name)
  26665. }
  26666. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  26667. type SopNodeMutation struct {
  26668. config
  26669. op Op
  26670. typ string
  26671. id *uint64
  26672. created_at *time.Time
  26673. updated_at *time.Time
  26674. status *uint8
  26675. addstatus *int8
  26676. deleted_at *time.Time
  26677. parent_id *uint64
  26678. addparent_id *int64
  26679. name *string
  26680. condition_type *int
  26681. addcondition_type *int
  26682. condition_list *[]string
  26683. appendcondition_list []string
  26684. no_reply_condition *uint64
  26685. addno_reply_condition *int64
  26686. no_reply_unit *string
  26687. action_message *[]custom_types.Action
  26688. appendaction_message []custom_types.Action
  26689. action_label_add *[]uint64
  26690. appendaction_label_add []uint64
  26691. action_label_del *[]uint64
  26692. appendaction_label_del []uint64
  26693. action_forward **custom_types.ActionForward
  26694. clearedFields map[string]struct{}
  26695. sop_stage *uint64
  26696. clearedsop_stage bool
  26697. node_messages map[uint64]struct{}
  26698. removednode_messages map[uint64]struct{}
  26699. clearednode_messages bool
  26700. done bool
  26701. oldValue func(context.Context) (*SopNode, error)
  26702. predicates []predicate.SopNode
  26703. }
  26704. var _ ent.Mutation = (*SopNodeMutation)(nil)
  26705. // sopnodeOption allows management of the mutation configuration using functional options.
  26706. type sopnodeOption func(*SopNodeMutation)
  26707. // newSopNodeMutation creates new mutation for the SopNode entity.
  26708. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  26709. m := &SopNodeMutation{
  26710. config: c,
  26711. op: op,
  26712. typ: TypeSopNode,
  26713. clearedFields: make(map[string]struct{}),
  26714. }
  26715. for _, opt := range opts {
  26716. opt(m)
  26717. }
  26718. return m
  26719. }
  26720. // withSopNodeID sets the ID field of the mutation.
  26721. func withSopNodeID(id uint64) sopnodeOption {
  26722. return func(m *SopNodeMutation) {
  26723. var (
  26724. err error
  26725. once sync.Once
  26726. value *SopNode
  26727. )
  26728. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  26729. once.Do(func() {
  26730. if m.done {
  26731. err = errors.New("querying old values post mutation is not allowed")
  26732. } else {
  26733. value, err = m.Client().SopNode.Get(ctx, id)
  26734. }
  26735. })
  26736. return value, err
  26737. }
  26738. m.id = &id
  26739. }
  26740. }
  26741. // withSopNode sets the old SopNode of the mutation.
  26742. func withSopNode(node *SopNode) sopnodeOption {
  26743. return func(m *SopNodeMutation) {
  26744. m.oldValue = func(context.Context) (*SopNode, error) {
  26745. return node, nil
  26746. }
  26747. m.id = &node.ID
  26748. }
  26749. }
  26750. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26751. // executed in a transaction (ent.Tx), a transactional client is returned.
  26752. func (m SopNodeMutation) Client() *Client {
  26753. client := &Client{config: m.config}
  26754. client.init()
  26755. return client
  26756. }
  26757. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26758. // it returns an error otherwise.
  26759. func (m SopNodeMutation) Tx() (*Tx, error) {
  26760. if _, ok := m.driver.(*txDriver); !ok {
  26761. return nil, errors.New("ent: mutation is not running in a transaction")
  26762. }
  26763. tx := &Tx{config: m.config}
  26764. tx.init()
  26765. return tx, nil
  26766. }
  26767. // SetID sets the value of the id field. Note that this
  26768. // operation is only accepted on creation of SopNode entities.
  26769. func (m *SopNodeMutation) SetID(id uint64) {
  26770. m.id = &id
  26771. }
  26772. // ID returns the ID value in the mutation. Note that the ID is only available
  26773. // if it was provided to the builder or after it was returned from the database.
  26774. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  26775. if m.id == nil {
  26776. return
  26777. }
  26778. return *m.id, true
  26779. }
  26780. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26781. // That means, if the mutation is applied within a transaction with an isolation level such
  26782. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26783. // or updated by the mutation.
  26784. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26785. switch {
  26786. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26787. id, exists := m.ID()
  26788. if exists {
  26789. return []uint64{id}, nil
  26790. }
  26791. fallthrough
  26792. case m.op.Is(OpUpdate | OpDelete):
  26793. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  26794. default:
  26795. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26796. }
  26797. }
  26798. // SetCreatedAt sets the "created_at" field.
  26799. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  26800. m.created_at = &t
  26801. }
  26802. // CreatedAt returns the value of the "created_at" field in the mutation.
  26803. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  26804. v := m.created_at
  26805. if v == nil {
  26806. return
  26807. }
  26808. return *v, true
  26809. }
  26810. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  26811. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26813. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26814. if !m.op.Is(OpUpdateOne) {
  26815. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26816. }
  26817. if m.id == nil || m.oldValue == nil {
  26818. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26819. }
  26820. oldValue, err := m.oldValue(ctx)
  26821. if err != nil {
  26822. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26823. }
  26824. return oldValue.CreatedAt, nil
  26825. }
  26826. // ResetCreatedAt resets all changes to the "created_at" field.
  26827. func (m *SopNodeMutation) ResetCreatedAt() {
  26828. m.created_at = nil
  26829. }
  26830. // SetUpdatedAt sets the "updated_at" field.
  26831. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  26832. m.updated_at = &t
  26833. }
  26834. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26835. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  26836. v := m.updated_at
  26837. if v == nil {
  26838. return
  26839. }
  26840. return *v, true
  26841. }
  26842. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  26843. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26845. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26846. if !m.op.Is(OpUpdateOne) {
  26847. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26848. }
  26849. if m.id == nil || m.oldValue == nil {
  26850. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26851. }
  26852. oldValue, err := m.oldValue(ctx)
  26853. if err != nil {
  26854. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26855. }
  26856. return oldValue.UpdatedAt, nil
  26857. }
  26858. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26859. func (m *SopNodeMutation) ResetUpdatedAt() {
  26860. m.updated_at = nil
  26861. }
  26862. // SetStatus sets the "status" field.
  26863. func (m *SopNodeMutation) SetStatus(u uint8) {
  26864. m.status = &u
  26865. m.addstatus = nil
  26866. }
  26867. // Status returns the value of the "status" field in the mutation.
  26868. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  26869. v := m.status
  26870. if v == nil {
  26871. return
  26872. }
  26873. return *v, true
  26874. }
  26875. // OldStatus returns the old "status" field's value of the SopNode entity.
  26876. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26878. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26879. if !m.op.Is(OpUpdateOne) {
  26880. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26881. }
  26882. if m.id == nil || m.oldValue == nil {
  26883. return v, errors.New("OldStatus requires an ID field in the mutation")
  26884. }
  26885. oldValue, err := m.oldValue(ctx)
  26886. if err != nil {
  26887. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26888. }
  26889. return oldValue.Status, nil
  26890. }
  26891. // AddStatus adds u to the "status" field.
  26892. func (m *SopNodeMutation) AddStatus(u int8) {
  26893. if m.addstatus != nil {
  26894. *m.addstatus += u
  26895. } else {
  26896. m.addstatus = &u
  26897. }
  26898. }
  26899. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26900. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  26901. v := m.addstatus
  26902. if v == nil {
  26903. return
  26904. }
  26905. return *v, true
  26906. }
  26907. // ClearStatus clears the value of the "status" field.
  26908. func (m *SopNodeMutation) ClearStatus() {
  26909. m.status = nil
  26910. m.addstatus = nil
  26911. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  26912. }
  26913. // StatusCleared returns if the "status" field was cleared in this mutation.
  26914. func (m *SopNodeMutation) StatusCleared() bool {
  26915. _, ok := m.clearedFields[sopnode.FieldStatus]
  26916. return ok
  26917. }
  26918. // ResetStatus resets all changes to the "status" field.
  26919. func (m *SopNodeMutation) ResetStatus() {
  26920. m.status = nil
  26921. m.addstatus = nil
  26922. delete(m.clearedFields, sopnode.FieldStatus)
  26923. }
  26924. // SetDeletedAt sets the "deleted_at" field.
  26925. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  26926. m.deleted_at = &t
  26927. }
  26928. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26929. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  26930. v := m.deleted_at
  26931. if v == nil {
  26932. return
  26933. }
  26934. return *v, true
  26935. }
  26936. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  26937. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26939. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26940. if !m.op.Is(OpUpdateOne) {
  26941. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26942. }
  26943. if m.id == nil || m.oldValue == nil {
  26944. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26945. }
  26946. oldValue, err := m.oldValue(ctx)
  26947. if err != nil {
  26948. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26949. }
  26950. return oldValue.DeletedAt, nil
  26951. }
  26952. // ClearDeletedAt clears the value of the "deleted_at" field.
  26953. func (m *SopNodeMutation) ClearDeletedAt() {
  26954. m.deleted_at = nil
  26955. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  26956. }
  26957. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26958. func (m *SopNodeMutation) DeletedAtCleared() bool {
  26959. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  26960. return ok
  26961. }
  26962. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26963. func (m *SopNodeMutation) ResetDeletedAt() {
  26964. m.deleted_at = nil
  26965. delete(m.clearedFields, sopnode.FieldDeletedAt)
  26966. }
  26967. // SetStageID sets the "stage_id" field.
  26968. func (m *SopNodeMutation) SetStageID(u uint64) {
  26969. m.sop_stage = &u
  26970. }
  26971. // StageID returns the value of the "stage_id" field in the mutation.
  26972. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  26973. v := m.sop_stage
  26974. if v == nil {
  26975. return
  26976. }
  26977. return *v, true
  26978. }
  26979. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  26980. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26982. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  26983. if !m.op.Is(OpUpdateOne) {
  26984. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  26985. }
  26986. if m.id == nil || m.oldValue == nil {
  26987. return v, errors.New("OldStageID requires an ID field in the mutation")
  26988. }
  26989. oldValue, err := m.oldValue(ctx)
  26990. if err != nil {
  26991. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  26992. }
  26993. return oldValue.StageID, nil
  26994. }
  26995. // ResetStageID resets all changes to the "stage_id" field.
  26996. func (m *SopNodeMutation) ResetStageID() {
  26997. m.sop_stage = nil
  26998. }
  26999. // SetParentID sets the "parent_id" field.
  27000. func (m *SopNodeMutation) SetParentID(u uint64) {
  27001. m.parent_id = &u
  27002. m.addparent_id = nil
  27003. }
  27004. // ParentID returns the value of the "parent_id" field in the mutation.
  27005. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  27006. v := m.parent_id
  27007. if v == nil {
  27008. return
  27009. }
  27010. return *v, true
  27011. }
  27012. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  27013. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27015. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  27016. if !m.op.Is(OpUpdateOne) {
  27017. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  27018. }
  27019. if m.id == nil || m.oldValue == nil {
  27020. return v, errors.New("OldParentID requires an ID field in the mutation")
  27021. }
  27022. oldValue, err := m.oldValue(ctx)
  27023. if err != nil {
  27024. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  27025. }
  27026. return oldValue.ParentID, nil
  27027. }
  27028. // AddParentID adds u to the "parent_id" field.
  27029. func (m *SopNodeMutation) AddParentID(u int64) {
  27030. if m.addparent_id != nil {
  27031. *m.addparent_id += u
  27032. } else {
  27033. m.addparent_id = &u
  27034. }
  27035. }
  27036. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  27037. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  27038. v := m.addparent_id
  27039. if v == nil {
  27040. return
  27041. }
  27042. return *v, true
  27043. }
  27044. // ResetParentID resets all changes to the "parent_id" field.
  27045. func (m *SopNodeMutation) ResetParentID() {
  27046. m.parent_id = nil
  27047. m.addparent_id = nil
  27048. }
  27049. // SetName sets the "name" field.
  27050. func (m *SopNodeMutation) SetName(s string) {
  27051. m.name = &s
  27052. }
  27053. // Name returns the value of the "name" field in the mutation.
  27054. func (m *SopNodeMutation) Name() (r string, exists bool) {
  27055. v := m.name
  27056. if v == nil {
  27057. return
  27058. }
  27059. return *v, true
  27060. }
  27061. // OldName returns the old "name" field's value of the SopNode entity.
  27062. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27064. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  27065. if !m.op.Is(OpUpdateOne) {
  27066. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27067. }
  27068. if m.id == nil || m.oldValue == nil {
  27069. return v, errors.New("OldName requires an ID field in the mutation")
  27070. }
  27071. oldValue, err := m.oldValue(ctx)
  27072. if err != nil {
  27073. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27074. }
  27075. return oldValue.Name, nil
  27076. }
  27077. // ResetName resets all changes to the "name" field.
  27078. func (m *SopNodeMutation) ResetName() {
  27079. m.name = nil
  27080. }
  27081. // SetConditionType sets the "condition_type" field.
  27082. func (m *SopNodeMutation) SetConditionType(i int) {
  27083. m.condition_type = &i
  27084. m.addcondition_type = nil
  27085. }
  27086. // ConditionType returns the value of the "condition_type" field in the mutation.
  27087. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  27088. v := m.condition_type
  27089. if v == nil {
  27090. return
  27091. }
  27092. return *v, true
  27093. }
  27094. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  27095. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27097. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  27098. if !m.op.Is(OpUpdateOne) {
  27099. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  27100. }
  27101. if m.id == nil || m.oldValue == nil {
  27102. return v, errors.New("OldConditionType requires an ID field in the mutation")
  27103. }
  27104. oldValue, err := m.oldValue(ctx)
  27105. if err != nil {
  27106. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  27107. }
  27108. return oldValue.ConditionType, nil
  27109. }
  27110. // AddConditionType adds i to the "condition_type" field.
  27111. func (m *SopNodeMutation) AddConditionType(i int) {
  27112. if m.addcondition_type != nil {
  27113. *m.addcondition_type += i
  27114. } else {
  27115. m.addcondition_type = &i
  27116. }
  27117. }
  27118. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  27119. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  27120. v := m.addcondition_type
  27121. if v == nil {
  27122. return
  27123. }
  27124. return *v, true
  27125. }
  27126. // ResetConditionType resets all changes to the "condition_type" field.
  27127. func (m *SopNodeMutation) ResetConditionType() {
  27128. m.condition_type = nil
  27129. m.addcondition_type = nil
  27130. }
  27131. // SetConditionList sets the "condition_list" field.
  27132. func (m *SopNodeMutation) SetConditionList(s []string) {
  27133. m.condition_list = &s
  27134. m.appendcondition_list = nil
  27135. }
  27136. // ConditionList returns the value of the "condition_list" field in the mutation.
  27137. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  27138. v := m.condition_list
  27139. if v == nil {
  27140. return
  27141. }
  27142. return *v, true
  27143. }
  27144. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  27145. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27147. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  27148. if !m.op.Is(OpUpdateOne) {
  27149. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  27150. }
  27151. if m.id == nil || m.oldValue == nil {
  27152. return v, errors.New("OldConditionList requires an ID field in the mutation")
  27153. }
  27154. oldValue, err := m.oldValue(ctx)
  27155. if err != nil {
  27156. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27157. }
  27158. return oldValue.ConditionList, nil
  27159. }
  27160. // AppendConditionList adds s to the "condition_list" field.
  27161. func (m *SopNodeMutation) AppendConditionList(s []string) {
  27162. m.appendcondition_list = append(m.appendcondition_list, s...)
  27163. }
  27164. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27165. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  27166. if len(m.appendcondition_list) == 0 {
  27167. return nil, false
  27168. }
  27169. return m.appendcondition_list, true
  27170. }
  27171. // ClearConditionList clears the value of the "condition_list" field.
  27172. func (m *SopNodeMutation) ClearConditionList() {
  27173. m.condition_list = nil
  27174. m.appendcondition_list = nil
  27175. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  27176. }
  27177. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  27178. func (m *SopNodeMutation) ConditionListCleared() bool {
  27179. _, ok := m.clearedFields[sopnode.FieldConditionList]
  27180. return ok
  27181. }
  27182. // ResetConditionList resets all changes to the "condition_list" field.
  27183. func (m *SopNodeMutation) ResetConditionList() {
  27184. m.condition_list = nil
  27185. m.appendcondition_list = nil
  27186. delete(m.clearedFields, sopnode.FieldConditionList)
  27187. }
  27188. // SetNoReplyCondition sets the "no_reply_condition" field.
  27189. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  27190. m.no_reply_condition = &u
  27191. m.addno_reply_condition = nil
  27192. }
  27193. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  27194. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  27195. v := m.no_reply_condition
  27196. if v == nil {
  27197. return
  27198. }
  27199. return *v, true
  27200. }
  27201. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  27202. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27204. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  27205. if !m.op.Is(OpUpdateOne) {
  27206. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  27207. }
  27208. if m.id == nil || m.oldValue == nil {
  27209. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  27210. }
  27211. oldValue, err := m.oldValue(ctx)
  27212. if err != nil {
  27213. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  27214. }
  27215. return oldValue.NoReplyCondition, nil
  27216. }
  27217. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  27218. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  27219. if m.addno_reply_condition != nil {
  27220. *m.addno_reply_condition += u
  27221. } else {
  27222. m.addno_reply_condition = &u
  27223. }
  27224. }
  27225. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  27226. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  27227. v := m.addno_reply_condition
  27228. if v == nil {
  27229. return
  27230. }
  27231. return *v, true
  27232. }
  27233. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  27234. func (m *SopNodeMutation) ResetNoReplyCondition() {
  27235. m.no_reply_condition = nil
  27236. m.addno_reply_condition = nil
  27237. }
  27238. // SetNoReplyUnit sets the "no_reply_unit" field.
  27239. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  27240. m.no_reply_unit = &s
  27241. }
  27242. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  27243. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  27244. v := m.no_reply_unit
  27245. if v == nil {
  27246. return
  27247. }
  27248. return *v, true
  27249. }
  27250. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  27251. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27253. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  27254. if !m.op.Is(OpUpdateOne) {
  27255. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  27256. }
  27257. if m.id == nil || m.oldValue == nil {
  27258. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  27259. }
  27260. oldValue, err := m.oldValue(ctx)
  27261. if err != nil {
  27262. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  27263. }
  27264. return oldValue.NoReplyUnit, nil
  27265. }
  27266. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  27267. func (m *SopNodeMutation) ResetNoReplyUnit() {
  27268. m.no_reply_unit = nil
  27269. }
  27270. // SetActionMessage sets the "action_message" field.
  27271. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  27272. m.action_message = &ct
  27273. m.appendaction_message = nil
  27274. }
  27275. // ActionMessage returns the value of the "action_message" field in the mutation.
  27276. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27277. v := m.action_message
  27278. if v == nil {
  27279. return
  27280. }
  27281. return *v, true
  27282. }
  27283. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  27284. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27286. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  27287. if !m.op.Is(OpUpdateOne) {
  27288. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  27289. }
  27290. if m.id == nil || m.oldValue == nil {
  27291. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  27292. }
  27293. oldValue, err := m.oldValue(ctx)
  27294. if err != nil {
  27295. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  27296. }
  27297. return oldValue.ActionMessage, nil
  27298. }
  27299. // AppendActionMessage adds ct to the "action_message" field.
  27300. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  27301. m.appendaction_message = append(m.appendaction_message, ct...)
  27302. }
  27303. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  27304. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  27305. if len(m.appendaction_message) == 0 {
  27306. return nil, false
  27307. }
  27308. return m.appendaction_message, true
  27309. }
  27310. // ClearActionMessage clears the value of the "action_message" field.
  27311. func (m *SopNodeMutation) ClearActionMessage() {
  27312. m.action_message = nil
  27313. m.appendaction_message = nil
  27314. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  27315. }
  27316. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  27317. func (m *SopNodeMutation) ActionMessageCleared() bool {
  27318. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  27319. return ok
  27320. }
  27321. // ResetActionMessage resets all changes to the "action_message" field.
  27322. func (m *SopNodeMutation) ResetActionMessage() {
  27323. m.action_message = nil
  27324. m.appendaction_message = nil
  27325. delete(m.clearedFields, sopnode.FieldActionMessage)
  27326. }
  27327. // SetActionLabelAdd sets the "action_label_add" field.
  27328. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  27329. m.action_label_add = &u
  27330. m.appendaction_label_add = nil
  27331. }
  27332. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  27333. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  27334. v := m.action_label_add
  27335. if v == nil {
  27336. return
  27337. }
  27338. return *v, true
  27339. }
  27340. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  27341. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27343. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  27344. if !m.op.Is(OpUpdateOne) {
  27345. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  27346. }
  27347. if m.id == nil || m.oldValue == nil {
  27348. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  27349. }
  27350. oldValue, err := m.oldValue(ctx)
  27351. if err != nil {
  27352. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  27353. }
  27354. return oldValue.ActionLabelAdd, nil
  27355. }
  27356. // AppendActionLabelAdd adds u to the "action_label_add" field.
  27357. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  27358. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  27359. }
  27360. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  27361. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  27362. if len(m.appendaction_label_add) == 0 {
  27363. return nil, false
  27364. }
  27365. return m.appendaction_label_add, true
  27366. }
  27367. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  27368. func (m *SopNodeMutation) ClearActionLabelAdd() {
  27369. m.action_label_add = nil
  27370. m.appendaction_label_add = nil
  27371. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  27372. }
  27373. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  27374. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  27375. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  27376. return ok
  27377. }
  27378. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  27379. func (m *SopNodeMutation) ResetActionLabelAdd() {
  27380. m.action_label_add = nil
  27381. m.appendaction_label_add = nil
  27382. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  27383. }
  27384. // SetActionLabelDel sets the "action_label_del" field.
  27385. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  27386. m.action_label_del = &u
  27387. m.appendaction_label_del = nil
  27388. }
  27389. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  27390. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  27391. v := m.action_label_del
  27392. if v == nil {
  27393. return
  27394. }
  27395. return *v, true
  27396. }
  27397. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  27398. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27400. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  27401. if !m.op.Is(OpUpdateOne) {
  27402. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  27403. }
  27404. if m.id == nil || m.oldValue == nil {
  27405. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  27406. }
  27407. oldValue, err := m.oldValue(ctx)
  27408. if err != nil {
  27409. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  27410. }
  27411. return oldValue.ActionLabelDel, nil
  27412. }
  27413. // AppendActionLabelDel adds u to the "action_label_del" field.
  27414. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  27415. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  27416. }
  27417. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  27418. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  27419. if len(m.appendaction_label_del) == 0 {
  27420. return nil, false
  27421. }
  27422. return m.appendaction_label_del, true
  27423. }
  27424. // ClearActionLabelDel clears the value of the "action_label_del" field.
  27425. func (m *SopNodeMutation) ClearActionLabelDel() {
  27426. m.action_label_del = nil
  27427. m.appendaction_label_del = nil
  27428. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  27429. }
  27430. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  27431. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  27432. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  27433. return ok
  27434. }
  27435. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  27436. func (m *SopNodeMutation) ResetActionLabelDel() {
  27437. m.action_label_del = nil
  27438. m.appendaction_label_del = nil
  27439. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  27440. }
  27441. // SetActionForward sets the "action_forward" field.
  27442. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  27443. m.action_forward = &ctf
  27444. }
  27445. // ActionForward returns the value of the "action_forward" field in the mutation.
  27446. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  27447. v := m.action_forward
  27448. if v == nil {
  27449. return
  27450. }
  27451. return *v, true
  27452. }
  27453. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  27454. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27456. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  27457. if !m.op.Is(OpUpdateOne) {
  27458. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  27459. }
  27460. if m.id == nil || m.oldValue == nil {
  27461. return v, errors.New("OldActionForward requires an ID field in the mutation")
  27462. }
  27463. oldValue, err := m.oldValue(ctx)
  27464. if err != nil {
  27465. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  27466. }
  27467. return oldValue.ActionForward, nil
  27468. }
  27469. // ClearActionForward clears the value of the "action_forward" field.
  27470. func (m *SopNodeMutation) ClearActionForward() {
  27471. m.action_forward = nil
  27472. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  27473. }
  27474. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  27475. func (m *SopNodeMutation) ActionForwardCleared() bool {
  27476. _, ok := m.clearedFields[sopnode.FieldActionForward]
  27477. return ok
  27478. }
  27479. // ResetActionForward resets all changes to the "action_forward" field.
  27480. func (m *SopNodeMutation) ResetActionForward() {
  27481. m.action_forward = nil
  27482. delete(m.clearedFields, sopnode.FieldActionForward)
  27483. }
  27484. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  27485. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  27486. m.sop_stage = &id
  27487. }
  27488. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  27489. func (m *SopNodeMutation) ClearSopStage() {
  27490. m.clearedsop_stage = true
  27491. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  27492. }
  27493. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  27494. func (m *SopNodeMutation) SopStageCleared() bool {
  27495. return m.clearedsop_stage
  27496. }
  27497. // SopStageID returns the "sop_stage" edge ID in the mutation.
  27498. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  27499. if m.sop_stage != nil {
  27500. return *m.sop_stage, true
  27501. }
  27502. return
  27503. }
  27504. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  27505. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27506. // SopStageID instead. It exists only for internal usage by the builders.
  27507. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  27508. if id := m.sop_stage; id != nil {
  27509. ids = append(ids, *id)
  27510. }
  27511. return
  27512. }
  27513. // ResetSopStage resets all changes to the "sop_stage" edge.
  27514. func (m *SopNodeMutation) ResetSopStage() {
  27515. m.sop_stage = nil
  27516. m.clearedsop_stage = false
  27517. }
  27518. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  27519. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  27520. if m.node_messages == nil {
  27521. m.node_messages = make(map[uint64]struct{})
  27522. }
  27523. for i := range ids {
  27524. m.node_messages[ids[i]] = struct{}{}
  27525. }
  27526. }
  27527. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  27528. func (m *SopNodeMutation) ClearNodeMessages() {
  27529. m.clearednode_messages = true
  27530. }
  27531. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  27532. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  27533. return m.clearednode_messages
  27534. }
  27535. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  27536. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  27537. if m.removednode_messages == nil {
  27538. m.removednode_messages = make(map[uint64]struct{})
  27539. }
  27540. for i := range ids {
  27541. delete(m.node_messages, ids[i])
  27542. m.removednode_messages[ids[i]] = struct{}{}
  27543. }
  27544. }
  27545. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  27546. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  27547. for id := range m.removednode_messages {
  27548. ids = append(ids, id)
  27549. }
  27550. return
  27551. }
  27552. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  27553. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  27554. for id := range m.node_messages {
  27555. ids = append(ids, id)
  27556. }
  27557. return
  27558. }
  27559. // ResetNodeMessages resets all changes to the "node_messages" edge.
  27560. func (m *SopNodeMutation) ResetNodeMessages() {
  27561. m.node_messages = nil
  27562. m.clearednode_messages = false
  27563. m.removednode_messages = nil
  27564. }
  27565. // Where appends a list predicates to the SopNodeMutation builder.
  27566. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  27567. m.predicates = append(m.predicates, ps...)
  27568. }
  27569. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  27570. // users can use type-assertion to append predicates that do not depend on any generated package.
  27571. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  27572. p := make([]predicate.SopNode, len(ps))
  27573. for i := range ps {
  27574. p[i] = ps[i]
  27575. }
  27576. m.Where(p...)
  27577. }
  27578. // Op returns the operation name.
  27579. func (m *SopNodeMutation) Op() Op {
  27580. return m.op
  27581. }
  27582. // SetOp allows setting the mutation operation.
  27583. func (m *SopNodeMutation) SetOp(op Op) {
  27584. m.op = op
  27585. }
  27586. // Type returns the node type of this mutation (SopNode).
  27587. func (m *SopNodeMutation) Type() string {
  27588. return m.typ
  27589. }
  27590. // Fields returns all fields that were changed during this mutation. Note that in
  27591. // order to get all numeric fields that were incremented/decremented, call
  27592. // AddedFields().
  27593. func (m *SopNodeMutation) Fields() []string {
  27594. fields := make([]string, 0, 15)
  27595. if m.created_at != nil {
  27596. fields = append(fields, sopnode.FieldCreatedAt)
  27597. }
  27598. if m.updated_at != nil {
  27599. fields = append(fields, sopnode.FieldUpdatedAt)
  27600. }
  27601. if m.status != nil {
  27602. fields = append(fields, sopnode.FieldStatus)
  27603. }
  27604. if m.deleted_at != nil {
  27605. fields = append(fields, sopnode.FieldDeletedAt)
  27606. }
  27607. if m.sop_stage != nil {
  27608. fields = append(fields, sopnode.FieldStageID)
  27609. }
  27610. if m.parent_id != nil {
  27611. fields = append(fields, sopnode.FieldParentID)
  27612. }
  27613. if m.name != nil {
  27614. fields = append(fields, sopnode.FieldName)
  27615. }
  27616. if m.condition_type != nil {
  27617. fields = append(fields, sopnode.FieldConditionType)
  27618. }
  27619. if m.condition_list != nil {
  27620. fields = append(fields, sopnode.FieldConditionList)
  27621. }
  27622. if m.no_reply_condition != nil {
  27623. fields = append(fields, sopnode.FieldNoReplyCondition)
  27624. }
  27625. if m.no_reply_unit != nil {
  27626. fields = append(fields, sopnode.FieldNoReplyUnit)
  27627. }
  27628. if m.action_message != nil {
  27629. fields = append(fields, sopnode.FieldActionMessage)
  27630. }
  27631. if m.action_label_add != nil {
  27632. fields = append(fields, sopnode.FieldActionLabelAdd)
  27633. }
  27634. if m.action_label_del != nil {
  27635. fields = append(fields, sopnode.FieldActionLabelDel)
  27636. }
  27637. if m.action_forward != nil {
  27638. fields = append(fields, sopnode.FieldActionForward)
  27639. }
  27640. return fields
  27641. }
  27642. // Field returns the value of a field with the given name. The second boolean
  27643. // return value indicates that this field was not set, or was not defined in the
  27644. // schema.
  27645. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  27646. switch name {
  27647. case sopnode.FieldCreatedAt:
  27648. return m.CreatedAt()
  27649. case sopnode.FieldUpdatedAt:
  27650. return m.UpdatedAt()
  27651. case sopnode.FieldStatus:
  27652. return m.Status()
  27653. case sopnode.FieldDeletedAt:
  27654. return m.DeletedAt()
  27655. case sopnode.FieldStageID:
  27656. return m.StageID()
  27657. case sopnode.FieldParentID:
  27658. return m.ParentID()
  27659. case sopnode.FieldName:
  27660. return m.Name()
  27661. case sopnode.FieldConditionType:
  27662. return m.ConditionType()
  27663. case sopnode.FieldConditionList:
  27664. return m.ConditionList()
  27665. case sopnode.FieldNoReplyCondition:
  27666. return m.NoReplyCondition()
  27667. case sopnode.FieldNoReplyUnit:
  27668. return m.NoReplyUnit()
  27669. case sopnode.FieldActionMessage:
  27670. return m.ActionMessage()
  27671. case sopnode.FieldActionLabelAdd:
  27672. return m.ActionLabelAdd()
  27673. case sopnode.FieldActionLabelDel:
  27674. return m.ActionLabelDel()
  27675. case sopnode.FieldActionForward:
  27676. return m.ActionForward()
  27677. }
  27678. return nil, false
  27679. }
  27680. // OldField returns the old value of the field from the database. An error is
  27681. // returned if the mutation operation is not UpdateOne, or the query to the
  27682. // database failed.
  27683. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27684. switch name {
  27685. case sopnode.FieldCreatedAt:
  27686. return m.OldCreatedAt(ctx)
  27687. case sopnode.FieldUpdatedAt:
  27688. return m.OldUpdatedAt(ctx)
  27689. case sopnode.FieldStatus:
  27690. return m.OldStatus(ctx)
  27691. case sopnode.FieldDeletedAt:
  27692. return m.OldDeletedAt(ctx)
  27693. case sopnode.FieldStageID:
  27694. return m.OldStageID(ctx)
  27695. case sopnode.FieldParentID:
  27696. return m.OldParentID(ctx)
  27697. case sopnode.FieldName:
  27698. return m.OldName(ctx)
  27699. case sopnode.FieldConditionType:
  27700. return m.OldConditionType(ctx)
  27701. case sopnode.FieldConditionList:
  27702. return m.OldConditionList(ctx)
  27703. case sopnode.FieldNoReplyCondition:
  27704. return m.OldNoReplyCondition(ctx)
  27705. case sopnode.FieldNoReplyUnit:
  27706. return m.OldNoReplyUnit(ctx)
  27707. case sopnode.FieldActionMessage:
  27708. return m.OldActionMessage(ctx)
  27709. case sopnode.FieldActionLabelAdd:
  27710. return m.OldActionLabelAdd(ctx)
  27711. case sopnode.FieldActionLabelDel:
  27712. return m.OldActionLabelDel(ctx)
  27713. case sopnode.FieldActionForward:
  27714. return m.OldActionForward(ctx)
  27715. }
  27716. return nil, fmt.Errorf("unknown SopNode field %s", name)
  27717. }
  27718. // SetField sets the value of a field with the given name. It returns an error if
  27719. // the field is not defined in the schema, or if the type mismatched the field
  27720. // type.
  27721. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  27722. switch name {
  27723. case sopnode.FieldCreatedAt:
  27724. v, ok := value.(time.Time)
  27725. if !ok {
  27726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27727. }
  27728. m.SetCreatedAt(v)
  27729. return nil
  27730. case sopnode.FieldUpdatedAt:
  27731. v, ok := value.(time.Time)
  27732. if !ok {
  27733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27734. }
  27735. m.SetUpdatedAt(v)
  27736. return nil
  27737. case sopnode.FieldStatus:
  27738. v, ok := value.(uint8)
  27739. if !ok {
  27740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27741. }
  27742. m.SetStatus(v)
  27743. return nil
  27744. case sopnode.FieldDeletedAt:
  27745. v, ok := value.(time.Time)
  27746. if !ok {
  27747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27748. }
  27749. m.SetDeletedAt(v)
  27750. return nil
  27751. case sopnode.FieldStageID:
  27752. v, ok := value.(uint64)
  27753. if !ok {
  27754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27755. }
  27756. m.SetStageID(v)
  27757. return nil
  27758. case sopnode.FieldParentID:
  27759. v, ok := value.(uint64)
  27760. if !ok {
  27761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27762. }
  27763. m.SetParentID(v)
  27764. return nil
  27765. case sopnode.FieldName:
  27766. v, ok := value.(string)
  27767. if !ok {
  27768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27769. }
  27770. m.SetName(v)
  27771. return nil
  27772. case sopnode.FieldConditionType:
  27773. v, ok := value.(int)
  27774. if !ok {
  27775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27776. }
  27777. m.SetConditionType(v)
  27778. return nil
  27779. case sopnode.FieldConditionList:
  27780. v, ok := value.([]string)
  27781. if !ok {
  27782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27783. }
  27784. m.SetConditionList(v)
  27785. return nil
  27786. case sopnode.FieldNoReplyCondition:
  27787. v, ok := value.(uint64)
  27788. if !ok {
  27789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27790. }
  27791. m.SetNoReplyCondition(v)
  27792. return nil
  27793. case sopnode.FieldNoReplyUnit:
  27794. v, ok := value.(string)
  27795. if !ok {
  27796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27797. }
  27798. m.SetNoReplyUnit(v)
  27799. return nil
  27800. case sopnode.FieldActionMessage:
  27801. v, ok := value.([]custom_types.Action)
  27802. if !ok {
  27803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27804. }
  27805. m.SetActionMessage(v)
  27806. return nil
  27807. case sopnode.FieldActionLabelAdd:
  27808. v, ok := value.([]uint64)
  27809. if !ok {
  27810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27811. }
  27812. m.SetActionLabelAdd(v)
  27813. return nil
  27814. case sopnode.FieldActionLabelDel:
  27815. v, ok := value.([]uint64)
  27816. if !ok {
  27817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27818. }
  27819. m.SetActionLabelDel(v)
  27820. return nil
  27821. case sopnode.FieldActionForward:
  27822. v, ok := value.(*custom_types.ActionForward)
  27823. if !ok {
  27824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27825. }
  27826. m.SetActionForward(v)
  27827. return nil
  27828. }
  27829. return fmt.Errorf("unknown SopNode field %s", name)
  27830. }
  27831. // AddedFields returns all numeric fields that were incremented/decremented during
  27832. // this mutation.
  27833. func (m *SopNodeMutation) AddedFields() []string {
  27834. var fields []string
  27835. if m.addstatus != nil {
  27836. fields = append(fields, sopnode.FieldStatus)
  27837. }
  27838. if m.addparent_id != nil {
  27839. fields = append(fields, sopnode.FieldParentID)
  27840. }
  27841. if m.addcondition_type != nil {
  27842. fields = append(fields, sopnode.FieldConditionType)
  27843. }
  27844. if m.addno_reply_condition != nil {
  27845. fields = append(fields, sopnode.FieldNoReplyCondition)
  27846. }
  27847. return fields
  27848. }
  27849. // AddedField returns the numeric value that was incremented/decremented on a field
  27850. // with the given name. The second boolean return value indicates that this field
  27851. // was not set, or was not defined in the schema.
  27852. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  27853. switch name {
  27854. case sopnode.FieldStatus:
  27855. return m.AddedStatus()
  27856. case sopnode.FieldParentID:
  27857. return m.AddedParentID()
  27858. case sopnode.FieldConditionType:
  27859. return m.AddedConditionType()
  27860. case sopnode.FieldNoReplyCondition:
  27861. return m.AddedNoReplyCondition()
  27862. }
  27863. return nil, false
  27864. }
  27865. // AddField adds the value to the field with the given name. It returns an error if
  27866. // the field is not defined in the schema, or if the type mismatched the field
  27867. // type.
  27868. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  27869. switch name {
  27870. case sopnode.FieldStatus:
  27871. v, ok := value.(int8)
  27872. if !ok {
  27873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27874. }
  27875. m.AddStatus(v)
  27876. return nil
  27877. case sopnode.FieldParentID:
  27878. v, ok := value.(int64)
  27879. if !ok {
  27880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27881. }
  27882. m.AddParentID(v)
  27883. return nil
  27884. case sopnode.FieldConditionType:
  27885. v, ok := value.(int)
  27886. if !ok {
  27887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27888. }
  27889. m.AddConditionType(v)
  27890. return nil
  27891. case sopnode.FieldNoReplyCondition:
  27892. v, ok := value.(int64)
  27893. if !ok {
  27894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27895. }
  27896. m.AddNoReplyCondition(v)
  27897. return nil
  27898. }
  27899. return fmt.Errorf("unknown SopNode numeric field %s", name)
  27900. }
  27901. // ClearedFields returns all nullable fields that were cleared during this
  27902. // mutation.
  27903. func (m *SopNodeMutation) ClearedFields() []string {
  27904. var fields []string
  27905. if m.FieldCleared(sopnode.FieldStatus) {
  27906. fields = append(fields, sopnode.FieldStatus)
  27907. }
  27908. if m.FieldCleared(sopnode.FieldDeletedAt) {
  27909. fields = append(fields, sopnode.FieldDeletedAt)
  27910. }
  27911. if m.FieldCleared(sopnode.FieldConditionList) {
  27912. fields = append(fields, sopnode.FieldConditionList)
  27913. }
  27914. if m.FieldCleared(sopnode.FieldActionMessage) {
  27915. fields = append(fields, sopnode.FieldActionMessage)
  27916. }
  27917. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  27918. fields = append(fields, sopnode.FieldActionLabelAdd)
  27919. }
  27920. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  27921. fields = append(fields, sopnode.FieldActionLabelDel)
  27922. }
  27923. if m.FieldCleared(sopnode.FieldActionForward) {
  27924. fields = append(fields, sopnode.FieldActionForward)
  27925. }
  27926. return fields
  27927. }
  27928. // FieldCleared returns a boolean indicating if a field with the given name was
  27929. // cleared in this mutation.
  27930. func (m *SopNodeMutation) FieldCleared(name string) bool {
  27931. _, ok := m.clearedFields[name]
  27932. return ok
  27933. }
  27934. // ClearField clears the value of the field with the given name. It returns an
  27935. // error if the field is not defined in the schema.
  27936. func (m *SopNodeMutation) ClearField(name string) error {
  27937. switch name {
  27938. case sopnode.FieldStatus:
  27939. m.ClearStatus()
  27940. return nil
  27941. case sopnode.FieldDeletedAt:
  27942. m.ClearDeletedAt()
  27943. return nil
  27944. case sopnode.FieldConditionList:
  27945. m.ClearConditionList()
  27946. return nil
  27947. case sopnode.FieldActionMessage:
  27948. m.ClearActionMessage()
  27949. return nil
  27950. case sopnode.FieldActionLabelAdd:
  27951. m.ClearActionLabelAdd()
  27952. return nil
  27953. case sopnode.FieldActionLabelDel:
  27954. m.ClearActionLabelDel()
  27955. return nil
  27956. case sopnode.FieldActionForward:
  27957. m.ClearActionForward()
  27958. return nil
  27959. }
  27960. return fmt.Errorf("unknown SopNode nullable field %s", name)
  27961. }
  27962. // ResetField resets all changes in the mutation for the field with the given name.
  27963. // It returns an error if the field is not defined in the schema.
  27964. func (m *SopNodeMutation) ResetField(name string) error {
  27965. switch name {
  27966. case sopnode.FieldCreatedAt:
  27967. m.ResetCreatedAt()
  27968. return nil
  27969. case sopnode.FieldUpdatedAt:
  27970. m.ResetUpdatedAt()
  27971. return nil
  27972. case sopnode.FieldStatus:
  27973. m.ResetStatus()
  27974. return nil
  27975. case sopnode.FieldDeletedAt:
  27976. m.ResetDeletedAt()
  27977. return nil
  27978. case sopnode.FieldStageID:
  27979. m.ResetStageID()
  27980. return nil
  27981. case sopnode.FieldParentID:
  27982. m.ResetParentID()
  27983. return nil
  27984. case sopnode.FieldName:
  27985. m.ResetName()
  27986. return nil
  27987. case sopnode.FieldConditionType:
  27988. m.ResetConditionType()
  27989. return nil
  27990. case sopnode.FieldConditionList:
  27991. m.ResetConditionList()
  27992. return nil
  27993. case sopnode.FieldNoReplyCondition:
  27994. m.ResetNoReplyCondition()
  27995. return nil
  27996. case sopnode.FieldNoReplyUnit:
  27997. m.ResetNoReplyUnit()
  27998. return nil
  27999. case sopnode.FieldActionMessage:
  28000. m.ResetActionMessage()
  28001. return nil
  28002. case sopnode.FieldActionLabelAdd:
  28003. m.ResetActionLabelAdd()
  28004. return nil
  28005. case sopnode.FieldActionLabelDel:
  28006. m.ResetActionLabelDel()
  28007. return nil
  28008. case sopnode.FieldActionForward:
  28009. m.ResetActionForward()
  28010. return nil
  28011. }
  28012. return fmt.Errorf("unknown SopNode field %s", name)
  28013. }
  28014. // AddedEdges returns all edge names that were set/added in this mutation.
  28015. func (m *SopNodeMutation) AddedEdges() []string {
  28016. edges := make([]string, 0, 2)
  28017. if m.sop_stage != nil {
  28018. edges = append(edges, sopnode.EdgeSopStage)
  28019. }
  28020. if m.node_messages != nil {
  28021. edges = append(edges, sopnode.EdgeNodeMessages)
  28022. }
  28023. return edges
  28024. }
  28025. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28026. // name in this mutation.
  28027. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  28028. switch name {
  28029. case sopnode.EdgeSopStage:
  28030. if id := m.sop_stage; id != nil {
  28031. return []ent.Value{*id}
  28032. }
  28033. case sopnode.EdgeNodeMessages:
  28034. ids := make([]ent.Value, 0, len(m.node_messages))
  28035. for id := range m.node_messages {
  28036. ids = append(ids, id)
  28037. }
  28038. return ids
  28039. }
  28040. return nil
  28041. }
  28042. // RemovedEdges returns all edge names that were removed in this mutation.
  28043. func (m *SopNodeMutation) RemovedEdges() []string {
  28044. edges := make([]string, 0, 2)
  28045. if m.removednode_messages != nil {
  28046. edges = append(edges, sopnode.EdgeNodeMessages)
  28047. }
  28048. return edges
  28049. }
  28050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28051. // the given name in this mutation.
  28052. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  28053. switch name {
  28054. case sopnode.EdgeNodeMessages:
  28055. ids := make([]ent.Value, 0, len(m.removednode_messages))
  28056. for id := range m.removednode_messages {
  28057. ids = append(ids, id)
  28058. }
  28059. return ids
  28060. }
  28061. return nil
  28062. }
  28063. // ClearedEdges returns all edge names that were cleared in this mutation.
  28064. func (m *SopNodeMutation) ClearedEdges() []string {
  28065. edges := make([]string, 0, 2)
  28066. if m.clearedsop_stage {
  28067. edges = append(edges, sopnode.EdgeSopStage)
  28068. }
  28069. if m.clearednode_messages {
  28070. edges = append(edges, sopnode.EdgeNodeMessages)
  28071. }
  28072. return edges
  28073. }
  28074. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28075. // was cleared in this mutation.
  28076. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  28077. switch name {
  28078. case sopnode.EdgeSopStage:
  28079. return m.clearedsop_stage
  28080. case sopnode.EdgeNodeMessages:
  28081. return m.clearednode_messages
  28082. }
  28083. return false
  28084. }
  28085. // ClearEdge clears the value of the edge with the given name. It returns an error
  28086. // if that edge is not defined in the schema.
  28087. func (m *SopNodeMutation) ClearEdge(name string) error {
  28088. switch name {
  28089. case sopnode.EdgeSopStage:
  28090. m.ClearSopStage()
  28091. return nil
  28092. }
  28093. return fmt.Errorf("unknown SopNode unique edge %s", name)
  28094. }
  28095. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28096. // It returns an error if the edge is not defined in the schema.
  28097. func (m *SopNodeMutation) ResetEdge(name string) error {
  28098. switch name {
  28099. case sopnode.EdgeSopStage:
  28100. m.ResetSopStage()
  28101. return nil
  28102. case sopnode.EdgeNodeMessages:
  28103. m.ResetNodeMessages()
  28104. return nil
  28105. }
  28106. return fmt.Errorf("unknown SopNode edge %s", name)
  28107. }
  28108. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  28109. type SopStageMutation struct {
  28110. config
  28111. op Op
  28112. typ string
  28113. id *uint64
  28114. created_at *time.Time
  28115. updated_at *time.Time
  28116. status *uint8
  28117. addstatus *int8
  28118. deleted_at *time.Time
  28119. name *string
  28120. condition_type *int
  28121. addcondition_type *int
  28122. condition_operator *int
  28123. addcondition_operator *int
  28124. condition_list *[]custom_types.Condition
  28125. appendcondition_list []custom_types.Condition
  28126. action_message *[]custom_types.Action
  28127. appendaction_message []custom_types.Action
  28128. action_label_add *[]uint64
  28129. appendaction_label_add []uint64
  28130. action_label_del *[]uint64
  28131. appendaction_label_del []uint64
  28132. action_forward **custom_types.ActionForward
  28133. index_sort *int
  28134. addindex_sort *int
  28135. clearedFields map[string]struct{}
  28136. sop_task *uint64
  28137. clearedsop_task bool
  28138. stage_nodes map[uint64]struct{}
  28139. removedstage_nodes map[uint64]struct{}
  28140. clearedstage_nodes bool
  28141. stage_messages map[uint64]struct{}
  28142. removedstage_messages map[uint64]struct{}
  28143. clearedstage_messages bool
  28144. done bool
  28145. oldValue func(context.Context) (*SopStage, error)
  28146. predicates []predicate.SopStage
  28147. }
  28148. var _ ent.Mutation = (*SopStageMutation)(nil)
  28149. // sopstageOption allows management of the mutation configuration using functional options.
  28150. type sopstageOption func(*SopStageMutation)
  28151. // newSopStageMutation creates new mutation for the SopStage entity.
  28152. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  28153. m := &SopStageMutation{
  28154. config: c,
  28155. op: op,
  28156. typ: TypeSopStage,
  28157. clearedFields: make(map[string]struct{}),
  28158. }
  28159. for _, opt := range opts {
  28160. opt(m)
  28161. }
  28162. return m
  28163. }
  28164. // withSopStageID sets the ID field of the mutation.
  28165. func withSopStageID(id uint64) sopstageOption {
  28166. return func(m *SopStageMutation) {
  28167. var (
  28168. err error
  28169. once sync.Once
  28170. value *SopStage
  28171. )
  28172. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  28173. once.Do(func() {
  28174. if m.done {
  28175. err = errors.New("querying old values post mutation is not allowed")
  28176. } else {
  28177. value, err = m.Client().SopStage.Get(ctx, id)
  28178. }
  28179. })
  28180. return value, err
  28181. }
  28182. m.id = &id
  28183. }
  28184. }
  28185. // withSopStage sets the old SopStage of the mutation.
  28186. func withSopStage(node *SopStage) sopstageOption {
  28187. return func(m *SopStageMutation) {
  28188. m.oldValue = func(context.Context) (*SopStage, error) {
  28189. return node, nil
  28190. }
  28191. m.id = &node.ID
  28192. }
  28193. }
  28194. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28195. // executed in a transaction (ent.Tx), a transactional client is returned.
  28196. func (m SopStageMutation) Client() *Client {
  28197. client := &Client{config: m.config}
  28198. client.init()
  28199. return client
  28200. }
  28201. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28202. // it returns an error otherwise.
  28203. func (m SopStageMutation) Tx() (*Tx, error) {
  28204. if _, ok := m.driver.(*txDriver); !ok {
  28205. return nil, errors.New("ent: mutation is not running in a transaction")
  28206. }
  28207. tx := &Tx{config: m.config}
  28208. tx.init()
  28209. return tx, nil
  28210. }
  28211. // SetID sets the value of the id field. Note that this
  28212. // operation is only accepted on creation of SopStage entities.
  28213. func (m *SopStageMutation) SetID(id uint64) {
  28214. m.id = &id
  28215. }
  28216. // ID returns the ID value in the mutation. Note that the ID is only available
  28217. // if it was provided to the builder or after it was returned from the database.
  28218. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  28219. if m.id == nil {
  28220. return
  28221. }
  28222. return *m.id, true
  28223. }
  28224. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28225. // That means, if the mutation is applied within a transaction with an isolation level such
  28226. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28227. // or updated by the mutation.
  28228. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  28229. switch {
  28230. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28231. id, exists := m.ID()
  28232. if exists {
  28233. return []uint64{id}, nil
  28234. }
  28235. fallthrough
  28236. case m.op.Is(OpUpdate | OpDelete):
  28237. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  28238. default:
  28239. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28240. }
  28241. }
  28242. // SetCreatedAt sets the "created_at" field.
  28243. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  28244. m.created_at = &t
  28245. }
  28246. // CreatedAt returns the value of the "created_at" field in the mutation.
  28247. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  28248. v := m.created_at
  28249. if v == nil {
  28250. return
  28251. }
  28252. return *v, true
  28253. }
  28254. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  28255. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28257. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28258. if !m.op.Is(OpUpdateOne) {
  28259. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28260. }
  28261. if m.id == nil || m.oldValue == nil {
  28262. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28263. }
  28264. oldValue, err := m.oldValue(ctx)
  28265. if err != nil {
  28266. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28267. }
  28268. return oldValue.CreatedAt, nil
  28269. }
  28270. // ResetCreatedAt resets all changes to the "created_at" field.
  28271. func (m *SopStageMutation) ResetCreatedAt() {
  28272. m.created_at = nil
  28273. }
  28274. // SetUpdatedAt sets the "updated_at" field.
  28275. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  28276. m.updated_at = &t
  28277. }
  28278. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28279. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  28280. v := m.updated_at
  28281. if v == nil {
  28282. return
  28283. }
  28284. return *v, true
  28285. }
  28286. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  28287. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28289. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28290. if !m.op.Is(OpUpdateOne) {
  28291. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28292. }
  28293. if m.id == nil || m.oldValue == nil {
  28294. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28295. }
  28296. oldValue, err := m.oldValue(ctx)
  28297. if err != nil {
  28298. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28299. }
  28300. return oldValue.UpdatedAt, nil
  28301. }
  28302. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28303. func (m *SopStageMutation) ResetUpdatedAt() {
  28304. m.updated_at = nil
  28305. }
  28306. // SetStatus sets the "status" field.
  28307. func (m *SopStageMutation) SetStatus(u uint8) {
  28308. m.status = &u
  28309. m.addstatus = nil
  28310. }
  28311. // Status returns the value of the "status" field in the mutation.
  28312. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  28313. v := m.status
  28314. if v == nil {
  28315. return
  28316. }
  28317. return *v, true
  28318. }
  28319. // OldStatus returns the old "status" field's value of the SopStage entity.
  28320. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28322. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28323. if !m.op.Is(OpUpdateOne) {
  28324. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28325. }
  28326. if m.id == nil || m.oldValue == nil {
  28327. return v, errors.New("OldStatus requires an ID field in the mutation")
  28328. }
  28329. oldValue, err := m.oldValue(ctx)
  28330. if err != nil {
  28331. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28332. }
  28333. return oldValue.Status, nil
  28334. }
  28335. // AddStatus adds u to the "status" field.
  28336. func (m *SopStageMutation) AddStatus(u int8) {
  28337. if m.addstatus != nil {
  28338. *m.addstatus += u
  28339. } else {
  28340. m.addstatus = &u
  28341. }
  28342. }
  28343. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28344. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  28345. v := m.addstatus
  28346. if v == nil {
  28347. return
  28348. }
  28349. return *v, true
  28350. }
  28351. // ClearStatus clears the value of the "status" field.
  28352. func (m *SopStageMutation) ClearStatus() {
  28353. m.status = nil
  28354. m.addstatus = nil
  28355. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  28356. }
  28357. // StatusCleared returns if the "status" field was cleared in this mutation.
  28358. func (m *SopStageMutation) StatusCleared() bool {
  28359. _, ok := m.clearedFields[sopstage.FieldStatus]
  28360. return ok
  28361. }
  28362. // ResetStatus resets all changes to the "status" field.
  28363. func (m *SopStageMutation) ResetStatus() {
  28364. m.status = nil
  28365. m.addstatus = nil
  28366. delete(m.clearedFields, sopstage.FieldStatus)
  28367. }
  28368. // SetDeletedAt sets the "deleted_at" field.
  28369. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  28370. m.deleted_at = &t
  28371. }
  28372. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28373. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  28374. v := m.deleted_at
  28375. if v == nil {
  28376. return
  28377. }
  28378. return *v, true
  28379. }
  28380. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  28381. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28383. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28384. if !m.op.Is(OpUpdateOne) {
  28385. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28386. }
  28387. if m.id == nil || m.oldValue == nil {
  28388. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28389. }
  28390. oldValue, err := m.oldValue(ctx)
  28391. if err != nil {
  28392. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28393. }
  28394. return oldValue.DeletedAt, nil
  28395. }
  28396. // ClearDeletedAt clears the value of the "deleted_at" field.
  28397. func (m *SopStageMutation) ClearDeletedAt() {
  28398. m.deleted_at = nil
  28399. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  28400. }
  28401. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28402. func (m *SopStageMutation) DeletedAtCleared() bool {
  28403. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  28404. return ok
  28405. }
  28406. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28407. func (m *SopStageMutation) ResetDeletedAt() {
  28408. m.deleted_at = nil
  28409. delete(m.clearedFields, sopstage.FieldDeletedAt)
  28410. }
  28411. // SetTaskID sets the "task_id" field.
  28412. func (m *SopStageMutation) SetTaskID(u uint64) {
  28413. m.sop_task = &u
  28414. }
  28415. // TaskID returns the value of the "task_id" field in the mutation.
  28416. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  28417. v := m.sop_task
  28418. if v == nil {
  28419. return
  28420. }
  28421. return *v, true
  28422. }
  28423. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  28424. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28426. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  28427. if !m.op.Is(OpUpdateOne) {
  28428. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  28429. }
  28430. if m.id == nil || m.oldValue == nil {
  28431. return v, errors.New("OldTaskID requires an ID field in the mutation")
  28432. }
  28433. oldValue, err := m.oldValue(ctx)
  28434. if err != nil {
  28435. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  28436. }
  28437. return oldValue.TaskID, nil
  28438. }
  28439. // ResetTaskID resets all changes to the "task_id" field.
  28440. func (m *SopStageMutation) ResetTaskID() {
  28441. m.sop_task = nil
  28442. }
  28443. // SetName sets the "name" field.
  28444. func (m *SopStageMutation) SetName(s string) {
  28445. m.name = &s
  28446. }
  28447. // Name returns the value of the "name" field in the mutation.
  28448. func (m *SopStageMutation) Name() (r string, exists bool) {
  28449. v := m.name
  28450. if v == nil {
  28451. return
  28452. }
  28453. return *v, true
  28454. }
  28455. // OldName returns the old "name" field's value of the SopStage entity.
  28456. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28458. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  28459. if !m.op.Is(OpUpdateOne) {
  28460. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28461. }
  28462. if m.id == nil || m.oldValue == nil {
  28463. return v, errors.New("OldName requires an ID field in the mutation")
  28464. }
  28465. oldValue, err := m.oldValue(ctx)
  28466. if err != nil {
  28467. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28468. }
  28469. return oldValue.Name, nil
  28470. }
  28471. // ResetName resets all changes to the "name" field.
  28472. func (m *SopStageMutation) ResetName() {
  28473. m.name = nil
  28474. }
  28475. // SetConditionType sets the "condition_type" field.
  28476. func (m *SopStageMutation) SetConditionType(i int) {
  28477. m.condition_type = &i
  28478. m.addcondition_type = nil
  28479. }
  28480. // ConditionType returns the value of the "condition_type" field in the mutation.
  28481. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  28482. v := m.condition_type
  28483. if v == nil {
  28484. return
  28485. }
  28486. return *v, true
  28487. }
  28488. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  28489. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28491. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28492. if !m.op.Is(OpUpdateOne) {
  28493. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28494. }
  28495. if m.id == nil || m.oldValue == nil {
  28496. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28497. }
  28498. oldValue, err := m.oldValue(ctx)
  28499. if err != nil {
  28500. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28501. }
  28502. return oldValue.ConditionType, nil
  28503. }
  28504. // AddConditionType adds i to the "condition_type" field.
  28505. func (m *SopStageMutation) AddConditionType(i int) {
  28506. if m.addcondition_type != nil {
  28507. *m.addcondition_type += i
  28508. } else {
  28509. m.addcondition_type = &i
  28510. }
  28511. }
  28512. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28513. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  28514. v := m.addcondition_type
  28515. if v == nil {
  28516. return
  28517. }
  28518. return *v, true
  28519. }
  28520. // ResetConditionType resets all changes to the "condition_type" field.
  28521. func (m *SopStageMutation) ResetConditionType() {
  28522. m.condition_type = nil
  28523. m.addcondition_type = nil
  28524. }
  28525. // SetConditionOperator sets the "condition_operator" field.
  28526. func (m *SopStageMutation) SetConditionOperator(i int) {
  28527. m.condition_operator = &i
  28528. m.addcondition_operator = nil
  28529. }
  28530. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  28531. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  28532. v := m.condition_operator
  28533. if v == nil {
  28534. return
  28535. }
  28536. return *v, true
  28537. }
  28538. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  28539. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28541. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  28542. if !m.op.Is(OpUpdateOne) {
  28543. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  28544. }
  28545. if m.id == nil || m.oldValue == nil {
  28546. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  28547. }
  28548. oldValue, err := m.oldValue(ctx)
  28549. if err != nil {
  28550. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  28551. }
  28552. return oldValue.ConditionOperator, nil
  28553. }
  28554. // AddConditionOperator adds i to the "condition_operator" field.
  28555. func (m *SopStageMutation) AddConditionOperator(i int) {
  28556. if m.addcondition_operator != nil {
  28557. *m.addcondition_operator += i
  28558. } else {
  28559. m.addcondition_operator = &i
  28560. }
  28561. }
  28562. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  28563. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  28564. v := m.addcondition_operator
  28565. if v == nil {
  28566. return
  28567. }
  28568. return *v, true
  28569. }
  28570. // ResetConditionOperator resets all changes to the "condition_operator" field.
  28571. func (m *SopStageMutation) ResetConditionOperator() {
  28572. m.condition_operator = nil
  28573. m.addcondition_operator = nil
  28574. }
  28575. // SetConditionList sets the "condition_list" field.
  28576. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  28577. m.condition_list = &ct
  28578. m.appendcondition_list = nil
  28579. }
  28580. // ConditionList returns the value of the "condition_list" field in the mutation.
  28581. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  28582. v := m.condition_list
  28583. if v == nil {
  28584. return
  28585. }
  28586. return *v, true
  28587. }
  28588. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  28589. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28591. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  28592. if !m.op.Is(OpUpdateOne) {
  28593. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28594. }
  28595. if m.id == nil || m.oldValue == nil {
  28596. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28597. }
  28598. oldValue, err := m.oldValue(ctx)
  28599. if err != nil {
  28600. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28601. }
  28602. return oldValue.ConditionList, nil
  28603. }
  28604. // AppendConditionList adds ct to the "condition_list" field.
  28605. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  28606. m.appendcondition_list = append(m.appendcondition_list, ct...)
  28607. }
  28608. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28609. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  28610. if len(m.appendcondition_list) == 0 {
  28611. return nil, false
  28612. }
  28613. return m.appendcondition_list, true
  28614. }
  28615. // ResetConditionList resets all changes to the "condition_list" field.
  28616. func (m *SopStageMutation) ResetConditionList() {
  28617. m.condition_list = nil
  28618. m.appendcondition_list = nil
  28619. }
  28620. // SetActionMessage sets the "action_message" field.
  28621. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  28622. m.action_message = &ct
  28623. m.appendaction_message = nil
  28624. }
  28625. // ActionMessage returns the value of the "action_message" field in the mutation.
  28626. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  28627. v := m.action_message
  28628. if v == nil {
  28629. return
  28630. }
  28631. return *v, true
  28632. }
  28633. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  28634. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28636. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28637. if !m.op.Is(OpUpdateOne) {
  28638. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28639. }
  28640. if m.id == nil || m.oldValue == nil {
  28641. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28642. }
  28643. oldValue, err := m.oldValue(ctx)
  28644. if err != nil {
  28645. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28646. }
  28647. return oldValue.ActionMessage, nil
  28648. }
  28649. // AppendActionMessage adds ct to the "action_message" field.
  28650. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  28651. m.appendaction_message = append(m.appendaction_message, ct...)
  28652. }
  28653. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  28654. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  28655. if len(m.appendaction_message) == 0 {
  28656. return nil, false
  28657. }
  28658. return m.appendaction_message, true
  28659. }
  28660. // ClearActionMessage clears the value of the "action_message" field.
  28661. func (m *SopStageMutation) ClearActionMessage() {
  28662. m.action_message = nil
  28663. m.appendaction_message = nil
  28664. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  28665. }
  28666. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  28667. func (m *SopStageMutation) ActionMessageCleared() bool {
  28668. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  28669. return ok
  28670. }
  28671. // ResetActionMessage resets all changes to the "action_message" field.
  28672. func (m *SopStageMutation) ResetActionMessage() {
  28673. m.action_message = nil
  28674. m.appendaction_message = nil
  28675. delete(m.clearedFields, sopstage.FieldActionMessage)
  28676. }
  28677. // SetActionLabelAdd sets the "action_label_add" field.
  28678. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  28679. m.action_label_add = &u
  28680. m.appendaction_label_add = nil
  28681. }
  28682. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  28683. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  28684. v := m.action_label_add
  28685. if v == nil {
  28686. return
  28687. }
  28688. return *v, true
  28689. }
  28690. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  28691. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28693. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  28694. if !m.op.Is(OpUpdateOne) {
  28695. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  28696. }
  28697. if m.id == nil || m.oldValue == nil {
  28698. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  28699. }
  28700. oldValue, err := m.oldValue(ctx)
  28701. if err != nil {
  28702. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  28703. }
  28704. return oldValue.ActionLabelAdd, nil
  28705. }
  28706. // AppendActionLabelAdd adds u to the "action_label_add" field.
  28707. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  28708. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  28709. }
  28710. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  28711. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  28712. if len(m.appendaction_label_add) == 0 {
  28713. return nil, false
  28714. }
  28715. return m.appendaction_label_add, true
  28716. }
  28717. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  28718. func (m *SopStageMutation) ClearActionLabelAdd() {
  28719. m.action_label_add = nil
  28720. m.appendaction_label_add = nil
  28721. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  28722. }
  28723. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  28724. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  28725. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  28726. return ok
  28727. }
  28728. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  28729. func (m *SopStageMutation) ResetActionLabelAdd() {
  28730. m.action_label_add = nil
  28731. m.appendaction_label_add = nil
  28732. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  28733. }
  28734. // SetActionLabelDel sets the "action_label_del" field.
  28735. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  28736. m.action_label_del = &u
  28737. m.appendaction_label_del = nil
  28738. }
  28739. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  28740. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  28741. v := m.action_label_del
  28742. if v == nil {
  28743. return
  28744. }
  28745. return *v, true
  28746. }
  28747. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  28748. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28750. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  28751. if !m.op.Is(OpUpdateOne) {
  28752. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  28753. }
  28754. if m.id == nil || m.oldValue == nil {
  28755. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  28756. }
  28757. oldValue, err := m.oldValue(ctx)
  28758. if err != nil {
  28759. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  28760. }
  28761. return oldValue.ActionLabelDel, nil
  28762. }
  28763. // AppendActionLabelDel adds u to the "action_label_del" field.
  28764. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  28765. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  28766. }
  28767. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  28768. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  28769. if len(m.appendaction_label_del) == 0 {
  28770. return nil, false
  28771. }
  28772. return m.appendaction_label_del, true
  28773. }
  28774. // ClearActionLabelDel clears the value of the "action_label_del" field.
  28775. func (m *SopStageMutation) ClearActionLabelDel() {
  28776. m.action_label_del = nil
  28777. m.appendaction_label_del = nil
  28778. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  28779. }
  28780. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  28781. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  28782. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  28783. return ok
  28784. }
  28785. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  28786. func (m *SopStageMutation) ResetActionLabelDel() {
  28787. m.action_label_del = nil
  28788. m.appendaction_label_del = nil
  28789. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  28790. }
  28791. // SetActionForward sets the "action_forward" field.
  28792. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  28793. m.action_forward = &ctf
  28794. }
  28795. // ActionForward returns the value of the "action_forward" field in the mutation.
  28796. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  28797. v := m.action_forward
  28798. if v == nil {
  28799. return
  28800. }
  28801. return *v, true
  28802. }
  28803. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  28804. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28806. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  28807. if !m.op.Is(OpUpdateOne) {
  28808. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  28809. }
  28810. if m.id == nil || m.oldValue == nil {
  28811. return v, errors.New("OldActionForward requires an ID field in the mutation")
  28812. }
  28813. oldValue, err := m.oldValue(ctx)
  28814. if err != nil {
  28815. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  28816. }
  28817. return oldValue.ActionForward, nil
  28818. }
  28819. // ClearActionForward clears the value of the "action_forward" field.
  28820. func (m *SopStageMutation) ClearActionForward() {
  28821. m.action_forward = nil
  28822. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  28823. }
  28824. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  28825. func (m *SopStageMutation) ActionForwardCleared() bool {
  28826. _, ok := m.clearedFields[sopstage.FieldActionForward]
  28827. return ok
  28828. }
  28829. // ResetActionForward resets all changes to the "action_forward" field.
  28830. func (m *SopStageMutation) ResetActionForward() {
  28831. m.action_forward = nil
  28832. delete(m.clearedFields, sopstage.FieldActionForward)
  28833. }
  28834. // SetIndexSort sets the "index_sort" field.
  28835. func (m *SopStageMutation) SetIndexSort(i int) {
  28836. m.index_sort = &i
  28837. m.addindex_sort = nil
  28838. }
  28839. // IndexSort returns the value of the "index_sort" field in the mutation.
  28840. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  28841. v := m.index_sort
  28842. if v == nil {
  28843. return
  28844. }
  28845. return *v, true
  28846. }
  28847. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  28848. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28850. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  28851. if !m.op.Is(OpUpdateOne) {
  28852. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  28853. }
  28854. if m.id == nil || m.oldValue == nil {
  28855. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  28856. }
  28857. oldValue, err := m.oldValue(ctx)
  28858. if err != nil {
  28859. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  28860. }
  28861. return oldValue.IndexSort, nil
  28862. }
  28863. // AddIndexSort adds i to the "index_sort" field.
  28864. func (m *SopStageMutation) AddIndexSort(i int) {
  28865. if m.addindex_sort != nil {
  28866. *m.addindex_sort += i
  28867. } else {
  28868. m.addindex_sort = &i
  28869. }
  28870. }
  28871. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  28872. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  28873. v := m.addindex_sort
  28874. if v == nil {
  28875. return
  28876. }
  28877. return *v, true
  28878. }
  28879. // ClearIndexSort clears the value of the "index_sort" field.
  28880. func (m *SopStageMutation) ClearIndexSort() {
  28881. m.index_sort = nil
  28882. m.addindex_sort = nil
  28883. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  28884. }
  28885. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  28886. func (m *SopStageMutation) IndexSortCleared() bool {
  28887. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  28888. return ok
  28889. }
  28890. // ResetIndexSort resets all changes to the "index_sort" field.
  28891. func (m *SopStageMutation) ResetIndexSort() {
  28892. m.index_sort = nil
  28893. m.addindex_sort = nil
  28894. delete(m.clearedFields, sopstage.FieldIndexSort)
  28895. }
  28896. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  28897. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  28898. m.sop_task = &id
  28899. }
  28900. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  28901. func (m *SopStageMutation) ClearSopTask() {
  28902. m.clearedsop_task = true
  28903. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  28904. }
  28905. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  28906. func (m *SopStageMutation) SopTaskCleared() bool {
  28907. return m.clearedsop_task
  28908. }
  28909. // SopTaskID returns the "sop_task" edge ID in the mutation.
  28910. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  28911. if m.sop_task != nil {
  28912. return *m.sop_task, true
  28913. }
  28914. return
  28915. }
  28916. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  28917. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28918. // SopTaskID instead. It exists only for internal usage by the builders.
  28919. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  28920. if id := m.sop_task; id != nil {
  28921. ids = append(ids, *id)
  28922. }
  28923. return
  28924. }
  28925. // ResetSopTask resets all changes to the "sop_task" edge.
  28926. func (m *SopStageMutation) ResetSopTask() {
  28927. m.sop_task = nil
  28928. m.clearedsop_task = false
  28929. }
  28930. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  28931. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  28932. if m.stage_nodes == nil {
  28933. m.stage_nodes = make(map[uint64]struct{})
  28934. }
  28935. for i := range ids {
  28936. m.stage_nodes[ids[i]] = struct{}{}
  28937. }
  28938. }
  28939. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  28940. func (m *SopStageMutation) ClearStageNodes() {
  28941. m.clearedstage_nodes = true
  28942. }
  28943. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  28944. func (m *SopStageMutation) StageNodesCleared() bool {
  28945. return m.clearedstage_nodes
  28946. }
  28947. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  28948. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  28949. if m.removedstage_nodes == nil {
  28950. m.removedstage_nodes = make(map[uint64]struct{})
  28951. }
  28952. for i := range ids {
  28953. delete(m.stage_nodes, ids[i])
  28954. m.removedstage_nodes[ids[i]] = struct{}{}
  28955. }
  28956. }
  28957. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  28958. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  28959. for id := range m.removedstage_nodes {
  28960. ids = append(ids, id)
  28961. }
  28962. return
  28963. }
  28964. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  28965. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  28966. for id := range m.stage_nodes {
  28967. ids = append(ids, id)
  28968. }
  28969. return
  28970. }
  28971. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  28972. func (m *SopStageMutation) ResetStageNodes() {
  28973. m.stage_nodes = nil
  28974. m.clearedstage_nodes = false
  28975. m.removedstage_nodes = nil
  28976. }
  28977. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  28978. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  28979. if m.stage_messages == nil {
  28980. m.stage_messages = make(map[uint64]struct{})
  28981. }
  28982. for i := range ids {
  28983. m.stage_messages[ids[i]] = struct{}{}
  28984. }
  28985. }
  28986. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  28987. func (m *SopStageMutation) ClearStageMessages() {
  28988. m.clearedstage_messages = true
  28989. }
  28990. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  28991. func (m *SopStageMutation) StageMessagesCleared() bool {
  28992. return m.clearedstage_messages
  28993. }
  28994. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  28995. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  28996. if m.removedstage_messages == nil {
  28997. m.removedstage_messages = make(map[uint64]struct{})
  28998. }
  28999. for i := range ids {
  29000. delete(m.stage_messages, ids[i])
  29001. m.removedstage_messages[ids[i]] = struct{}{}
  29002. }
  29003. }
  29004. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  29005. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  29006. for id := range m.removedstage_messages {
  29007. ids = append(ids, id)
  29008. }
  29009. return
  29010. }
  29011. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  29012. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  29013. for id := range m.stage_messages {
  29014. ids = append(ids, id)
  29015. }
  29016. return
  29017. }
  29018. // ResetStageMessages resets all changes to the "stage_messages" edge.
  29019. func (m *SopStageMutation) ResetStageMessages() {
  29020. m.stage_messages = nil
  29021. m.clearedstage_messages = false
  29022. m.removedstage_messages = nil
  29023. }
  29024. // Where appends a list predicates to the SopStageMutation builder.
  29025. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  29026. m.predicates = append(m.predicates, ps...)
  29027. }
  29028. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  29029. // users can use type-assertion to append predicates that do not depend on any generated package.
  29030. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  29031. p := make([]predicate.SopStage, len(ps))
  29032. for i := range ps {
  29033. p[i] = ps[i]
  29034. }
  29035. m.Where(p...)
  29036. }
  29037. // Op returns the operation name.
  29038. func (m *SopStageMutation) Op() Op {
  29039. return m.op
  29040. }
  29041. // SetOp allows setting the mutation operation.
  29042. func (m *SopStageMutation) SetOp(op Op) {
  29043. m.op = op
  29044. }
  29045. // Type returns the node type of this mutation (SopStage).
  29046. func (m *SopStageMutation) Type() string {
  29047. return m.typ
  29048. }
  29049. // Fields returns all fields that were changed during this mutation. Note that in
  29050. // order to get all numeric fields that were incremented/decremented, call
  29051. // AddedFields().
  29052. func (m *SopStageMutation) Fields() []string {
  29053. fields := make([]string, 0, 14)
  29054. if m.created_at != nil {
  29055. fields = append(fields, sopstage.FieldCreatedAt)
  29056. }
  29057. if m.updated_at != nil {
  29058. fields = append(fields, sopstage.FieldUpdatedAt)
  29059. }
  29060. if m.status != nil {
  29061. fields = append(fields, sopstage.FieldStatus)
  29062. }
  29063. if m.deleted_at != nil {
  29064. fields = append(fields, sopstage.FieldDeletedAt)
  29065. }
  29066. if m.sop_task != nil {
  29067. fields = append(fields, sopstage.FieldTaskID)
  29068. }
  29069. if m.name != nil {
  29070. fields = append(fields, sopstage.FieldName)
  29071. }
  29072. if m.condition_type != nil {
  29073. fields = append(fields, sopstage.FieldConditionType)
  29074. }
  29075. if m.condition_operator != nil {
  29076. fields = append(fields, sopstage.FieldConditionOperator)
  29077. }
  29078. if m.condition_list != nil {
  29079. fields = append(fields, sopstage.FieldConditionList)
  29080. }
  29081. if m.action_message != nil {
  29082. fields = append(fields, sopstage.FieldActionMessage)
  29083. }
  29084. if m.action_label_add != nil {
  29085. fields = append(fields, sopstage.FieldActionLabelAdd)
  29086. }
  29087. if m.action_label_del != nil {
  29088. fields = append(fields, sopstage.FieldActionLabelDel)
  29089. }
  29090. if m.action_forward != nil {
  29091. fields = append(fields, sopstage.FieldActionForward)
  29092. }
  29093. if m.index_sort != nil {
  29094. fields = append(fields, sopstage.FieldIndexSort)
  29095. }
  29096. return fields
  29097. }
  29098. // Field returns the value of a field with the given name. The second boolean
  29099. // return value indicates that this field was not set, or was not defined in the
  29100. // schema.
  29101. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  29102. switch name {
  29103. case sopstage.FieldCreatedAt:
  29104. return m.CreatedAt()
  29105. case sopstage.FieldUpdatedAt:
  29106. return m.UpdatedAt()
  29107. case sopstage.FieldStatus:
  29108. return m.Status()
  29109. case sopstage.FieldDeletedAt:
  29110. return m.DeletedAt()
  29111. case sopstage.FieldTaskID:
  29112. return m.TaskID()
  29113. case sopstage.FieldName:
  29114. return m.Name()
  29115. case sopstage.FieldConditionType:
  29116. return m.ConditionType()
  29117. case sopstage.FieldConditionOperator:
  29118. return m.ConditionOperator()
  29119. case sopstage.FieldConditionList:
  29120. return m.ConditionList()
  29121. case sopstage.FieldActionMessage:
  29122. return m.ActionMessage()
  29123. case sopstage.FieldActionLabelAdd:
  29124. return m.ActionLabelAdd()
  29125. case sopstage.FieldActionLabelDel:
  29126. return m.ActionLabelDel()
  29127. case sopstage.FieldActionForward:
  29128. return m.ActionForward()
  29129. case sopstage.FieldIndexSort:
  29130. return m.IndexSort()
  29131. }
  29132. return nil, false
  29133. }
  29134. // OldField returns the old value of the field from the database. An error is
  29135. // returned if the mutation operation is not UpdateOne, or the query to the
  29136. // database failed.
  29137. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29138. switch name {
  29139. case sopstage.FieldCreatedAt:
  29140. return m.OldCreatedAt(ctx)
  29141. case sopstage.FieldUpdatedAt:
  29142. return m.OldUpdatedAt(ctx)
  29143. case sopstage.FieldStatus:
  29144. return m.OldStatus(ctx)
  29145. case sopstage.FieldDeletedAt:
  29146. return m.OldDeletedAt(ctx)
  29147. case sopstage.FieldTaskID:
  29148. return m.OldTaskID(ctx)
  29149. case sopstage.FieldName:
  29150. return m.OldName(ctx)
  29151. case sopstage.FieldConditionType:
  29152. return m.OldConditionType(ctx)
  29153. case sopstage.FieldConditionOperator:
  29154. return m.OldConditionOperator(ctx)
  29155. case sopstage.FieldConditionList:
  29156. return m.OldConditionList(ctx)
  29157. case sopstage.FieldActionMessage:
  29158. return m.OldActionMessage(ctx)
  29159. case sopstage.FieldActionLabelAdd:
  29160. return m.OldActionLabelAdd(ctx)
  29161. case sopstage.FieldActionLabelDel:
  29162. return m.OldActionLabelDel(ctx)
  29163. case sopstage.FieldActionForward:
  29164. return m.OldActionForward(ctx)
  29165. case sopstage.FieldIndexSort:
  29166. return m.OldIndexSort(ctx)
  29167. }
  29168. return nil, fmt.Errorf("unknown SopStage field %s", name)
  29169. }
  29170. // SetField sets the value of a field with the given name. It returns an error if
  29171. // the field is not defined in the schema, or if the type mismatched the field
  29172. // type.
  29173. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  29174. switch name {
  29175. case sopstage.FieldCreatedAt:
  29176. v, ok := value.(time.Time)
  29177. if !ok {
  29178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29179. }
  29180. m.SetCreatedAt(v)
  29181. return nil
  29182. case sopstage.FieldUpdatedAt:
  29183. v, ok := value.(time.Time)
  29184. if !ok {
  29185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29186. }
  29187. m.SetUpdatedAt(v)
  29188. return nil
  29189. case sopstage.FieldStatus:
  29190. v, ok := value.(uint8)
  29191. if !ok {
  29192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29193. }
  29194. m.SetStatus(v)
  29195. return nil
  29196. case sopstage.FieldDeletedAt:
  29197. v, ok := value.(time.Time)
  29198. if !ok {
  29199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29200. }
  29201. m.SetDeletedAt(v)
  29202. return nil
  29203. case sopstage.FieldTaskID:
  29204. v, ok := value.(uint64)
  29205. if !ok {
  29206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29207. }
  29208. m.SetTaskID(v)
  29209. return nil
  29210. case sopstage.FieldName:
  29211. v, ok := value.(string)
  29212. if !ok {
  29213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29214. }
  29215. m.SetName(v)
  29216. return nil
  29217. case sopstage.FieldConditionType:
  29218. v, ok := value.(int)
  29219. if !ok {
  29220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29221. }
  29222. m.SetConditionType(v)
  29223. return nil
  29224. case sopstage.FieldConditionOperator:
  29225. v, ok := value.(int)
  29226. if !ok {
  29227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29228. }
  29229. m.SetConditionOperator(v)
  29230. return nil
  29231. case sopstage.FieldConditionList:
  29232. v, ok := value.([]custom_types.Condition)
  29233. if !ok {
  29234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29235. }
  29236. m.SetConditionList(v)
  29237. return nil
  29238. case sopstage.FieldActionMessage:
  29239. v, ok := value.([]custom_types.Action)
  29240. if !ok {
  29241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29242. }
  29243. m.SetActionMessage(v)
  29244. return nil
  29245. case sopstage.FieldActionLabelAdd:
  29246. v, ok := value.([]uint64)
  29247. if !ok {
  29248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29249. }
  29250. m.SetActionLabelAdd(v)
  29251. return nil
  29252. case sopstage.FieldActionLabelDel:
  29253. v, ok := value.([]uint64)
  29254. if !ok {
  29255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29256. }
  29257. m.SetActionLabelDel(v)
  29258. return nil
  29259. case sopstage.FieldActionForward:
  29260. v, ok := value.(*custom_types.ActionForward)
  29261. if !ok {
  29262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29263. }
  29264. m.SetActionForward(v)
  29265. return nil
  29266. case sopstage.FieldIndexSort:
  29267. v, ok := value.(int)
  29268. if !ok {
  29269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29270. }
  29271. m.SetIndexSort(v)
  29272. return nil
  29273. }
  29274. return fmt.Errorf("unknown SopStage field %s", name)
  29275. }
  29276. // AddedFields returns all numeric fields that were incremented/decremented during
  29277. // this mutation.
  29278. func (m *SopStageMutation) AddedFields() []string {
  29279. var fields []string
  29280. if m.addstatus != nil {
  29281. fields = append(fields, sopstage.FieldStatus)
  29282. }
  29283. if m.addcondition_type != nil {
  29284. fields = append(fields, sopstage.FieldConditionType)
  29285. }
  29286. if m.addcondition_operator != nil {
  29287. fields = append(fields, sopstage.FieldConditionOperator)
  29288. }
  29289. if m.addindex_sort != nil {
  29290. fields = append(fields, sopstage.FieldIndexSort)
  29291. }
  29292. return fields
  29293. }
  29294. // AddedField returns the numeric value that was incremented/decremented on a field
  29295. // with the given name. The second boolean return value indicates that this field
  29296. // was not set, or was not defined in the schema.
  29297. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  29298. switch name {
  29299. case sopstage.FieldStatus:
  29300. return m.AddedStatus()
  29301. case sopstage.FieldConditionType:
  29302. return m.AddedConditionType()
  29303. case sopstage.FieldConditionOperator:
  29304. return m.AddedConditionOperator()
  29305. case sopstage.FieldIndexSort:
  29306. return m.AddedIndexSort()
  29307. }
  29308. return nil, false
  29309. }
  29310. // AddField adds the value to the field with the given name. It returns an error if
  29311. // the field is not defined in the schema, or if the type mismatched the field
  29312. // type.
  29313. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  29314. switch name {
  29315. case sopstage.FieldStatus:
  29316. v, ok := value.(int8)
  29317. if !ok {
  29318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29319. }
  29320. m.AddStatus(v)
  29321. return nil
  29322. case sopstage.FieldConditionType:
  29323. v, ok := value.(int)
  29324. if !ok {
  29325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29326. }
  29327. m.AddConditionType(v)
  29328. return nil
  29329. case sopstage.FieldConditionOperator:
  29330. v, ok := value.(int)
  29331. if !ok {
  29332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29333. }
  29334. m.AddConditionOperator(v)
  29335. return nil
  29336. case sopstage.FieldIndexSort:
  29337. v, ok := value.(int)
  29338. if !ok {
  29339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29340. }
  29341. m.AddIndexSort(v)
  29342. return nil
  29343. }
  29344. return fmt.Errorf("unknown SopStage numeric field %s", name)
  29345. }
  29346. // ClearedFields returns all nullable fields that were cleared during this
  29347. // mutation.
  29348. func (m *SopStageMutation) ClearedFields() []string {
  29349. var fields []string
  29350. if m.FieldCleared(sopstage.FieldStatus) {
  29351. fields = append(fields, sopstage.FieldStatus)
  29352. }
  29353. if m.FieldCleared(sopstage.FieldDeletedAt) {
  29354. fields = append(fields, sopstage.FieldDeletedAt)
  29355. }
  29356. if m.FieldCleared(sopstage.FieldActionMessage) {
  29357. fields = append(fields, sopstage.FieldActionMessage)
  29358. }
  29359. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  29360. fields = append(fields, sopstage.FieldActionLabelAdd)
  29361. }
  29362. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  29363. fields = append(fields, sopstage.FieldActionLabelDel)
  29364. }
  29365. if m.FieldCleared(sopstage.FieldActionForward) {
  29366. fields = append(fields, sopstage.FieldActionForward)
  29367. }
  29368. if m.FieldCleared(sopstage.FieldIndexSort) {
  29369. fields = append(fields, sopstage.FieldIndexSort)
  29370. }
  29371. return fields
  29372. }
  29373. // FieldCleared returns a boolean indicating if a field with the given name was
  29374. // cleared in this mutation.
  29375. func (m *SopStageMutation) FieldCleared(name string) bool {
  29376. _, ok := m.clearedFields[name]
  29377. return ok
  29378. }
  29379. // ClearField clears the value of the field with the given name. It returns an
  29380. // error if the field is not defined in the schema.
  29381. func (m *SopStageMutation) ClearField(name string) error {
  29382. switch name {
  29383. case sopstage.FieldStatus:
  29384. m.ClearStatus()
  29385. return nil
  29386. case sopstage.FieldDeletedAt:
  29387. m.ClearDeletedAt()
  29388. return nil
  29389. case sopstage.FieldActionMessage:
  29390. m.ClearActionMessage()
  29391. return nil
  29392. case sopstage.FieldActionLabelAdd:
  29393. m.ClearActionLabelAdd()
  29394. return nil
  29395. case sopstage.FieldActionLabelDel:
  29396. m.ClearActionLabelDel()
  29397. return nil
  29398. case sopstage.FieldActionForward:
  29399. m.ClearActionForward()
  29400. return nil
  29401. case sopstage.FieldIndexSort:
  29402. m.ClearIndexSort()
  29403. return nil
  29404. }
  29405. return fmt.Errorf("unknown SopStage nullable field %s", name)
  29406. }
  29407. // ResetField resets all changes in the mutation for the field with the given name.
  29408. // It returns an error if the field is not defined in the schema.
  29409. func (m *SopStageMutation) ResetField(name string) error {
  29410. switch name {
  29411. case sopstage.FieldCreatedAt:
  29412. m.ResetCreatedAt()
  29413. return nil
  29414. case sopstage.FieldUpdatedAt:
  29415. m.ResetUpdatedAt()
  29416. return nil
  29417. case sopstage.FieldStatus:
  29418. m.ResetStatus()
  29419. return nil
  29420. case sopstage.FieldDeletedAt:
  29421. m.ResetDeletedAt()
  29422. return nil
  29423. case sopstage.FieldTaskID:
  29424. m.ResetTaskID()
  29425. return nil
  29426. case sopstage.FieldName:
  29427. m.ResetName()
  29428. return nil
  29429. case sopstage.FieldConditionType:
  29430. m.ResetConditionType()
  29431. return nil
  29432. case sopstage.FieldConditionOperator:
  29433. m.ResetConditionOperator()
  29434. return nil
  29435. case sopstage.FieldConditionList:
  29436. m.ResetConditionList()
  29437. return nil
  29438. case sopstage.FieldActionMessage:
  29439. m.ResetActionMessage()
  29440. return nil
  29441. case sopstage.FieldActionLabelAdd:
  29442. m.ResetActionLabelAdd()
  29443. return nil
  29444. case sopstage.FieldActionLabelDel:
  29445. m.ResetActionLabelDel()
  29446. return nil
  29447. case sopstage.FieldActionForward:
  29448. m.ResetActionForward()
  29449. return nil
  29450. case sopstage.FieldIndexSort:
  29451. m.ResetIndexSort()
  29452. return nil
  29453. }
  29454. return fmt.Errorf("unknown SopStage field %s", name)
  29455. }
  29456. // AddedEdges returns all edge names that were set/added in this mutation.
  29457. func (m *SopStageMutation) AddedEdges() []string {
  29458. edges := make([]string, 0, 3)
  29459. if m.sop_task != nil {
  29460. edges = append(edges, sopstage.EdgeSopTask)
  29461. }
  29462. if m.stage_nodes != nil {
  29463. edges = append(edges, sopstage.EdgeStageNodes)
  29464. }
  29465. if m.stage_messages != nil {
  29466. edges = append(edges, sopstage.EdgeStageMessages)
  29467. }
  29468. return edges
  29469. }
  29470. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29471. // name in this mutation.
  29472. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  29473. switch name {
  29474. case sopstage.EdgeSopTask:
  29475. if id := m.sop_task; id != nil {
  29476. return []ent.Value{*id}
  29477. }
  29478. case sopstage.EdgeStageNodes:
  29479. ids := make([]ent.Value, 0, len(m.stage_nodes))
  29480. for id := range m.stage_nodes {
  29481. ids = append(ids, id)
  29482. }
  29483. return ids
  29484. case sopstage.EdgeStageMessages:
  29485. ids := make([]ent.Value, 0, len(m.stage_messages))
  29486. for id := range m.stage_messages {
  29487. ids = append(ids, id)
  29488. }
  29489. return ids
  29490. }
  29491. return nil
  29492. }
  29493. // RemovedEdges returns all edge names that were removed in this mutation.
  29494. func (m *SopStageMutation) RemovedEdges() []string {
  29495. edges := make([]string, 0, 3)
  29496. if m.removedstage_nodes != nil {
  29497. edges = append(edges, sopstage.EdgeStageNodes)
  29498. }
  29499. if m.removedstage_messages != nil {
  29500. edges = append(edges, sopstage.EdgeStageMessages)
  29501. }
  29502. return edges
  29503. }
  29504. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29505. // the given name in this mutation.
  29506. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  29507. switch name {
  29508. case sopstage.EdgeStageNodes:
  29509. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  29510. for id := range m.removedstage_nodes {
  29511. ids = append(ids, id)
  29512. }
  29513. return ids
  29514. case sopstage.EdgeStageMessages:
  29515. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  29516. for id := range m.removedstage_messages {
  29517. ids = append(ids, id)
  29518. }
  29519. return ids
  29520. }
  29521. return nil
  29522. }
  29523. // ClearedEdges returns all edge names that were cleared in this mutation.
  29524. func (m *SopStageMutation) ClearedEdges() []string {
  29525. edges := make([]string, 0, 3)
  29526. if m.clearedsop_task {
  29527. edges = append(edges, sopstage.EdgeSopTask)
  29528. }
  29529. if m.clearedstage_nodes {
  29530. edges = append(edges, sopstage.EdgeStageNodes)
  29531. }
  29532. if m.clearedstage_messages {
  29533. edges = append(edges, sopstage.EdgeStageMessages)
  29534. }
  29535. return edges
  29536. }
  29537. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29538. // was cleared in this mutation.
  29539. func (m *SopStageMutation) EdgeCleared(name string) bool {
  29540. switch name {
  29541. case sopstage.EdgeSopTask:
  29542. return m.clearedsop_task
  29543. case sopstage.EdgeStageNodes:
  29544. return m.clearedstage_nodes
  29545. case sopstage.EdgeStageMessages:
  29546. return m.clearedstage_messages
  29547. }
  29548. return false
  29549. }
  29550. // ClearEdge clears the value of the edge with the given name. It returns an error
  29551. // if that edge is not defined in the schema.
  29552. func (m *SopStageMutation) ClearEdge(name string) error {
  29553. switch name {
  29554. case sopstage.EdgeSopTask:
  29555. m.ClearSopTask()
  29556. return nil
  29557. }
  29558. return fmt.Errorf("unknown SopStage unique edge %s", name)
  29559. }
  29560. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29561. // It returns an error if the edge is not defined in the schema.
  29562. func (m *SopStageMutation) ResetEdge(name string) error {
  29563. switch name {
  29564. case sopstage.EdgeSopTask:
  29565. m.ResetSopTask()
  29566. return nil
  29567. case sopstage.EdgeStageNodes:
  29568. m.ResetStageNodes()
  29569. return nil
  29570. case sopstage.EdgeStageMessages:
  29571. m.ResetStageMessages()
  29572. return nil
  29573. }
  29574. return fmt.Errorf("unknown SopStage edge %s", name)
  29575. }
  29576. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  29577. type SopTaskMutation struct {
  29578. config
  29579. op Op
  29580. typ string
  29581. id *uint64
  29582. created_at *time.Time
  29583. updated_at *time.Time
  29584. status *uint8
  29585. addstatus *int8
  29586. deleted_at *time.Time
  29587. name *string
  29588. bot_wxid_list *[]string
  29589. appendbot_wxid_list []string
  29590. _type *int
  29591. add_type *int
  29592. plan_start_time *time.Time
  29593. plan_end_time *time.Time
  29594. creator_id *string
  29595. organization_id *uint64
  29596. addorganization_id *int64
  29597. token *[]string
  29598. appendtoken []string
  29599. clearedFields map[string]struct{}
  29600. task_stages map[uint64]struct{}
  29601. removedtask_stages map[uint64]struct{}
  29602. clearedtask_stages bool
  29603. done bool
  29604. oldValue func(context.Context) (*SopTask, error)
  29605. predicates []predicate.SopTask
  29606. }
  29607. var _ ent.Mutation = (*SopTaskMutation)(nil)
  29608. // soptaskOption allows management of the mutation configuration using functional options.
  29609. type soptaskOption func(*SopTaskMutation)
  29610. // newSopTaskMutation creates new mutation for the SopTask entity.
  29611. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  29612. m := &SopTaskMutation{
  29613. config: c,
  29614. op: op,
  29615. typ: TypeSopTask,
  29616. clearedFields: make(map[string]struct{}),
  29617. }
  29618. for _, opt := range opts {
  29619. opt(m)
  29620. }
  29621. return m
  29622. }
  29623. // withSopTaskID sets the ID field of the mutation.
  29624. func withSopTaskID(id uint64) soptaskOption {
  29625. return func(m *SopTaskMutation) {
  29626. var (
  29627. err error
  29628. once sync.Once
  29629. value *SopTask
  29630. )
  29631. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  29632. once.Do(func() {
  29633. if m.done {
  29634. err = errors.New("querying old values post mutation is not allowed")
  29635. } else {
  29636. value, err = m.Client().SopTask.Get(ctx, id)
  29637. }
  29638. })
  29639. return value, err
  29640. }
  29641. m.id = &id
  29642. }
  29643. }
  29644. // withSopTask sets the old SopTask of the mutation.
  29645. func withSopTask(node *SopTask) soptaskOption {
  29646. return func(m *SopTaskMutation) {
  29647. m.oldValue = func(context.Context) (*SopTask, error) {
  29648. return node, nil
  29649. }
  29650. m.id = &node.ID
  29651. }
  29652. }
  29653. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29654. // executed in a transaction (ent.Tx), a transactional client is returned.
  29655. func (m SopTaskMutation) Client() *Client {
  29656. client := &Client{config: m.config}
  29657. client.init()
  29658. return client
  29659. }
  29660. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29661. // it returns an error otherwise.
  29662. func (m SopTaskMutation) Tx() (*Tx, error) {
  29663. if _, ok := m.driver.(*txDriver); !ok {
  29664. return nil, errors.New("ent: mutation is not running in a transaction")
  29665. }
  29666. tx := &Tx{config: m.config}
  29667. tx.init()
  29668. return tx, nil
  29669. }
  29670. // SetID sets the value of the id field. Note that this
  29671. // operation is only accepted on creation of SopTask entities.
  29672. func (m *SopTaskMutation) SetID(id uint64) {
  29673. m.id = &id
  29674. }
  29675. // ID returns the ID value in the mutation. Note that the ID is only available
  29676. // if it was provided to the builder or after it was returned from the database.
  29677. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  29678. if m.id == nil {
  29679. return
  29680. }
  29681. return *m.id, true
  29682. }
  29683. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29684. // That means, if the mutation is applied within a transaction with an isolation level such
  29685. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29686. // or updated by the mutation.
  29687. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  29688. switch {
  29689. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29690. id, exists := m.ID()
  29691. if exists {
  29692. return []uint64{id}, nil
  29693. }
  29694. fallthrough
  29695. case m.op.Is(OpUpdate | OpDelete):
  29696. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  29697. default:
  29698. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29699. }
  29700. }
  29701. // SetCreatedAt sets the "created_at" field.
  29702. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  29703. m.created_at = &t
  29704. }
  29705. // CreatedAt returns the value of the "created_at" field in the mutation.
  29706. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  29707. v := m.created_at
  29708. if v == nil {
  29709. return
  29710. }
  29711. return *v, true
  29712. }
  29713. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  29714. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29716. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29717. if !m.op.Is(OpUpdateOne) {
  29718. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29719. }
  29720. if m.id == nil || m.oldValue == nil {
  29721. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29722. }
  29723. oldValue, err := m.oldValue(ctx)
  29724. if err != nil {
  29725. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29726. }
  29727. return oldValue.CreatedAt, nil
  29728. }
  29729. // ResetCreatedAt resets all changes to the "created_at" field.
  29730. func (m *SopTaskMutation) ResetCreatedAt() {
  29731. m.created_at = nil
  29732. }
  29733. // SetUpdatedAt sets the "updated_at" field.
  29734. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  29735. m.updated_at = &t
  29736. }
  29737. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29738. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  29739. v := m.updated_at
  29740. if v == nil {
  29741. return
  29742. }
  29743. return *v, true
  29744. }
  29745. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  29746. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29748. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29749. if !m.op.Is(OpUpdateOne) {
  29750. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29751. }
  29752. if m.id == nil || m.oldValue == nil {
  29753. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29754. }
  29755. oldValue, err := m.oldValue(ctx)
  29756. if err != nil {
  29757. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29758. }
  29759. return oldValue.UpdatedAt, nil
  29760. }
  29761. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29762. func (m *SopTaskMutation) ResetUpdatedAt() {
  29763. m.updated_at = nil
  29764. }
  29765. // SetStatus sets the "status" field.
  29766. func (m *SopTaskMutation) SetStatus(u uint8) {
  29767. m.status = &u
  29768. m.addstatus = nil
  29769. }
  29770. // Status returns the value of the "status" field in the mutation.
  29771. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  29772. v := m.status
  29773. if v == nil {
  29774. return
  29775. }
  29776. return *v, true
  29777. }
  29778. // OldStatus returns the old "status" field's value of the SopTask entity.
  29779. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29781. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29782. if !m.op.Is(OpUpdateOne) {
  29783. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29784. }
  29785. if m.id == nil || m.oldValue == nil {
  29786. return v, errors.New("OldStatus requires an ID field in the mutation")
  29787. }
  29788. oldValue, err := m.oldValue(ctx)
  29789. if err != nil {
  29790. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29791. }
  29792. return oldValue.Status, nil
  29793. }
  29794. // AddStatus adds u to the "status" field.
  29795. func (m *SopTaskMutation) AddStatus(u int8) {
  29796. if m.addstatus != nil {
  29797. *m.addstatus += u
  29798. } else {
  29799. m.addstatus = &u
  29800. }
  29801. }
  29802. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29803. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  29804. v := m.addstatus
  29805. if v == nil {
  29806. return
  29807. }
  29808. return *v, true
  29809. }
  29810. // ClearStatus clears the value of the "status" field.
  29811. func (m *SopTaskMutation) ClearStatus() {
  29812. m.status = nil
  29813. m.addstatus = nil
  29814. m.clearedFields[soptask.FieldStatus] = struct{}{}
  29815. }
  29816. // StatusCleared returns if the "status" field was cleared in this mutation.
  29817. func (m *SopTaskMutation) StatusCleared() bool {
  29818. _, ok := m.clearedFields[soptask.FieldStatus]
  29819. return ok
  29820. }
  29821. // ResetStatus resets all changes to the "status" field.
  29822. func (m *SopTaskMutation) ResetStatus() {
  29823. m.status = nil
  29824. m.addstatus = nil
  29825. delete(m.clearedFields, soptask.FieldStatus)
  29826. }
  29827. // SetDeletedAt sets the "deleted_at" field.
  29828. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  29829. m.deleted_at = &t
  29830. }
  29831. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29832. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  29833. v := m.deleted_at
  29834. if v == nil {
  29835. return
  29836. }
  29837. return *v, true
  29838. }
  29839. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  29840. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29842. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29843. if !m.op.Is(OpUpdateOne) {
  29844. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29845. }
  29846. if m.id == nil || m.oldValue == nil {
  29847. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29848. }
  29849. oldValue, err := m.oldValue(ctx)
  29850. if err != nil {
  29851. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29852. }
  29853. return oldValue.DeletedAt, nil
  29854. }
  29855. // ClearDeletedAt clears the value of the "deleted_at" field.
  29856. func (m *SopTaskMutation) ClearDeletedAt() {
  29857. m.deleted_at = nil
  29858. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  29859. }
  29860. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29861. func (m *SopTaskMutation) DeletedAtCleared() bool {
  29862. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  29863. return ok
  29864. }
  29865. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29866. func (m *SopTaskMutation) ResetDeletedAt() {
  29867. m.deleted_at = nil
  29868. delete(m.clearedFields, soptask.FieldDeletedAt)
  29869. }
  29870. // SetName sets the "name" field.
  29871. func (m *SopTaskMutation) SetName(s string) {
  29872. m.name = &s
  29873. }
  29874. // Name returns the value of the "name" field in the mutation.
  29875. func (m *SopTaskMutation) Name() (r string, exists bool) {
  29876. v := m.name
  29877. if v == nil {
  29878. return
  29879. }
  29880. return *v, true
  29881. }
  29882. // OldName returns the old "name" field's value of the SopTask entity.
  29883. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29885. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  29886. if !m.op.Is(OpUpdateOne) {
  29887. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29888. }
  29889. if m.id == nil || m.oldValue == nil {
  29890. return v, errors.New("OldName requires an ID field in the mutation")
  29891. }
  29892. oldValue, err := m.oldValue(ctx)
  29893. if err != nil {
  29894. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29895. }
  29896. return oldValue.Name, nil
  29897. }
  29898. // ResetName resets all changes to the "name" field.
  29899. func (m *SopTaskMutation) ResetName() {
  29900. m.name = nil
  29901. }
  29902. // SetBotWxidList sets the "bot_wxid_list" field.
  29903. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  29904. m.bot_wxid_list = &s
  29905. m.appendbot_wxid_list = nil
  29906. }
  29907. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  29908. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  29909. v := m.bot_wxid_list
  29910. if v == nil {
  29911. return
  29912. }
  29913. return *v, true
  29914. }
  29915. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  29916. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29918. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  29919. if !m.op.Is(OpUpdateOne) {
  29920. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  29921. }
  29922. if m.id == nil || m.oldValue == nil {
  29923. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  29924. }
  29925. oldValue, err := m.oldValue(ctx)
  29926. if err != nil {
  29927. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  29928. }
  29929. return oldValue.BotWxidList, nil
  29930. }
  29931. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  29932. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  29933. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  29934. }
  29935. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  29936. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  29937. if len(m.appendbot_wxid_list) == 0 {
  29938. return nil, false
  29939. }
  29940. return m.appendbot_wxid_list, true
  29941. }
  29942. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  29943. func (m *SopTaskMutation) ClearBotWxidList() {
  29944. m.bot_wxid_list = nil
  29945. m.appendbot_wxid_list = nil
  29946. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  29947. }
  29948. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  29949. func (m *SopTaskMutation) BotWxidListCleared() bool {
  29950. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  29951. return ok
  29952. }
  29953. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  29954. func (m *SopTaskMutation) ResetBotWxidList() {
  29955. m.bot_wxid_list = nil
  29956. m.appendbot_wxid_list = nil
  29957. delete(m.clearedFields, soptask.FieldBotWxidList)
  29958. }
  29959. // SetType sets the "type" field.
  29960. func (m *SopTaskMutation) SetType(i int) {
  29961. m._type = &i
  29962. m.add_type = nil
  29963. }
  29964. // GetType returns the value of the "type" field in the mutation.
  29965. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  29966. v := m._type
  29967. if v == nil {
  29968. return
  29969. }
  29970. return *v, true
  29971. }
  29972. // OldType returns the old "type" field's value of the SopTask entity.
  29973. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29975. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  29976. if !m.op.Is(OpUpdateOne) {
  29977. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29978. }
  29979. if m.id == nil || m.oldValue == nil {
  29980. return v, errors.New("OldType requires an ID field in the mutation")
  29981. }
  29982. oldValue, err := m.oldValue(ctx)
  29983. if err != nil {
  29984. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29985. }
  29986. return oldValue.Type, nil
  29987. }
  29988. // AddType adds i to the "type" field.
  29989. func (m *SopTaskMutation) AddType(i int) {
  29990. if m.add_type != nil {
  29991. *m.add_type += i
  29992. } else {
  29993. m.add_type = &i
  29994. }
  29995. }
  29996. // AddedType returns the value that was added to the "type" field in this mutation.
  29997. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  29998. v := m.add_type
  29999. if v == nil {
  30000. return
  30001. }
  30002. return *v, true
  30003. }
  30004. // ResetType resets all changes to the "type" field.
  30005. func (m *SopTaskMutation) ResetType() {
  30006. m._type = nil
  30007. m.add_type = nil
  30008. }
  30009. // SetPlanStartTime sets the "plan_start_time" field.
  30010. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  30011. m.plan_start_time = &t
  30012. }
  30013. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  30014. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  30015. v := m.plan_start_time
  30016. if v == nil {
  30017. return
  30018. }
  30019. return *v, true
  30020. }
  30021. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  30022. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30024. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  30025. if !m.op.Is(OpUpdateOne) {
  30026. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  30027. }
  30028. if m.id == nil || m.oldValue == nil {
  30029. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  30030. }
  30031. oldValue, err := m.oldValue(ctx)
  30032. if err != nil {
  30033. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  30034. }
  30035. return oldValue.PlanStartTime, nil
  30036. }
  30037. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  30038. func (m *SopTaskMutation) ClearPlanStartTime() {
  30039. m.plan_start_time = nil
  30040. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  30041. }
  30042. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  30043. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  30044. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  30045. return ok
  30046. }
  30047. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  30048. func (m *SopTaskMutation) ResetPlanStartTime() {
  30049. m.plan_start_time = nil
  30050. delete(m.clearedFields, soptask.FieldPlanStartTime)
  30051. }
  30052. // SetPlanEndTime sets the "plan_end_time" field.
  30053. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  30054. m.plan_end_time = &t
  30055. }
  30056. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  30057. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  30058. v := m.plan_end_time
  30059. if v == nil {
  30060. return
  30061. }
  30062. return *v, true
  30063. }
  30064. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  30065. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30067. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  30068. if !m.op.Is(OpUpdateOne) {
  30069. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  30070. }
  30071. if m.id == nil || m.oldValue == nil {
  30072. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  30073. }
  30074. oldValue, err := m.oldValue(ctx)
  30075. if err != nil {
  30076. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  30077. }
  30078. return oldValue.PlanEndTime, nil
  30079. }
  30080. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  30081. func (m *SopTaskMutation) ClearPlanEndTime() {
  30082. m.plan_end_time = nil
  30083. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  30084. }
  30085. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  30086. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  30087. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  30088. return ok
  30089. }
  30090. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  30091. func (m *SopTaskMutation) ResetPlanEndTime() {
  30092. m.plan_end_time = nil
  30093. delete(m.clearedFields, soptask.FieldPlanEndTime)
  30094. }
  30095. // SetCreatorID sets the "creator_id" field.
  30096. func (m *SopTaskMutation) SetCreatorID(s string) {
  30097. m.creator_id = &s
  30098. }
  30099. // CreatorID returns the value of the "creator_id" field in the mutation.
  30100. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  30101. v := m.creator_id
  30102. if v == nil {
  30103. return
  30104. }
  30105. return *v, true
  30106. }
  30107. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  30108. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30110. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  30111. if !m.op.Is(OpUpdateOne) {
  30112. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  30113. }
  30114. if m.id == nil || m.oldValue == nil {
  30115. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  30116. }
  30117. oldValue, err := m.oldValue(ctx)
  30118. if err != nil {
  30119. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  30120. }
  30121. return oldValue.CreatorID, nil
  30122. }
  30123. // ClearCreatorID clears the value of the "creator_id" field.
  30124. func (m *SopTaskMutation) ClearCreatorID() {
  30125. m.creator_id = nil
  30126. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  30127. }
  30128. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  30129. func (m *SopTaskMutation) CreatorIDCleared() bool {
  30130. _, ok := m.clearedFields[soptask.FieldCreatorID]
  30131. return ok
  30132. }
  30133. // ResetCreatorID resets all changes to the "creator_id" field.
  30134. func (m *SopTaskMutation) ResetCreatorID() {
  30135. m.creator_id = nil
  30136. delete(m.clearedFields, soptask.FieldCreatorID)
  30137. }
  30138. // SetOrganizationID sets the "organization_id" field.
  30139. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  30140. m.organization_id = &u
  30141. m.addorganization_id = nil
  30142. }
  30143. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30144. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  30145. v := m.organization_id
  30146. if v == nil {
  30147. return
  30148. }
  30149. return *v, true
  30150. }
  30151. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  30152. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30154. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30155. if !m.op.Is(OpUpdateOne) {
  30156. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30157. }
  30158. if m.id == nil || m.oldValue == nil {
  30159. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30160. }
  30161. oldValue, err := m.oldValue(ctx)
  30162. if err != nil {
  30163. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30164. }
  30165. return oldValue.OrganizationID, nil
  30166. }
  30167. // AddOrganizationID adds u to the "organization_id" field.
  30168. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  30169. if m.addorganization_id != nil {
  30170. *m.addorganization_id += u
  30171. } else {
  30172. m.addorganization_id = &u
  30173. }
  30174. }
  30175. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30176. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  30177. v := m.addorganization_id
  30178. if v == nil {
  30179. return
  30180. }
  30181. return *v, true
  30182. }
  30183. // ClearOrganizationID clears the value of the "organization_id" field.
  30184. func (m *SopTaskMutation) ClearOrganizationID() {
  30185. m.organization_id = nil
  30186. m.addorganization_id = nil
  30187. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  30188. }
  30189. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30190. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  30191. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  30192. return ok
  30193. }
  30194. // ResetOrganizationID resets all changes to the "organization_id" field.
  30195. func (m *SopTaskMutation) ResetOrganizationID() {
  30196. m.organization_id = nil
  30197. m.addorganization_id = nil
  30198. delete(m.clearedFields, soptask.FieldOrganizationID)
  30199. }
  30200. // SetToken sets the "token" field.
  30201. func (m *SopTaskMutation) SetToken(s []string) {
  30202. m.token = &s
  30203. m.appendtoken = nil
  30204. }
  30205. // Token returns the value of the "token" field in the mutation.
  30206. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  30207. v := m.token
  30208. if v == nil {
  30209. return
  30210. }
  30211. return *v, true
  30212. }
  30213. // OldToken returns the old "token" field's value of the SopTask entity.
  30214. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30216. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  30217. if !m.op.Is(OpUpdateOne) {
  30218. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30219. }
  30220. if m.id == nil || m.oldValue == nil {
  30221. return v, errors.New("OldToken requires an ID field in the mutation")
  30222. }
  30223. oldValue, err := m.oldValue(ctx)
  30224. if err != nil {
  30225. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30226. }
  30227. return oldValue.Token, nil
  30228. }
  30229. // AppendToken adds s to the "token" field.
  30230. func (m *SopTaskMutation) AppendToken(s []string) {
  30231. m.appendtoken = append(m.appendtoken, s...)
  30232. }
  30233. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  30234. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  30235. if len(m.appendtoken) == 0 {
  30236. return nil, false
  30237. }
  30238. return m.appendtoken, true
  30239. }
  30240. // ClearToken clears the value of the "token" field.
  30241. func (m *SopTaskMutation) ClearToken() {
  30242. m.token = nil
  30243. m.appendtoken = nil
  30244. m.clearedFields[soptask.FieldToken] = struct{}{}
  30245. }
  30246. // TokenCleared returns if the "token" field was cleared in this mutation.
  30247. func (m *SopTaskMutation) TokenCleared() bool {
  30248. _, ok := m.clearedFields[soptask.FieldToken]
  30249. return ok
  30250. }
  30251. // ResetToken resets all changes to the "token" field.
  30252. func (m *SopTaskMutation) ResetToken() {
  30253. m.token = nil
  30254. m.appendtoken = nil
  30255. delete(m.clearedFields, soptask.FieldToken)
  30256. }
  30257. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  30258. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  30259. if m.task_stages == nil {
  30260. m.task_stages = make(map[uint64]struct{})
  30261. }
  30262. for i := range ids {
  30263. m.task_stages[ids[i]] = struct{}{}
  30264. }
  30265. }
  30266. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  30267. func (m *SopTaskMutation) ClearTaskStages() {
  30268. m.clearedtask_stages = true
  30269. }
  30270. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  30271. func (m *SopTaskMutation) TaskStagesCleared() bool {
  30272. return m.clearedtask_stages
  30273. }
  30274. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  30275. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  30276. if m.removedtask_stages == nil {
  30277. m.removedtask_stages = make(map[uint64]struct{})
  30278. }
  30279. for i := range ids {
  30280. delete(m.task_stages, ids[i])
  30281. m.removedtask_stages[ids[i]] = struct{}{}
  30282. }
  30283. }
  30284. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  30285. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  30286. for id := range m.removedtask_stages {
  30287. ids = append(ids, id)
  30288. }
  30289. return
  30290. }
  30291. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  30292. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  30293. for id := range m.task_stages {
  30294. ids = append(ids, id)
  30295. }
  30296. return
  30297. }
  30298. // ResetTaskStages resets all changes to the "task_stages" edge.
  30299. func (m *SopTaskMutation) ResetTaskStages() {
  30300. m.task_stages = nil
  30301. m.clearedtask_stages = false
  30302. m.removedtask_stages = nil
  30303. }
  30304. // Where appends a list predicates to the SopTaskMutation builder.
  30305. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  30306. m.predicates = append(m.predicates, ps...)
  30307. }
  30308. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  30309. // users can use type-assertion to append predicates that do not depend on any generated package.
  30310. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  30311. p := make([]predicate.SopTask, len(ps))
  30312. for i := range ps {
  30313. p[i] = ps[i]
  30314. }
  30315. m.Where(p...)
  30316. }
  30317. // Op returns the operation name.
  30318. func (m *SopTaskMutation) Op() Op {
  30319. return m.op
  30320. }
  30321. // SetOp allows setting the mutation operation.
  30322. func (m *SopTaskMutation) SetOp(op Op) {
  30323. m.op = op
  30324. }
  30325. // Type returns the node type of this mutation (SopTask).
  30326. func (m *SopTaskMutation) Type() string {
  30327. return m.typ
  30328. }
  30329. // Fields returns all fields that were changed during this mutation. Note that in
  30330. // order to get all numeric fields that were incremented/decremented, call
  30331. // AddedFields().
  30332. func (m *SopTaskMutation) Fields() []string {
  30333. fields := make([]string, 0, 12)
  30334. if m.created_at != nil {
  30335. fields = append(fields, soptask.FieldCreatedAt)
  30336. }
  30337. if m.updated_at != nil {
  30338. fields = append(fields, soptask.FieldUpdatedAt)
  30339. }
  30340. if m.status != nil {
  30341. fields = append(fields, soptask.FieldStatus)
  30342. }
  30343. if m.deleted_at != nil {
  30344. fields = append(fields, soptask.FieldDeletedAt)
  30345. }
  30346. if m.name != nil {
  30347. fields = append(fields, soptask.FieldName)
  30348. }
  30349. if m.bot_wxid_list != nil {
  30350. fields = append(fields, soptask.FieldBotWxidList)
  30351. }
  30352. if m._type != nil {
  30353. fields = append(fields, soptask.FieldType)
  30354. }
  30355. if m.plan_start_time != nil {
  30356. fields = append(fields, soptask.FieldPlanStartTime)
  30357. }
  30358. if m.plan_end_time != nil {
  30359. fields = append(fields, soptask.FieldPlanEndTime)
  30360. }
  30361. if m.creator_id != nil {
  30362. fields = append(fields, soptask.FieldCreatorID)
  30363. }
  30364. if m.organization_id != nil {
  30365. fields = append(fields, soptask.FieldOrganizationID)
  30366. }
  30367. if m.token != nil {
  30368. fields = append(fields, soptask.FieldToken)
  30369. }
  30370. return fields
  30371. }
  30372. // Field returns the value of a field with the given name. The second boolean
  30373. // return value indicates that this field was not set, or was not defined in the
  30374. // schema.
  30375. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  30376. switch name {
  30377. case soptask.FieldCreatedAt:
  30378. return m.CreatedAt()
  30379. case soptask.FieldUpdatedAt:
  30380. return m.UpdatedAt()
  30381. case soptask.FieldStatus:
  30382. return m.Status()
  30383. case soptask.FieldDeletedAt:
  30384. return m.DeletedAt()
  30385. case soptask.FieldName:
  30386. return m.Name()
  30387. case soptask.FieldBotWxidList:
  30388. return m.BotWxidList()
  30389. case soptask.FieldType:
  30390. return m.GetType()
  30391. case soptask.FieldPlanStartTime:
  30392. return m.PlanStartTime()
  30393. case soptask.FieldPlanEndTime:
  30394. return m.PlanEndTime()
  30395. case soptask.FieldCreatorID:
  30396. return m.CreatorID()
  30397. case soptask.FieldOrganizationID:
  30398. return m.OrganizationID()
  30399. case soptask.FieldToken:
  30400. return m.Token()
  30401. }
  30402. return nil, false
  30403. }
  30404. // OldField returns the old value of the field from the database. An error is
  30405. // returned if the mutation operation is not UpdateOne, or the query to the
  30406. // database failed.
  30407. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30408. switch name {
  30409. case soptask.FieldCreatedAt:
  30410. return m.OldCreatedAt(ctx)
  30411. case soptask.FieldUpdatedAt:
  30412. return m.OldUpdatedAt(ctx)
  30413. case soptask.FieldStatus:
  30414. return m.OldStatus(ctx)
  30415. case soptask.FieldDeletedAt:
  30416. return m.OldDeletedAt(ctx)
  30417. case soptask.FieldName:
  30418. return m.OldName(ctx)
  30419. case soptask.FieldBotWxidList:
  30420. return m.OldBotWxidList(ctx)
  30421. case soptask.FieldType:
  30422. return m.OldType(ctx)
  30423. case soptask.FieldPlanStartTime:
  30424. return m.OldPlanStartTime(ctx)
  30425. case soptask.FieldPlanEndTime:
  30426. return m.OldPlanEndTime(ctx)
  30427. case soptask.FieldCreatorID:
  30428. return m.OldCreatorID(ctx)
  30429. case soptask.FieldOrganizationID:
  30430. return m.OldOrganizationID(ctx)
  30431. case soptask.FieldToken:
  30432. return m.OldToken(ctx)
  30433. }
  30434. return nil, fmt.Errorf("unknown SopTask field %s", name)
  30435. }
  30436. // SetField sets the value of a field with the given name. It returns an error if
  30437. // the field is not defined in the schema, or if the type mismatched the field
  30438. // type.
  30439. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  30440. switch name {
  30441. case soptask.FieldCreatedAt:
  30442. v, ok := value.(time.Time)
  30443. if !ok {
  30444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30445. }
  30446. m.SetCreatedAt(v)
  30447. return nil
  30448. case soptask.FieldUpdatedAt:
  30449. v, ok := value.(time.Time)
  30450. if !ok {
  30451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30452. }
  30453. m.SetUpdatedAt(v)
  30454. return nil
  30455. case soptask.FieldStatus:
  30456. v, ok := value.(uint8)
  30457. if !ok {
  30458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30459. }
  30460. m.SetStatus(v)
  30461. return nil
  30462. case soptask.FieldDeletedAt:
  30463. v, ok := value.(time.Time)
  30464. if !ok {
  30465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30466. }
  30467. m.SetDeletedAt(v)
  30468. return nil
  30469. case soptask.FieldName:
  30470. v, ok := value.(string)
  30471. if !ok {
  30472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30473. }
  30474. m.SetName(v)
  30475. return nil
  30476. case soptask.FieldBotWxidList:
  30477. v, ok := value.([]string)
  30478. if !ok {
  30479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30480. }
  30481. m.SetBotWxidList(v)
  30482. return nil
  30483. case soptask.FieldType:
  30484. v, ok := value.(int)
  30485. if !ok {
  30486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30487. }
  30488. m.SetType(v)
  30489. return nil
  30490. case soptask.FieldPlanStartTime:
  30491. v, ok := value.(time.Time)
  30492. if !ok {
  30493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30494. }
  30495. m.SetPlanStartTime(v)
  30496. return nil
  30497. case soptask.FieldPlanEndTime:
  30498. v, ok := value.(time.Time)
  30499. if !ok {
  30500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30501. }
  30502. m.SetPlanEndTime(v)
  30503. return nil
  30504. case soptask.FieldCreatorID:
  30505. v, ok := value.(string)
  30506. if !ok {
  30507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30508. }
  30509. m.SetCreatorID(v)
  30510. return nil
  30511. case soptask.FieldOrganizationID:
  30512. v, ok := value.(uint64)
  30513. if !ok {
  30514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30515. }
  30516. m.SetOrganizationID(v)
  30517. return nil
  30518. case soptask.FieldToken:
  30519. v, ok := value.([]string)
  30520. if !ok {
  30521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30522. }
  30523. m.SetToken(v)
  30524. return nil
  30525. }
  30526. return fmt.Errorf("unknown SopTask field %s", name)
  30527. }
  30528. // AddedFields returns all numeric fields that were incremented/decremented during
  30529. // this mutation.
  30530. func (m *SopTaskMutation) AddedFields() []string {
  30531. var fields []string
  30532. if m.addstatus != nil {
  30533. fields = append(fields, soptask.FieldStatus)
  30534. }
  30535. if m.add_type != nil {
  30536. fields = append(fields, soptask.FieldType)
  30537. }
  30538. if m.addorganization_id != nil {
  30539. fields = append(fields, soptask.FieldOrganizationID)
  30540. }
  30541. return fields
  30542. }
  30543. // AddedField returns the numeric value that was incremented/decremented on a field
  30544. // with the given name. The second boolean return value indicates that this field
  30545. // was not set, or was not defined in the schema.
  30546. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  30547. switch name {
  30548. case soptask.FieldStatus:
  30549. return m.AddedStatus()
  30550. case soptask.FieldType:
  30551. return m.AddedType()
  30552. case soptask.FieldOrganizationID:
  30553. return m.AddedOrganizationID()
  30554. }
  30555. return nil, false
  30556. }
  30557. // AddField adds the value to the field with the given name. It returns an error if
  30558. // the field is not defined in the schema, or if the type mismatched the field
  30559. // type.
  30560. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  30561. switch name {
  30562. case soptask.FieldStatus:
  30563. v, ok := value.(int8)
  30564. if !ok {
  30565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30566. }
  30567. m.AddStatus(v)
  30568. return nil
  30569. case soptask.FieldType:
  30570. v, ok := value.(int)
  30571. if !ok {
  30572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30573. }
  30574. m.AddType(v)
  30575. return nil
  30576. case soptask.FieldOrganizationID:
  30577. v, ok := value.(int64)
  30578. if !ok {
  30579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30580. }
  30581. m.AddOrganizationID(v)
  30582. return nil
  30583. }
  30584. return fmt.Errorf("unknown SopTask numeric field %s", name)
  30585. }
  30586. // ClearedFields returns all nullable fields that were cleared during this
  30587. // mutation.
  30588. func (m *SopTaskMutation) ClearedFields() []string {
  30589. var fields []string
  30590. if m.FieldCleared(soptask.FieldStatus) {
  30591. fields = append(fields, soptask.FieldStatus)
  30592. }
  30593. if m.FieldCleared(soptask.FieldDeletedAt) {
  30594. fields = append(fields, soptask.FieldDeletedAt)
  30595. }
  30596. if m.FieldCleared(soptask.FieldBotWxidList) {
  30597. fields = append(fields, soptask.FieldBotWxidList)
  30598. }
  30599. if m.FieldCleared(soptask.FieldPlanStartTime) {
  30600. fields = append(fields, soptask.FieldPlanStartTime)
  30601. }
  30602. if m.FieldCleared(soptask.FieldPlanEndTime) {
  30603. fields = append(fields, soptask.FieldPlanEndTime)
  30604. }
  30605. if m.FieldCleared(soptask.FieldCreatorID) {
  30606. fields = append(fields, soptask.FieldCreatorID)
  30607. }
  30608. if m.FieldCleared(soptask.FieldOrganizationID) {
  30609. fields = append(fields, soptask.FieldOrganizationID)
  30610. }
  30611. if m.FieldCleared(soptask.FieldToken) {
  30612. fields = append(fields, soptask.FieldToken)
  30613. }
  30614. return fields
  30615. }
  30616. // FieldCleared returns a boolean indicating if a field with the given name was
  30617. // cleared in this mutation.
  30618. func (m *SopTaskMutation) FieldCleared(name string) bool {
  30619. _, ok := m.clearedFields[name]
  30620. return ok
  30621. }
  30622. // ClearField clears the value of the field with the given name. It returns an
  30623. // error if the field is not defined in the schema.
  30624. func (m *SopTaskMutation) ClearField(name string) error {
  30625. switch name {
  30626. case soptask.FieldStatus:
  30627. m.ClearStatus()
  30628. return nil
  30629. case soptask.FieldDeletedAt:
  30630. m.ClearDeletedAt()
  30631. return nil
  30632. case soptask.FieldBotWxidList:
  30633. m.ClearBotWxidList()
  30634. return nil
  30635. case soptask.FieldPlanStartTime:
  30636. m.ClearPlanStartTime()
  30637. return nil
  30638. case soptask.FieldPlanEndTime:
  30639. m.ClearPlanEndTime()
  30640. return nil
  30641. case soptask.FieldCreatorID:
  30642. m.ClearCreatorID()
  30643. return nil
  30644. case soptask.FieldOrganizationID:
  30645. m.ClearOrganizationID()
  30646. return nil
  30647. case soptask.FieldToken:
  30648. m.ClearToken()
  30649. return nil
  30650. }
  30651. return fmt.Errorf("unknown SopTask nullable field %s", name)
  30652. }
  30653. // ResetField resets all changes in the mutation for the field with the given name.
  30654. // It returns an error if the field is not defined in the schema.
  30655. func (m *SopTaskMutation) ResetField(name string) error {
  30656. switch name {
  30657. case soptask.FieldCreatedAt:
  30658. m.ResetCreatedAt()
  30659. return nil
  30660. case soptask.FieldUpdatedAt:
  30661. m.ResetUpdatedAt()
  30662. return nil
  30663. case soptask.FieldStatus:
  30664. m.ResetStatus()
  30665. return nil
  30666. case soptask.FieldDeletedAt:
  30667. m.ResetDeletedAt()
  30668. return nil
  30669. case soptask.FieldName:
  30670. m.ResetName()
  30671. return nil
  30672. case soptask.FieldBotWxidList:
  30673. m.ResetBotWxidList()
  30674. return nil
  30675. case soptask.FieldType:
  30676. m.ResetType()
  30677. return nil
  30678. case soptask.FieldPlanStartTime:
  30679. m.ResetPlanStartTime()
  30680. return nil
  30681. case soptask.FieldPlanEndTime:
  30682. m.ResetPlanEndTime()
  30683. return nil
  30684. case soptask.FieldCreatorID:
  30685. m.ResetCreatorID()
  30686. return nil
  30687. case soptask.FieldOrganizationID:
  30688. m.ResetOrganizationID()
  30689. return nil
  30690. case soptask.FieldToken:
  30691. m.ResetToken()
  30692. return nil
  30693. }
  30694. return fmt.Errorf("unknown SopTask field %s", name)
  30695. }
  30696. // AddedEdges returns all edge names that were set/added in this mutation.
  30697. func (m *SopTaskMutation) AddedEdges() []string {
  30698. edges := make([]string, 0, 1)
  30699. if m.task_stages != nil {
  30700. edges = append(edges, soptask.EdgeTaskStages)
  30701. }
  30702. return edges
  30703. }
  30704. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30705. // name in this mutation.
  30706. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  30707. switch name {
  30708. case soptask.EdgeTaskStages:
  30709. ids := make([]ent.Value, 0, len(m.task_stages))
  30710. for id := range m.task_stages {
  30711. ids = append(ids, id)
  30712. }
  30713. return ids
  30714. }
  30715. return nil
  30716. }
  30717. // RemovedEdges returns all edge names that were removed in this mutation.
  30718. func (m *SopTaskMutation) RemovedEdges() []string {
  30719. edges := make([]string, 0, 1)
  30720. if m.removedtask_stages != nil {
  30721. edges = append(edges, soptask.EdgeTaskStages)
  30722. }
  30723. return edges
  30724. }
  30725. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30726. // the given name in this mutation.
  30727. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  30728. switch name {
  30729. case soptask.EdgeTaskStages:
  30730. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  30731. for id := range m.removedtask_stages {
  30732. ids = append(ids, id)
  30733. }
  30734. return ids
  30735. }
  30736. return nil
  30737. }
  30738. // ClearedEdges returns all edge names that were cleared in this mutation.
  30739. func (m *SopTaskMutation) ClearedEdges() []string {
  30740. edges := make([]string, 0, 1)
  30741. if m.clearedtask_stages {
  30742. edges = append(edges, soptask.EdgeTaskStages)
  30743. }
  30744. return edges
  30745. }
  30746. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30747. // was cleared in this mutation.
  30748. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  30749. switch name {
  30750. case soptask.EdgeTaskStages:
  30751. return m.clearedtask_stages
  30752. }
  30753. return false
  30754. }
  30755. // ClearEdge clears the value of the edge with the given name. It returns an error
  30756. // if that edge is not defined in the schema.
  30757. func (m *SopTaskMutation) ClearEdge(name string) error {
  30758. switch name {
  30759. }
  30760. return fmt.Errorf("unknown SopTask unique edge %s", name)
  30761. }
  30762. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30763. // It returns an error if the edge is not defined in the schema.
  30764. func (m *SopTaskMutation) ResetEdge(name string) error {
  30765. switch name {
  30766. case soptask.EdgeTaskStages:
  30767. m.ResetTaskStages()
  30768. return nil
  30769. }
  30770. return fmt.Errorf("unknown SopTask edge %s", name)
  30771. }
  30772. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  30773. type TokenMutation struct {
  30774. config
  30775. op Op
  30776. typ string
  30777. id *uint64
  30778. created_at *time.Time
  30779. updated_at *time.Time
  30780. deleted_at *time.Time
  30781. expire_at *time.Time
  30782. token *string
  30783. mac *string
  30784. organization_id *uint64
  30785. addorganization_id *int64
  30786. custom_agent_base *string
  30787. custom_agent_key *string
  30788. openai_base *string
  30789. openai_key *string
  30790. clearedFields map[string]struct{}
  30791. agent *uint64
  30792. clearedagent bool
  30793. done bool
  30794. oldValue func(context.Context) (*Token, error)
  30795. predicates []predicate.Token
  30796. }
  30797. var _ ent.Mutation = (*TokenMutation)(nil)
  30798. // tokenOption allows management of the mutation configuration using functional options.
  30799. type tokenOption func(*TokenMutation)
  30800. // newTokenMutation creates new mutation for the Token entity.
  30801. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  30802. m := &TokenMutation{
  30803. config: c,
  30804. op: op,
  30805. typ: TypeToken,
  30806. clearedFields: make(map[string]struct{}),
  30807. }
  30808. for _, opt := range opts {
  30809. opt(m)
  30810. }
  30811. return m
  30812. }
  30813. // withTokenID sets the ID field of the mutation.
  30814. func withTokenID(id uint64) tokenOption {
  30815. return func(m *TokenMutation) {
  30816. var (
  30817. err error
  30818. once sync.Once
  30819. value *Token
  30820. )
  30821. m.oldValue = func(ctx context.Context) (*Token, error) {
  30822. once.Do(func() {
  30823. if m.done {
  30824. err = errors.New("querying old values post mutation is not allowed")
  30825. } else {
  30826. value, err = m.Client().Token.Get(ctx, id)
  30827. }
  30828. })
  30829. return value, err
  30830. }
  30831. m.id = &id
  30832. }
  30833. }
  30834. // withToken sets the old Token of the mutation.
  30835. func withToken(node *Token) tokenOption {
  30836. return func(m *TokenMutation) {
  30837. m.oldValue = func(context.Context) (*Token, error) {
  30838. return node, nil
  30839. }
  30840. m.id = &node.ID
  30841. }
  30842. }
  30843. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30844. // executed in a transaction (ent.Tx), a transactional client is returned.
  30845. func (m TokenMutation) Client() *Client {
  30846. client := &Client{config: m.config}
  30847. client.init()
  30848. return client
  30849. }
  30850. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30851. // it returns an error otherwise.
  30852. func (m TokenMutation) Tx() (*Tx, error) {
  30853. if _, ok := m.driver.(*txDriver); !ok {
  30854. return nil, errors.New("ent: mutation is not running in a transaction")
  30855. }
  30856. tx := &Tx{config: m.config}
  30857. tx.init()
  30858. return tx, nil
  30859. }
  30860. // SetID sets the value of the id field. Note that this
  30861. // operation is only accepted on creation of Token entities.
  30862. func (m *TokenMutation) SetID(id uint64) {
  30863. m.id = &id
  30864. }
  30865. // ID returns the ID value in the mutation. Note that the ID is only available
  30866. // if it was provided to the builder or after it was returned from the database.
  30867. func (m *TokenMutation) ID() (id uint64, exists bool) {
  30868. if m.id == nil {
  30869. return
  30870. }
  30871. return *m.id, true
  30872. }
  30873. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30874. // That means, if the mutation is applied within a transaction with an isolation level such
  30875. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30876. // or updated by the mutation.
  30877. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  30878. switch {
  30879. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30880. id, exists := m.ID()
  30881. if exists {
  30882. return []uint64{id}, nil
  30883. }
  30884. fallthrough
  30885. case m.op.Is(OpUpdate | OpDelete):
  30886. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  30887. default:
  30888. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30889. }
  30890. }
  30891. // SetCreatedAt sets the "created_at" field.
  30892. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  30893. m.created_at = &t
  30894. }
  30895. // CreatedAt returns the value of the "created_at" field in the mutation.
  30896. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  30897. v := m.created_at
  30898. if v == nil {
  30899. return
  30900. }
  30901. return *v, true
  30902. }
  30903. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  30904. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30906. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30907. if !m.op.Is(OpUpdateOne) {
  30908. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30909. }
  30910. if m.id == nil || m.oldValue == nil {
  30911. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30912. }
  30913. oldValue, err := m.oldValue(ctx)
  30914. if err != nil {
  30915. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30916. }
  30917. return oldValue.CreatedAt, nil
  30918. }
  30919. // ResetCreatedAt resets all changes to the "created_at" field.
  30920. func (m *TokenMutation) ResetCreatedAt() {
  30921. m.created_at = nil
  30922. }
  30923. // SetUpdatedAt sets the "updated_at" field.
  30924. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  30925. m.updated_at = &t
  30926. }
  30927. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30928. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  30929. v := m.updated_at
  30930. if v == nil {
  30931. return
  30932. }
  30933. return *v, true
  30934. }
  30935. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  30936. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30938. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30939. if !m.op.Is(OpUpdateOne) {
  30940. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30941. }
  30942. if m.id == nil || m.oldValue == nil {
  30943. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30944. }
  30945. oldValue, err := m.oldValue(ctx)
  30946. if err != nil {
  30947. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30948. }
  30949. return oldValue.UpdatedAt, nil
  30950. }
  30951. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30952. func (m *TokenMutation) ResetUpdatedAt() {
  30953. m.updated_at = nil
  30954. }
  30955. // SetDeletedAt sets the "deleted_at" field.
  30956. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  30957. m.deleted_at = &t
  30958. }
  30959. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30960. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  30961. v := m.deleted_at
  30962. if v == nil {
  30963. return
  30964. }
  30965. return *v, true
  30966. }
  30967. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  30968. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30970. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30971. if !m.op.Is(OpUpdateOne) {
  30972. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30973. }
  30974. if m.id == nil || m.oldValue == nil {
  30975. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30976. }
  30977. oldValue, err := m.oldValue(ctx)
  30978. if err != nil {
  30979. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30980. }
  30981. return oldValue.DeletedAt, nil
  30982. }
  30983. // ClearDeletedAt clears the value of the "deleted_at" field.
  30984. func (m *TokenMutation) ClearDeletedAt() {
  30985. m.deleted_at = nil
  30986. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  30987. }
  30988. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30989. func (m *TokenMutation) DeletedAtCleared() bool {
  30990. _, ok := m.clearedFields[token.FieldDeletedAt]
  30991. return ok
  30992. }
  30993. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30994. func (m *TokenMutation) ResetDeletedAt() {
  30995. m.deleted_at = nil
  30996. delete(m.clearedFields, token.FieldDeletedAt)
  30997. }
  30998. // SetExpireAt sets the "expire_at" field.
  30999. func (m *TokenMutation) SetExpireAt(t time.Time) {
  31000. m.expire_at = &t
  31001. }
  31002. // ExpireAt returns the value of the "expire_at" field in the mutation.
  31003. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  31004. v := m.expire_at
  31005. if v == nil {
  31006. return
  31007. }
  31008. return *v, true
  31009. }
  31010. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  31011. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31013. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  31014. if !m.op.Is(OpUpdateOne) {
  31015. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  31016. }
  31017. if m.id == nil || m.oldValue == nil {
  31018. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  31019. }
  31020. oldValue, err := m.oldValue(ctx)
  31021. if err != nil {
  31022. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  31023. }
  31024. return oldValue.ExpireAt, nil
  31025. }
  31026. // ClearExpireAt clears the value of the "expire_at" field.
  31027. func (m *TokenMutation) ClearExpireAt() {
  31028. m.expire_at = nil
  31029. m.clearedFields[token.FieldExpireAt] = struct{}{}
  31030. }
  31031. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  31032. func (m *TokenMutation) ExpireAtCleared() bool {
  31033. _, ok := m.clearedFields[token.FieldExpireAt]
  31034. return ok
  31035. }
  31036. // ResetExpireAt resets all changes to the "expire_at" field.
  31037. func (m *TokenMutation) ResetExpireAt() {
  31038. m.expire_at = nil
  31039. delete(m.clearedFields, token.FieldExpireAt)
  31040. }
  31041. // SetToken sets the "token" field.
  31042. func (m *TokenMutation) SetToken(s string) {
  31043. m.token = &s
  31044. }
  31045. // Token returns the value of the "token" field in the mutation.
  31046. func (m *TokenMutation) Token() (r string, exists bool) {
  31047. v := m.token
  31048. if v == nil {
  31049. return
  31050. }
  31051. return *v, true
  31052. }
  31053. // OldToken returns the old "token" field's value of the Token entity.
  31054. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31056. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  31057. if !m.op.Is(OpUpdateOne) {
  31058. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31059. }
  31060. if m.id == nil || m.oldValue == nil {
  31061. return v, errors.New("OldToken requires an ID field in the mutation")
  31062. }
  31063. oldValue, err := m.oldValue(ctx)
  31064. if err != nil {
  31065. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31066. }
  31067. return oldValue.Token, nil
  31068. }
  31069. // ClearToken clears the value of the "token" field.
  31070. func (m *TokenMutation) ClearToken() {
  31071. m.token = nil
  31072. m.clearedFields[token.FieldToken] = struct{}{}
  31073. }
  31074. // TokenCleared returns if the "token" field was cleared in this mutation.
  31075. func (m *TokenMutation) TokenCleared() bool {
  31076. _, ok := m.clearedFields[token.FieldToken]
  31077. return ok
  31078. }
  31079. // ResetToken resets all changes to the "token" field.
  31080. func (m *TokenMutation) ResetToken() {
  31081. m.token = nil
  31082. delete(m.clearedFields, token.FieldToken)
  31083. }
  31084. // SetMAC sets the "mac" field.
  31085. func (m *TokenMutation) SetMAC(s string) {
  31086. m.mac = &s
  31087. }
  31088. // MAC returns the value of the "mac" field in the mutation.
  31089. func (m *TokenMutation) MAC() (r string, exists bool) {
  31090. v := m.mac
  31091. if v == nil {
  31092. return
  31093. }
  31094. return *v, true
  31095. }
  31096. // OldMAC returns the old "mac" field's value of the Token entity.
  31097. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31099. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  31100. if !m.op.Is(OpUpdateOne) {
  31101. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  31102. }
  31103. if m.id == nil || m.oldValue == nil {
  31104. return v, errors.New("OldMAC requires an ID field in the mutation")
  31105. }
  31106. oldValue, err := m.oldValue(ctx)
  31107. if err != nil {
  31108. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  31109. }
  31110. return oldValue.MAC, nil
  31111. }
  31112. // ClearMAC clears the value of the "mac" field.
  31113. func (m *TokenMutation) ClearMAC() {
  31114. m.mac = nil
  31115. m.clearedFields[token.FieldMAC] = struct{}{}
  31116. }
  31117. // MACCleared returns if the "mac" field was cleared in this mutation.
  31118. func (m *TokenMutation) MACCleared() bool {
  31119. _, ok := m.clearedFields[token.FieldMAC]
  31120. return ok
  31121. }
  31122. // ResetMAC resets all changes to the "mac" field.
  31123. func (m *TokenMutation) ResetMAC() {
  31124. m.mac = nil
  31125. delete(m.clearedFields, token.FieldMAC)
  31126. }
  31127. // SetOrganizationID sets the "organization_id" field.
  31128. func (m *TokenMutation) SetOrganizationID(u uint64) {
  31129. m.organization_id = &u
  31130. m.addorganization_id = nil
  31131. }
  31132. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31133. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  31134. v := m.organization_id
  31135. if v == nil {
  31136. return
  31137. }
  31138. return *v, true
  31139. }
  31140. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  31141. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31143. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31144. if !m.op.Is(OpUpdateOne) {
  31145. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31146. }
  31147. if m.id == nil || m.oldValue == nil {
  31148. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31149. }
  31150. oldValue, err := m.oldValue(ctx)
  31151. if err != nil {
  31152. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31153. }
  31154. return oldValue.OrganizationID, nil
  31155. }
  31156. // AddOrganizationID adds u to the "organization_id" field.
  31157. func (m *TokenMutation) AddOrganizationID(u int64) {
  31158. if m.addorganization_id != nil {
  31159. *m.addorganization_id += u
  31160. } else {
  31161. m.addorganization_id = &u
  31162. }
  31163. }
  31164. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31165. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  31166. v := m.addorganization_id
  31167. if v == nil {
  31168. return
  31169. }
  31170. return *v, true
  31171. }
  31172. // ResetOrganizationID resets all changes to the "organization_id" field.
  31173. func (m *TokenMutation) ResetOrganizationID() {
  31174. m.organization_id = nil
  31175. m.addorganization_id = nil
  31176. }
  31177. // SetAgentID sets the "agent_id" field.
  31178. func (m *TokenMutation) SetAgentID(u uint64) {
  31179. m.agent = &u
  31180. }
  31181. // AgentID returns the value of the "agent_id" field in the mutation.
  31182. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  31183. v := m.agent
  31184. if v == nil {
  31185. return
  31186. }
  31187. return *v, true
  31188. }
  31189. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  31190. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31192. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  31193. if !m.op.Is(OpUpdateOne) {
  31194. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  31195. }
  31196. if m.id == nil || m.oldValue == nil {
  31197. return v, errors.New("OldAgentID requires an ID field in the mutation")
  31198. }
  31199. oldValue, err := m.oldValue(ctx)
  31200. if err != nil {
  31201. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  31202. }
  31203. return oldValue.AgentID, nil
  31204. }
  31205. // ResetAgentID resets all changes to the "agent_id" field.
  31206. func (m *TokenMutation) ResetAgentID() {
  31207. m.agent = nil
  31208. }
  31209. // SetCustomAgentBase sets the "custom_agent_base" field.
  31210. func (m *TokenMutation) SetCustomAgentBase(s string) {
  31211. m.custom_agent_base = &s
  31212. }
  31213. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  31214. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  31215. v := m.custom_agent_base
  31216. if v == nil {
  31217. return
  31218. }
  31219. return *v, true
  31220. }
  31221. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  31222. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31224. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  31225. if !m.op.Is(OpUpdateOne) {
  31226. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  31227. }
  31228. if m.id == nil || m.oldValue == nil {
  31229. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  31230. }
  31231. oldValue, err := m.oldValue(ctx)
  31232. if err != nil {
  31233. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  31234. }
  31235. return oldValue.CustomAgentBase, nil
  31236. }
  31237. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  31238. func (m *TokenMutation) ClearCustomAgentBase() {
  31239. m.custom_agent_base = nil
  31240. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  31241. }
  31242. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  31243. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  31244. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  31245. return ok
  31246. }
  31247. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  31248. func (m *TokenMutation) ResetCustomAgentBase() {
  31249. m.custom_agent_base = nil
  31250. delete(m.clearedFields, token.FieldCustomAgentBase)
  31251. }
  31252. // SetCustomAgentKey sets the "custom_agent_key" field.
  31253. func (m *TokenMutation) SetCustomAgentKey(s string) {
  31254. m.custom_agent_key = &s
  31255. }
  31256. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  31257. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  31258. v := m.custom_agent_key
  31259. if v == nil {
  31260. return
  31261. }
  31262. return *v, true
  31263. }
  31264. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  31265. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31267. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  31268. if !m.op.Is(OpUpdateOne) {
  31269. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  31270. }
  31271. if m.id == nil || m.oldValue == nil {
  31272. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  31273. }
  31274. oldValue, err := m.oldValue(ctx)
  31275. if err != nil {
  31276. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  31277. }
  31278. return oldValue.CustomAgentKey, nil
  31279. }
  31280. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  31281. func (m *TokenMutation) ClearCustomAgentKey() {
  31282. m.custom_agent_key = nil
  31283. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  31284. }
  31285. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  31286. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  31287. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  31288. return ok
  31289. }
  31290. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  31291. func (m *TokenMutation) ResetCustomAgentKey() {
  31292. m.custom_agent_key = nil
  31293. delete(m.clearedFields, token.FieldCustomAgentKey)
  31294. }
  31295. // SetOpenaiBase sets the "openai_base" field.
  31296. func (m *TokenMutation) SetOpenaiBase(s string) {
  31297. m.openai_base = &s
  31298. }
  31299. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  31300. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  31301. v := m.openai_base
  31302. if v == nil {
  31303. return
  31304. }
  31305. return *v, true
  31306. }
  31307. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  31308. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31310. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  31311. if !m.op.Is(OpUpdateOne) {
  31312. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  31313. }
  31314. if m.id == nil || m.oldValue == nil {
  31315. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  31316. }
  31317. oldValue, err := m.oldValue(ctx)
  31318. if err != nil {
  31319. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  31320. }
  31321. return oldValue.OpenaiBase, nil
  31322. }
  31323. // ClearOpenaiBase clears the value of the "openai_base" field.
  31324. func (m *TokenMutation) ClearOpenaiBase() {
  31325. m.openai_base = nil
  31326. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  31327. }
  31328. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  31329. func (m *TokenMutation) OpenaiBaseCleared() bool {
  31330. _, ok := m.clearedFields[token.FieldOpenaiBase]
  31331. return ok
  31332. }
  31333. // ResetOpenaiBase resets all changes to the "openai_base" field.
  31334. func (m *TokenMutation) ResetOpenaiBase() {
  31335. m.openai_base = nil
  31336. delete(m.clearedFields, token.FieldOpenaiBase)
  31337. }
  31338. // SetOpenaiKey sets the "openai_key" field.
  31339. func (m *TokenMutation) SetOpenaiKey(s string) {
  31340. m.openai_key = &s
  31341. }
  31342. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  31343. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  31344. v := m.openai_key
  31345. if v == nil {
  31346. return
  31347. }
  31348. return *v, true
  31349. }
  31350. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  31351. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31353. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  31354. if !m.op.Is(OpUpdateOne) {
  31355. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  31356. }
  31357. if m.id == nil || m.oldValue == nil {
  31358. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  31359. }
  31360. oldValue, err := m.oldValue(ctx)
  31361. if err != nil {
  31362. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  31363. }
  31364. return oldValue.OpenaiKey, nil
  31365. }
  31366. // ClearOpenaiKey clears the value of the "openai_key" field.
  31367. func (m *TokenMutation) ClearOpenaiKey() {
  31368. m.openai_key = nil
  31369. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  31370. }
  31371. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  31372. func (m *TokenMutation) OpenaiKeyCleared() bool {
  31373. _, ok := m.clearedFields[token.FieldOpenaiKey]
  31374. return ok
  31375. }
  31376. // ResetOpenaiKey resets all changes to the "openai_key" field.
  31377. func (m *TokenMutation) ResetOpenaiKey() {
  31378. m.openai_key = nil
  31379. delete(m.clearedFields, token.FieldOpenaiKey)
  31380. }
  31381. // ClearAgent clears the "agent" edge to the Agent entity.
  31382. func (m *TokenMutation) ClearAgent() {
  31383. m.clearedagent = true
  31384. m.clearedFields[token.FieldAgentID] = struct{}{}
  31385. }
  31386. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  31387. func (m *TokenMutation) AgentCleared() bool {
  31388. return m.clearedagent
  31389. }
  31390. // AgentIDs returns the "agent" edge IDs in the mutation.
  31391. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  31392. // AgentID instead. It exists only for internal usage by the builders.
  31393. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  31394. if id := m.agent; id != nil {
  31395. ids = append(ids, *id)
  31396. }
  31397. return
  31398. }
  31399. // ResetAgent resets all changes to the "agent" edge.
  31400. func (m *TokenMutation) ResetAgent() {
  31401. m.agent = nil
  31402. m.clearedagent = false
  31403. }
  31404. // Where appends a list predicates to the TokenMutation builder.
  31405. func (m *TokenMutation) Where(ps ...predicate.Token) {
  31406. m.predicates = append(m.predicates, ps...)
  31407. }
  31408. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  31409. // users can use type-assertion to append predicates that do not depend on any generated package.
  31410. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  31411. p := make([]predicate.Token, len(ps))
  31412. for i := range ps {
  31413. p[i] = ps[i]
  31414. }
  31415. m.Where(p...)
  31416. }
  31417. // Op returns the operation name.
  31418. func (m *TokenMutation) Op() Op {
  31419. return m.op
  31420. }
  31421. // SetOp allows setting the mutation operation.
  31422. func (m *TokenMutation) SetOp(op Op) {
  31423. m.op = op
  31424. }
  31425. // Type returns the node type of this mutation (Token).
  31426. func (m *TokenMutation) Type() string {
  31427. return m.typ
  31428. }
  31429. // Fields returns all fields that were changed during this mutation. Note that in
  31430. // order to get all numeric fields that were incremented/decremented, call
  31431. // AddedFields().
  31432. func (m *TokenMutation) Fields() []string {
  31433. fields := make([]string, 0, 12)
  31434. if m.created_at != nil {
  31435. fields = append(fields, token.FieldCreatedAt)
  31436. }
  31437. if m.updated_at != nil {
  31438. fields = append(fields, token.FieldUpdatedAt)
  31439. }
  31440. if m.deleted_at != nil {
  31441. fields = append(fields, token.FieldDeletedAt)
  31442. }
  31443. if m.expire_at != nil {
  31444. fields = append(fields, token.FieldExpireAt)
  31445. }
  31446. if m.token != nil {
  31447. fields = append(fields, token.FieldToken)
  31448. }
  31449. if m.mac != nil {
  31450. fields = append(fields, token.FieldMAC)
  31451. }
  31452. if m.organization_id != nil {
  31453. fields = append(fields, token.FieldOrganizationID)
  31454. }
  31455. if m.agent != nil {
  31456. fields = append(fields, token.FieldAgentID)
  31457. }
  31458. if m.custom_agent_base != nil {
  31459. fields = append(fields, token.FieldCustomAgentBase)
  31460. }
  31461. if m.custom_agent_key != nil {
  31462. fields = append(fields, token.FieldCustomAgentKey)
  31463. }
  31464. if m.openai_base != nil {
  31465. fields = append(fields, token.FieldOpenaiBase)
  31466. }
  31467. if m.openai_key != nil {
  31468. fields = append(fields, token.FieldOpenaiKey)
  31469. }
  31470. return fields
  31471. }
  31472. // Field returns the value of a field with the given name. The second boolean
  31473. // return value indicates that this field was not set, or was not defined in the
  31474. // schema.
  31475. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  31476. switch name {
  31477. case token.FieldCreatedAt:
  31478. return m.CreatedAt()
  31479. case token.FieldUpdatedAt:
  31480. return m.UpdatedAt()
  31481. case token.FieldDeletedAt:
  31482. return m.DeletedAt()
  31483. case token.FieldExpireAt:
  31484. return m.ExpireAt()
  31485. case token.FieldToken:
  31486. return m.Token()
  31487. case token.FieldMAC:
  31488. return m.MAC()
  31489. case token.FieldOrganizationID:
  31490. return m.OrganizationID()
  31491. case token.FieldAgentID:
  31492. return m.AgentID()
  31493. case token.FieldCustomAgentBase:
  31494. return m.CustomAgentBase()
  31495. case token.FieldCustomAgentKey:
  31496. return m.CustomAgentKey()
  31497. case token.FieldOpenaiBase:
  31498. return m.OpenaiBase()
  31499. case token.FieldOpenaiKey:
  31500. return m.OpenaiKey()
  31501. }
  31502. return nil, false
  31503. }
  31504. // OldField returns the old value of the field from the database. An error is
  31505. // returned if the mutation operation is not UpdateOne, or the query to the
  31506. // database failed.
  31507. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31508. switch name {
  31509. case token.FieldCreatedAt:
  31510. return m.OldCreatedAt(ctx)
  31511. case token.FieldUpdatedAt:
  31512. return m.OldUpdatedAt(ctx)
  31513. case token.FieldDeletedAt:
  31514. return m.OldDeletedAt(ctx)
  31515. case token.FieldExpireAt:
  31516. return m.OldExpireAt(ctx)
  31517. case token.FieldToken:
  31518. return m.OldToken(ctx)
  31519. case token.FieldMAC:
  31520. return m.OldMAC(ctx)
  31521. case token.FieldOrganizationID:
  31522. return m.OldOrganizationID(ctx)
  31523. case token.FieldAgentID:
  31524. return m.OldAgentID(ctx)
  31525. case token.FieldCustomAgentBase:
  31526. return m.OldCustomAgentBase(ctx)
  31527. case token.FieldCustomAgentKey:
  31528. return m.OldCustomAgentKey(ctx)
  31529. case token.FieldOpenaiBase:
  31530. return m.OldOpenaiBase(ctx)
  31531. case token.FieldOpenaiKey:
  31532. return m.OldOpenaiKey(ctx)
  31533. }
  31534. return nil, fmt.Errorf("unknown Token field %s", name)
  31535. }
  31536. // SetField sets the value of a field with the given name. It returns an error if
  31537. // the field is not defined in the schema, or if the type mismatched the field
  31538. // type.
  31539. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  31540. switch name {
  31541. case token.FieldCreatedAt:
  31542. v, ok := value.(time.Time)
  31543. if !ok {
  31544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31545. }
  31546. m.SetCreatedAt(v)
  31547. return nil
  31548. case token.FieldUpdatedAt:
  31549. v, ok := value.(time.Time)
  31550. if !ok {
  31551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31552. }
  31553. m.SetUpdatedAt(v)
  31554. return nil
  31555. case token.FieldDeletedAt:
  31556. v, ok := value.(time.Time)
  31557. if !ok {
  31558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31559. }
  31560. m.SetDeletedAt(v)
  31561. return nil
  31562. case token.FieldExpireAt:
  31563. v, ok := value.(time.Time)
  31564. if !ok {
  31565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31566. }
  31567. m.SetExpireAt(v)
  31568. return nil
  31569. case token.FieldToken:
  31570. v, ok := value.(string)
  31571. if !ok {
  31572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31573. }
  31574. m.SetToken(v)
  31575. return nil
  31576. case token.FieldMAC:
  31577. v, ok := value.(string)
  31578. if !ok {
  31579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31580. }
  31581. m.SetMAC(v)
  31582. return nil
  31583. case token.FieldOrganizationID:
  31584. v, ok := value.(uint64)
  31585. if !ok {
  31586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31587. }
  31588. m.SetOrganizationID(v)
  31589. return nil
  31590. case token.FieldAgentID:
  31591. v, ok := value.(uint64)
  31592. if !ok {
  31593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31594. }
  31595. m.SetAgentID(v)
  31596. return nil
  31597. case token.FieldCustomAgentBase:
  31598. v, ok := value.(string)
  31599. if !ok {
  31600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31601. }
  31602. m.SetCustomAgentBase(v)
  31603. return nil
  31604. case token.FieldCustomAgentKey:
  31605. v, ok := value.(string)
  31606. if !ok {
  31607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31608. }
  31609. m.SetCustomAgentKey(v)
  31610. return nil
  31611. case token.FieldOpenaiBase:
  31612. v, ok := value.(string)
  31613. if !ok {
  31614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31615. }
  31616. m.SetOpenaiBase(v)
  31617. return nil
  31618. case token.FieldOpenaiKey:
  31619. v, ok := value.(string)
  31620. if !ok {
  31621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31622. }
  31623. m.SetOpenaiKey(v)
  31624. return nil
  31625. }
  31626. return fmt.Errorf("unknown Token field %s", name)
  31627. }
  31628. // AddedFields returns all numeric fields that were incremented/decremented during
  31629. // this mutation.
  31630. func (m *TokenMutation) AddedFields() []string {
  31631. var fields []string
  31632. if m.addorganization_id != nil {
  31633. fields = append(fields, token.FieldOrganizationID)
  31634. }
  31635. return fields
  31636. }
  31637. // AddedField returns the numeric value that was incremented/decremented on a field
  31638. // with the given name. The second boolean return value indicates that this field
  31639. // was not set, or was not defined in the schema.
  31640. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  31641. switch name {
  31642. case token.FieldOrganizationID:
  31643. return m.AddedOrganizationID()
  31644. }
  31645. return nil, false
  31646. }
  31647. // AddField adds the value to the field with the given name. It returns an error if
  31648. // the field is not defined in the schema, or if the type mismatched the field
  31649. // type.
  31650. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  31651. switch name {
  31652. case token.FieldOrganizationID:
  31653. v, ok := value.(int64)
  31654. if !ok {
  31655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31656. }
  31657. m.AddOrganizationID(v)
  31658. return nil
  31659. }
  31660. return fmt.Errorf("unknown Token numeric field %s", name)
  31661. }
  31662. // ClearedFields returns all nullable fields that were cleared during this
  31663. // mutation.
  31664. func (m *TokenMutation) ClearedFields() []string {
  31665. var fields []string
  31666. if m.FieldCleared(token.FieldDeletedAt) {
  31667. fields = append(fields, token.FieldDeletedAt)
  31668. }
  31669. if m.FieldCleared(token.FieldExpireAt) {
  31670. fields = append(fields, token.FieldExpireAt)
  31671. }
  31672. if m.FieldCleared(token.FieldToken) {
  31673. fields = append(fields, token.FieldToken)
  31674. }
  31675. if m.FieldCleared(token.FieldMAC) {
  31676. fields = append(fields, token.FieldMAC)
  31677. }
  31678. if m.FieldCleared(token.FieldCustomAgentBase) {
  31679. fields = append(fields, token.FieldCustomAgentBase)
  31680. }
  31681. if m.FieldCleared(token.FieldCustomAgentKey) {
  31682. fields = append(fields, token.FieldCustomAgentKey)
  31683. }
  31684. if m.FieldCleared(token.FieldOpenaiBase) {
  31685. fields = append(fields, token.FieldOpenaiBase)
  31686. }
  31687. if m.FieldCleared(token.FieldOpenaiKey) {
  31688. fields = append(fields, token.FieldOpenaiKey)
  31689. }
  31690. return fields
  31691. }
  31692. // FieldCleared returns a boolean indicating if a field with the given name was
  31693. // cleared in this mutation.
  31694. func (m *TokenMutation) FieldCleared(name string) bool {
  31695. _, ok := m.clearedFields[name]
  31696. return ok
  31697. }
  31698. // ClearField clears the value of the field with the given name. It returns an
  31699. // error if the field is not defined in the schema.
  31700. func (m *TokenMutation) ClearField(name string) error {
  31701. switch name {
  31702. case token.FieldDeletedAt:
  31703. m.ClearDeletedAt()
  31704. return nil
  31705. case token.FieldExpireAt:
  31706. m.ClearExpireAt()
  31707. return nil
  31708. case token.FieldToken:
  31709. m.ClearToken()
  31710. return nil
  31711. case token.FieldMAC:
  31712. m.ClearMAC()
  31713. return nil
  31714. case token.FieldCustomAgentBase:
  31715. m.ClearCustomAgentBase()
  31716. return nil
  31717. case token.FieldCustomAgentKey:
  31718. m.ClearCustomAgentKey()
  31719. return nil
  31720. case token.FieldOpenaiBase:
  31721. m.ClearOpenaiBase()
  31722. return nil
  31723. case token.FieldOpenaiKey:
  31724. m.ClearOpenaiKey()
  31725. return nil
  31726. }
  31727. return fmt.Errorf("unknown Token nullable field %s", name)
  31728. }
  31729. // ResetField resets all changes in the mutation for the field with the given name.
  31730. // It returns an error if the field is not defined in the schema.
  31731. func (m *TokenMutation) ResetField(name string) error {
  31732. switch name {
  31733. case token.FieldCreatedAt:
  31734. m.ResetCreatedAt()
  31735. return nil
  31736. case token.FieldUpdatedAt:
  31737. m.ResetUpdatedAt()
  31738. return nil
  31739. case token.FieldDeletedAt:
  31740. m.ResetDeletedAt()
  31741. return nil
  31742. case token.FieldExpireAt:
  31743. m.ResetExpireAt()
  31744. return nil
  31745. case token.FieldToken:
  31746. m.ResetToken()
  31747. return nil
  31748. case token.FieldMAC:
  31749. m.ResetMAC()
  31750. return nil
  31751. case token.FieldOrganizationID:
  31752. m.ResetOrganizationID()
  31753. return nil
  31754. case token.FieldAgentID:
  31755. m.ResetAgentID()
  31756. return nil
  31757. case token.FieldCustomAgentBase:
  31758. m.ResetCustomAgentBase()
  31759. return nil
  31760. case token.FieldCustomAgentKey:
  31761. m.ResetCustomAgentKey()
  31762. return nil
  31763. case token.FieldOpenaiBase:
  31764. m.ResetOpenaiBase()
  31765. return nil
  31766. case token.FieldOpenaiKey:
  31767. m.ResetOpenaiKey()
  31768. return nil
  31769. }
  31770. return fmt.Errorf("unknown Token field %s", name)
  31771. }
  31772. // AddedEdges returns all edge names that were set/added in this mutation.
  31773. func (m *TokenMutation) AddedEdges() []string {
  31774. edges := make([]string, 0, 1)
  31775. if m.agent != nil {
  31776. edges = append(edges, token.EdgeAgent)
  31777. }
  31778. return edges
  31779. }
  31780. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31781. // name in this mutation.
  31782. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  31783. switch name {
  31784. case token.EdgeAgent:
  31785. if id := m.agent; id != nil {
  31786. return []ent.Value{*id}
  31787. }
  31788. }
  31789. return nil
  31790. }
  31791. // RemovedEdges returns all edge names that were removed in this mutation.
  31792. func (m *TokenMutation) RemovedEdges() []string {
  31793. edges := make([]string, 0, 1)
  31794. return edges
  31795. }
  31796. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31797. // the given name in this mutation.
  31798. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  31799. return nil
  31800. }
  31801. // ClearedEdges returns all edge names that were cleared in this mutation.
  31802. func (m *TokenMutation) ClearedEdges() []string {
  31803. edges := make([]string, 0, 1)
  31804. if m.clearedagent {
  31805. edges = append(edges, token.EdgeAgent)
  31806. }
  31807. return edges
  31808. }
  31809. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31810. // was cleared in this mutation.
  31811. func (m *TokenMutation) EdgeCleared(name string) bool {
  31812. switch name {
  31813. case token.EdgeAgent:
  31814. return m.clearedagent
  31815. }
  31816. return false
  31817. }
  31818. // ClearEdge clears the value of the edge with the given name. It returns an error
  31819. // if that edge is not defined in the schema.
  31820. func (m *TokenMutation) ClearEdge(name string) error {
  31821. switch name {
  31822. case token.EdgeAgent:
  31823. m.ClearAgent()
  31824. return nil
  31825. }
  31826. return fmt.Errorf("unknown Token unique edge %s", name)
  31827. }
  31828. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31829. // It returns an error if the edge is not defined in the schema.
  31830. func (m *TokenMutation) ResetEdge(name string) error {
  31831. switch name {
  31832. case token.EdgeAgent:
  31833. m.ResetAgent()
  31834. return nil
  31835. }
  31836. return fmt.Errorf("unknown Token edge %s", name)
  31837. }
  31838. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  31839. type TutorialMutation struct {
  31840. config
  31841. op Op
  31842. typ string
  31843. id *uint64
  31844. created_at *time.Time
  31845. updated_at *time.Time
  31846. deleted_at *time.Time
  31847. index *int
  31848. addindex *int
  31849. title *string
  31850. content *string
  31851. organization_id *uint64
  31852. addorganization_id *int64
  31853. clearedFields map[string]struct{}
  31854. employee *uint64
  31855. clearedemployee bool
  31856. done bool
  31857. oldValue func(context.Context) (*Tutorial, error)
  31858. predicates []predicate.Tutorial
  31859. }
  31860. var _ ent.Mutation = (*TutorialMutation)(nil)
  31861. // tutorialOption allows management of the mutation configuration using functional options.
  31862. type tutorialOption func(*TutorialMutation)
  31863. // newTutorialMutation creates new mutation for the Tutorial entity.
  31864. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  31865. m := &TutorialMutation{
  31866. config: c,
  31867. op: op,
  31868. typ: TypeTutorial,
  31869. clearedFields: make(map[string]struct{}),
  31870. }
  31871. for _, opt := range opts {
  31872. opt(m)
  31873. }
  31874. return m
  31875. }
  31876. // withTutorialID sets the ID field of the mutation.
  31877. func withTutorialID(id uint64) tutorialOption {
  31878. return func(m *TutorialMutation) {
  31879. var (
  31880. err error
  31881. once sync.Once
  31882. value *Tutorial
  31883. )
  31884. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  31885. once.Do(func() {
  31886. if m.done {
  31887. err = errors.New("querying old values post mutation is not allowed")
  31888. } else {
  31889. value, err = m.Client().Tutorial.Get(ctx, id)
  31890. }
  31891. })
  31892. return value, err
  31893. }
  31894. m.id = &id
  31895. }
  31896. }
  31897. // withTutorial sets the old Tutorial of the mutation.
  31898. func withTutorial(node *Tutorial) tutorialOption {
  31899. return func(m *TutorialMutation) {
  31900. m.oldValue = func(context.Context) (*Tutorial, error) {
  31901. return node, nil
  31902. }
  31903. m.id = &node.ID
  31904. }
  31905. }
  31906. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31907. // executed in a transaction (ent.Tx), a transactional client is returned.
  31908. func (m TutorialMutation) Client() *Client {
  31909. client := &Client{config: m.config}
  31910. client.init()
  31911. return client
  31912. }
  31913. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31914. // it returns an error otherwise.
  31915. func (m TutorialMutation) Tx() (*Tx, error) {
  31916. if _, ok := m.driver.(*txDriver); !ok {
  31917. return nil, errors.New("ent: mutation is not running in a transaction")
  31918. }
  31919. tx := &Tx{config: m.config}
  31920. tx.init()
  31921. return tx, nil
  31922. }
  31923. // SetID sets the value of the id field. Note that this
  31924. // operation is only accepted on creation of Tutorial entities.
  31925. func (m *TutorialMutation) SetID(id uint64) {
  31926. m.id = &id
  31927. }
  31928. // ID returns the ID value in the mutation. Note that the ID is only available
  31929. // if it was provided to the builder or after it was returned from the database.
  31930. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  31931. if m.id == nil {
  31932. return
  31933. }
  31934. return *m.id, true
  31935. }
  31936. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31937. // That means, if the mutation is applied within a transaction with an isolation level such
  31938. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31939. // or updated by the mutation.
  31940. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  31941. switch {
  31942. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31943. id, exists := m.ID()
  31944. if exists {
  31945. return []uint64{id}, nil
  31946. }
  31947. fallthrough
  31948. case m.op.Is(OpUpdate | OpDelete):
  31949. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  31950. default:
  31951. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31952. }
  31953. }
  31954. // SetCreatedAt sets the "created_at" field.
  31955. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  31956. m.created_at = &t
  31957. }
  31958. // CreatedAt returns the value of the "created_at" field in the mutation.
  31959. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  31960. v := m.created_at
  31961. if v == nil {
  31962. return
  31963. }
  31964. return *v, true
  31965. }
  31966. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  31967. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31969. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31970. if !m.op.Is(OpUpdateOne) {
  31971. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31972. }
  31973. if m.id == nil || m.oldValue == nil {
  31974. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31975. }
  31976. oldValue, err := m.oldValue(ctx)
  31977. if err != nil {
  31978. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31979. }
  31980. return oldValue.CreatedAt, nil
  31981. }
  31982. // ResetCreatedAt resets all changes to the "created_at" field.
  31983. func (m *TutorialMutation) ResetCreatedAt() {
  31984. m.created_at = nil
  31985. }
  31986. // SetUpdatedAt sets the "updated_at" field.
  31987. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  31988. m.updated_at = &t
  31989. }
  31990. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31991. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  31992. v := m.updated_at
  31993. if v == nil {
  31994. return
  31995. }
  31996. return *v, true
  31997. }
  31998. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  31999. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32001. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32002. if !m.op.Is(OpUpdateOne) {
  32003. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32004. }
  32005. if m.id == nil || m.oldValue == nil {
  32006. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32007. }
  32008. oldValue, err := m.oldValue(ctx)
  32009. if err != nil {
  32010. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32011. }
  32012. return oldValue.UpdatedAt, nil
  32013. }
  32014. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32015. func (m *TutorialMutation) ResetUpdatedAt() {
  32016. m.updated_at = nil
  32017. }
  32018. // SetDeletedAt sets the "deleted_at" field.
  32019. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  32020. m.deleted_at = &t
  32021. }
  32022. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32023. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  32024. v := m.deleted_at
  32025. if v == nil {
  32026. return
  32027. }
  32028. return *v, true
  32029. }
  32030. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  32031. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32033. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32034. if !m.op.Is(OpUpdateOne) {
  32035. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32036. }
  32037. if m.id == nil || m.oldValue == nil {
  32038. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32039. }
  32040. oldValue, err := m.oldValue(ctx)
  32041. if err != nil {
  32042. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32043. }
  32044. return oldValue.DeletedAt, nil
  32045. }
  32046. // ClearDeletedAt clears the value of the "deleted_at" field.
  32047. func (m *TutorialMutation) ClearDeletedAt() {
  32048. m.deleted_at = nil
  32049. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  32050. }
  32051. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32052. func (m *TutorialMutation) DeletedAtCleared() bool {
  32053. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  32054. return ok
  32055. }
  32056. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32057. func (m *TutorialMutation) ResetDeletedAt() {
  32058. m.deleted_at = nil
  32059. delete(m.clearedFields, tutorial.FieldDeletedAt)
  32060. }
  32061. // SetEmployeeID sets the "employee_id" field.
  32062. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  32063. m.employee = &u
  32064. }
  32065. // EmployeeID returns the value of the "employee_id" field in the mutation.
  32066. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  32067. v := m.employee
  32068. if v == nil {
  32069. return
  32070. }
  32071. return *v, true
  32072. }
  32073. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  32074. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32076. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  32077. if !m.op.Is(OpUpdateOne) {
  32078. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  32079. }
  32080. if m.id == nil || m.oldValue == nil {
  32081. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  32082. }
  32083. oldValue, err := m.oldValue(ctx)
  32084. if err != nil {
  32085. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  32086. }
  32087. return oldValue.EmployeeID, nil
  32088. }
  32089. // ResetEmployeeID resets all changes to the "employee_id" field.
  32090. func (m *TutorialMutation) ResetEmployeeID() {
  32091. m.employee = nil
  32092. }
  32093. // SetIndex sets the "index" field.
  32094. func (m *TutorialMutation) SetIndex(i int) {
  32095. m.index = &i
  32096. m.addindex = nil
  32097. }
  32098. // Index returns the value of the "index" field in the mutation.
  32099. func (m *TutorialMutation) Index() (r int, exists bool) {
  32100. v := m.index
  32101. if v == nil {
  32102. return
  32103. }
  32104. return *v, true
  32105. }
  32106. // OldIndex returns the old "index" field's value of the Tutorial entity.
  32107. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32109. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  32110. if !m.op.Is(OpUpdateOne) {
  32111. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  32112. }
  32113. if m.id == nil || m.oldValue == nil {
  32114. return v, errors.New("OldIndex requires an ID field in the mutation")
  32115. }
  32116. oldValue, err := m.oldValue(ctx)
  32117. if err != nil {
  32118. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  32119. }
  32120. return oldValue.Index, nil
  32121. }
  32122. // AddIndex adds i to the "index" field.
  32123. func (m *TutorialMutation) AddIndex(i int) {
  32124. if m.addindex != nil {
  32125. *m.addindex += i
  32126. } else {
  32127. m.addindex = &i
  32128. }
  32129. }
  32130. // AddedIndex returns the value that was added to the "index" field in this mutation.
  32131. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  32132. v := m.addindex
  32133. if v == nil {
  32134. return
  32135. }
  32136. return *v, true
  32137. }
  32138. // ResetIndex resets all changes to the "index" field.
  32139. func (m *TutorialMutation) ResetIndex() {
  32140. m.index = nil
  32141. m.addindex = nil
  32142. }
  32143. // SetTitle sets the "title" field.
  32144. func (m *TutorialMutation) SetTitle(s string) {
  32145. m.title = &s
  32146. }
  32147. // Title returns the value of the "title" field in the mutation.
  32148. func (m *TutorialMutation) Title() (r string, exists bool) {
  32149. v := m.title
  32150. if v == nil {
  32151. return
  32152. }
  32153. return *v, true
  32154. }
  32155. // OldTitle returns the old "title" field's value of the Tutorial entity.
  32156. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32158. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  32159. if !m.op.Is(OpUpdateOne) {
  32160. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  32161. }
  32162. if m.id == nil || m.oldValue == nil {
  32163. return v, errors.New("OldTitle requires an ID field in the mutation")
  32164. }
  32165. oldValue, err := m.oldValue(ctx)
  32166. if err != nil {
  32167. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  32168. }
  32169. return oldValue.Title, nil
  32170. }
  32171. // ResetTitle resets all changes to the "title" field.
  32172. func (m *TutorialMutation) ResetTitle() {
  32173. m.title = nil
  32174. }
  32175. // SetContent sets the "content" field.
  32176. func (m *TutorialMutation) SetContent(s string) {
  32177. m.content = &s
  32178. }
  32179. // Content returns the value of the "content" field in the mutation.
  32180. func (m *TutorialMutation) Content() (r string, exists bool) {
  32181. v := m.content
  32182. if v == nil {
  32183. return
  32184. }
  32185. return *v, true
  32186. }
  32187. // OldContent returns the old "content" field's value of the Tutorial entity.
  32188. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32190. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  32191. if !m.op.Is(OpUpdateOne) {
  32192. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  32193. }
  32194. if m.id == nil || m.oldValue == nil {
  32195. return v, errors.New("OldContent requires an ID field in the mutation")
  32196. }
  32197. oldValue, err := m.oldValue(ctx)
  32198. if err != nil {
  32199. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  32200. }
  32201. return oldValue.Content, nil
  32202. }
  32203. // ResetContent resets all changes to the "content" field.
  32204. func (m *TutorialMutation) ResetContent() {
  32205. m.content = nil
  32206. }
  32207. // SetOrganizationID sets the "organization_id" field.
  32208. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  32209. m.organization_id = &u
  32210. m.addorganization_id = nil
  32211. }
  32212. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32213. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  32214. v := m.organization_id
  32215. if v == nil {
  32216. return
  32217. }
  32218. return *v, true
  32219. }
  32220. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  32221. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32223. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32224. if !m.op.Is(OpUpdateOne) {
  32225. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32226. }
  32227. if m.id == nil || m.oldValue == nil {
  32228. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32229. }
  32230. oldValue, err := m.oldValue(ctx)
  32231. if err != nil {
  32232. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32233. }
  32234. return oldValue.OrganizationID, nil
  32235. }
  32236. // AddOrganizationID adds u to the "organization_id" field.
  32237. func (m *TutorialMutation) AddOrganizationID(u int64) {
  32238. if m.addorganization_id != nil {
  32239. *m.addorganization_id += u
  32240. } else {
  32241. m.addorganization_id = &u
  32242. }
  32243. }
  32244. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32245. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  32246. v := m.addorganization_id
  32247. if v == nil {
  32248. return
  32249. }
  32250. return *v, true
  32251. }
  32252. // ResetOrganizationID resets all changes to the "organization_id" field.
  32253. func (m *TutorialMutation) ResetOrganizationID() {
  32254. m.organization_id = nil
  32255. m.addorganization_id = nil
  32256. }
  32257. // ClearEmployee clears the "employee" edge to the Employee entity.
  32258. func (m *TutorialMutation) ClearEmployee() {
  32259. m.clearedemployee = true
  32260. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  32261. }
  32262. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  32263. func (m *TutorialMutation) EmployeeCleared() bool {
  32264. return m.clearedemployee
  32265. }
  32266. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  32267. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32268. // EmployeeID instead. It exists only for internal usage by the builders.
  32269. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  32270. if id := m.employee; id != nil {
  32271. ids = append(ids, *id)
  32272. }
  32273. return
  32274. }
  32275. // ResetEmployee resets all changes to the "employee" edge.
  32276. func (m *TutorialMutation) ResetEmployee() {
  32277. m.employee = nil
  32278. m.clearedemployee = false
  32279. }
  32280. // Where appends a list predicates to the TutorialMutation builder.
  32281. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  32282. m.predicates = append(m.predicates, ps...)
  32283. }
  32284. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  32285. // users can use type-assertion to append predicates that do not depend on any generated package.
  32286. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  32287. p := make([]predicate.Tutorial, len(ps))
  32288. for i := range ps {
  32289. p[i] = ps[i]
  32290. }
  32291. m.Where(p...)
  32292. }
  32293. // Op returns the operation name.
  32294. func (m *TutorialMutation) Op() Op {
  32295. return m.op
  32296. }
  32297. // SetOp allows setting the mutation operation.
  32298. func (m *TutorialMutation) SetOp(op Op) {
  32299. m.op = op
  32300. }
  32301. // Type returns the node type of this mutation (Tutorial).
  32302. func (m *TutorialMutation) Type() string {
  32303. return m.typ
  32304. }
  32305. // Fields returns all fields that were changed during this mutation. Note that in
  32306. // order to get all numeric fields that were incremented/decremented, call
  32307. // AddedFields().
  32308. func (m *TutorialMutation) Fields() []string {
  32309. fields := make([]string, 0, 8)
  32310. if m.created_at != nil {
  32311. fields = append(fields, tutorial.FieldCreatedAt)
  32312. }
  32313. if m.updated_at != nil {
  32314. fields = append(fields, tutorial.FieldUpdatedAt)
  32315. }
  32316. if m.deleted_at != nil {
  32317. fields = append(fields, tutorial.FieldDeletedAt)
  32318. }
  32319. if m.employee != nil {
  32320. fields = append(fields, tutorial.FieldEmployeeID)
  32321. }
  32322. if m.index != nil {
  32323. fields = append(fields, tutorial.FieldIndex)
  32324. }
  32325. if m.title != nil {
  32326. fields = append(fields, tutorial.FieldTitle)
  32327. }
  32328. if m.content != nil {
  32329. fields = append(fields, tutorial.FieldContent)
  32330. }
  32331. if m.organization_id != nil {
  32332. fields = append(fields, tutorial.FieldOrganizationID)
  32333. }
  32334. return fields
  32335. }
  32336. // Field returns the value of a field with the given name. The second boolean
  32337. // return value indicates that this field was not set, or was not defined in the
  32338. // schema.
  32339. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  32340. switch name {
  32341. case tutorial.FieldCreatedAt:
  32342. return m.CreatedAt()
  32343. case tutorial.FieldUpdatedAt:
  32344. return m.UpdatedAt()
  32345. case tutorial.FieldDeletedAt:
  32346. return m.DeletedAt()
  32347. case tutorial.FieldEmployeeID:
  32348. return m.EmployeeID()
  32349. case tutorial.FieldIndex:
  32350. return m.Index()
  32351. case tutorial.FieldTitle:
  32352. return m.Title()
  32353. case tutorial.FieldContent:
  32354. return m.Content()
  32355. case tutorial.FieldOrganizationID:
  32356. return m.OrganizationID()
  32357. }
  32358. return nil, false
  32359. }
  32360. // OldField returns the old value of the field from the database. An error is
  32361. // returned if the mutation operation is not UpdateOne, or the query to the
  32362. // database failed.
  32363. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32364. switch name {
  32365. case tutorial.FieldCreatedAt:
  32366. return m.OldCreatedAt(ctx)
  32367. case tutorial.FieldUpdatedAt:
  32368. return m.OldUpdatedAt(ctx)
  32369. case tutorial.FieldDeletedAt:
  32370. return m.OldDeletedAt(ctx)
  32371. case tutorial.FieldEmployeeID:
  32372. return m.OldEmployeeID(ctx)
  32373. case tutorial.FieldIndex:
  32374. return m.OldIndex(ctx)
  32375. case tutorial.FieldTitle:
  32376. return m.OldTitle(ctx)
  32377. case tutorial.FieldContent:
  32378. return m.OldContent(ctx)
  32379. case tutorial.FieldOrganizationID:
  32380. return m.OldOrganizationID(ctx)
  32381. }
  32382. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  32383. }
  32384. // SetField sets the value of a field with the given name. It returns an error if
  32385. // the field is not defined in the schema, or if the type mismatched the field
  32386. // type.
  32387. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  32388. switch name {
  32389. case tutorial.FieldCreatedAt:
  32390. v, ok := value.(time.Time)
  32391. if !ok {
  32392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32393. }
  32394. m.SetCreatedAt(v)
  32395. return nil
  32396. case tutorial.FieldUpdatedAt:
  32397. v, ok := value.(time.Time)
  32398. if !ok {
  32399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32400. }
  32401. m.SetUpdatedAt(v)
  32402. return nil
  32403. case tutorial.FieldDeletedAt:
  32404. v, ok := value.(time.Time)
  32405. if !ok {
  32406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32407. }
  32408. m.SetDeletedAt(v)
  32409. return nil
  32410. case tutorial.FieldEmployeeID:
  32411. v, ok := value.(uint64)
  32412. if !ok {
  32413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32414. }
  32415. m.SetEmployeeID(v)
  32416. return nil
  32417. case tutorial.FieldIndex:
  32418. v, ok := value.(int)
  32419. if !ok {
  32420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32421. }
  32422. m.SetIndex(v)
  32423. return nil
  32424. case tutorial.FieldTitle:
  32425. v, ok := value.(string)
  32426. if !ok {
  32427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32428. }
  32429. m.SetTitle(v)
  32430. return nil
  32431. case tutorial.FieldContent:
  32432. v, ok := value.(string)
  32433. if !ok {
  32434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32435. }
  32436. m.SetContent(v)
  32437. return nil
  32438. case tutorial.FieldOrganizationID:
  32439. v, ok := value.(uint64)
  32440. if !ok {
  32441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32442. }
  32443. m.SetOrganizationID(v)
  32444. return nil
  32445. }
  32446. return fmt.Errorf("unknown Tutorial field %s", name)
  32447. }
  32448. // AddedFields returns all numeric fields that were incremented/decremented during
  32449. // this mutation.
  32450. func (m *TutorialMutation) AddedFields() []string {
  32451. var fields []string
  32452. if m.addindex != nil {
  32453. fields = append(fields, tutorial.FieldIndex)
  32454. }
  32455. if m.addorganization_id != nil {
  32456. fields = append(fields, tutorial.FieldOrganizationID)
  32457. }
  32458. return fields
  32459. }
  32460. // AddedField returns the numeric value that was incremented/decremented on a field
  32461. // with the given name. The second boolean return value indicates that this field
  32462. // was not set, or was not defined in the schema.
  32463. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  32464. switch name {
  32465. case tutorial.FieldIndex:
  32466. return m.AddedIndex()
  32467. case tutorial.FieldOrganizationID:
  32468. return m.AddedOrganizationID()
  32469. }
  32470. return nil, false
  32471. }
  32472. // AddField adds the value to the field with the given name. It returns an error if
  32473. // the field is not defined in the schema, or if the type mismatched the field
  32474. // type.
  32475. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  32476. switch name {
  32477. case tutorial.FieldIndex:
  32478. v, ok := value.(int)
  32479. if !ok {
  32480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32481. }
  32482. m.AddIndex(v)
  32483. return nil
  32484. case tutorial.FieldOrganizationID:
  32485. v, ok := value.(int64)
  32486. if !ok {
  32487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32488. }
  32489. m.AddOrganizationID(v)
  32490. return nil
  32491. }
  32492. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  32493. }
  32494. // ClearedFields returns all nullable fields that were cleared during this
  32495. // mutation.
  32496. func (m *TutorialMutation) ClearedFields() []string {
  32497. var fields []string
  32498. if m.FieldCleared(tutorial.FieldDeletedAt) {
  32499. fields = append(fields, tutorial.FieldDeletedAt)
  32500. }
  32501. return fields
  32502. }
  32503. // FieldCleared returns a boolean indicating if a field with the given name was
  32504. // cleared in this mutation.
  32505. func (m *TutorialMutation) FieldCleared(name string) bool {
  32506. _, ok := m.clearedFields[name]
  32507. return ok
  32508. }
  32509. // ClearField clears the value of the field with the given name. It returns an
  32510. // error if the field is not defined in the schema.
  32511. func (m *TutorialMutation) ClearField(name string) error {
  32512. switch name {
  32513. case tutorial.FieldDeletedAt:
  32514. m.ClearDeletedAt()
  32515. return nil
  32516. }
  32517. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  32518. }
  32519. // ResetField resets all changes in the mutation for the field with the given name.
  32520. // It returns an error if the field is not defined in the schema.
  32521. func (m *TutorialMutation) ResetField(name string) error {
  32522. switch name {
  32523. case tutorial.FieldCreatedAt:
  32524. m.ResetCreatedAt()
  32525. return nil
  32526. case tutorial.FieldUpdatedAt:
  32527. m.ResetUpdatedAt()
  32528. return nil
  32529. case tutorial.FieldDeletedAt:
  32530. m.ResetDeletedAt()
  32531. return nil
  32532. case tutorial.FieldEmployeeID:
  32533. m.ResetEmployeeID()
  32534. return nil
  32535. case tutorial.FieldIndex:
  32536. m.ResetIndex()
  32537. return nil
  32538. case tutorial.FieldTitle:
  32539. m.ResetTitle()
  32540. return nil
  32541. case tutorial.FieldContent:
  32542. m.ResetContent()
  32543. return nil
  32544. case tutorial.FieldOrganizationID:
  32545. m.ResetOrganizationID()
  32546. return nil
  32547. }
  32548. return fmt.Errorf("unknown Tutorial field %s", name)
  32549. }
  32550. // AddedEdges returns all edge names that were set/added in this mutation.
  32551. func (m *TutorialMutation) AddedEdges() []string {
  32552. edges := make([]string, 0, 1)
  32553. if m.employee != nil {
  32554. edges = append(edges, tutorial.EdgeEmployee)
  32555. }
  32556. return edges
  32557. }
  32558. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32559. // name in this mutation.
  32560. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  32561. switch name {
  32562. case tutorial.EdgeEmployee:
  32563. if id := m.employee; id != nil {
  32564. return []ent.Value{*id}
  32565. }
  32566. }
  32567. return nil
  32568. }
  32569. // RemovedEdges returns all edge names that were removed in this mutation.
  32570. func (m *TutorialMutation) RemovedEdges() []string {
  32571. edges := make([]string, 0, 1)
  32572. return edges
  32573. }
  32574. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32575. // the given name in this mutation.
  32576. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  32577. return nil
  32578. }
  32579. // ClearedEdges returns all edge names that were cleared in this mutation.
  32580. func (m *TutorialMutation) ClearedEdges() []string {
  32581. edges := make([]string, 0, 1)
  32582. if m.clearedemployee {
  32583. edges = append(edges, tutorial.EdgeEmployee)
  32584. }
  32585. return edges
  32586. }
  32587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32588. // was cleared in this mutation.
  32589. func (m *TutorialMutation) EdgeCleared(name string) bool {
  32590. switch name {
  32591. case tutorial.EdgeEmployee:
  32592. return m.clearedemployee
  32593. }
  32594. return false
  32595. }
  32596. // ClearEdge clears the value of the edge with the given name. It returns an error
  32597. // if that edge is not defined in the schema.
  32598. func (m *TutorialMutation) ClearEdge(name string) error {
  32599. switch name {
  32600. case tutorial.EdgeEmployee:
  32601. m.ClearEmployee()
  32602. return nil
  32603. }
  32604. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  32605. }
  32606. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32607. // It returns an error if the edge is not defined in the schema.
  32608. func (m *TutorialMutation) ResetEdge(name string) error {
  32609. switch name {
  32610. case tutorial.EdgeEmployee:
  32611. m.ResetEmployee()
  32612. return nil
  32613. }
  32614. return fmt.Errorf("unknown Tutorial edge %s", name)
  32615. }
  32616. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  32617. type UsageDetailMutation struct {
  32618. config
  32619. op Op
  32620. typ string
  32621. id *uint64
  32622. created_at *time.Time
  32623. updated_at *time.Time
  32624. status *uint8
  32625. addstatus *int8
  32626. _type *int
  32627. add_type *int
  32628. bot_id *string
  32629. receiver_id *string
  32630. app *int
  32631. addapp *int
  32632. session_id *uint64
  32633. addsession_id *int64
  32634. request *string
  32635. response *string
  32636. original_data *custom_types.OriginalData
  32637. total_tokens *uint64
  32638. addtotal_tokens *int64
  32639. prompt_tokens *uint64
  32640. addprompt_tokens *int64
  32641. completion_tokens *uint64
  32642. addcompletion_tokens *int64
  32643. organization_id *uint64
  32644. addorganization_id *int64
  32645. clearedFields map[string]struct{}
  32646. done bool
  32647. oldValue func(context.Context) (*UsageDetail, error)
  32648. predicates []predicate.UsageDetail
  32649. }
  32650. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  32651. // usagedetailOption allows management of the mutation configuration using functional options.
  32652. type usagedetailOption func(*UsageDetailMutation)
  32653. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  32654. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  32655. m := &UsageDetailMutation{
  32656. config: c,
  32657. op: op,
  32658. typ: TypeUsageDetail,
  32659. clearedFields: make(map[string]struct{}),
  32660. }
  32661. for _, opt := range opts {
  32662. opt(m)
  32663. }
  32664. return m
  32665. }
  32666. // withUsageDetailID sets the ID field of the mutation.
  32667. func withUsageDetailID(id uint64) usagedetailOption {
  32668. return func(m *UsageDetailMutation) {
  32669. var (
  32670. err error
  32671. once sync.Once
  32672. value *UsageDetail
  32673. )
  32674. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  32675. once.Do(func() {
  32676. if m.done {
  32677. err = errors.New("querying old values post mutation is not allowed")
  32678. } else {
  32679. value, err = m.Client().UsageDetail.Get(ctx, id)
  32680. }
  32681. })
  32682. return value, err
  32683. }
  32684. m.id = &id
  32685. }
  32686. }
  32687. // withUsageDetail sets the old UsageDetail of the mutation.
  32688. func withUsageDetail(node *UsageDetail) usagedetailOption {
  32689. return func(m *UsageDetailMutation) {
  32690. m.oldValue = func(context.Context) (*UsageDetail, error) {
  32691. return node, nil
  32692. }
  32693. m.id = &node.ID
  32694. }
  32695. }
  32696. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32697. // executed in a transaction (ent.Tx), a transactional client is returned.
  32698. func (m UsageDetailMutation) Client() *Client {
  32699. client := &Client{config: m.config}
  32700. client.init()
  32701. return client
  32702. }
  32703. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32704. // it returns an error otherwise.
  32705. func (m UsageDetailMutation) Tx() (*Tx, error) {
  32706. if _, ok := m.driver.(*txDriver); !ok {
  32707. return nil, errors.New("ent: mutation is not running in a transaction")
  32708. }
  32709. tx := &Tx{config: m.config}
  32710. tx.init()
  32711. return tx, nil
  32712. }
  32713. // SetID sets the value of the id field. Note that this
  32714. // operation is only accepted on creation of UsageDetail entities.
  32715. func (m *UsageDetailMutation) SetID(id uint64) {
  32716. m.id = &id
  32717. }
  32718. // ID returns the ID value in the mutation. Note that the ID is only available
  32719. // if it was provided to the builder or after it was returned from the database.
  32720. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  32721. if m.id == nil {
  32722. return
  32723. }
  32724. return *m.id, true
  32725. }
  32726. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32727. // That means, if the mutation is applied within a transaction with an isolation level such
  32728. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32729. // or updated by the mutation.
  32730. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  32731. switch {
  32732. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32733. id, exists := m.ID()
  32734. if exists {
  32735. return []uint64{id}, nil
  32736. }
  32737. fallthrough
  32738. case m.op.Is(OpUpdate | OpDelete):
  32739. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  32740. default:
  32741. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32742. }
  32743. }
  32744. // SetCreatedAt sets the "created_at" field.
  32745. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  32746. m.created_at = &t
  32747. }
  32748. // CreatedAt returns the value of the "created_at" field in the mutation.
  32749. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  32750. v := m.created_at
  32751. if v == nil {
  32752. return
  32753. }
  32754. return *v, true
  32755. }
  32756. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  32757. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32759. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32760. if !m.op.Is(OpUpdateOne) {
  32761. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32762. }
  32763. if m.id == nil || m.oldValue == nil {
  32764. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32765. }
  32766. oldValue, err := m.oldValue(ctx)
  32767. if err != nil {
  32768. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32769. }
  32770. return oldValue.CreatedAt, nil
  32771. }
  32772. // ResetCreatedAt resets all changes to the "created_at" field.
  32773. func (m *UsageDetailMutation) ResetCreatedAt() {
  32774. m.created_at = nil
  32775. }
  32776. // SetUpdatedAt sets the "updated_at" field.
  32777. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  32778. m.updated_at = &t
  32779. }
  32780. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32781. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  32782. v := m.updated_at
  32783. if v == nil {
  32784. return
  32785. }
  32786. return *v, true
  32787. }
  32788. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  32789. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32791. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32792. if !m.op.Is(OpUpdateOne) {
  32793. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32794. }
  32795. if m.id == nil || m.oldValue == nil {
  32796. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32797. }
  32798. oldValue, err := m.oldValue(ctx)
  32799. if err != nil {
  32800. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32801. }
  32802. return oldValue.UpdatedAt, nil
  32803. }
  32804. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32805. func (m *UsageDetailMutation) ResetUpdatedAt() {
  32806. m.updated_at = nil
  32807. }
  32808. // SetStatus sets the "status" field.
  32809. func (m *UsageDetailMutation) SetStatus(u uint8) {
  32810. m.status = &u
  32811. m.addstatus = nil
  32812. }
  32813. // Status returns the value of the "status" field in the mutation.
  32814. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  32815. v := m.status
  32816. if v == nil {
  32817. return
  32818. }
  32819. return *v, true
  32820. }
  32821. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  32822. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32824. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32825. if !m.op.Is(OpUpdateOne) {
  32826. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32827. }
  32828. if m.id == nil || m.oldValue == nil {
  32829. return v, errors.New("OldStatus requires an ID field in the mutation")
  32830. }
  32831. oldValue, err := m.oldValue(ctx)
  32832. if err != nil {
  32833. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32834. }
  32835. return oldValue.Status, nil
  32836. }
  32837. // AddStatus adds u to the "status" field.
  32838. func (m *UsageDetailMutation) AddStatus(u int8) {
  32839. if m.addstatus != nil {
  32840. *m.addstatus += u
  32841. } else {
  32842. m.addstatus = &u
  32843. }
  32844. }
  32845. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32846. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  32847. v := m.addstatus
  32848. if v == nil {
  32849. return
  32850. }
  32851. return *v, true
  32852. }
  32853. // ClearStatus clears the value of the "status" field.
  32854. func (m *UsageDetailMutation) ClearStatus() {
  32855. m.status = nil
  32856. m.addstatus = nil
  32857. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  32858. }
  32859. // StatusCleared returns if the "status" field was cleared in this mutation.
  32860. func (m *UsageDetailMutation) StatusCleared() bool {
  32861. _, ok := m.clearedFields[usagedetail.FieldStatus]
  32862. return ok
  32863. }
  32864. // ResetStatus resets all changes to the "status" field.
  32865. func (m *UsageDetailMutation) ResetStatus() {
  32866. m.status = nil
  32867. m.addstatus = nil
  32868. delete(m.clearedFields, usagedetail.FieldStatus)
  32869. }
  32870. // SetType sets the "type" field.
  32871. func (m *UsageDetailMutation) SetType(i int) {
  32872. m._type = &i
  32873. m.add_type = nil
  32874. }
  32875. // GetType returns the value of the "type" field in the mutation.
  32876. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  32877. v := m._type
  32878. if v == nil {
  32879. return
  32880. }
  32881. return *v, true
  32882. }
  32883. // OldType returns the old "type" field's value of the UsageDetail entity.
  32884. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32886. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  32887. if !m.op.Is(OpUpdateOne) {
  32888. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32889. }
  32890. if m.id == nil || m.oldValue == nil {
  32891. return v, errors.New("OldType requires an ID field in the mutation")
  32892. }
  32893. oldValue, err := m.oldValue(ctx)
  32894. if err != nil {
  32895. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32896. }
  32897. return oldValue.Type, nil
  32898. }
  32899. // AddType adds i to the "type" field.
  32900. func (m *UsageDetailMutation) AddType(i int) {
  32901. if m.add_type != nil {
  32902. *m.add_type += i
  32903. } else {
  32904. m.add_type = &i
  32905. }
  32906. }
  32907. // AddedType returns the value that was added to the "type" field in this mutation.
  32908. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  32909. v := m.add_type
  32910. if v == nil {
  32911. return
  32912. }
  32913. return *v, true
  32914. }
  32915. // ClearType clears the value of the "type" field.
  32916. func (m *UsageDetailMutation) ClearType() {
  32917. m._type = nil
  32918. m.add_type = nil
  32919. m.clearedFields[usagedetail.FieldType] = struct{}{}
  32920. }
  32921. // TypeCleared returns if the "type" field was cleared in this mutation.
  32922. func (m *UsageDetailMutation) TypeCleared() bool {
  32923. _, ok := m.clearedFields[usagedetail.FieldType]
  32924. return ok
  32925. }
  32926. // ResetType resets all changes to the "type" field.
  32927. func (m *UsageDetailMutation) ResetType() {
  32928. m._type = nil
  32929. m.add_type = nil
  32930. delete(m.clearedFields, usagedetail.FieldType)
  32931. }
  32932. // SetBotID sets the "bot_id" field.
  32933. func (m *UsageDetailMutation) SetBotID(s string) {
  32934. m.bot_id = &s
  32935. }
  32936. // BotID returns the value of the "bot_id" field in the mutation.
  32937. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  32938. v := m.bot_id
  32939. if v == nil {
  32940. return
  32941. }
  32942. return *v, true
  32943. }
  32944. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  32945. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32947. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  32948. if !m.op.Is(OpUpdateOne) {
  32949. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32950. }
  32951. if m.id == nil || m.oldValue == nil {
  32952. return v, errors.New("OldBotID requires an ID field in the mutation")
  32953. }
  32954. oldValue, err := m.oldValue(ctx)
  32955. if err != nil {
  32956. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32957. }
  32958. return oldValue.BotID, nil
  32959. }
  32960. // ResetBotID resets all changes to the "bot_id" field.
  32961. func (m *UsageDetailMutation) ResetBotID() {
  32962. m.bot_id = nil
  32963. }
  32964. // SetReceiverID sets the "receiver_id" field.
  32965. func (m *UsageDetailMutation) SetReceiverID(s string) {
  32966. m.receiver_id = &s
  32967. }
  32968. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  32969. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  32970. v := m.receiver_id
  32971. if v == nil {
  32972. return
  32973. }
  32974. return *v, true
  32975. }
  32976. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  32977. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32979. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  32980. if !m.op.Is(OpUpdateOne) {
  32981. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  32982. }
  32983. if m.id == nil || m.oldValue == nil {
  32984. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  32985. }
  32986. oldValue, err := m.oldValue(ctx)
  32987. if err != nil {
  32988. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  32989. }
  32990. return oldValue.ReceiverID, nil
  32991. }
  32992. // ResetReceiverID resets all changes to the "receiver_id" field.
  32993. func (m *UsageDetailMutation) ResetReceiverID() {
  32994. m.receiver_id = nil
  32995. }
  32996. // SetApp sets the "app" field.
  32997. func (m *UsageDetailMutation) SetApp(i int) {
  32998. m.app = &i
  32999. m.addapp = nil
  33000. }
  33001. // App returns the value of the "app" field in the mutation.
  33002. func (m *UsageDetailMutation) App() (r int, exists bool) {
  33003. v := m.app
  33004. if v == nil {
  33005. return
  33006. }
  33007. return *v, true
  33008. }
  33009. // OldApp returns the old "app" field's value of the UsageDetail entity.
  33010. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33012. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  33013. if !m.op.Is(OpUpdateOne) {
  33014. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  33015. }
  33016. if m.id == nil || m.oldValue == nil {
  33017. return v, errors.New("OldApp requires an ID field in the mutation")
  33018. }
  33019. oldValue, err := m.oldValue(ctx)
  33020. if err != nil {
  33021. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  33022. }
  33023. return oldValue.App, nil
  33024. }
  33025. // AddApp adds i to the "app" field.
  33026. func (m *UsageDetailMutation) AddApp(i int) {
  33027. if m.addapp != nil {
  33028. *m.addapp += i
  33029. } else {
  33030. m.addapp = &i
  33031. }
  33032. }
  33033. // AddedApp returns the value that was added to the "app" field in this mutation.
  33034. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  33035. v := m.addapp
  33036. if v == nil {
  33037. return
  33038. }
  33039. return *v, true
  33040. }
  33041. // ClearApp clears the value of the "app" field.
  33042. func (m *UsageDetailMutation) ClearApp() {
  33043. m.app = nil
  33044. m.addapp = nil
  33045. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  33046. }
  33047. // AppCleared returns if the "app" field was cleared in this mutation.
  33048. func (m *UsageDetailMutation) AppCleared() bool {
  33049. _, ok := m.clearedFields[usagedetail.FieldApp]
  33050. return ok
  33051. }
  33052. // ResetApp resets all changes to the "app" field.
  33053. func (m *UsageDetailMutation) ResetApp() {
  33054. m.app = nil
  33055. m.addapp = nil
  33056. delete(m.clearedFields, usagedetail.FieldApp)
  33057. }
  33058. // SetSessionID sets the "session_id" field.
  33059. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  33060. m.session_id = &u
  33061. m.addsession_id = nil
  33062. }
  33063. // SessionID returns the value of the "session_id" field in the mutation.
  33064. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  33065. v := m.session_id
  33066. if v == nil {
  33067. return
  33068. }
  33069. return *v, true
  33070. }
  33071. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  33072. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33074. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  33075. if !m.op.Is(OpUpdateOne) {
  33076. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  33077. }
  33078. if m.id == nil || m.oldValue == nil {
  33079. return v, errors.New("OldSessionID requires an ID field in the mutation")
  33080. }
  33081. oldValue, err := m.oldValue(ctx)
  33082. if err != nil {
  33083. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  33084. }
  33085. return oldValue.SessionID, nil
  33086. }
  33087. // AddSessionID adds u to the "session_id" field.
  33088. func (m *UsageDetailMutation) AddSessionID(u int64) {
  33089. if m.addsession_id != nil {
  33090. *m.addsession_id += u
  33091. } else {
  33092. m.addsession_id = &u
  33093. }
  33094. }
  33095. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  33096. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  33097. v := m.addsession_id
  33098. if v == nil {
  33099. return
  33100. }
  33101. return *v, true
  33102. }
  33103. // ClearSessionID clears the value of the "session_id" field.
  33104. func (m *UsageDetailMutation) ClearSessionID() {
  33105. m.session_id = nil
  33106. m.addsession_id = nil
  33107. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  33108. }
  33109. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  33110. func (m *UsageDetailMutation) SessionIDCleared() bool {
  33111. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  33112. return ok
  33113. }
  33114. // ResetSessionID resets all changes to the "session_id" field.
  33115. func (m *UsageDetailMutation) ResetSessionID() {
  33116. m.session_id = nil
  33117. m.addsession_id = nil
  33118. delete(m.clearedFields, usagedetail.FieldSessionID)
  33119. }
  33120. // SetRequest sets the "request" field.
  33121. func (m *UsageDetailMutation) SetRequest(s string) {
  33122. m.request = &s
  33123. }
  33124. // Request returns the value of the "request" field in the mutation.
  33125. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  33126. v := m.request
  33127. if v == nil {
  33128. return
  33129. }
  33130. return *v, true
  33131. }
  33132. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  33133. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33135. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  33136. if !m.op.Is(OpUpdateOne) {
  33137. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  33138. }
  33139. if m.id == nil || m.oldValue == nil {
  33140. return v, errors.New("OldRequest requires an ID field in the mutation")
  33141. }
  33142. oldValue, err := m.oldValue(ctx)
  33143. if err != nil {
  33144. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  33145. }
  33146. return oldValue.Request, nil
  33147. }
  33148. // ResetRequest resets all changes to the "request" field.
  33149. func (m *UsageDetailMutation) ResetRequest() {
  33150. m.request = nil
  33151. }
  33152. // SetResponse sets the "response" field.
  33153. func (m *UsageDetailMutation) SetResponse(s string) {
  33154. m.response = &s
  33155. }
  33156. // Response returns the value of the "response" field in the mutation.
  33157. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  33158. v := m.response
  33159. if v == nil {
  33160. return
  33161. }
  33162. return *v, true
  33163. }
  33164. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  33165. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33167. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  33168. if !m.op.Is(OpUpdateOne) {
  33169. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  33170. }
  33171. if m.id == nil || m.oldValue == nil {
  33172. return v, errors.New("OldResponse requires an ID field in the mutation")
  33173. }
  33174. oldValue, err := m.oldValue(ctx)
  33175. if err != nil {
  33176. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  33177. }
  33178. return oldValue.Response, nil
  33179. }
  33180. // ResetResponse resets all changes to the "response" field.
  33181. func (m *UsageDetailMutation) ResetResponse() {
  33182. m.response = nil
  33183. }
  33184. // SetOriginalData sets the "original_data" field.
  33185. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  33186. m.original_data = &ctd
  33187. }
  33188. // OriginalData returns the value of the "original_data" field in the mutation.
  33189. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  33190. v := m.original_data
  33191. if v == nil {
  33192. return
  33193. }
  33194. return *v, true
  33195. }
  33196. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  33197. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33199. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  33200. if !m.op.Is(OpUpdateOne) {
  33201. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  33202. }
  33203. if m.id == nil || m.oldValue == nil {
  33204. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  33205. }
  33206. oldValue, err := m.oldValue(ctx)
  33207. if err != nil {
  33208. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  33209. }
  33210. return oldValue.OriginalData, nil
  33211. }
  33212. // ResetOriginalData resets all changes to the "original_data" field.
  33213. func (m *UsageDetailMutation) ResetOriginalData() {
  33214. m.original_data = nil
  33215. }
  33216. // SetTotalTokens sets the "total_tokens" field.
  33217. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  33218. m.total_tokens = &u
  33219. m.addtotal_tokens = nil
  33220. }
  33221. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33222. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  33223. v := m.total_tokens
  33224. if v == nil {
  33225. return
  33226. }
  33227. return *v, true
  33228. }
  33229. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  33230. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33232. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33233. if !m.op.Is(OpUpdateOne) {
  33234. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33235. }
  33236. if m.id == nil || m.oldValue == nil {
  33237. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33238. }
  33239. oldValue, err := m.oldValue(ctx)
  33240. if err != nil {
  33241. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33242. }
  33243. return oldValue.TotalTokens, nil
  33244. }
  33245. // AddTotalTokens adds u to the "total_tokens" field.
  33246. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  33247. if m.addtotal_tokens != nil {
  33248. *m.addtotal_tokens += u
  33249. } else {
  33250. m.addtotal_tokens = &u
  33251. }
  33252. }
  33253. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33254. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  33255. v := m.addtotal_tokens
  33256. if v == nil {
  33257. return
  33258. }
  33259. return *v, true
  33260. }
  33261. // ClearTotalTokens clears the value of the "total_tokens" field.
  33262. func (m *UsageDetailMutation) ClearTotalTokens() {
  33263. m.total_tokens = nil
  33264. m.addtotal_tokens = nil
  33265. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  33266. }
  33267. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33268. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  33269. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  33270. return ok
  33271. }
  33272. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33273. func (m *UsageDetailMutation) ResetTotalTokens() {
  33274. m.total_tokens = nil
  33275. m.addtotal_tokens = nil
  33276. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  33277. }
  33278. // SetPromptTokens sets the "prompt_tokens" field.
  33279. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  33280. m.prompt_tokens = &u
  33281. m.addprompt_tokens = nil
  33282. }
  33283. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  33284. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  33285. v := m.prompt_tokens
  33286. if v == nil {
  33287. return
  33288. }
  33289. return *v, true
  33290. }
  33291. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  33292. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33294. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  33295. if !m.op.Is(OpUpdateOne) {
  33296. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  33297. }
  33298. if m.id == nil || m.oldValue == nil {
  33299. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  33300. }
  33301. oldValue, err := m.oldValue(ctx)
  33302. if err != nil {
  33303. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  33304. }
  33305. return oldValue.PromptTokens, nil
  33306. }
  33307. // AddPromptTokens adds u to the "prompt_tokens" field.
  33308. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  33309. if m.addprompt_tokens != nil {
  33310. *m.addprompt_tokens += u
  33311. } else {
  33312. m.addprompt_tokens = &u
  33313. }
  33314. }
  33315. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  33316. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  33317. v := m.addprompt_tokens
  33318. if v == nil {
  33319. return
  33320. }
  33321. return *v, true
  33322. }
  33323. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  33324. func (m *UsageDetailMutation) ClearPromptTokens() {
  33325. m.prompt_tokens = nil
  33326. m.addprompt_tokens = nil
  33327. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  33328. }
  33329. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  33330. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  33331. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  33332. return ok
  33333. }
  33334. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  33335. func (m *UsageDetailMutation) ResetPromptTokens() {
  33336. m.prompt_tokens = nil
  33337. m.addprompt_tokens = nil
  33338. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  33339. }
  33340. // SetCompletionTokens sets the "completion_tokens" field.
  33341. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  33342. m.completion_tokens = &u
  33343. m.addcompletion_tokens = nil
  33344. }
  33345. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  33346. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  33347. v := m.completion_tokens
  33348. if v == nil {
  33349. return
  33350. }
  33351. return *v, true
  33352. }
  33353. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  33354. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33356. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  33357. if !m.op.Is(OpUpdateOne) {
  33358. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  33359. }
  33360. if m.id == nil || m.oldValue == nil {
  33361. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  33362. }
  33363. oldValue, err := m.oldValue(ctx)
  33364. if err != nil {
  33365. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  33366. }
  33367. return oldValue.CompletionTokens, nil
  33368. }
  33369. // AddCompletionTokens adds u to the "completion_tokens" field.
  33370. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  33371. if m.addcompletion_tokens != nil {
  33372. *m.addcompletion_tokens += u
  33373. } else {
  33374. m.addcompletion_tokens = &u
  33375. }
  33376. }
  33377. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  33378. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  33379. v := m.addcompletion_tokens
  33380. if v == nil {
  33381. return
  33382. }
  33383. return *v, true
  33384. }
  33385. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  33386. func (m *UsageDetailMutation) ClearCompletionTokens() {
  33387. m.completion_tokens = nil
  33388. m.addcompletion_tokens = nil
  33389. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  33390. }
  33391. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  33392. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  33393. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  33394. return ok
  33395. }
  33396. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  33397. func (m *UsageDetailMutation) ResetCompletionTokens() {
  33398. m.completion_tokens = nil
  33399. m.addcompletion_tokens = nil
  33400. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  33401. }
  33402. // SetOrganizationID sets the "organization_id" field.
  33403. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  33404. m.organization_id = &u
  33405. m.addorganization_id = nil
  33406. }
  33407. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33408. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  33409. v := m.organization_id
  33410. if v == nil {
  33411. return
  33412. }
  33413. return *v, true
  33414. }
  33415. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  33416. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33418. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33419. if !m.op.Is(OpUpdateOne) {
  33420. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33421. }
  33422. if m.id == nil || m.oldValue == nil {
  33423. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33424. }
  33425. oldValue, err := m.oldValue(ctx)
  33426. if err != nil {
  33427. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33428. }
  33429. return oldValue.OrganizationID, nil
  33430. }
  33431. // AddOrganizationID adds u to the "organization_id" field.
  33432. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  33433. if m.addorganization_id != nil {
  33434. *m.addorganization_id += u
  33435. } else {
  33436. m.addorganization_id = &u
  33437. }
  33438. }
  33439. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33440. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  33441. v := m.addorganization_id
  33442. if v == nil {
  33443. return
  33444. }
  33445. return *v, true
  33446. }
  33447. // ClearOrganizationID clears the value of the "organization_id" field.
  33448. func (m *UsageDetailMutation) ClearOrganizationID() {
  33449. m.organization_id = nil
  33450. m.addorganization_id = nil
  33451. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  33452. }
  33453. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33454. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  33455. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  33456. return ok
  33457. }
  33458. // ResetOrganizationID resets all changes to the "organization_id" field.
  33459. func (m *UsageDetailMutation) ResetOrganizationID() {
  33460. m.organization_id = nil
  33461. m.addorganization_id = nil
  33462. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  33463. }
  33464. // Where appends a list predicates to the UsageDetailMutation builder.
  33465. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  33466. m.predicates = append(m.predicates, ps...)
  33467. }
  33468. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  33469. // users can use type-assertion to append predicates that do not depend on any generated package.
  33470. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  33471. p := make([]predicate.UsageDetail, len(ps))
  33472. for i := range ps {
  33473. p[i] = ps[i]
  33474. }
  33475. m.Where(p...)
  33476. }
  33477. // Op returns the operation name.
  33478. func (m *UsageDetailMutation) Op() Op {
  33479. return m.op
  33480. }
  33481. // SetOp allows setting the mutation operation.
  33482. func (m *UsageDetailMutation) SetOp(op Op) {
  33483. m.op = op
  33484. }
  33485. // Type returns the node type of this mutation (UsageDetail).
  33486. func (m *UsageDetailMutation) Type() string {
  33487. return m.typ
  33488. }
  33489. // Fields returns all fields that were changed during this mutation. Note that in
  33490. // order to get all numeric fields that were incremented/decremented, call
  33491. // AddedFields().
  33492. func (m *UsageDetailMutation) Fields() []string {
  33493. fields := make([]string, 0, 15)
  33494. if m.created_at != nil {
  33495. fields = append(fields, usagedetail.FieldCreatedAt)
  33496. }
  33497. if m.updated_at != nil {
  33498. fields = append(fields, usagedetail.FieldUpdatedAt)
  33499. }
  33500. if m.status != nil {
  33501. fields = append(fields, usagedetail.FieldStatus)
  33502. }
  33503. if m._type != nil {
  33504. fields = append(fields, usagedetail.FieldType)
  33505. }
  33506. if m.bot_id != nil {
  33507. fields = append(fields, usagedetail.FieldBotID)
  33508. }
  33509. if m.receiver_id != nil {
  33510. fields = append(fields, usagedetail.FieldReceiverID)
  33511. }
  33512. if m.app != nil {
  33513. fields = append(fields, usagedetail.FieldApp)
  33514. }
  33515. if m.session_id != nil {
  33516. fields = append(fields, usagedetail.FieldSessionID)
  33517. }
  33518. if m.request != nil {
  33519. fields = append(fields, usagedetail.FieldRequest)
  33520. }
  33521. if m.response != nil {
  33522. fields = append(fields, usagedetail.FieldResponse)
  33523. }
  33524. if m.original_data != nil {
  33525. fields = append(fields, usagedetail.FieldOriginalData)
  33526. }
  33527. if m.total_tokens != nil {
  33528. fields = append(fields, usagedetail.FieldTotalTokens)
  33529. }
  33530. if m.prompt_tokens != nil {
  33531. fields = append(fields, usagedetail.FieldPromptTokens)
  33532. }
  33533. if m.completion_tokens != nil {
  33534. fields = append(fields, usagedetail.FieldCompletionTokens)
  33535. }
  33536. if m.organization_id != nil {
  33537. fields = append(fields, usagedetail.FieldOrganizationID)
  33538. }
  33539. return fields
  33540. }
  33541. // Field returns the value of a field with the given name. The second boolean
  33542. // return value indicates that this field was not set, or was not defined in the
  33543. // schema.
  33544. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  33545. switch name {
  33546. case usagedetail.FieldCreatedAt:
  33547. return m.CreatedAt()
  33548. case usagedetail.FieldUpdatedAt:
  33549. return m.UpdatedAt()
  33550. case usagedetail.FieldStatus:
  33551. return m.Status()
  33552. case usagedetail.FieldType:
  33553. return m.GetType()
  33554. case usagedetail.FieldBotID:
  33555. return m.BotID()
  33556. case usagedetail.FieldReceiverID:
  33557. return m.ReceiverID()
  33558. case usagedetail.FieldApp:
  33559. return m.App()
  33560. case usagedetail.FieldSessionID:
  33561. return m.SessionID()
  33562. case usagedetail.FieldRequest:
  33563. return m.Request()
  33564. case usagedetail.FieldResponse:
  33565. return m.Response()
  33566. case usagedetail.FieldOriginalData:
  33567. return m.OriginalData()
  33568. case usagedetail.FieldTotalTokens:
  33569. return m.TotalTokens()
  33570. case usagedetail.FieldPromptTokens:
  33571. return m.PromptTokens()
  33572. case usagedetail.FieldCompletionTokens:
  33573. return m.CompletionTokens()
  33574. case usagedetail.FieldOrganizationID:
  33575. return m.OrganizationID()
  33576. }
  33577. return nil, false
  33578. }
  33579. // OldField returns the old value of the field from the database. An error is
  33580. // returned if the mutation operation is not UpdateOne, or the query to the
  33581. // database failed.
  33582. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33583. switch name {
  33584. case usagedetail.FieldCreatedAt:
  33585. return m.OldCreatedAt(ctx)
  33586. case usagedetail.FieldUpdatedAt:
  33587. return m.OldUpdatedAt(ctx)
  33588. case usagedetail.FieldStatus:
  33589. return m.OldStatus(ctx)
  33590. case usagedetail.FieldType:
  33591. return m.OldType(ctx)
  33592. case usagedetail.FieldBotID:
  33593. return m.OldBotID(ctx)
  33594. case usagedetail.FieldReceiverID:
  33595. return m.OldReceiverID(ctx)
  33596. case usagedetail.FieldApp:
  33597. return m.OldApp(ctx)
  33598. case usagedetail.FieldSessionID:
  33599. return m.OldSessionID(ctx)
  33600. case usagedetail.FieldRequest:
  33601. return m.OldRequest(ctx)
  33602. case usagedetail.FieldResponse:
  33603. return m.OldResponse(ctx)
  33604. case usagedetail.FieldOriginalData:
  33605. return m.OldOriginalData(ctx)
  33606. case usagedetail.FieldTotalTokens:
  33607. return m.OldTotalTokens(ctx)
  33608. case usagedetail.FieldPromptTokens:
  33609. return m.OldPromptTokens(ctx)
  33610. case usagedetail.FieldCompletionTokens:
  33611. return m.OldCompletionTokens(ctx)
  33612. case usagedetail.FieldOrganizationID:
  33613. return m.OldOrganizationID(ctx)
  33614. }
  33615. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  33616. }
  33617. // SetField sets the value of a field with the given name. It returns an error if
  33618. // the field is not defined in the schema, or if the type mismatched the field
  33619. // type.
  33620. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  33621. switch name {
  33622. case usagedetail.FieldCreatedAt:
  33623. v, ok := value.(time.Time)
  33624. if !ok {
  33625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33626. }
  33627. m.SetCreatedAt(v)
  33628. return nil
  33629. case usagedetail.FieldUpdatedAt:
  33630. v, ok := value.(time.Time)
  33631. if !ok {
  33632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33633. }
  33634. m.SetUpdatedAt(v)
  33635. return nil
  33636. case usagedetail.FieldStatus:
  33637. v, ok := value.(uint8)
  33638. if !ok {
  33639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33640. }
  33641. m.SetStatus(v)
  33642. return nil
  33643. case usagedetail.FieldType:
  33644. v, ok := value.(int)
  33645. if !ok {
  33646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33647. }
  33648. m.SetType(v)
  33649. return nil
  33650. case usagedetail.FieldBotID:
  33651. v, ok := value.(string)
  33652. if !ok {
  33653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33654. }
  33655. m.SetBotID(v)
  33656. return nil
  33657. case usagedetail.FieldReceiverID:
  33658. v, ok := value.(string)
  33659. if !ok {
  33660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33661. }
  33662. m.SetReceiverID(v)
  33663. return nil
  33664. case usagedetail.FieldApp:
  33665. v, ok := value.(int)
  33666. if !ok {
  33667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33668. }
  33669. m.SetApp(v)
  33670. return nil
  33671. case usagedetail.FieldSessionID:
  33672. v, ok := value.(uint64)
  33673. if !ok {
  33674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33675. }
  33676. m.SetSessionID(v)
  33677. return nil
  33678. case usagedetail.FieldRequest:
  33679. v, ok := value.(string)
  33680. if !ok {
  33681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33682. }
  33683. m.SetRequest(v)
  33684. return nil
  33685. case usagedetail.FieldResponse:
  33686. v, ok := value.(string)
  33687. if !ok {
  33688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33689. }
  33690. m.SetResponse(v)
  33691. return nil
  33692. case usagedetail.FieldOriginalData:
  33693. v, ok := value.(custom_types.OriginalData)
  33694. if !ok {
  33695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33696. }
  33697. m.SetOriginalData(v)
  33698. return nil
  33699. case usagedetail.FieldTotalTokens:
  33700. v, ok := value.(uint64)
  33701. if !ok {
  33702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33703. }
  33704. m.SetTotalTokens(v)
  33705. return nil
  33706. case usagedetail.FieldPromptTokens:
  33707. v, ok := value.(uint64)
  33708. if !ok {
  33709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33710. }
  33711. m.SetPromptTokens(v)
  33712. return nil
  33713. case usagedetail.FieldCompletionTokens:
  33714. v, ok := value.(uint64)
  33715. if !ok {
  33716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33717. }
  33718. m.SetCompletionTokens(v)
  33719. return nil
  33720. case usagedetail.FieldOrganizationID:
  33721. v, ok := value.(uint64)
  33722. if !ok {
  33723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33724. }
  33725. m.SetOrganizationID(v)
  33726. return nil
  33727. }
  33728. return fmt.Errorf("unknown UsageDetail field %s", name)
  33729. }
  33730. // AddedFields returns all numeric fields that were incremented/decremented during
  33731. // this mutation.
  33732. func (m *UsageDetailMutation) AddedFields() []string {
  33733. var fields []string
  33734. if m.addstatus != nil {
  33735. fields = append(fields, usagedetail.FieldStatus)
  33736. }
  33737. if m.add_type != nil {
  33738. fields = append(fields, usagedetail.FieldType)
  33739. }
  33740. if m.addapp != nil {
  33741. fields = append(fields, usagedetail.FieldApp)
  33742. }
  33743. if m.addsession_id != nil {
  33744. fields = append(fields, usagedetail.FieldSessionID)
  33745. }
  33746. if m.addtotal_tokens != nil {
  33747. fields = append(fields, usagedetail.FieldTotalTokens)
  33748. }
  33749. if m.addprompt_tokens != nil {
  33750. fields = append(fields, usagedetail.FieldPromptTokens)
  33751. }
  33752. if m.addcompletion_tokens != nil {
  33753. fields = append(fields, usagedetail.FieldCompletionTokens)
  33754. }
  33755. if m.addorganization_id != nil {
  33756. fields = append(fields, usagedetail.FieldOrganizationID)
  33757. }
  33758. return fields
  33759. }
  33760. // AddedField returns the numeric value that was incremented/decremented on a field
  33761. // with the given name. The second boolean return value indicates that this field
  33762. // was not set, or was not defined in the schema.
  33763. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  33764. switch name {
  33765. case usagedetail.FieldStatus:
  33766. return m.AddedStatus()
  33767. case usagedetail.FieldType:
  33768. return m.AddedType()
  33769. case usagedetail.FieldApp:
  33770. return m.AddedApp()
  33771. case usagedetail.FieldSessionID:
  33772. return m.AddedSessionID()
  33773. case usagedetail.FieldTotalTokens:
  33774. return m.AddedTotalTokens()
  33775. case usagedetail.FieldPromptTokens:
  33776. return m.AddedPromptTokens()
  33777. case usagedetail.FieldCompletionTokens:
  33778. return m.AddedCompletionTokens()
  33779. case usagedetail.FieldOrganizationID:
  33780. return m.AddedOrganizationID()
  33781. }
  33782. return nil, false
  33783. }
  33784. // AddField adds the value to the field with the given name. It returns an error if
  33785. // the field is not defined in the schema, or if the type mismatched the field
  33786. // type.
  33787. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  33788. switch name {
  33789. case usagedetail.FieldStatus:
  33790. v, ok := value.(int8)
  33791. if !ok {
  33792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33793. }
  33794. m.AddStatus(v)
  33795. return nil
  33796. case usagedetail.FieldType:
  33797. v, ok := value.(int)
  33798. if !ok {
  33799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33800. }
  33801. m.AddType(v)
  33802. return nil
  33803. case usagedetail.FieldApp:
  33804. v, ok := value.(int)
  33805. if !ok {
  33806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33807. }
  33808. m.AddApp(v)
  33809. return nil
  33810. case usagedetail.FieldSessionID:
  33811. v, ok := value.(int64)
  33812. if !ok {
  33813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33814. }
  33815. m.AddSessionID(v)
  33816. return nil
  33817. case usagedetail.FieldTotalTokens:
  33818. v, ok := value.(int64)
  33819. if !ok {
  33820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33821. }
  33822. m.AddTotalTokens(v)
  33823. return nil
  33824. case usagedetail.FieldPromptTokens:
  33825. v, ok := value.(int64)
  33826. if !ok {
  33827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33828. }
  33829. m.AddPromptTokens(v)
  33830. return nil
  33831. case usagedetail.FieldCompletionTokens:
  33832. v, ok := value.(int64)
  33833. if !ok {
  33834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33835. }
  33836. m.AddCompletionTokens(v)
  33837. return nil
  33838. case usagedetail.FieldOrganizationID:
  33839. v, ok := value.(int64)
  33840. if !ok {
  33841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33842. }
  33843. m.AddOrganizationID(v)
  33844. return nil
  33845. }
  33846. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  33847. }
  33848. // ClearedFields returns all nullable fields that were cleared during this
  33849. // mutation.
  33850. func (m *UsageDetailMutation) ClearedFields() []string {
  33851. var fields []string
  33852. if m.FieldCleared(usagedetail.FieldStatus) {
  33853. fields = append(fields, usagedetail.FieldStatus)
  33854. }
  33855. if m.FieldCleared(usagedetail.FieldType) {
  33856. fields = append(fields, usagedetail.FieldType)
  33857. }
  33858. if m.FieldCleared(usagedetail.FieldApp) {
  33859. fields = append(fields, usagedetail.FieldApp)
  33860. }
  33861. if m.FieldCleared(usagedetail.FieldSessionID) {
  33862. fields = append(fields, usagedetail.FieldSessionID)
  33863. }
  33864. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  33865. fields = append(fields, usagedetail.FieldTotalTokens)
  33866. }
  33867. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  33868. fields = append(fields, usagedetail.FieldPromptTokens)
  33869. }
  33870. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  33871. fields = append(fields, usagedetail.FieldCompletionTokens)
  33872. }
  33873. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  33874. fields = append(fields, usagedetail.FieldOrganizationID)
  33875. }
  33876. return fields
  33877. }
  33878. // FieldCleared returns a boolean indicating if a field with the given name was
  33879. // cleared in this mutation.
  33880. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  33881. _, ok := m.clearedFields[name]
  33882. return ok
  33883. }
  33884. // ClearField clears the value of the field with the given name. It returns an
  33885. // error if the field is not defined in the schema.
  33886. func (m *UsageDetailMutation) ClearField(name string) error {
  33887. switch name {
  33888. case usagedetail.FieldStatus:
  33889. m.ClearStatus()
  33890. return nil
  33891. case usagedetail.FieldType:
  33892. m.ClearType()
  33893. return nil
  33894. case usagedetail.FieldApp:
  33895. m.ClearApp()
  33896. return nil
  33897. case usagedetail.FieldSessionID:
  33898. m.ClearSessionID()
  33899. return nil
  33900. case usagedetail.FieldTotalTokens:
  33901. m.ClearTotalTokens()
  33902. return nil
  33903. case usagedetail.FieldPromptTokens:
  33904. m.ClearPromptTokens()
  33905. return nil
  33906. case usagedetail.FieldCompletionTokens:
  33907. m.ClearCompletionTokens()
  33908. return nil
  33909. case usagedetail.FieldOrganizationID:
  33910. m.ClearOrganizationID()
  33911. return nil
  33912. }
  33913. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  33914. }
  33915. // ResetField resets all changes in the mutation for the field with the given name.
  33916. // It returns an error if the field is not defined in the schema.
  33917. func (m *UsageDetailMutation) ResetField(name string) error {
  33918. switch name {
  33919. case usagedetail.FieldCreatedAt:
  33920. m.ResetCreatedAt()
  33921. return nil
  33922. case usagedetail.FieldUpdatedAt:
  33923. m.ResetUpdatedAt()
  33924. return nil
  33925. case usagedetail.FieldStatus:
  33926. m.ResetStatus()
  33927. return nil
  33928. case usagedetail.FieldType:
  33929. m.ResetType()
  33930. return nil
  33931. case usagedetail.FieldBotID:
  33932. m.ResetBotID()
  33933. return nil
  33934. case usagedetail.FieldReceiverID:
  33935. m.ResetReceiverID()
  33936. return nil
  33937. case usagedetail.FieldApp:
  33938. m.ResetApp()
  33939. return nil
  33940. case usagedetail.FieldSessionID:
  33941. m.ResetSessionID()
  33942. return nil
  33943. case usagedetail.FieldRequest:
  33944. m.ResetRequest()
  33945. return nil
  33946. case usagedetail.FieldResponse:
  33947. m.ResetResponse()
  33948. return nil
  33949. case usagedetail.FieldOriginalData:
  33950. m.ResetOriginalData()
  33951. return nil
  33952. case usagedetail.FieldTotalTokens:
  33953. m.ResetTotalTokens()
  33954. return nil
  33955. case usagedetail.FieldPromptTokens:
  33956. m.ResetPromptTokens()
  33957. return nil
  33958. case usagedetail.FieldCompletionTokens:
  33959. m.ResetCompletionTokens()
  33960. return nil
  33961. case usagedetail.FieldOrganizationID:
  33962. m.ResetOrganizationID()
  33963. return nil
  33964. }
  33965. return fmt.Errorf("unknown UsageDetail field %s", name)
  33966. }
  33967. // AddedEdges returns all edge names that were set/added in this mutation.
  33968. func (m *UsageDetailMutation) AddedEdges() []string {
  33969. edges := make([]string, 0, 0)
  33970. return edges
  33971. }
  33972. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33973. // name in this mutation.
  33974. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  33975. return nil
  33976. }
  33977. // RemovedEdges returns all edge names that were removed in this mutation.
  33978. func (m *UsageDetailMutation) RemovedEdges() []string {
  33979. edges := make([]string, 0, 0)
  33980. return edges
  33981. }
  33982. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33983. // the given name in this mutation.
  33984. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  33985. return nil
  33986. }
  33987. // ClearedEdges returns all edge names that were cleared in this mutation.
  33988. func (m *UsageDetailMutation) ClearedEdges() []string {
  33989. edges := make([]string, 0, 0)
  33990. return edges
  33991. }
  33992. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33993. // was cleared in this mutation.
  33994. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  33995. return false
  33996. }
  33997. // ClearEdge clears the value of the edge with the given name. It returns an error
  33998. // if that edge is not defined in the schema.
  33999. func (m *UsageDetailMutation) ClearEdge(name string) error {
  34000. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  34001. }
  34002. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34003. // It returns an error if the edge is not defined in the schema.
  34004. func (m *UsageDetailMutation) ResetEdge(name string) error {
  34005. return fmt.Errorf("unknown UsageDetail edge %s", name)
  34006. }
  34007. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  34008. type UsageStatisticDayMutation struct {
  34009. config
  34010. op Op
  34011. typ string
  34012. id *uint64
  34013. created_at *time.Time
  34014. updated_at *time.Time
  34015. status *uint8
  34016. addstatus *int8
  34017. deleted_at *time.Time
  34018. addtime *uint64
  34019. addaddtime *int64
  34020. _type *int
  34021. add_type *int
  34022. bot_id *string
  34023. organization_id *uint64
  34024. addorganization_id *int64
  34025. ai_response *uint64
  34026. addai_response *int64
  34027. sop_run *uint64
  34028. addsop_run *int64
  34029. total_friend *uint64
  34030. addtotal_friend *int64
  34031. total_group *uint64
  34032. addtotal_group *int64
  34033. account_balance *uint64
  34034. addaccount_balance *int64
  34035. consume_token *uint64
  34036. addconsume_token *int64
  34037. active_user *uint64
  34038. addactive_user *int64
  34039. new_user *int64
  34040. addnew_user *int64
  34041. label_dist *[]custom_types.LabelDist
  34042. appendlabel_dist []custom_types.LabelDist
  34043. clearedFields map[string]struct{}
  34044. done bool
  34045. oldValue func(context.Context) (*UsageStatisticDay, error)
  34046. predicates []predicate.UsageStatisticDay
  34047. }
  34048. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  34049. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  34050. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  34051. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  34052. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  34053. m := &UsageStatisticDayMutation{
  34054. config: c,
  34055. op: op,
  34056. typ: TypeUsageStatisticDay,
  34057. clearedFields: make(map[string]struct{}),
  34058. }
  34059. for _, opt := range opts {
  34060. opt(m)
  34061. }
  34062. return m
  34063. }
  34064. // withUsageStatisticDayID sets the ID field of the mutation.
  34065. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  34066. return func(m *UsageStatisticDayMutation) {
  34067. var (
  34068. err error
  34069. once sync.Once
  34070. value *UsageStatisticDay
  34071. )
  34072. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  34073. once.Do(func() {
  34074. if m.done {
  34075. err = errors.New("querying old values post mutation is not allowed")
  34076. } else {
  34077. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  34078. }
  34079. })
  34080. return value, err
  34081. }
  34082. m.id = &id
  34083. }
  34084. }
  34085. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  34086. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  34087. return func(m *UsageStatisticDayMutation) {
  34088. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  34089. return node, nil
  34090. }
  34091. m.id = &node.ID
  34092. }
  34093. }
  34094. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34095. // executed in a transaction (ent.Tx), a transactional client is returned.
  34096. func (m UsageStatisticDayMutation) Client() *Client {
  34097. client := &Client{config: m.config}
  34098. client.init()
  34099. return client
  34100. }
  34101. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34102. // it returns an error otherwise.
  34103. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  34104. if _, ok := m.driver.(*txDriver); !ok {
  34105. return nil, errors.New("ent: mutation is not running in a transaction")
  34106. }
  34107. tx := &Tx{config: m.config}
  34108. tx.init()
  34109. return tx, nil
  34110. }
  34111. // SetID sets the value of the id field. Note that this
  34112. // operation is only accepted on creation of UsageStatisticDay entities.
  34113. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  34114. m.id = &id
  34115. }
  34116. // ID returns the ID value in the mutation. Note that the ID is only available
  34117. // if it was provided to the builder or after it was returned from the database.
  34118. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  34119. if m.id == nil {
  34120. return
  34121. }
  34122. return *m.id, true
  34123. }
  34124. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34125. // That means, if the mutation is applied within a transaction with an isolation level such
  34126. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34127. // or updated by the mutation.
  34128. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  34129. switch {
  34130. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34131. id, exists := m.ID()
  34132. if exists {
  34133. return []uint64{id}, nil
  34134. }
  34135. fallthrough
  34136. case m.op.Is(OpUpdate | OpDelete):
  34137. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  34138. default:
  34139. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34140. }
  34141. }
  34142. // SetCreatedAt sets the "created_at" field.
  34143. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  34144. m.created_at = &t
  34145. }
  34146. // CreatedAt returns the value of the "created_at" field in the mutation.
  34147. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  34148. v := m.created_at
  34149. if v == nil {
  34150. return
  34151. }
  34152. return *v, true
  34153. }
  34154. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  34155. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34157. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34158. if !m.op.Is(OpUpdateOne) {
  34159. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34160. }
  34161. if m.id == nil || m.oldValue == nil {
  34162. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34163. }
  34164. oldValue, err := m.oldValue(ctx)
  34165. if err != nil {
  34166. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34167. }
  34168. return oldValue.CreatedAt, nil
  34169. }
  34170. // ResetCreatedAt resets all changes to the "created_at" field.
  34171. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  34172. m.created_at = nil
  34173. }
  34174. // SetUpdatedAt sets the "updated_at" field.
  34175. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  34176. m.updated_at = &t
  34177. }
  34178. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34179. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  34180. v := m.updated_at
  34181. if v == nil {
  34182. return
  34183. }
  34184. return *v, true
  34185. }
  34186. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  34187. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34189. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34190. if !m.op.Is(OpUpdateOne) {
  34191. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34192. }
  34193. if m.id == nil || m.oldValue == nil {
  34194. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34195. }
  34196. oldValue, err := m.oldValue(ctx)
  34197. if err != nil {
  34198. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34199. }
  34200. return oldValue.UpdatedAt, nil
  34201. }
  34202. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34203. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  34204. m.updated_at = nil
  34205. }
  34206. // SetStatus sets the "status" field.
  34207. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  34208. m.status = &u
  34209. m.addstatus = nil
  34210. }
  34211. // Status returns the value of the "status" field in the mutation.
  34212. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  34213. v := m.status
  34214. if v == nil {
  34215. return
  34216. }
  34217. return *v, true
  34218. }
  34219. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  34220. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34222. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34223. if !m.op.Is(OpUpdateOne) {
  34224. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34225. }
  34226. if m.id == nil || m.oldValue == nil {
  34227. return v, errors.New("OldStatus requires an ID field in the mutation")
  34228. }
  34229. oldValue, err := m.oldValue(ctx)
  34230. if err != nil {
  34231. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34232. }
  34233. return oldValue.Status, nil
  34234. }
  34235. // AddStatus adds u to the "status" field.
  34236. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  34237. if m.addstatus != nil {
  34238. *m.addstatus += u
  34239. } else {
  34240. m.addstatus = &u
  34241. }
  34242. }
  34243. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34244. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  34245. v := m.addstatus
  34246. if v == nil {
  34247. return
  34248. }
  34249. return *v, true
  34250. }
  34251. // ClearStatus clears the value of the "status" field.
  34252. func (m *UsageStatisticDayMutation) ClearStatus() {
  34253. m.status = nil
  34254. m.addstatus = nil
  34255. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  34256. }
  34257. // StatusCleared returns if the "status" field was cleared in this mutation.
  34258. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  34259. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  34260. return ok
  34261. }
  34262. // ResetStatus resets all changes to the "status" field.
  34263. func (m *UsageStatisticDayMutation) ResetStatus() {
  34264. m.status = nil
  34265. m.addstatus = nil
  34266. delete(m.clearedFields, usagestatisticday.FieldStatus)
  34267. }
  34268. // SetDeletedAt sets the "deleted_at" field.
  34269. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  34270. m.deleted_at = &t
  34271. }
  34272. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34273. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  34274. v := m.deleted_at
  34275. if v == nil {
  34276. return
  34277. }
  34278. return *v, true
  34279. }
  34280. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  34281. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34283. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34284. if !m.op.Is(OpUpdateOne) {
  34285. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34286. }
  34287. if m.id == nil || m.oldValue == nil {
  34288. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34289. }
  34290. oldValue, err := m.oldValue(ctx)
  34291. if err != nil {
  34292. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34293. }
  34294. return oldValue.DeletedAt, nil
  34295. }
  34296. // ClearDeletedAt clears the value of the "deleted_at" field.
  34297. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  34298. m.deleted_at = nil
  34299. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  34300. }
  34301. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34302. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  34303. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  34304. return ok
  34305. }
  34306. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34307. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  34308. m.deleted_at = nil
  34309. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  34310. }
  34311. // SetAddtime sets the "addtime" field.
  34312. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  34313. m.addtime = &u
  34314. m.addaddtime = nil
  34315. }
  34316. // Addtime returns the value of the "addtime" field in the mutation.
  34317. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  34318. v := m.addtime
  34319. if v == nil {
  34320. return
  34321. }
  34322. return *v, true
  34323. }
  34324. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  34325. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34327. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34328. if !m.op.Is(OpUpdateOne) {
  34329. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34330. }
  34331. if m.id == nil || m.oldValue == nil {
  34332. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34333. }
  34334. oldValue, err := m.oldValue(ctx)
  34335. if err != nil {
  34336. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34337. }
  34338. return oldValue.Addtime, nil
  34339. }
  34340. // AddAddtime adds u to the "addtime" field.
  34341. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  34342. if m.addaddtime != nil {
  34343. *m.addaddtime += u
  34344. } else {
  34345. m.addaddtime = &u
  34346. }
  34347. }
  34348. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34349. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  34350. v := m.addaddtime
  34351. if v == nil {
  34352. return
  34353. }
  34354. return *v, true
  34355. }
  34356. // ResetAddtime resets all changes to the "addtime" field.
  34357. func (m *UsageStatisticDayMutation) ResetAddtime() {
  34358. m.addtime = nil
  34359. m.addaddtime = nil
  34360. }
  34361. // SetType sets the "type" field.
  34362. func (m *UsageStatisticDayMutation) SetType(i int) {
  34363. m._type = &i
  34364. m.add_type = nil
  34365. }
  34366. // GetType returns the value of the "type" field in the mutation.
  34367. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  34368. v := m._type
  34369. if v == nil {
  34370. return
  34371. }
  34372. return *v, true
  34373. }
  34374. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  34375. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34377. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  34378. if !m.op.Is(OpUpdateOne) {
  34379. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34380. }
  34381. if m.id == nil || m.oldValue == nil {
  34382. return v, errors.New("OldType requires an ID field in the mutation")
  34383. }
  34384. oldValue, err := m.oldValue(ctx)
  34385. if err != nil {
  34386. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34387. }
  34388. return oldValue.Type, nil
  34389. }
  34390. // AddType adds i to the "type" field.
  34391. func (m *UsageStatisticDayMutation) AddType(i int) {
  34392. if m.add_type != nil {
  34393. *m.add_type += i
  34394. } else {
  34395. m.add_type = &i
  34396. }
  34397. }
  34398. // AddedType returns the value that was added to the "type" field in this mutation.
  34399. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  34400. v := m.add_type
  34401. if v == nil {
  34402. return
  34403. }
  34404. return *v, true
  34405. }
  34406. // ResetType resets all changes to the "type" field.
  34407. func (m *UsageStatisticDayMutation) ResetType() {
  34408. m._type = nil
  34409. m.add_type = nil
  34410. }
  34411. // SetBotID sets the "bot_id" field.
  34412. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  34413. m.bot_id = &s
  34414. }
  34415. // BotID returns the value of the "bot_id" field in the mutation.
  34416. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  34417. v := m.bot_id
  34418. if v == nil {
  34419. return
  34420. }
  34421. return *v, true
  34422. }
  34423. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  34424. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34426. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  34427. if !m.op.Is(OpUpdateOne) {
  34428. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34429. }
  34430. if m.id == nil || m.oldValue == nil {
  34431. return v, errors.New("OldBotID requires an ID field in the mutation")
  34432. }
  34433. oldValue, err := m.oldValue(ctx)
  34434. if err != nil {
  34435. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34436. }
  34437. return oldValue.BotID, nil
  34438. }
  34439. // ClearBotID clears the value of the "bot_id" field.
  34440. func (m *UsageStatisticDayMutation) ClearBotID() {
  34441. m.bot_id = nil
  34442. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  34443. }
  34444. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34445. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  34446. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  34447. return ok
  34448. }
  34449. // ResetBotID resets all changes to the "bot_id" field.
  34450. func (m *UsageStatisticDayMutation) ResetBotID() {
  34451. m.bot_id = nil
  34452. delete(m.clearedFields, usagestatisticday.FieldBotID)
  34453. }
  34454. // SetOrganizationID sets the "organization_id" field.
  34455. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  34456. m.organization_id = &u
  34457. m.addorganization_id = nil
  34458. }
  34459. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34460. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  34461. v := m.organization_id
  34462. if v == nil {
  34463. return
  34464. }
  34465. return *v, true
  34466. }
  34467. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  34468. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34470. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34471. if !m.op.Is(OpUpdateOne) {
  34472. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34473. }
  34474. if m.id == nil || m.oldValue == nil {
  34475. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34476. }
  34477. oldValue, err := m.oldValue(ctx)
  34478. if err != nil {
  34479. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34480. }
  34481. return oldValue.OrganizationID, nil
  34482. }
  34483. // AddOrganizationID adds u to the "organization_id" field.
  34484. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  34485. if m.addorganization_id != nil {
  34486. *m.addorganization_id += u
  34487. } else {
  34488. m.addorganization_id = &u
  34489. }
  34490. }
  34491. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34492. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  34493. v := m.addorganization_id
  34494. if v == nil {
  34495. return
  34496. }
  34497. return *v, true
  34498. }
  34499. // ClearOrganizationID clears the value of the "organization_id" field.
  34500. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  34501. m.organization_id = nil
  34502. m.addorganization_id = nil
  34503. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  34504. }
  34505. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34506. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  34507. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  34508. return ok
  34509. }
  34510. // ResetOrganizationID resets all changes to the "organization_id" field.
  34511. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  34512. m.organization_id = nil
  34513. m.addorganization_id = nil
  34514. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  34515. }
  34516. // SetAiResponse sets the "ai_response" field.
  34517. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  34518. m.ai_response = &u
  34519. m.addai_response = nil
  34520. }
  34521. // AiResponse returns the value of the "ai_response" field in the mutation.
  34522. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  34523. v := m.ai_response
  34524. if v == nil {
  34525. return
  34526. }
  34527. return *v, true
  34528. }
  34529. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  34530. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34532. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34533. if !m.op.Is(OpUpdateOne) {
  34534. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34535. }
  34536. if m.id == nil || m.oldValue == nil {
  34537. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34538. }
  34539. oldValue, err := m.oldValue(ctx)
  34540. if err != nil {
  34541. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34542. }
  34543. return oldValue.AiResponse, nil
  34544. }
  34545. // AddAiResponse adds u to the "ai_response" field.
  34546. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  34547. if m.addai_response != nil {
  34548. *m.addai_response += u
  34549. } else {
  34550. m.addai_response = &u
  34551. }
  34552. }
  34553. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34554. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  34555. v := m.addai_response
  34556. if v == nil {
  34557. return
  34558. }
  34559. return *v, true
  34560. }
  34561. // ResetAiResponse resets all changes to the "ai_response" field.
  34562. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  34563. m.ai_response = nil
  34564. m.addai_response = nil
  34565. }
  34566. // SetSopRun sets the "sop_run" field.
  34567. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  34568. m.sop_run = &u
  34569. m.addsop_run = nil
  34570. }
  34571. // SopRun returns the value of the "sop_run" field in the mutation.
  34572. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  34573. v := m.sop_run
  34574. if v == nil {
  34575. return
  34576. }
  34577. return *v, true
  34578. }
  34579. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  34580. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34582. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34583. if !m.op.Is(OpUpdateOne) {
  34584. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34585. }
  34586. if m.id == nil || m.oldValue == nil {
  34587. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34588. }
  34589. oldValue, err := m.oldValue(ctx)
  34590. if err != nil {
  34591. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34592. }
  34593. return oldValue.SopRun, nil
  34594. }
  34595. // AddSopRun adds u to the "sop_run" field.
  34596. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  34597. if m.addsop_run != nil {
  34598. *m.addsop_run += u
  34599. } else {
  34600. m.addsop_run = &u
  34601. }
  34602. }
  34603. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34604. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  34605. v := m.addsop_run
  34606. if v == nil {
  34607. return
  34608. }
  34609. return *v, true
  34610. }
  34611. // ResetSopRun resets all changes to the "sop_run" field.
  34612. func (m *UsageStatisticDayMutation) ResetSopRun() {
  34613. m.sop_run = nil
  34614. m.addsop_run = nil
  34615. }
  34616. // SetTotalFriend sets the "total_friend" field.
  34617. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  34618. m.total_friend = &u
  34619. m.addtotal_friend = nil
  34620. }
  34621. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34622. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  34623. v := m.total_friend
  34624. if v == nil {
  34625. return
  34626. }
  34627. return *v, true
  34628. }
  34629. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  34630. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34632. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34633. if !m.op.Is(OpUpdateOne) {
  34634. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34635. }
  34636. if m.id == nil || m.oldValue == nil {
  34637. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34638. }
  34639. oldValue, err := m.oldValue(ctx)
  34640. if err != nil {
  34641. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34642. }
  34643. return oldValue.TotalFriend, nil
  34644. }
  34645. // AddTotalFriend adds u to the "total_friend" field.
  34646. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  34647. if m.addtotal_friend != nil {
  34648. *m.addtotal_friend += u
  34649. } else {
  34650. m.addtotal_friend = &u
  34651. }
  34652. }
  34653. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34654. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  34655. v := m.addtotal_friend
  34656. if v == nil {
  34657. return
  34658. }
  34659. return *v, true
  34660. }
  34661. // ResetTotalFriend resets all changes to the "total_friend" field.
  34662. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  34663. m.total_friend = nil
  34664. m.addtotal_friend = nil
  34665. }
  34666. // SetTotalGroup sets the "total_group" field.
  34667. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  34668. m.total_group = &u
  34669. m.addtotal_group = nil
  34670. }
  34671. // TotalGroup returns the value of the "total_group" field in the mutation.
  34672. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  34673. v := m.total_group
  34674. if v == nil {
  34675. return
  34676. }
  34677. return *v, true
  34678. }
  34679. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  34680. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34682. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34683. if !m.op.Is(OpUpdateOne) {
  34684. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34685. }
  34686. if m.id == nil || m.oldValue == nil {
  34687. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34688. }
  34689. oldValue, err := m.oldValue(ctx)
  34690. if err != nil {
  34691. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34692. }
  34693. return oldValue.TotalGroup, nil
  34694. }
  34695. // AddTotalGroup adds u to the "total_group" field.
  34696. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  34697. if m.addtotal_group != nil {
  34698. *m.addtotal_group += u
  34699. } else {
  34700. m.addtotal_group = &u
  34701. }
  34702. }
  34703. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34704. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  34705. v := m.addtotal_group
  34706. if v == nil {
  34707. return
  34708. }
  34709. return *v, true
  34710. }
  34711. // ResetTotalGroup resets all changes to the "total_group" field.
  34712. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  34713. m.total_group = nil
  34714. m.addtotal_group = nil
  34715. }
  34716. // SetAccountBalance sets the "account_balance" field.
  34717. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  34718. m.account_balance = &u
  34719. m.addaccount_balance = nil
  34720. }
  34721. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34722. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  34723. v := m.account_balance
  34724. if v == nil {
  34725. return
  34726. }
  34727. return *v, true
  34728. }
  34729. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  34730. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34732. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34733. if !m.op.Is(OpUpdateOne) {
  34734. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34735. }
  34736. if m.id == nil || m.oldValue == nil {
  34737. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34738. }
  34739. oldValue, err := m.oldValue(ctx)
  34740. if err != nil {
  34741. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34742. }
  34743. return oldValue.AccountBalance, nil
  34744. }
  34745. // AddAccountBalance adds u to the "account_balance" field.
  34746. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  34747. if m.addaccount_balance != nil {
  34748. *m.addaccount_balance += u
  34749. } else {
  34750. m.addaccount_balance = &u
  34751. }
  34752. }
  34753. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34754. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  34755. v := m.addaccount_balance
  34756. if v == nil {
  34757. return
  34758. }
  34759. return *v, true
  34760. }
  34761. // ResetAccountBalance resets all changes to the "account_balance" field.
  34762. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  34763. m.account_balance = nil
  34764. m.addaccount_balance = nil
  34765. }
  34766. // SetConsumeToken sets the "consume_token" field.
  34767. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  34768. m.consume_token = &u
  34769. m.addconsume_token = nil
  34770. }
  34771. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34772. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  34773. v := m.consume_token
  34774. if v == nil {
  34775. return
  34776. }
  34777. return *v, true
  34778. }
  34779. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  34780. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34782. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34783. if !m.op.Is(OpUpdateOne) {
  34784. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34785. }
  34786. if m.id == nil || m.oldValue == nil {
  34787. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34788. }
  34789. oldValue, err := m.oldValue(ctx)
  34790. if err != nil {
  34791. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34792. }
  34793. return oldValue.ConsumeToken, nil
  34794. }
  34795. // AddConsumeToken adds u to the "consume_token" field.
  34796. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  34797. if m.addconsume_token != nil {
  34798. *m.addconsume_token += u
  34799. } else {
  34800. m.addconsume_token = &u
  34801. }
  34802. }
  34803. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34804. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  34805. v := m.addconsume_token
  34806. if v == nil {
  34807. return
  34808. }
  34809. return *v, true
  34810. }
  34811. // ResetConsumeToken resets all changes to the "consume_token" field.
  34812. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  34813. m.consume_token = nil
  34814. m.addconsume_token = nil
  34815. }
  34816. // SetActiveUser sets the "active_user" field.
  34817. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  34818. m.active_user = &u
  34819. m.addactive_user = nil
  34820. }
  34821. // ActiveUser returns the value of the "active_user" field in the mutation.
  34822. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  34823. v := m.active_user
  34824. if v == nil {
  34825. return
  34826. }
  34827. return *v, true
  34828. }
  34829. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  34830. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34832. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34833. if !m.op.Is(OpUpdateOne) {
  34834. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34835. }
  34836. if m.id == nil || m.oldValue == nil {
  34837. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34838. }
  34839. oldValue, err := m.oldValue(ctx)
  34840. if err != nil {
  34841. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34842. }
  34843. return oldValue.ActiveUser, nil
  34844. }
  34845. // AddActiveUser adds u to the "active_user" field.
  34846. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  34847. if m.addactive_user != nil {
  34848. *m.addactive_user += u
  34849. } else {
  34850. m.addactive_user = &u
  34851. }
  34852. }
  34853. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34854. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  34855. v := m.addactive_user
  34856. if v == nil {
  34857. return
  34858. }
  34859. return *v, true
  34860. }
  34861. // ResetActiveUser resets all changes to the "active_user" field.
  34862. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  34863. m.active_user = nil
  34864. m.addactive_user = nil
  34865. }
  34866. // SetNewUser sets the "new_user" field.
  34867. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  34868. m.new_user = &i
  34869. m.addnew_user = nil
  34870. }
  34871. // NewUser returns the value of the "new_user" field in the mutation.
  34872. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  34873. v := m.new_user
  34874. if v == nil {
  34875. return
  34876. }
  34877. return *v, true
  34878. }
  34879. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  34880. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34882. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34883. if !m.op.Is(OpUpdateOne) {
  34884. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34885. }
  34886. if m.id == nil || m.oldValue == nil {
  34887. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34888. }
  34889. oldValue, err := m.oldValue(ctx)
  34890. if err != nil {
  34891. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34892. }
  34893. return oldValue.NewUser, nil
  34894. }
  34895. // AddNewUser adds i to the "new_user" field.
  34896. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  34897. if m.addnew_user != nil {
  34898. *m.addnew_user += i
  34899. } else {
  34900. m.addnew_user = &i
  34901. }
  34902. }
  34903. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34904. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  34905. v := m.addnew_user
  34906. if v == nil {
  34907. return
  34908. }
  34909. return *v, true
  34910. }
  34911. // ResetNewUser resets all changes to the "new_user" field.
  34912. func (m *UsageStatisticDayMutation) ResetNewUser() {
  34913. m.new_user = nil
  34914. m.addnew_user = nil
  34915. }
  34916. // SetLabelDist sets the "label_dist" field.
  34917. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34918. m.label_dist = &ctd
  34919. m.appendlabel_dist = nil
  34920. }
  34921. // LabelDist returns the value of the "label_dist" field in the mutation.
  34922. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34923. v := m.label_dist
  34924. if v == nil {
  34925. return
  34926. }
  34927. return *v, true
  34928. }
  34929. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  34930. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34932. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34933. if !m.op.Is(OpUpdateOne) {
  34934. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34935. }
  34936. if m.id == nil || m.oldValue == nil {
  34937. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34938. }
  34939. oldValue, err := m.oldValue(ctx)
  34940. if err != nil {
  34941. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34942. }
  34943. return oldValue.LabelDist, nil
  34944. }
  34945. // AppendLabelDist adds ctd to the "label_dist" field.
  34946. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34947. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34948. }
  34949. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34950. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34951. if len(m.appendlabel_dist) == 0 {
  34952. return nil, false
  34953. }
  34954. return m.appendlabel_dist, true
  34955. }
  34956. // ResetLabelDist resets all changes to the "label_dist" field.
  34957. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  34958. m.label_dist = nil
  34959. m.appendlabel_dist = nil
  34960. }
  34961. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  34962. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  34963. m.predicates = append(m.predicates, ps...)
  34964. }
  34965. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  34966. // users can use type-assertion to append predicates that do not depend on any generated package.
  34967. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  34968. p := make([]predicate.UsageStatisticDay, len(ps))
  34969. for i := range ps {
  34970. p[i] = ps[i]
  34971. }
  34972. m.Where(p...)
  34973. }
  34974. // Op returns the operation name.
  34975. func (m *UsageStatisticDayMutation) Op() Op {
  34976. return m.op
  34977. }
  34978. // SetOp allows setting the mutation operation.
  34979. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  34980. m.op = op
  34981. }
  34982. // Type returns the node type of this mutation (UsageStatisticDay).
  34983. func (m *UsageStatisticDayMutation) Type() string {
  34984. return m.typ
  34985. }
  34986. // Fields returns all fields that were changed during this mutation. Note that in
  34987. // order to get all numeric fields that were incremented/decremented, call
  34988. // AddedFields().
  34989. func (m *UsageStatisticDayMutation) Fields() []string {
  34990. fields := make([]string, 0, 17)
  34991. if m.created_at != nil {
  34992. fields = append(fields, usagestatisticday.FieldCreatedAt)
  34993. }
  34994. if m.updated_at != nil {
  34995. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  34996. }
  34997. if m.status != nil {
  34998. fields = append(fields, usagestatisticday.FieldStatus)
  34999. }
  35000. if m.deleted_at != nil {
  35001. fields = append(fields, usagestatisticday.FieldDeletedAt)
  35002. }
  35003. if m.addtime != nil {
  35004. fields = append(fields, usagestatisticday.FieldAddtime)
  35005. }
  35006. if m._type != nil {
  35007. fields = append(fields, usagestatisticday.FieldType)
  35008. }
  35009. if m.bot_id != nil {
  35010. fields = append(fields, usagestatisticday.FieldBotID)
  35011. }
  35012. if m.organization_id != nil {
  35013. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35014. }
  35015. if m.ai_response != nil {
  35016. fields = append(fields, usagestatisticday.FieldAiResponse)
  35017. }
  35018. if m.sop_run != nil {
  35019. fields = append(fields, usagestatisticday.FieldSopRun)
  35020. }
  35021. if m.total_friend != nil {
  35022. fields = append(fields, usagestatisticday.FieldTotalFriend)
  35023. }
  35024. if m.total_group != nil {
  35025. fields = append(fields, usagestatisticday.FieldTotalGroup)
  35026. }
  35027. if m.account_balance != nil {
  35028. fields = append(fields, usagestatisticday.FieldAccountBalance)
  35029. }
  35030. if m.consume_token != nil {
  35031. fields = append(fields, usagestatisticday.FieldConsumeToken)
  35032. }
  35033. if m.active_user != nil {
  35034. fields = append(fields, usagestatisticday.FieldActiveUser)
  35035. }
  35036. if m.new_user != nil {
  35037. fields = append(fields, usagestatisticday.FieldNewUser)
  35038. }
  35039. if m.label_dist != nil {
  35040. fields = append(fields, usagestatisticday.FieldLabelDist)
  35041. }
  35042. return fields
  35043. }
  35044. // Field returns the value of a field with the given name. The second boolean
  35045. // return value indicates that this field was not set, or was not defined in the
  35046. // schema.
  35047. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  35048. switch name {
  35049. case usagestatisticday.FieldCreatedAt:
  35050. return m.CreatedAt()
  35051. case usagestatisticday.FieldUpdatedAt:
  35052. return m.UpdatedAt()
  35053. case usagestatisticday.FieldStatus:
  35054. return m.Status()
  35055. case usagestatisticday.FieldDeletedAt:
  35056. return m.DeletedAt()
  35057. case usagestatisticday.FieldAddtime:
  35058. return m.Addtime()
  35059. case usagestatisticday.FieldType:
  35060. return m.GetType()
  35061. case usagestatisticday.FieldBotID:
  35062. return m.BotID()
  35063. case usagestatisticday.FieldOrganizationID:
  35064. return m.OrganizationID()
  35065. case usagestatisticday.FieldAiResponse:
  35066. return m.AiResponse()
  35067. case usagestatisticday.FieldSopRun:
  35068. return m.SopRun()
  35069. case usagestatisticday.FieldTotalFriend:
  35070. return m.TotalFriend()
  35071. case usagestatisticday.FieldTotalGroup:
  35072. return m.TotalGroup()
  35073. case usagestatisticday.FieldAccountBalance:
  35074. return m.AccountBalance()
  35075. case usagestatisticday.FieldConsumeToken:
  35076. return m.ConsumeToken()
  35077. case usagestatisticday.FieldActiveUser:
  35078. return m.ActiveUser()
  35079. case usagestatisticday.FieldNewUser:
  35080. return m.NewUser()
  35081. case usagestatisticday.FieldLabelDist:
  35082. return m.LabelDist()
  35083. }
  35084. return nil, false
  35085. }
  35086. // OldField returns the old value of the field from the database. An error is
  35087. // returned if the mutation operation is not UpdateOne, or the query to the
  35088. // database failed.
  35089. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35090. switch name {
  35091. case usagestatisticday.FieldCreatedAt:
  35092. return m.OldCreatedAt(ctx)
  35093. case usagestatisticday.FieldUpdatedAt:
  35094. return m.OldUpdatedAt(ctx)
  35095. case usagestatisticday.FieldStatus:
  35096. return m.OldStatus(ctx)
  35097. case usagestatisticday.FieldDeletedAt:
  35098. return m.OldDeletedAt(ctx)
  35099. case usagestatisticday.FieldAddtime:
  35100. return m.OldAddtime(ctx)
  35101. case usagestatisticday.FieldType:
  35102. return m.OldType(ctx)
  35103. case usagestatisticday.FieldBotID:
  35104. return m.OldBotID(ctx)
  35105. case usagestatisticday.FieldOrganizationID:
  35106. return m.OldOrganizationID(ctx)
  35107. case usagestatisticday.FieldAiResponse:
  35108. return m.OldAiResponse(ctx)
  35109. case usagestatisticday.FieldSopRun:
  35110. return m.OldSopRun(ctx)
  35111. case usagestatisticday.FieldTotalFriend:
  35112. return m.OldTotalFriend(ctx)
  35113. case usagestatisticday.FieldTotalGroup:
  35114. return m.OldTotalGroup(ctx)
  35115. case usagestatisticday.FieldAccountBalance:
  35116. return m.OldAccountBalance(ctx)
  35117. case usagestatisticday.FieldConsumeToken:
  35118. return m.OldConsumeToken(ctx)
  35119. case usagestatisticday.FieldActiveUser:
  35120. return m.OldActiveUser(ctx)
  35121. case usagestatisticday.FieldNewUser:
  35122. return m.OldNewUser(ctx)
  35123. case usagestatisticday.FieldLabelDist:
  35124. return m.OldLabelDist(ctx)
  35125. }
  35126. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35127. }
  35128. // SetField sets the value of a field with the given name. It returns an error if
  35129. // the field is not defined in the schema, or if the type mismatched the field
  35130. // type.
  35131. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  35132. switch name {
  35133. case usagestatisticday.FieldCreatedAt:
  35134. v, ok := value.(time.Time)
  35135. if !ok {
  35136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35137. }
  35138. m.SetCreatedAt(v)
  35139. return nil
  35140. case usagestatisticday.FieldUpdatedAt:
  35141. v, ok := value.(time.Time)
  35142. if !ok {
  35143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35144. }
  35145. m.SetUpdatedAt(v)
  35146. return nil
  35147. case usagestatisticday.FieldStatus:
  35148. v, ok := value.(uint8)
  35149. if !ok {
  35150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35151. }
  35152. m.SetStatus(v)
  35153. return nil
  35154. case usagestatisticday.FieldDeletedAt:
  35155. v, ok := value.(time.Time)
  35156. if !ok {
  35157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35158. }
  35159. m.SetDeletedAt(v)
  35160. return nil
  35161. case usagestatisticday.FieldAddtime:
  35162. v, ok := value.(uint64)
  35163. if !ok {
  35164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35165. }
  35166. m.SetAddtime(v)
  35167. return nil
  35168. case usagestatisticday.FieldType:
  35169. v, ok := value.(int)
  35170. if !ok {
  35171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35172. }
  35173. m.SetType(v)
  35174. return nil
  35175. case usagestatisticday.FieldBotID:
  35176. v, ok := value.(string)
  35177. if !ok {
  35178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35179. }
  35180. m.SetBotID(v)
  35181. return nil
  35182. case usagestatisticday.FieldOrganizationID:
  35183. v, ok := value.(uint64)
  35184. if !ok {
  35185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35186. }
  35187. m.SetOrganizationID(v)
  35188. return nil
  35189. case usagestatisticday.FieldAiResponse:
  35190. v, ok := value.(uint64)
  35191. if !ok {
  35192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35193. }
  35194. m.SetAiResponse(v)
  35195. return nil
  35196. case usagestatisticday.FieldSopRun:
  35197. v, ok := value.(uint64)
  35198. if !ok {
  35199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35200. }
  35201. m.SetSopRun(v)
  35202. return nil
  35203. case usagestatisticday.FieldTotalFriend:
  35204. v, ok := value.(uint64)
  35205. if !ok {
  35206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35207. }
  35208. m.SetTotalFriend(v)
  35209. return nil
  35210. case usagestatisticday.FieldTotalGroup:
  35211. v, ok := value.(uint64)
  35212. if !ok {
  35213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35214. }
  35215. m.SetTotalGroup(v)
  35216. return nil
  35217. case usagestatisticday.FieldAccountBalance:
  35218. v, ok := value.(uint64)
  35219. if !ok {
  35220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35221. }
  35222. m.SetAccountBalance(v)
  35223. return nil
  35224. case usagestatisticday.FieldConsumeToken:
  35225. v, ok := value.(uint64)
  35226. if !ok {
  35227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35228. }
  35229. m.SetConsumeToken(v)
  35230. return nil
  35231. case usagestatisticday.FieldActiveUser:
  35232. v, ok := value.(uint64)
  35233. if !ok {
  35234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35235. }
  35236. m.SetActiveUser(v)
  35237. return nil
  35238. case usagestatisticday.FieldNewUser:
  35239. v, ok := value.(int64)
  35240. if !ok {
  35241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35242. }
  35243. m.SetNewUser(v)
  35244. return nil
  35245. case usagestatisticday.FieldLabelDist:
  35246. v, ok := value.([]custom_types.LabelDist)
  35247. if !ok {
  35248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35249. }
  35250. m.SetLabelDist(v)
  35251. return nil
  35252. }
  35253. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35254. }
  35255. // AddedFields returns all numeric fields that were incremented/decremented during
  35256. // this mutation.
  35257. func (m *UsageStatisticDayMutation) AddedFields() []string {
  35258. var fields []string
  35259. if m.addstatus != nil {
  35260. fields = append(fields, usagestatisticday.FieldStatus)
  35261. }
  35262. if m.addaddtime != nil {
  35263. fields = append(fields, usagestatisticday.FieldAddtime)
  35264. }
  35265. if m.add_type != nil {
  35266. fields = append(fields, usagestatisticday.FieldType)
  35267. }
  35268. if m.addorganization_id != nil {
  35269. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35270. }
  35271. if m.addai_response != nil {
  35272. fields = append(fields, usagestatisticday.FieldAiResponse)
  35273. }
  35274. if m.addsop_run != nil {
  35275. fields = append(fields, usagestatisticday.FieldSopRun)
  35276. }
  35277. if m.addtotal_friend != nil {
  35278. fields = append(fields, usagestatisticday.FieldTotalFriend)
  35279. }
  35280. if m.addtotal_group != nil {
  35281. fields = append(fields, usagestatisticday.FieldTotalGroup)
  35282. }
  35283. if m.addaccount_balance != nil {
  35284. fields = append(fields, usagestatisticday.FieldAccountBalance)
  35285. }
  35286. if m.addconsume_token != nil {
  35287. fields = append(fields, usagestatisticday.FieldConsumeToken)
  35288. }
  35289. if m.addactive_user != nil {
  35290. fields = append(fields, usagestatisticday.FieldActiveUser)
  35291. }
  35292. if m.addnew_user != nil {
  35293. fields = append(fields, usagestatisticday.FieldNewUser)
  35294. }
  35295. return fields
  35296. }
  35297. // AddedField returns the numeric value that was incremented/decremented on a field
  35298. // with the given name. The second boolean return value indicates that this field
  35299. // was not set, or was not defined in the schema.
  35300. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  35301. switch name {
  35302. case usagestatisticday.FieldStatus:
  35303. return m.AddedStatus()
  35304. case usagestatisticday.FieldAddtime:
  35305. return m.AddedAddtime()
  35306. case usagestatisticday.FieldType:
  35307. return m.AddedType()
  35308. case usagestatisticday.FieldOrganizationID:
  35309. return m.AddedOrganizationID()
  35310. case usagestatisticday.FieldAiResponse:
  35311. return m.AddedAiResponse()
  35312. case usagestatisticday.FieldSopRun:
  35313. return m.AddedSopRun()
  35314. case usagestatisticday.FieldTotalFriend:
  35315. return m.AddedTotalFriend()
  35316. case usagestatisticday.FieldTotalGroup:
  35317. return m.AddedTotalGroup()
  35318. case usagestatisticday.FieldAccountBalance:
  35319. return m.AddedAccountBalance()
  35320. case usagestatisticday.FieldConsumeToken:
  35321. return m.AddedConsumeToken()
  35322. case usagestatisticday.FieldActiveUser:
  35323. return m.AddedActiveUser()
  35324. case usagestatisticday.FieldNewUser:
  35325. return m.AddedNewUser()
  35326. }
  35327. return nil, false
  35328. }
  35329. // AddField adds the value to the field with the given name. It returns an error if
  35330. // the field is not defined in the schema, or if the type mismatched the field
  35331. // type.
  35332. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  35333. switch name {
  35334. case usagestatisticday.FieldStatus:
  35335. v, ok := value.(int8)
  35336. if !ok {
  35337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35338. }
  35339. m.AddStatus(v)
  35340. return nil
  35341. case usagestatisticday.FieldAddtime:
  35342. v, ok := value.(int64)
  35343. if !ok {
  35344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35345. }
  35346. m.AddAddtime(v)
  35347. return nil
  35348. case usagestatisticday.FieldType:
  35349. v, ok := value.(int)
  35350. if !ok {
  35351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35352. }
  35353. m.AddType(v)
  35354. return nil
  35355. case usagestatisticday.FieldOrganizationID:
  35356. v, ok := value.(int64)
  35357. if !ok {
  35358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35359. }
  35360. m.AddOrganizationID(v)
  35361. return nil
  35362. case usagestatisticday.FieldAiResponse:
  35363. v, ok := value.(int64)
  35364. if !ok {
  35365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35366. }
  35367. m.AddAiResponse(v)
  35368. return nil
  35369. case usagestatisticday.FieldSopRun:
  35370. v, ok := value.(int64)
  35371. if !ok {
  35372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35373. }
  35374. m.AddSopRun(v)
  35375. return nil
  35376. case usagestatisticday.FieldTotalFriend:
  35377. v, ok := value.(int64)
  35378. if !ok {
  35379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35380. }
  35381. m.AddTotalFriend(v)
  35382. return nil
  35383. case usagestatisticday.FieldTotalGroup:
  35384. v, ok := value.(int64)
  35385. if !ok {
  35386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35387. }
  35388. m.AddTotalGroup(v)
  35389. return nil
  35390. case usagestatisticday.FieldAccountBalance:
  35391. v, ok := value.(int64)
  35392. if !ok {
  35393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35394. }
  35395. m.AddAccountBalance(v)
  35396. return nil
  35397. case usagestatisticday.FieldConsumeToken:
  35398. v, ok := value.(int64)
  35399. if !ok {
  35400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35401. }
  35402. m.AddConsumeToken(v)
  35403. return nil
  35404. case usagestatisticday.FieldActiveUser:
  35405. v, ok := value.(int64)
  35406. if !ok {
  35407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35408. }
  35409. m.AddActiveUser(v)
  35410. return nil
  35411. case usagestatisticday.FieldNewUser:
  35412. v, ok := value.(int64)
  35413. if !ok {
  35414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35415. }
  35416. m.AddNewUser(v)
  35417. return nil
  35418. }
  35419. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  35420. }
  35421. // ClearedFields returns all nullable fields that were cleared during this
  35422. // mutation.
  35423. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  35424. var fields []string
  35425. if m.FieldCleared(usagestatisticday.FieldStatus) {
  35426. fields = append(fields, usagestatisticday.FieldStatus)
  35427. }
  35428. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  35429. fields = append(fields, usagestatisticday.FieldDeletedAt)
  35430. }
  35431. if m.FieldCleared(usagestatisticday.FieldBotID) {
  35432. fields = append(fields, usagestatisticday.FieldBotID)
  35433. }
  35434. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  35435. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35436. }
  35437. return fields
  35438. }
  35439. // FieldCleared returns a boolean indicating if a field with the given name was
  35440. // cleared in this mutation.
  35441. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  35442. _, ok := m.clearedFields[name]
  35443. return ok
  35444. }
  35445. // ClearField clears the value of the field with the given name. It returns an
  35446. // error if the field is not defined in the schema.
  35447. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  35448. switch name {
  35449. case usagestatisticday.FieldStatus:
  35450. m.ClearStatus()
  35451. return nil
  35452. case usagestatisticday.FieldDeletedAt:
  35453. m.ClearDeletedAt()
  35454. return nil
  35455. case usagestatisticday.FieldBotID:
  35456. m.ClearBotID()
  35457. return nil
  35458. case usagestatisticday.FieldOrganizationID:
  35459. m.ClearOrganizationID()
  35460. return nil
  35461. }
  35462. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  35463. }
  35464. // ResetField resets all changes in the mutation for the field with the given name.
  35465. // It returns an error if the field is not defined in the schema.
  35466. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  35467. switch name {
  35468. case usagestatisticday.FieldCreatedAt:
  35469. m.ResetCreatedAt()
  35470. return nil
  35471. case usagestatisticday.FieldUpdatedAt:
  35472. m.ResetUpdatedAt()
  35473. return nil
  35474. case usagestatisticday.FieldStatus:
  35475. m.ResetStatus()
  35476. return nil
  35477. case usagestatisticday.FieldDeletedAt:
  35478. m.ResetDeletedAt()
  35479. return nil
  35480. case usagestatisticday.FieldAddtime:
  35481. m.ResetAddtime()
  35482. return nil
  35483. case usagestatisticday.FieldType:
  35484. m.ResetType()
  35485. return nil
  35486. case usagestatisticday.FieldBotID:
  35487. m.ResetBotID()
  35488. return nil
  35489. case usagestatisticday.FieldOrganizationID:
  35490. m.ResetOrganizationID()
  35491. return nil
  35492. case usagestatisticday.FieldAiResponse:
  35493. m.ResetAiResponse()
  35494. return nil
  35495. case usagestatisticday.FieldSopRun:
  35496. m.ResetSopRun()
  35497. return nil
  35498. case usagestatisticday.FieldTotalFriend:
  35499. m.ResetTotalFriend()
  35500. return nil
  35501. case usagestatisticday.FieldTotalGroup:
  35502. m.ResetTotalGroup()
  35503. return nil
  35504. case usagestatisticday.FieldAccountBalance:
  35505. m.ResetAccountBalance()
  35506. return nil
  35507. case usagestatisticday.FieldConsumeToken:
  35508. m.ResetConsumeToken()
  35509. return nil
  35510. case usagestatisticday.FieldActiveUser:
  35511. m.ResetActiveUser()
  35512. return nil
  35513. case usagestatisticday.FieldNewUser:
  35514. m.ResetNewUser()
  35515. return nil
  35516. case usagestatisticday.FieldLabelDist:
  35517. m.ResetLabelDist()
  35518. return nil
  35519. }
  35520. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35521. }
  35522. // AddedEdges returns all edge names that were set/added in this mutation.
  35523. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  35524. edges := make([]string, 0, 0)
  35525. return edges
  35526. }
  35527. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35528. // name in this mutation.
  35529. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  35530. return nil
  35531. }
  35532. // RemovedEdges returns all edge names that were removed in this mutation.
  35533. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  35534. edges := make([]string, 0, 0)
  35535. return edges
  35536. }
  35537. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35538. // the given name in this mutation.
  35539. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  35540. return nil
  35541. }
  35542. // ClearedEdges returns all edge names that were cleared in this mutation.
  35543. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  35544. edges := make([]string, 0, 0)
  35545. return edges
  35546. }
  35547. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35548. // was cleared in this mutation.
  35549. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  35550. return false
  35551. }
  35552. // ClearEdge clears the value of the edge with the given name. It returns an error
  35553. // if that edge is not defined in the schema.
  35554. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  35555. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  35556. }
  35557. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35558. // It returns an error if the edge is not defined in the schema.
  35559. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  35560. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  35561. }
  35562. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  35563. type UsageStatisticHourMutation struct {
  35564. config
  35565. op Op
  35566. typ string
  35567. id *uint64
  35568. created_at *time.Time
  35569. updated_at *time.Time
  35570. status *uint8
  35571. addstatus *int8
  35572. deleted_at *time.Time
  35573. addtime *uint64
  35574. addaddtime *int64
  35575. _type *int
  35576. add_type *int
  35577. bot_id *string
  35578. organization_id *uint64
  35579. addorganization_id *int64
  35580. ai_response *uint64
  35581. addai_response *int64
  35582. sop_run *uint64
  35583. addsop_run *int64
  35584. total_friend *uint64
  35585. addtotal_friend *int64
  35586. total_group *uint64
  35587. addtotal_group *int64
  35588. account_balance *uint64
  35589. addaccount_balance *int64
  35590. consume_token *uint64
  35591. addconsume_token *int64
  35592. active_user *uint64
  35593. addactive_user *int64
  35594. new_user *int64
  35595. addnew_user *int64
  35596. label_dist *[]custom_types.LabelDist
  35597. appendlabel_dist []custom_types.LabelDist
  35598. clearedFields map[string]struct{}
  35599. done bool
  35600. oldValue func(context.Context) (*UsageStatisticHour, error)
  35601. predicates []predicate.UsageStatisticHour
  35602. }
  35603. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  35604. // usagestatistichourOption allows management of the mutation configuration using functional options.
  35605. type usagestatistichourOption func(*UsageStatisticHourMutation)
  35606. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  35607. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  35608. m := &UsageStatisticHourMutation{
  35609. config: c,
  35610. op: op,
  35611. typ: TypeUsageStatisticHour,
  35612. clearedFields: make(map[string]struct{}),
  35613. }
  35614. for _, opt := range opts {
  35615. opt(m)
  35616. }
  35617. return m
  35618. }
  35619. // withUsageStatisticHourID sets the ID field of the mutation.
  35620. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  35621. return func(m *UsageStatisticHourMutation) {
  35622. var (
  35623. err error
  35624. once sync.Once
  35625. value *UsageStatisticHour
  35626. )
  35627. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  35628. once.Do(func() {
  35629. if m.done {
  35630. err = errors.New("querying old values post mutation is not allowed")
  35631. } else {
  35632. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  35633. }
  35634. })
  35635. return value, err
  35636. }
  35637. m.id = &id
  35638. }
  35639. }
  35640. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  35641. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  35642. return func(m *UsageStatisticHourMutation) {
  35643. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  35644. return node, nil
  35645. }
  35646. m.id = &node.ID
  35647. }
  35648. }
  35649. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35650. // executed in a transaction (ent.Tx), a transactional client is returned.
  35651. func (m UsageStatisticHourMutation) Client() *Client {
  35652. client := &Client{config: m.config}
  35653. client.init()
  35654. return client
  35655. }
  35656. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35657. // it returns an error otherwise.
  35658. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  35659. if _, ok := m.driver.(*txDriver); !ok {
  35660. return nil, errors.New("ent: mutation is not running in a transaction")
  35661. }
  35662. tx := &Tx{config: m.config}
  35663. tx.init()
  35664. return tx, nil
  35665. }
  35666. // SetID sets the value of the id field. Note that this
  35667. // operation is only accepted on creation of UsageStatisticHour entities.
  35668. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  35669. m.id = &id
  35670. }
  35671. // ID returns the ID value in the mutation. Note that the ID is only available
  35672. // if it was provided to the builder or after it was returned from the database.
  35673. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  35674. if m.id == nil {
  35675. return
  35676. }
  35677. return *m.id, true
  35678. }
  35679. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35680. // That means, if the mutation is applied within a transaction with an isolation level such
  35681. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35682. // or updated by the mutation.
  35683. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  35684. switch {
  35685. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35686. id, exists := m.ID()
  35687. if exists {
  35688. return []uint64{id}, nil
  35689. }
  35690. fallthrough
  35691. case m.op.Is(OpUpdate | OpDelete):
  35692. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  35693. default:
  35694. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35695. }
  35696. }
  35697. // SetCreatedAt sets the "created_at" field.
  35698. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  35699. m.created_at = &t
  35700. }
  35701. // CreatedAt returns the value of the "created_at" field in the mutation.
  35702. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  35703. v := m.created_at
  35704. if v == nil {
  35705. return
  35706. }
  35707. return *v, true
  35708. }
  35709. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  35710. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35712. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35713. if !m.op.Is(OpUpdateOne) {
  35714. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35715. }
  35716. if m.id == nil || m.oldValue == nil {
  35717. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35718. }
  35719. oldValue, err := m.oldValue(ctx)
  35720. if err != nil {
  35721. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35722. }
  35723. return oldValue.CreatedAt, nil
  35724. }
  35725. // ResetCreatedAt resets all changes to the "created_at" field.
  35726. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  35727. m.created_at = nil
  35728. }
  35729. // SetUpdatedAt sets the "updated_at" field.
  35730. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  35731. m.updated_at = &t
  35732. }
  35733. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35734. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  35735. v := m.updated_at
  35736. if v == nil {
  35737. return
  35738. }
  35739. return *v, true
  35740. }
  35741. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  35742. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35744. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35745. if !m.op.Is(OpUpdateOne) {
  35746. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35747. }
  35748. if m.id == nil || m.oldValue == nil {
  35749. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35750. }
  35751. oldValue, err := m.oldValue(ctx)
  35752. if err != nil {
  35753. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35754. }
  35755. return oldValue.UpdatedAt, nil
  35756. }
  35757. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35758. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  35759. m.updated_at = nil
  35760. }
  35761. // SetStatus sets the "status" field.
  35762. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  35763. m.status = &u
  35764. m.addstatus = nil
  35765. }
  35766. // Status returns the value of the "status" field in the mutation.
  35767. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  35768. v := m.status
  35769. if v == nil {
  35770. return
  35771. }
  35772. return *v, true
  35773. }
  35774. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  35775. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35777. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35778. if !m.op.Is(OpUpdateOne) {
  35779. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35780. }
  35781. if m.id == nil || m.oldValue == nil {
  35782. return v, errors.New("OldStatus requires an ID field in the mutation")
  35783. }
  35784. oldValue, err := m.oldValue(ctx)
  35785. if err != nil {
  35786. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35787. }
  35788. return oldValue.Status, nil
  35789. }
  35790. // AddStatus adds u to the "status" field.
  35791. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  35792. if m.addstatus != nil {
  35793. *m.addstatus += u
  35794. } else {
  35795. m.addstatus = &u
  35796. }
  35797. }
  35798. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35799. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  35800. v := m.addstatus
  35801. if v == nil {
  35802. return
  35803. }
  35804. return *v, true
  35805. }
  35806. // ClearStatus clears the value of the "status" field.
  35807. func (m *UsageStatisticHourMutation) ClearStatus() {
  35808. m.status = nil
  35809. m.addstatus = nil
  35810. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  35811. }
  35812. // StatusCleared returns if the "status" field was cleared in this mutation.
  35813. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  35814. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  35815. return ok
  35816. }
  35817. // ResetStatus resets all changes to the "status" field.
  35818. func (m *UsageStatisticHourMutation) ResetStatus() {
  35819. m.status = nil
  35820. m.addstatus = nil
  35821. delete(m.clearedFields, usagestatistichour.FieldStatus)
  35822. }
  35823. // SetDeletedAt sets the "deleted_at" field.
  35824. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  35825. m.deleted_at = &t
  35826. }
  35827. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35828. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  35829. v := m.deleted_at
  35830. if v == nil {
  35831. return
  35832. }
  35833. return *v, true
  35834. }
  35835. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  35836. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35838. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35839. if !m.op.Is(OpUpdateOne) {
  35840. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35841. }
  35842. if m.id == nil || m.oldValue == nil {
  35843. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35844. }
  35845. oldValue, err := m.oldValue(ctx)
  35846. if err != nil {
  35847. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35848. }
  35849. return oldValue.DeletedAt, nil
  35850. }
  35851. // ClearDeletedAt clears the value of the "deleted_at" field.
  35852. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  35853. m.deleted_at = nil
  35854. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  35855. }
  35856. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35857. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  35858. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  35859. return ok
  35860. }
  35861. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35862. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  35863. m.deleted_at = nil
  35864. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  35865. }
  35866. // SetAddtime sets the "addtime" field.
  35867. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  35868. m.addtime = &u
  35869. m.addaddtime = nil
  35870. }
  35871. // Addtime returns the value of the "addtime" field in the mutation.
  35872. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  35873. v := m.addtime
  35874. if v == nil {
  35875. return
  35876. }
  35877. return *v, true
  35878. }
  35879. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  35880. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35882. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35883. if !m.op.Is(OpUpdateOne) {
  35884. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35885. }
  35886. if m.id == nil || m.oldValue == nil {
  35887. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35888. }
  35889. oldValue, err := m.oldValue(ctx)
  35890. if err != nil {
  35891. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35892. }
  35893. return oldValue.Addtime, nil
  35894. }
  35895. // AddAddtime adds u to the "addtime" field.
  35896. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  35897. if m.addaddtime != nil {
  35898. *m.addaddtime += u
  35899. } else {
  35900. m.addaddtime = &u
  35901. }
  35902. }
  35903. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35904. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  35905. v := m.addaddtime
  35906. if v == nil {
  35907. return
  35908. }
  35909. return *v, true
  35910. }
  35911. // ResetAddtime resets all changes to the "addtime" field.
  35912. func (m *UsageStatisticHourMutation) ResetAddtime() {
  35913. m.addtime = nil
  35914. m.addaddtime = nil
  35915. }
  35916. // SetType sets the "type" field.
  35917. func (m *UsageStatisticHourMutation) SetType(i int) {
  35918. m._type = &i
  35919. m.add_type = nil
  35920. }
  35921. // GetType returns the value of the "type" field in the mutation.
  35922. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  35923. v := m._type
  35924. if v == nil {
  35925. return
  35926. }
  35927. return *v, true
  35928. }
  35929. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  35930. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35932. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  35933. if !m.op.Is(OpUpdateOne) {
  35934. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35935. }
  35936. if m.id == nil || m.oldValue == nil {
  35937. return v, errors.New("OldType requires an ID field in the mutation")
  35938. }
  35939. oldValue, err := m.oldValue(ctx)
  35940. if err != nil {
  35941. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35942. }
  35943. return oldValue.Type, nil
  35944. }
  35945. // AddType adds i to the "type" field.
  35946. func (m *UsageStatisticHourMutation) AddType(i int) {
  35947. if m.add_type != nil {
  35948. *m.add_type += i
  35949. } else {
  35950. m.add_type = &i
  35951. }
  35952. }
  35953. // AddedType returns the value that was added to the "type" field in this mutation.
  35954. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  35955. v := m.add_type
  35956. if v == nil {
  35957. return
  35958. }
  35959. return *v, true
  35960. }
  35961. // ResetType resets all changes to the "type" field.
  35962. func (m *UsageStatisticHourMutation) ResetType() {
  35963. m._type = nil
  35964. m.add_type = nil
  35965. }
  35966. // SetBotID sets the "bot_id" field.
  35967. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  35968. m.bot_id = &s
  35969. }
  35970. // BotID returns the value of the "bot_id" field in the mutation.
  35971. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  35972. v := m.bot_id
  35973. if v == nil {
  35974. return
  35975. }
  35976. return *v, true
  35977. }
  35978. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  35979. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35981. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  35982. if !m.op.Is(OpUpdateOne) {
  35983. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35984. }
  35985. if m.id == nil || m.oldValue == nil {
  35986. return v, errors.New("OldBotID requires an ID field in the mutation")
  35987. }
  35988. oldValue, err := m.oldValue(ctx)
  35989. if err != nil {
  35990. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35991. }
  35992. return oldValue.BotID, nil
  35993. }
  35994. // ClearBotID clears the value of the "bot_id" field.
  35995. func (m *UsageStatisticHourMutation) ClearBotID() {
  35996. m.bot_id = nil
  35997. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  35998. }
  35999. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36000. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  36001. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  36002. return ok
  36003. }
  36004. // ResetBotID resets all changes to the "bot_id" field.
  36005. func (m *UsageStatisticHourMutation) ResetBotID() {
  36006. m.bot_id = nil
  36007. delete(m.clearedFields, usagestatistichour.FieldBotID)
  36008. }
  36009. // SetOrganizationID sets the "organization_id" field.
  36010. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  36011. m.organization_id = &u
  36012. m.addorganization_id = nil
  36013. }
  36014. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36015. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  36016. v := m.organization_id
  36017. if v == nil {
  36018. return
  36019. }
  36020. return *v, true
  36021. }
  36022. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  36023. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36025. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36026. if !m.op.Is(OpUpdateOne) {
  36027. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36028. }
  36029. if m.id == nil || m.oldValue == nil {
  36030. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36031. }
  36032. oldValue, err := m.oldValue(ctx)
  36033. if err != nil {
  36034. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36035. }
  36036. return oldValue.OrganizationID, nil
  36037. }
  36038. // AddOrganizationID adds u to the "organization_id" field.
  36039. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  36040. if m.addorganization_id != nil {
  36041. *m.addorganization_id += u
  36042. } else {
  36043. m.addorganization_id = &u
  36044. }
  36045. }
  36046. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36047. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  36048. v := m.addorganization_id
  36049. if v == nil {
  36050. return
  36051. }
  36052. return *v, true
  36053. }
  36054. // ClearOrganizationID clears the value of the "organization_id" field.
  36055. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  36056. m.organization_id = nil
  36057. m.addorganization_id = nil
  36058. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  36059. }
  36060. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36061. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  36062. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  36063. return ok
  36064. }
  36065. // ResetOrganizationID resets all changes to the "organization_id" field.
  36066. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  36067. m.organization_id = nil
  36068. m.addorganization_id = nil
  36069. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  36070. }
  36071. // SetAiResponse sets the "ai_response" field.
  36072. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  36073. m.ai_response = &u
  36074. m.addai_response = nil
  36075. }
  36076. // AiResponse returns the value of the "ai_response" field in the mutation.
  36077. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  36078. v := m.ai_response
  36079. if v == nil {
  36080. return
  36081. }
  36082. return *v, true
  36083. }
  36084. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  36085. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36087. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36088. if !m.op.Is(OpUpdateOne) {
  36089. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36090. }
  36091. if m.id == nil || m.oldValue == nil {
  36092. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36093. }
  36094. oldValue, err := m.oldValue(ctx)
  36095. if err != nil {
  36096. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36097. }
  36098. return oldValue.AiResponse, nil
  36099. }
  36100. // AddAiResponse adds u to the "ai_response" field.
  36101. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  36102. if m.addai_response != nil {
  36103. *m.addai_response += u
  36104. } else {
  36105. m.addai_response = &u
  36106. }
  36107. }
  36108. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36109. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  36110. v := m.addai_response
  36111. if v == nil {
  36112. return
  36113. }
  36114. return *v, true
  36115. }
  36116. // ResetAiResponse resets all changes to the "ai_response" field.
  36117. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  36118. m.ai_response = nil
  36119. m.addai_response = nil
  36120. }
  36121. // SetSopRun sets the "sop_run" field.
  36122. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  36123. m.sop_run = &u
  36124. m.addsop_run = nil
  36125. }
  36126. // SopRun returns the value of the "sop_run" field in the mutation.
  36127. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  36128. v := m.sop_run
  36129. if v == nil {
  36130. return
  36131. }
  36132. return *v, true
  36133. }
  36134. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  36135. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36137. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36138. if !m.op.Is(OpUpdateOne) {
  36139. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36140. }
  36141. if m.id == nil || m.oldValue == nil {
  36142. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36143. }
  36144. oldValue, err := m.oldValue(ctx)
  36145. if err != nil {
  36146. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36147. }
  36148. return oldValue.SopRun, nil
  36149. }
  36150. // AddSopRun adds u to the "sop_run" field.
  36151. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  36152. if m.addsop_run != nil {
  36153. *m.addsop_run += u
  36154. } else {
  36155. m.addsop_run = &u
  36156. }
  36157. }
  36158. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36159. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  36160. v := m.addsop_run
  36161. if v == nil {
  36162. return
  36163. }
  36164. return *v, true
  36165. }
  36166. // ResetSopRun resets all changes to the "sop_run" field.
  36167. func (m *UsageStatisticHourMutation) ResetSopRun() {
  36168. m.sop_run = nil
  36169. m.addsop_run = nil
  36170. }
  36171. // SetTotalFriend sets the "total_friend" field.
  36172. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  36173. m.total_friend = &u
  36174. m.addtotal_friend = nil
  36175. }
  36176. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36177. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  36178. v := m.total_friend
  36179. if v == nil {
  36180. return
  36181. }
  36182. return *v, true
  36183. }
  36184. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  36185. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36187. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36188. if !m.op.Is(OpUpdateOne) {
  36189. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36190. }
  36191. if m.id == nil || m.oldValue == nil {
  36192. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36193. }
  36194. oldValue, err := m.oldValue(ctx)
  36195. if err != nil {
  36196. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36197. }
  36198. return oldValue.TotalFriend, nil
  36199. }
  36200. // AddTotalFriend adds u to the "total_friend" field.
  36201. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  36202. if m.addtotal_friend != nil {
  36203. *m.addtotal_friend += u
  36204. } else {
  36205. m.addtotal_friend = &u
  36206. }
  36207. }
  36208. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36209. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  36210. v := m.addtotal_friend
  36211. if v == nil {
  36212. return
  36213. }
  36214. return *v, true
  36215. }
  36216. // ResetTotalFriend resets all changes to the "total_friend" field.
  36217. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  36218. m.total_friend = nil
  36219. m.addtotal_friend = nil
  36220. }
  36221. // SetTotalGroup sets the "total_group" field.
  36222. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  36223. m.total_group = &u
  36224. m.addtotal_group = nil
  36225. }
  36226. // TotalGroup returns the value of the "total_group" field in the mutation.
  36227. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  36228. v := m.total_group
  36229. if v == nil {
  36230. return
  36231. }
  36232. return *v, true
  36233. }
  36234. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  36235. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36237. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36238. if !m.op.Is(OpUpdateOne) {
  36239. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36240. }
  36241. if m.id == nil || m.oldValue == nil {
  36242. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36243. }
  36244. oldValue, err := m.oldValue(ctx)
  36245. if err != nil {
  36246. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36247. }
  36248. return oldValue.TotalGroup, nil
  36249. }
  36250. // AddTotalGroup adds u to the "total_group" field.
  36251. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  36252. if m.addtotal_group != nil {
  36253. *m.addtotal_group += u
  36254. } else {
  36255. m.addtotal_group = &u
  36256. }
  36257. }
  36258. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36259. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  36260. v := m.addtotal_group
  36261. if v == nil {
  36262. return
  36263. }
  36264. return *v, true
  36265. }
  36266. // ResetTotalGroup resets all changes to the "total_group" field.
  36267. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  36268. m.total_group = nil
  36269. m.addtotal_group = nil
  36270. }
  36271. // SetAccountBalance sets the "account_balance" field.
  36272. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  36273. m.account_balance = &u
  36274. m.addaccount_balance = nil
  36275. }
  36276. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36277. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  36278. v := m.account_balance
  36279. if v == nil {
  36280. return
  36281. }
  36282. return *v, true
  36283. }
  36284. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  36285. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36287. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36288. if !m.op.Is(OpUpdateOne) {
  36289. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36290. }
  36291. if m.id == nil || m.oldValue == nil {
  36292. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36293. }
  36294. oldValue, err := m.oldValue(ctx)
  36295. if err != nil {
  36296. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36297. }
  36298. return oldValue.AccountBalance, nil
  36299. }
  36300. // AddAccountBalance adds u to the "account_balance" field.
  36301. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  36302. if m.addaccount_balance != nil {
  36303. *m.addaccount_balance += u
  36304. } else {
  36305. m.addaccount_balance = &u
  36306. }
  36307. }
  36308. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36309. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  36310. v := m.addaccount_balance
  36311. if v == nil {
  36312. return
  36313. }
  36314. return *v, true
  36315. }
  36316. // ResetAccountBalance resets all changes to the "account_balance" field.
  36317. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  36318. m.account_balance = nil
  36319. m.addaccount_balance = nil
  36320. }
  36321. // SetConsumeToken sets the "consume_token" field.
  36322. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  36323. m.consume_token = &u
  36324. m.addconsume_token = nil
  36325. }
  36326. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36327. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  36328. v := m.consume_token
  36329. if v == nil {
  36330. return
  36331. }
  36332. return *v, true
  36333. }
  36334. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  36335. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36337. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36338. if !m.op.Is(OpUpdateOne) {
  36339. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36340. }
  36341. if m.id == nil || m.oldValue == nil {
  36342. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36343. }
  36344. oldValue, err := m.oldValue(ctx)
  36345. if err != nil {
  36346. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36347. }
  36348. return oldValue.ConsumeToken, nil
  36349. }
  36350. // AddConsumeToken adds u to the "consume_token" field.
  36351. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  36352. if m.addconsume_token != nil {
  36353. *m.addconsume_token += u
  36354. } else {
  36355. m.addconsume_token = &u
  36356. }
  36357. }
  36358. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36359. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  36360. v := m.addconsume_token
  36361. if v == nil {
  36362. return
  36363. }
  36364. return *v, true
  36365. }
  36366. // ResetConsumeToken resets all changes to the "consume_token" field.
  36367. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  36368. m.consume_token = nil
  36369. m.addconsume_token = nil
  36370. }
  36371. // SetActiveUser sets the "active_user" field.
  36372. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  36373. m.active_user = &u
  36374. m.addactive_user = nil
  36375. }
  36376. // ActiveUser returns the value of the "active_user" field in the mutation.
  36377. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  36378. v := m.active_user
  36379. if v == nil {
  36380. return
  36381. }
  36382. return *v, true
  36383. }
  36384. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  36385. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36387. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36388. if !m.op.Is(OpUpdateOne) {
  36389. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36390. }
  36391. if m.id == nil || m.oldValue == nil {
  36392. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36393. }
  36394. oldValue, err := m.oldValue(ctx)
  36395. if err != nil {
  36396. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36397. }
  36398. return oldValue.ActiveUser, nil
  36399. }
  36400. // AddActiveUser adds u to the "active_user" field.
  36401. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  36402. if m.addactive_user != nil {
  36403. *m.addactive_user += u
  36404. } else {
  36405. m.addactive_user = &u
  36406. }
  36407. }
  36408. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36409. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  36410. v := m.addactive_user
  36411. if v == nil {
  36412. return
  36413. }
  36414. return *v, true
  36415. }
  36416. // ResetActiveUser resets all changes to the "active_user" field.
  36417. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  36418. m.active_user = nil
  36419. m.addactive_user = nil
  36420. }
  36421. // SetNewUser sets the "new_user" field.
  36422. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  36423. m.new_user = &i
  36424. m.addnew_user = nil
  36425. }
  36426. // NewUser returns the value of the "new_user" field in the mutation.
  36427. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  36428. v := m.new_user
  36429. if v == nil {
  36430. return
  36431. }
  36432. return *v, true
  36433. }
  36434. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  36435. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36437. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36438. if !m.op.Is(OpUpdateOne) {
  36439. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36440. }
  36441. if m.id == nil || m.oldValue == nil {
  36442. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36443. }
  36444. oldValue, err := m.oldValue(ctx)
  36445. if err != nil {
  36446. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36447. }
  36448. return oldValue.NewUser, nil
  36449. }
  36450. // AddNewUser adds i to the "new_user" field.
  36451. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  36452. if m.addnew_user != nil {
  36453. *m.addnew_user += i
  36454. } else {
  36455. m.addnew_user = &i
  36456. }
  36457. }
  36458. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36459. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  36460. v := m.addnew_user
  36461. if v == nil {
  36462. return
  36463. }
  36464. return *v, true
  36465. }
  36466. // ResetNewUser resets all changes to the "new_user" field.
  36467. func (m *UsageStatisticHourMutation) ResetNewUser() {
  36468. m.new_user = nil
  36469. m.addnew_user = nil
  36470. }
  36471. // SetLabelDist sets the "label_dist" field.
  36472. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36473. m.label_dist = &ctd
  36474. m.appendlabel_dist = nil
  36475. }
  36476. // LabelDist returns the value of the "label_dist" field in the mutation.
  36477. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36478. v := m.label_dist
  36479. if v == nil {
  36480. return
  36481. }
  36482. return *v, true
  36483. }
  36484. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  36485. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36487. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36488. if !m.op.Is(OpUpdateOne) {
  36489. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36490. }
  36491. if m.id == nil || m.oldValue == nil {
  36492. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36493. }
  36494. oldValue, err := m.oldValue(ctx)
  36495. if err != nil {
  36496. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36497. }
  36498. return oldValue.LabelDist, nil
  36499. }
  36500. // AppendLabelDist adds ctd to the "label_dist" field.
  36501. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36502. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36503. }
  36504. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36505. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36506. if len(m.appendlabel_dist) == 0 {
  36507. return nil, false
  36508. }
  36509. return m.appendlabel_dist, true
  36510. }
  36511. // ResetLabelDist resets all changes to the "label_dist" field.
  36512. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  36513. m.label_dist = nil
  36514. m.appendlabel_dist = nil
  36515. }
  36516. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  36517. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  36518. m.predicates = append(m.predicates, ps...)
  36519. }
  36520. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  36521. // users can use type-assertion to append predicates that do not depend on any generated package.
  36522. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  36523. p := make([]predicate.UsageStatisticHour, len(ps))
  36524. for i := range ps {
  36525. p[i] = ps[i]
  36526. }
  36527. m.Where(p...)
  36528. }
  36529. // Op returns the operation name.
  36530. func (m *UsageStatisticHourMutation) Op() Op {
  36531. return m.op
  36532. }
  36533. // SetOp allows setting the mutation operation.
  36534. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  36535. m.op = op
  36536. }
  36537. // Type returns the node type of this mutation (UsageStatisticHour).
  36538. func (m *UsageStatisticHourMutation) Type() string {
  36539. return m.typ
  36540. }
  36541. // Fields returns all fields that were changed during this mutation. Note that in
  36542. // order to get all numeric fields that were incremented/decremented, call
  36543. // AddedFields().
  36544. func (m *UsageStatisticHourMutation) Fields() []string {
  36545. fields := make([]string, 0, 17)
  36546. if m.created_at != nil {
  36547. fields = append(fields, usagestatistichour.FieldCreatedAt)
  36548. }
  36549. if m.updated_at != nil {
  36550. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  36551. }
  36552. if m.status != nil {
  36553. fields = append(fields, usagestatistichour.FieldStatus)
  36554. }
  36555. if m.deleted_at != nil {
  36556. fields = append(fields, usagestatistichour.FieldDeletedAt)
  36557. }
  36558. if m.addtime != nil {
  36559. fields = append(fields, usagestatistichour.FieldAddtime)
  36560. }
  36561. if m._type != nil {
  36562. fields = append(fields, usagestatistichour.FieldType)
  36563. }
  36564. if m.bot_id != nil {
  36565. fields = append(fields, usagestatistichour.FieldBotID)
  36566. }
  36567. if m.organization_id != nil {
  36568. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36569. }
  36570. if m.ai_response != nil {
  36571. fields = append(fields, usagestatistichour.FieldAiResponse)
  36572. }
  36573. if m.sop_run != nil {
  36574. fields = append(fields, usagestatistichour.FieldSopRun)
  36575. }
  36576. if m.total_friend != nil {
  36577. fields = append(fields, usagestatistichour.FieldTotalFriend)
  36578. }
  36579. if m.total_group != nil {
  36580. fields = append(fields, usagestatistichour.FieldTotalGroup)
  36581. }
  36582. if m.account_balance != nil {
  36583. fields = append(fields, usagestatistichour.FieldAccountBalance)
  36584. }
  36585. if m.consume_token != nil {
  36586. fields = append(fields, usagestatistichour.FieldConsumeToken)
  36587. }
  36588. if m.active_user != nil {
  36589. fields = append(fields, usagestatistichour.FieldActiveUser)
  36590. }
  36591. if m.new_user != nil {
  36592. fields = append(fields, usagestatistichour.FieldNewUser)
  36593. }
  36594. if m.label_dist != nil {
  36595. fields = append(fields, usagestatistichour.FieldLabelDist)
  36596. }
  36597. return fields
  36598. }
  36599. // Field returns the value of a field with the given name. The second boolean
  36600. // return value indicates that this field was not set, or was not defined in the
  36601. // schema.
  36602. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  36603. switch name {
  36604. case usagestatistichour.FieldCreatedAt:
  36605. return m.CreatedAt()
  36606. case usagestatistichour.FieldUpdatedAt:
  36607. return m.UpdatedAt()
  36608. case usagestatistichour.FieldStatus:
  36609. return m.Status()
  36610. case usagestatistichour.FieldDeletedAt:
  36611. return m.DeletedAt()
  36612. case usagestatistichour.FieldAddtime:
  36613. return m.Addtime()
  36614. case usagestatistichour.FieldType:
  36615. return m.GetType()
  36616. case usagestatistichour.FieldBotID:
  36617. return m.BotID()
  36618. case usagestatistichour.FieldOrganizationID:
  36619. return m.OrganizationID()
  36620. case usagestatistichour.FieldAiResponse:
  36621. return m.AiResponse()
  36622. case usagestatistichour.FieldSopRun:
  36623. return m.SopRun()
  36624. case usagestatistichour.FieldTotalFriend:
  36625. return m.TotalFriend()
  36626. case usagestatistichour.FieldTotalGroup:
  36627. return m.TotalGroup()
  36628. case usagestatistichour.FieldAccountBalance:
  36629. return m.AccountBalance()
  36630. case usagestatistichour.FieldConsumeToken:
  36631. return m.ConsumeToken()
  36632. case usagestatistichour.FieldActiveUser:
  36633. return m.ActiveUser()
  36634. case usagestatistichour.FieldNewUser:
  36635. return m.NewUser()
  36636. case usagestatistichour.FieldLabelDist:
  36637. return m.LabelDist()
  36638. }
  36639. return nil, false
  36640. }
  36641. // OldField returns the old value of the field from the database. An error is
  36642. // returned if the mutation operation is not UpdateOne, or the query to the
  36643. // database failed.
  36644. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36645. switch name {
  36646. case usagestatistichour.FieldCreatedAt:
  36647. return m.OldCreatedAt(ctx)
  36648. case usagestatistichour.FieldUpdatedAt:
  36649. return m.OldUpdatedAt(ctx)
  36650. case usagestatistichour.FieldStatus:
  36651. return m.OldStatus(ctx)
  36652. case usagestatistichour.FieldDeletedAt:
  36653. return m.OldDeletedAt(ctx)
  36654. case usagestatistichour.FieldAddtime:
  36655. return m.OldAddtime(ctx)
  36656. case usagestatistichour.FieldType:
  36657. return m.OldType(ctx)
  36658. case usagestatistichour.FieldBotID:
  36659. return m.OldBotID(ctx)
  36660. case usagestatistichour.FieldOrganizationID:
  36661. return m.OldOrganizationID(ctx)
  36662. case usagestatistichour.FieldAiResponse:
  36663. return m.OldAiResponse(ctx)
  36664. case usagestatistichour.FieldSopRun:
  36665. return m.OldSopRun(ctx)
  36666. case usagestatistichour.FieldTotalFriend:
  36667. return m.OldTotalFriend(ctx)
  36668. case usagestatistichour.FieldTotalGroup:
  36669. return m.OldTotalGroup(ctx)
  36670. case usagestatistichour.FieldAccountBalance:
  36671. return m.OldAccountBalance(ctx)
  36672. case usagestatistichour.FieldConsumeToken:
  36673. return m.OldConsumeToken(ctx)
  36674. case usagestatistichour.FieldActiveUser:
  36675. return m.OldActiveUser(ctx)
  36676. case usagestatistichour.FieldNewUser:
  36677. return m.OldNewUser(ctx)
  36678. case usagestatistichour.FieldLabelDist:
  36679. return m.OldLabelDist(ctx)
  36680. }
  36681. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36682. }
  36683. // SetField sets the value of a field with the given name. It returns an error if
  36684. // the field is not defined in the schema, or if the type mismatched the field
  36685. // type.
  36686. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  36687. switch name {
  36688. case usagestatistichour.FieldCreatedAt:
  36689. v, ok := value.(time.Time)
  36690. if !ok {
  36691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36692. }
  36693. m.SetCreatedAt(v)
  36694. return nil
  36695. case usagestatistichour.FieldUpdatedAt:
  36696. v, ok := value.(time.Time)
  36697. if !ok {
  36698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36699. }
  36700. m.SetUpdatedAt(v)
  36701. return nil
  36702. case usagestatistichour.FieldStatus:
  36703. v, ok := value.(uint8)
  36704. if !ok {
  36705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36706. }
  36707. m.SetStatus(v)
  36708. return nil
  36709. case usagestatistichour.FieldDeletedAt:
  36710. v, ok := value.(time.Time)
  36711. if !ok {
  36712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36713. }
  36714. m.SetDeletedAt(v)
  36715. return nil
  36716. case usagestatistichour.FieldAddtime:
  36717. v, ok := value.(uint64)
  36718. if !ok {
  36719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36720. }
  36721. m.SetAddtime(v)
  36722. return nil
  36723. case usagestatistichour.FieldType:
  36724. v, ok := value.(int)
  36725. if !ok {
  36726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36727. }
  36728. m.SetType(v)
  36729. return nil
  36730. case usagestatistichour.FieldBotID:
  36731. v, ok := value.(string)
  36732. if !ok {
  36733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36734. }
  36735. m.SetBotID(v)
  36736. return nil
  36737. case usagestatistichour.FieldOrganizationID:
  36738. v, ok := value.(uint64)
  36739. if !ok {
  36740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36741. }
  36742. m.SetOrganizationID(v)
  36743. return nil
  36744. case usagestatistichour.FieldAiResponse:
  36745. v, ok := value.(uint64)
  36746. if !ok {
  36747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36748. }
  36749. m.SetAiResponse(v)
  36750. return nil
  36751. case usagestatistichour.FieldSopRun:
  36752. v, ok := value.(uint64)
  36753. if !ok {
  36754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36755. }
  36756. m.SetSopRun(v)
  36757. return nil
  36758. case usagestatistichour.FieldTotalFriend:
  36759. v, ok := value.(uint64)
  36760. if !ok {
  36761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36762. }
  36763. m.SetTotalFriend(v)
  36764. return nil
  36765. case usagestatistichour.FieldTotalGroup:
  36766. v, ok := value.(uint64)
  36767. if !ok {
  36768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36769. }
  36770. m.SetTotalGroup(v)
  36771. return nil
  36772. case usagestatistichour.FieldAccountBalance:
  36773. v, ok := value.(uint64)
  36774. if !ok {
  36775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36776. }
  36777. m.SetAccountBalance(v)
  36778. return nil
  36779. case usagestatistichour.FieldConsumeToken:
  36780. v, ok := value.(uint64)
  36781. if !ok {
  36782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36783. }
  36784. m.SetConsumeToken(v)
  36785. return nil
  36786. case usagestatistichour.FieldActiveUser:
  36787. v, ok := value.(uint64)
  36788. if !ok {
  36789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36790. }
  36791. m.SetActiveUser(v)
  36792. return nil
  36793. case usagestatistichour.FieldNewUser:
  36794. v, ok := value.(int64)
  36795. if !ok {
  36796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36797. }
  36798. m.SetNewUser(v)
  36799. return nil
  36800. case usagestatistichour.FieldLabelDist:
  36801. v, ok := value.([]custom_types.LabelDist)
  36802. if !ok {
  36803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36804. }
  36805. m.SetLabelDist(v)
  36806. return nil
  36807. }
  36808. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36809. }
  36810. // AddedFields returns all numeric fields that were incremented/decremented during
  36811. // this mutation.
  36812. func (m *UsageStatisticHourMutation) AddedFields() []string {
  36813. var fields []string
  36814. if m.addstatus != nil {
  36815. fields = append(fields, usagestatistichour.FieldStatus)
  36816. }
  36817. if m.addaddtime != nil {
  36818. fields = append(fields, usagestatistichour.FieldAddtime)
  36819. }
  36820. if m.add_type != nil {
  36821. fields = append(fields, usagestatistichour.FieldType)
  36822. }
  36823. if m.addorganization_id != nil {
  36824. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36825. }
  36826. if m.addai_response != nil {
  36827. fields = append(fields, usagestatistichour.FieldAiResponse)
  36828. }
  36829. if m.addsop_run != nil {
  36830. fields = append(fields, usagestatistichour.FieldSopRun)
  36831. }
  36832. if m.addtotal_friend != nil {
  36833. fields = append(fields, usagestatistichour.FieldTotalFriend)
  36834. }
  36835. if m.addtotal_group != nil {
  36836. fields = append(fields, usagestatistichour.FieldTotalGroup)
  36837. }
  36838. if m.addaccount_balance != nil {
  36839. fields = append(fields, usagestatistichour.FieldAccountBalance)
  36840. }
  36841. if m.addconsume_token != nil {
  36842. fields = append(fields, usagestatistichour.FieldConsumeToken)
  36843. }
  36844. if m.addactive_user != nil {
  36845. fields = append(fields, usagestatistichour.FieldActiveUser)
  36846. }
  36847. if m.addnew_user != nil {
  36848. fields = append(fields, usagestatistichour.FieldNewUser)
  36849. }
  36850. return fields
  36851. }
  36852. // AddedField returns the numeric value that was incremented/decremented on a field
  36853. // with the given name. The second boolean return value indicates that this field
  36854. // was not set, or was not defined in the schema.
  36855. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  36856. switch name {
  36857. case usagestatistichour.FieldStatus:
  36858. return m.AddedStatus()
  36859. case usagestatistichour.FieldAddtime:
  36860. return m.AddedAddtime()
  36861. case usagestatistichour.FieldType:
  36862. return m.AddedType()
  36863. case usagestatistichour.FieldOrganizationID:
  36864. return m.AddedOrganizationID()
  36865. case usagestatistichour.FieldAiResponse:
  36866. return m.AddedAiResponse()
  36867. case usagestatistichour.FieldSopRun:
  36868. return m.AddedSopRun()
  36869. case usagestatistichour.FieldTotalFriend:
  36870. return m.AddedTotalFriend()
  36871. case usagestatistichour.FieldTotalGroup:
  36872. return m.AddedTotalGroup()
  36873. case usagestatistichour.FieldAccountBalance:
  36874. return m.AddedAccountBalance()
  36875. case usagestatistichour.FieldConsumeToken:
  36876. return m.AddedConsumeToken()
  36877. case usagestatistichour.FieldActiveUser:
  36878. return m.AddedActiveUser()
  36879. case usagestatistichour.FieldNewUser:
  36880. return m.AddedNewUser()
  36881. }
  36882. return nil, false
  36883. }
  36884. // AddField adds the value to the field with the given name. It returns an error if
  36885. // the field is not defined in the schema, or if the type mismatched the field
  36886. // type.
  36887. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  36888. switch name {
  36889. case usagestatistichour.FieldStatus:
  36890. v, ok := value.(int8)
  36891. if !ok {
  36892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36893. }
  36894. m.AddStatus(v)
  36895. return nil
  36896. case usagestatistichour.FieldAddtime:
  36897. v, ok := value.(int64)
  36898. if !ok {
  36899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36900. }
  36901. m.AddAddtime(v)
  36902. return nil
  36903. case usagestatistichour.FieldType:
  36904. v, ok := value.(int)
  36905. if !ok {
  36906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36907. }
  36908. m.AddType(v)
  36909. return nil
  36910. case usagestatistichour.FieldOrganizationID:
  36911. v, ok := value.(int64)
  36912. if !ok {
  36913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36914. }
  36915. m.AddOrganizationID(v)
  36916. return nil
  36917. case usagestatistichour.FieldAiResponse:
  36918. v, ok := value.(int64)
  36919. if !ok {
  36920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36921. }
  36922. m.AddAiResponse(v)
  36923. return nil
  36924. case usagestatistichour.FieldSopRun:
  36925. v, ok := value.(int64)
  36926. if !ok {
  36927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36928. }
  36929. m.AddSopRun(v)
  36930. return nil
  36931. case usagestatistichour.FieldTotalFriend:
  36932. v, ok := value.(int64)
  36933. if !ok {
  36934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36935. }
  36936. m.AddTotalFriend(v)
  36937. return nil
  36938. case usagestatistichour.FieldTotalGroup:
  36939. v, ok := value.(int64)
  36940. if !ok {
  36941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36942. }
  36943. m.AddTotalGroup(v)
  36944. return nil
  36945. case usagestatistichour.FieldAccountBalance:
  36946. v, ok := value.(int64)
  36947. if !ok {
  36948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36949. }
  36950. m.AddAccountBalance(v)
  36951. return nil
  36952. case usagestatistichour.FieldConsumeToken:
  36953. v, ok := value.(int64)
  36954. if !ok {
  36955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36956. }
  36957. m.AddConsumeToken(v)
  36958. return nil
  36959. case usagestatistichour.FieldActiveUser:
  36960. v, ok := value.(int64)
  36961. if !ok {
  36962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36963. }
  36964. m.AddActiveUser(v)
  36965. return nil
  36966. case usagestatistichour.FieldNewUser:
  36967. v, ok := value.(int64)
  36968. if !ok {
  36969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36970. }
  36971. m.AddNewUser(v)
  36972. return nil
  36973. }
  36974. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  36975. }
  36976. // ClearedFields returns all nullable fields that were cleared during this
  36977. // mutation.
  36978. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  36979. var fields []string
  36980. if m.FieldCleared(usagestatistichour.FieldStatus) {
  36981. fields = append(fields, usagestatistichour.FieldStatus)
  36982. }
  36983. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  36984. fields = append(fields, usagestatistichour.FieldDeletedAt)
  36985. }
  36986. if m.FieldCleared(usagestatistichour.FieldBotID) {
  36987. fields = append(fields, usagestatistichour.FieldBotID)
  36988. }
  36989. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  36990. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36991. }
  36992. return fields
  36993. }
  36994. // FieldCleared returns a boolean indicating if a field with the given name was
  36995. // cleared in this mutation.
  36996. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  36997. _, ok := m.clearedFields[name]
  36998. return ok
  36999. }
  37000. // ClearField clears the value of the field with the given name. It returns an
  37001. // error if the field is not defined in the schema.
  37002. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  37003. switch name {
  37004. case usagestatistichour.FieldStatus:
  37005. m.ClearStatus()
  37006. return nil
  37007. case usagestatistichour.FieldDeletedAt:
  37008. m.ClearDeletedAt()
  37009. return nil
  37010. case usagestatistichour.FieldBotID:
  37011. m.ClearBotID()
  37012. return nil
  37013. case usagestatistichour.FieldOrganizationID:
  37014. m.ClearOrganizationID()
  37015. return nil
  37016. }
  37017. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  37018. }
  37019. // ResetField resets all changes in the mutation for the field with the given name.
  37020. // It returns an error if the field is not defined in the schema.
  37021. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  37022. switch name {
  37023. case usagestatistichour.FieldCreatedAt:
  37024. m.ResetCreatedAt()
  37025. return nil
  37026. case usagestatistichour.FieldUpdatedAt:
  37027. m.ResetUpdatedAt()
  37028. return nil
  37029. case usagestatistichour.FieldStatus:
  37030. m.ResetStatus()
  37031. return nil
  37032. case usagestatistichour.FieldDeletedAt:
  37033. m.ResetDeletedAt()
  37034. return nil
  37035. case usagestatistichour.FieldAddtime:
  37036. m.ResetAddtime()
  37037. return nil
  37038. case usagestatistichour.FieldType:
  37039. m.ResetType()
  37040. return nil
  37041. case usagestatistichour.FieldBotID:
  37042. m.ResetBotID()
  37043. return nil
  37044. case usagestatistichour.FieldOrganizationID:
  37045. m.ResetOrganizationID()
  37046. return nil
  37047. case usagestatistichour.FieldAiResponse:
  37048. m.ResetAiResponse()
  37049. return nil
  37050. case usagestatistichour.FieldSopRun:
  37051. m.ResetSopRun()
  37052. return nil
  37053. case usagestatistichour.FieldTotalFriend:
  37054. m.ResetTotalFriend()
  37055. return nil
  37056. case usagestatistichour.FieldTotalGroup:
  37057. m.ResetTotalGroup()
  37058. return nil
  37059. case usagestatistichour.FieldAccountBalance:
  37060. m.ResetAccountBalance()
  37061. return nil
  37062. case usagestatistichour.FieldConsumeToken:
  37063. m.ResetConsumeToken()
  37064. return nil
  37065. case usagestatistichour.FieldActiveUser:
  37066. m.ResetActiveUser()
  37067. return nil
  37068. case usagestatistichour.FieldNewUser:
  37069. m.ResetNewUser()
  37070. return nil
  37071. case usagestatistichour.FieldLabelDist:
  37072. m.ResetLabelDist()
  37073. return nil
  37074. }
  37075. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  37076. }
  37077. // AddedEdges returns all edge names that were set/added in this mutation.
  37078. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  37079. edges := make([]string, 0, 0)
  37080. return edges
  37081. }
  37082. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37083. // name in this mutation.
  37084. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  37085. return nil
  37086. }
  37087. // RemovedEdges returns all edge names that were removed in this mutation.
  37088. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  37089. edges := make([]string, 0, 0)
  37090. return edges
  37091. }
  37092. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37093. // the given name in this mutation.
  37094. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  37095. return nil
  37096. }
  37097. // ClearedEdges returns all edge names that were cleared in this mutation.
  37098. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  37099. edges := make([]string, 0, 0)
  37100. return edges
  37101. }
  37102. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37103. // was cleared in this mutation.
  37104. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  37105. return false
  37106. }
  37107. // ClearEdge clears the value of the edge with the given name. It returns an error
  37108. // if that edge is not defined in the schema.
  37109. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  37110. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  37111. }
  37112. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37113. // It returns an error if the edge is not defined in the schema.
  37114. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  37115. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  37116. }
  37117. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  37118. type UsageStatisticMonthMutation struct {
  37119. config
  37120. op Op
  37121. typ string
  37122. id *uint64
  37123. created_at *time.Time
  37124. updated_at *time.Time
  37125. status *uint8
  37126. addstatus *int8
  37127. deleted_at *time.Time
  37128. addtime *uint64
  37129. addaddtime *int64
  37130. _type *int
  37131. add_type *int
  37132. bot_id *string
  37133. organization_id *uint64
  37134. addorganization_id *int64
  37135. ai_response *uint64
  37136. addai_response *int64
  37137. sop_run *uint64
  37138. addsop_run *int64
  37139. total_friend *uint64
  37140. addtotal_friend *int64
  37141. total_group *uint64
  37142. addtotal_group *int64
  37143. account_balance *uint64
  37144. addaccount_balance *int64
  37145. consume_token *uint64
  37146. addconsume_token *int64
  37147. active_user *uint64
  37148. addactive_user *int64
  37149. new_user *int64
  37150. addnew_user *int64
  37151. label_dist *[]custom_types.LabelDist
  37152. appendlabel_dist []custom_types.LabelDist
  37153. clearedFields map[string]struct{}
  37154. done bool
  37155. oldValue func(context.Context) (*UsageStatisticMonth, error)
  37156. predicates []predicate.UsageStatisticMonth
  37157. }
  37158. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  37159. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  37160. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  37161. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  37162. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  37163. m := &UsageStatisticMonthMutation{
  37164. config: c,
  37165. op: op,
  37166. typ: TypeUsageStatisticMonth,
  37167. clearedFields: make(map[string]struct{}),
  37168. }
  37169. for _, opt := range opts {
  37170. opt(m)
  37171. }
  37172. return m
  37173. }
  37174. // withUsageStatisticMonthID sets the ID field of the mutation.
  37175. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  37176. return func(m *UsageStatisticMonthMutation) {
  37177. var (
  37178. err error
  37179. once sync.Once
  37180. value *UsageStatisticMonth
  37181. )
  37182. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  37183. once.Do(func() {
  37184. if m.done {
  37185. err = errors.New("querying old values post mutation is not allowed")
  37186. } else {
  37187. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  37188. }
  37189. })
  37190. return value, err
  37191. }
  37192. m.id = &id
  37193. }
  37194. }
  37195. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  37196. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  37197. return func(m *UsageStatisticMonthMutation) {
  37198. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  37199. return node, nil
  37200. }
  37201. m.id = &node.ID
  37202. }
  37203. }
  37204. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37205. // executed in a transaction (ent.Tx), a transactional client is returned.
  37206. func (m UsageStatisticMonthMutation) Client() *Client {
  37207. client := &Client{config: m.config}
  37208. client.init()
  37209. return client
  37210. }
  37211. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37212. // it returns an error otherwise.
  37213. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  37214. if _, ok := m.driver.(*txDriver); !ok {
  37215. return nil, errors.New("ent: mutation is not running in a transaction")
  37216. }
  37217. tx := &Tx{config: m.config}
  37218. tx.init()
  37219. return tx, nil
  37220. }
  37221. // SetID sets the value of the id field. Note that this
  37222. // operation is only accepted on creation of UsageStatisticMonth entities.
  37223. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  37224. m.id = &id
  37225. }
  37226. // ID returns the ID value in the mutation. Note that the ID is only available
  37227. // if it was provided to the builder or after it was returned from the database.
  37228. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  37229. if m.id == nil {
  37230. return
  37231. }
  37232. return *m.id, true
  37233. }
  37234. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37235. // That means, if the mutation is applied within a transaction with an isolation level such
  37236. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37237. // or updated by the mutation.
  37238. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  37239. switch {
  37240. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37241. id, exists := m.ID()
  37242. if exists {
  37243. return []uint64{id}, nil
  37244. }
  37245. fallthrough
  37246. case m.op.Is(OpUpdate | OpDelete):
  37247. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  37248. default:
  37249. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37250. }
  37251. }
  37252. // SetCreatedAt sets the "created_at" field.
  37253. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  37254. m.created_at = &t
  37255. }
  37256. // CreatedAt returns the value of the "created_at" field in the mutation.
  37257. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  37258. v := m.created_at
  37259. if v == nil {
  37260. return
  37261. }
  37262. return *v, true
  37263. }
  37264. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  37265. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37267. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37268. if !m.op.Is(OpUpdateOne) {
  37269. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37270. }
  37271. if m.id == nil || m.oldValue == nil {
  37272. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37273. }
  37274. oldValue, err := m.oldValue(ctx)
  37275. if err != nil {
  37276. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37277. }
  37278. return oldValue.CreatedAt, nil
  37279. }
  37280. // ResetCreatedAt resets all changes to the "created_at" field.
  37281. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  37282. m.created_at = nil
  37283. }
  37284. // SetUpdatedAt sets the "updated_at" field.
  37285. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  37286. m.updated_at = &t
  37287. }
  37288. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37289. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  37290. v := m.updated_at
  37291. if v == nil {
  37292. return
  37293. }
  37294. return *v, true
  37295. }
  37296. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  37297. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37299. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37300. if !m.op.Is(OpUpdateOne) {
  37301. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37302. }
  37303. if m.id == nil || m.oldValue == nil {
  37304. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37305. }
  37306. oldValue, err := m.oldValue(ctx)
  37307. if err != nil {
  37308. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37309. }
  37310. return oldValue.UpdatedAt, nil
  37311. }
  37312. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37313. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  37314. m.updated_at = nil
  37315. }
  37316. // SetStatus sets the "status" field.
  37317. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  37318. m.status = &u
  37319. m.addstatus = nil
  37320. }
  37321. // Status returns the value of the "status" field in the mutation.
  37322. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  37323. v := m.status
  37324. if v == nil {
  37325. return
  37326. }
  37327. return *v, true
  37328. }
  37329. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  37330. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37332. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37333. if !m.op.Is(OpUpdateOne) {
  37334. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37335. }
  37336. if m.id == nil || m.oldValue == nil {
  37337. return v, errors.New("OldStatus requires an ID field in the mutation")
  37338. }
  37339. oldValue, err := m.oldValue(ctx)
  37340. if err != nil {
  37341. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37342. }
  37343. return oldValue.Status, nil
  37344. }
  37345. // AddStatus adds u to the "status" field.
  37346. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  37347. if m.addstatus != nil {
  37348. *m.addstatus += u
  37349. } else {
  37350. m.addstatus = &u
  37351. }
  37352. }
  37353. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37354. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  37355. v := m.addstatus
  37356. if v == nil {
  37357. return
  37358. }
  37359. return *v, true
  37360. }
  37361. // ClearStatus clears the value of the "status" field.
  37362. func (m *UsageStatisticMonthMutation) ClearStatus() {
  37363. m.status = nil
  37364. m.addstatus = nil
  37365. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  37366. }
  37367. // StatusCleared returns if the "status" field was cleared in this mutation.
  37368. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  37369. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  37370. return ok
  37371. }
  37372. // ResetStatus resets all changes to the "status" field.
  37373. func (m *UsageStatisticMonthMutation) ResetStatus() {
  37374. m.status = nil
  37375. m.addstatus = nil
  37376. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  37377. }
  37378. // SetDeletedAt sets the "deleted_at" field.
  37379. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  37380. m.deleted_at = &t
  37381. }
  37382. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37383. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  37384. v := m.deleted_at
  37385. if v == nil {
  37386. return
  37387. }
  37388. return *v, true
  37389. }
  37390. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  37391. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37393. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37394. if !m.op.Is(OpUpdateOne) {
  37395. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37396. }
  37397. if m.id == nil || m.oldValue == nil {
  37398. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37399. }
  37400. oldValue, err := m.oldValue(ctx)
  37401. if err != nil {
  37402. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37403. }
  37404. return oldValue.DeletedAt, nil
  37405. }
  37406. // ClearDeletedAt clears the value of the "deleted_at" field.
  37407. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  37408. m.deleted_at = nil
  37409. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  37410. }
  37411. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37412. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  37413. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  37414. return ok
  37415. }
  37416. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37417. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  37418. m.deleted_at = nil
  37419. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  37420. }
  37421. // SetAddtime sets the "addtime" field.
  37422. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  37423. m.addtime = &u
  37424. m.addaddtime = nil
  37425. }
  37426. // Addtime returns the value of the "addtime" field in the mutation.
  37427. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  37428. v := m.addtime
  37429. if v == nil {
  37430. return
  37431. }
  37432. return *v, true
  37433. }
  37434. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  37435. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37437. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37438. if !m.op.Is(OpUpdateOne) {
  37439. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37440. }
  37441. if m.id == nil || m.oldValue == nil {
  37442. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37443. }
  37444. oldValue, err := m.oldValue(ctx)
  37445. if err != nil {
  37446. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37447. }
  37448. return oldValue.Addtime, nil
  37449. }
  37450. // AddAddtime adds u to the "addtime" field.
  37451. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  37452. if m.addaddtime != nil {
  37453. *m.addaddtime += u
  37454. } else {
  37455. m.addaddtime = &u
  37456. }
  37457. }
  37458. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37459. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  37460. v := m.addaddtime
  37461. if v == nil {
  37462. return
  37463. }
  37464. return *v, true
  37465. }
  37466. // ResetAddtime resets all changes to the "addtime" field.
  37467. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  37468. m.addtime = nil
  37469. m.addaddtime = nil
  37470. }
  37471. // SetType sets the "type" field.
  37472. func (m *UsageStatisticMonthMutation) SetType(i int) {
  37473. m._type = &i
  37474. m.add_type = nil
  37475. }
  37476. // GetType returns the value of the "type" field in the mutation.
  37477. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  37478. v := m._type
  37479. if v == nil {
  37480. return
  37481. }
  37482. return *v, true
  37483. }
  37484. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  37485. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37487. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  37488. if !m.op.Is(OpUpdateOne) {
  37489. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37490. }
  37491. if m.id == nil || m.oldValue == nil {
  37492. return v, errors.New("OldType requires an ID field in the mutation")
  37493. }
  37494. oldValue, err := m.oldValue(ctx)
  37495. if err != nil {
  37496. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37497. }
  37498. return oldValue.Type, nil
  37499. }
  37500. // AddType adds i to the "type" field.
  37501. func (m *UsageStatisticMonthMutation) AddType(i int) {
  37502. if m.add_type != nil {
  37503. *m.add_type += i
  37504. } else {
  37505. m.add_type = &i
  37506. }
  37507. }
  37508. // AddedType returns the value that was added to the "type" field in this mutation.
  37509. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  37510. v := m.add_type
  37511. if v == nil {
  37512. return
  37513. }
  37514. return *v, true
  37515. }
  37516. // ResetType resets all changes to the "type" field.
  37517. func (m *UsageStatisticMonthMutation) ResetType() {
  37518. m._type = nil
  37519. m.add_type = nil
  37520. }
  37521. // SetBotID sets the "bot_id" field.
  37522. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  37523. m.bot_id = &s
  37524. }
  37525. // BotID returns the value of the "bot_id" field in the mutation.
  37526. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  37527. v := m.bot_id
  37528. if v == nil {
  37529. return
  37530. }
  37531. return *v, true
  37532. }
  37533. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  37534. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37536. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  37537. if !m.op.Is(OpUpdateOne) {
  37538. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37539. }
  37540. if m.id == nil || m.oldValue == nil {
  37541. return v, errors.New("OldBotID requires an ID field in the mutation")
  37542. }
  37543. oldValue, err := m.oldValue(ctx)
  37544. if err != nil {
  37545. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37546. }
  37547. return oldValue.BotID, nil
  37548. }
  37549. // ClearBotID clears the value of the "bot_id" field.
  37550. func (m *UsageStatisticMonthMutation) ClearBotID() {
  37551. m.bot_id = nil
  37552. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  37553. }
  37554. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  37555. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  37556. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  37557. return ok
  37558. }
  37559. // ResetBotID resets all changes to the "bot_id" field.
  37560. func (m *UsageStatisticMonthMutation) ResetBotID() {
  37561. m.bot_id = nil
  37562. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  37563. }
  37564. // SetOrganizationID sets the "organization_id" field.
  37565. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  37566. m.organization_id = &u
  37567. m.addorganization_id = nil
  37568. }
  37569. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37570. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  37571. v := m.organization_id
  37572. if v == nil {
  37573. return
  37574. }
  37575. return *v, true
  37576. }
  37577. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  37578. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37580. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37581. if !m.op.Is(OpUpdateOne) {
  37582. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37583. }
  37584. if m.id == nil || m.oldValue == nil {
  37585. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37586. }
  37587. oldValue, err := m.oldValue(ctx)
  37588. if err != nil {
  37589. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37590. }
  37591. return oldValue.OrganizationID, nil
  37592. }
  37593. // AddOrganizationID adds u to the "organization_id" field.
  37594. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  37595. if m.addorganization_id != nil {
  37596. *m.addorganization_id += u
  37597. } else {
  37598. m.addorganization_id = &u
  37599. }
  37600. }
  37601. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37602. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  37603. v := m.addorganization_id
  37604. if v == nil {
  37605. return
  37606. }
  37607. return *v, true
  37608. }
  37609. // ClearOrganizationID clears the value of the "organization_id" field.
  37610. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  37611. m.organization_id = nil
  37612. m.addorganization_id = nil
  37613. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  37614. }
  37615. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37616. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  37617. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  37618. return ok
  37619. }
  37620. // ResetOrganizationID resets all changes to the "organization_id" field.
  37621. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  37622. m.organization_id = nil
  37623. m.addorganization_id = nil
  37624. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  37625. }
  37626. // SetAiResponse sets the "ai_response" field.
  37627. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  37628. m.ai_response = &u
  37629. m.addai_response = nil
  37630. }
  37631. // AiResponse returns the value of the "ai_response" field in the mutation.
  37632. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  37633. v := m.ai_response
  37634. if v == nil {
  37635. return
  37636. }
  37637. return *v, true
  37638. }
  37639. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  37640. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37642. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  37643. if !m.op.Is(OpUpdateOne) {
  37644. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  37645. }
  37646. if m.id == nil || m.oldValue == nil {
  37647. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  37648. }
  37649. oldValue, err := m.oldValue(ctx)
  37650. if err != nil {
  37651. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  37652. }
  37653. return oldValue.AiResponse, nil
  37654. }
  37655. // AddAiResponse adds u to the "ai_response" field.
  37656. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  37657. if m.addai_response != nil {
  37658. *m.addai_response += u
  37659. } else {
  37660. m.addai_response = &u
  37661. }
  37662. }
  37663. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  37664. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  37665. v := m.addai_response
  37666. if v == nil {
  37667. return
  37668. }
  37669. return *v, true
  37670. }
  37671. // ResetAiResponse resets all changes to the "ai_response" field.
  37672. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  37673. m.ai_response = nil
  37674. m.addai_response = nil
  37675. }
  37676. // SetSopRun sets the "sop_run" field.
  37677. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  37678. m.sop_run = &u
  37679. m.addsop_run = nil
  37680. }
  37681. // SopRun returns the value of the "sop_run" field in the mutation.
  37682. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  37683. v := m.sop_run
  37684. if v == nil {
  37685. return
  37686. }
  37687. return *v, true
  37688. }
  37689. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  37690. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37692. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  37693. if !m.op.Is(OpUpdateOne) {
  37694. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  37695. }
  37696. if m.id == nil || m.oldValue == nil {
  37697. return v, errors.New("OldSopRun requires an ID field in the mutation")
  37698. }
  37699. oldValue, err := m.oldValue(ctx)
  37700. if err != nil {
  37701. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  37702. }
  37703. return oldValue.SopRun, nil
  37704. }
  37705. // AddSopRun adds u to the "sop_run" field.
  37706. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  37707. if m.addsop_run != nil {
  37708. *m.addsop_run += u
  37709. } else {
  37710. m.addsop_run = &u
  37711. }
  37712. }
  37713. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  37714. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  37715. v := m.addsop_run
  37716. if v == nil {
  37717. return
  37718. }
  37719. return *v, true
  37720. }
  37721. // ResetSopRun resets all changes to the "sop_run" field.
  37722. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  37723. m.sop_run = nil
  37724. m.addsop_run = nil
  37725. }
  37726. // SetTotalFriend sets the "total_friend" field.
  37727. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  37728. m.total_friend = &u
  37729. m.addtotal_friend = nil
  37730. }
  37731. // TotalFriend returns the value of the "total_friend" field in the mutation.
  37732. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  37733. v := m.total_friend
  37734. if v == nil {
  37735. return
  37736. }
  37737. return *v, true
  37738. }
  37739. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  37740. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  37743. if !m.op.Is(OpUpdateOne) {
  37744. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  37745. }
  37746. if m.id == nil || m.oldValue == nil {
  37747. return v, errors.New("OldTotalFriend 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 OldTotalFriend: %w", err)
  37752. }
  37753. return oldValue.TotalFriend, nil
  37754. }
  37755. // AddTotalFriend adds u to the "total_friend" field.
  37756. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  37757. if m.addtotal_friend != nil {
  37758. *m.addtotal_friend += u
  37759. } else {
  37760. m.addtotal_friend = &u
  37761. }
  37762. }
  37763. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  37764. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  37765. v := m.addtotal_friend
  37766. if v == nil {
  37767. return
  37768. }
  37769. return *v, true
  37770. }
  37771. // ResetTotalFriend resets all changes to the "total_friend" field.
  37772. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  37773. m.total_friend = nil
  37774. m.addtotal_friend = nil
  37775. }
  37776. // SetTotalGroup sets the "total_group" field.
  37777. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  37778. m.total_group = &u
  37779. m.addtotal_group = nil
  37780. }
  37781. // TotalGroup returns the value of the "total_group" field in the mutation.
  37782. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  37783. v := m.total_group
  37784. if v == nil {
  37785. return
  37786. }
  37787. return *v, true
  37788. }
  37789. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  37790. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37792. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  37793. if !m.op.Is(OpUpdateOne) {
  37794. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  37795. }
  37796. if m.id == nil || m.oldValue == nil {
  37797. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  37798. }
  37799. oldValue, err := m.oldValue(ctx)
  37800. if err != nil {
  37801. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  37802. }
  37803. return oldValue.TotalGroup, nil
  37804. }
  37805. // AddTotalGroup adds u to the "total_group" field.
  37806. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  37807. if m.addtotal_group != nil {
  37808. *m.addtotal_group += u
  37809. } else {
  37810. m.addtotal_group = &u
  37811. }
  37812. }
  37813. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  37814. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  37815. v := m.addtotal_group
  37816. if v == nil {
  37817. return
  37818. }
  37819. return *v, true
  37820. }
  37821. // ResetTotalGroup resets all changes to the "total_group" field.
  37822. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  37823. m.total_group = nil
  37824. m.addtotal_group = nil
  37825. }
  37826. // SetAccountBalance sets the "account_balance" field.
  37827. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  37828. m.account_balance = &u
  37829. m.addaccount_balance = nil
  37830. }
  37831. // AccountBalance returns the value of the "account_balance" field in the mutation.
  37832. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  37833. v := m.account_balance
  37834. if v == nil {
  37835. return
  37836. }
  37837. return *v, true
  37838. }
  37839. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  37840. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37842. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  37843. if !m.op.Is(OpUpdateOne) {
  37844. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  37845. }
  37846. if m.id == nil || m.oldValue == nil {
  37847. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  37848. }
  37849. oldValue, err := m.oldValue(ctx)
  37850. if err != nil {
  37851. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  37852. }
  37853. return oldValue.AccountBalance, nil
  37854. }
  37855. // AddAccountBalance adds u to the "account_balance" field.
  37856. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  37857. if m.addaccount_balance != nil {
  37858. *m.addaccount_balance += u
  37859. } else {
  37860. m.addaccount_balance = &u
  37861. }
  37862. }
  37863. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  37864. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  37865. v := m.addaccount_balance
  37866. if v == nil {
  37867. return
  37868. }
  37869. return *v, true
  37870. }
  37871. // ResetAccountBalance resets all changes to the "account_balance" field.
  37872. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  37873. m.account_balance = nil
  37874. m.addaccount_balance = nil
  37875. }
  37876. // SetConsumeToken sets the "consume_token" field.
  37877. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  37878. m.consume_token = &u
  37879. m.addconsume_token = nil
  37880. }
  37881. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  37882. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  37883. v := m.consume_token
  37884. if v == nil {
  37885. return
  37886. }
  37887. return *v, true
  37888. }
  37889. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  37890. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37892. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  37893. if !m.op.Is(OpUpdateOne) {
  37894. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  37895. }
  37896. if m.id == nil || m.oldValue == nil {
  37897. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  37898. }
  37899. oldValue, err := m.oldValue(ctx)
  37900. if err != nil {
  37901. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  37902. }
  37903. return oldValue.ConsumeToken, nil
  37904. }
  37905. // AddConsumeToken adds u to the "consume_token" field.
  37906. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  37907. if m.addconsume_token != nil {
  37908. *m.addconsume_token += u
  37909. } else {
  37910. m.addconsume_token = &u
  37911. }
  37912. }
  37913. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  37914. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  37915. v := m.addconsume_token
  37916. if v == nil {
  37917. return
  37918. }
  37919. return *v, true
  37920. }
  37921. // ResetConsumeToken resets all changes to the "consume_token" field.
  37922. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  37923. m.consume_token = nil
  37924. m.addconsume_token = nil
  37925. }
  37926. // SetActiveUser sets the "active_user" field.
  37927. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  37928. m.active_user = &u
  37929. m.addactive_user = nil
  37930. }
  37931. // ActiveUser returns the value of the "active_user" field in the mutation.
  37932. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  37933. v := m.active_user
  37934. if v == nil {
  37935. return
  37936. }
  37937. return *v, true
  37938. }
  37939. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  37940. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37942. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  37943. if !m.op.Is(OpUpdateOne) {
  37944. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  37945. }
  37946. if m.id == nil || m.oldValue == nil {
  37947. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  37948. }
  37949. oldValue, err := m.oldValue(ctx)
  37950. if err != nil {
  37951. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  37952. }
  37953. return oldValue.ActiveUser, nil
  37954. }
  37955. // AddActiveUser adds u to the "active_user" field.
  37956. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  37957. if m.addactive_user != nil {
  37958. *m.addactive_user += u
  37959. } else {
  37960. m.addactive_user = &u
  37961. }
  37962. }
  37963. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  37964. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  37965. v := m.addactive_user
  37966. if v == nil {
  37967. return
  37968. }
  37969. return *v, true
  37970. }
  37971. // ResetActiveUser resets all changes to the "active_user" field.
  37972. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  37973. m.active_user = nil
  37974. m.addactive_user = nil
  37975. }
  37976. // SetNewUser sets the "new_user" field.
  37977. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  37978. m.new_user = &i
  37979. m.addnew_user = nil
  37980. }
  37981. // NewUser returns the value of the "new_user" field in the mutation.
  37982. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  37983. v := m.new_user
  37984. if v == nil {
  37985. return
  37986. }
  37987. return *v, true
  37988. }
  37989. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  37990. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37992. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  37993. if !m.op.Is(OpUpdateOne) {
  37994. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  37995. }
  37996. if m.id == nil || m.oldValue == nil {
  37997. return v, errors.New("OldNewUser requires an ID field in the mutation")
  37998. }
  37999. oldValue, err := m.oldValue(ctx)
  38000. if err != nil {
  38001. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38002. }
  38003. return oldValue.NewUser, nil
  38004. }
  38005. // AddNewUser adds i to the "new_user" field.
  38006. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  38007. if m.addnew_user != nil {
  38008. *m.addnew_user += i
  38009. } else {
  38010. m.addnew_user = &i
  38011. }
  38012. }
  38013. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38014. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  38015. v := m.addnew_user
  38016. if v == nil {
  38017. return
  38018. }
  38019. return *v, true
  38020. }
  38021. // ResetNewUser resets all changes to the "new_user" field.
  38022. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  38023. m.new_user = nil
  38024. m.addnew_user = nil
  38025. }
  38026. // SetLabelDist sets the "label_dist" field.
  38027. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38028. m.label_dist = &ctd
  38029. m.appendlabel_dist = nil
  38030. }
  38031. // LabelDist returns the value of the "label_dist" field in the mutation.
  38032. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38033. v := m.label_dist
  38034. if v == nil {
  38035. return
  38036. }
  38037. return *v, true
  38038. }
  38039. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  38040. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  38041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38042. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38043. if !m.op.Is(OpUpdateOne) {
  38044. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38045. }
  38046. if m.id == nil || m.oldValue == nil {
  38047. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38048. }
  38049. oldValue, err := m.oldValue(ctx)
  38050. if err != nil {
  38051. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38052. }
  38053. return oldValue.LabelDist, nil
  38054. }
  38055. // AppendLabelDist adds ctd to the "label_dist" field.
  38056. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38057. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38058. }
  38059. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38060. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38061. if len(m.appendlabel_dist) == 0 {
  38062. return nil, false
  38063. }
  38064. return m.appendlabel_dist, true
  38065. }
  38066. // ResetLabelDist resets all changes to the "label_dist" field.
  38067. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  38068. m.label_dist = nil
  38069. m.appendlabel_dist = nil
  38070. }
  38071. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  38072. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  38073. m.predicates = append(m.predicates, ps...)
  38074. }
  38075. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  38076. // users can use type-assertion to append predicates that do not depend on any generated package.
  38077. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  38078. p := make([]predicate.UsageStatisticMonth, len(ps))
  38079. for i := range ps {
  38080. p[i] = ps[i]
  38081. }
  38082. m.Where(p...)
  38083. }
  38084. // Op returns the operation name.
  38085. func (m *UsageStatisticMonthMutation) Op() Op {
  38086. return m.op
  38087. }
  38088. // SetOp allows setting the mutation operation.
  38089. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  38090. m.op = op
  38091. }
  38092. // Type returns the node type of this mutation (UsageStatisticMonth).
  38093. func (m *UsageStatisticMonthMutation) Type() string {
  38094. return m.typ
  38095. }
  38096. // Fields returns all fields that were changed during this mutation. Note that in
  38097. // order to get all numeric fields that were incremented/decremented, call
  38098. // AddedFields().
  38099. func (m *UsageStatisticMonthMutation) Fields() []string {
  38100. fields := make([]string, 0, 17)
  38101. if m.created_at != nil {
  38102. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  38103. }
  38104. if m.updated_at != nil {
  38105. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  38106. }
  38107. if m.status != nil {
  38108. fields = append(fields, usagestatisticmonth.FieldStatus)
  38109. }
  38110. if m.deleted_at != nil {
  38111. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  38112. }
  38113. if m.addtime != nil {
  38114. fields = append(fields, usagestatisticmonth.FieldAddtime)
  38115. }
  38116. if m._type != nil {
  38117. fields = append(fields, usagestatisticmonth.FieldType)
  38118. }
  38119. if m.bot_id != nil {
  38120. fields = append(fields, usagestatisticmonth.FieldBotID)
  38121. }
  38122. if m.organization_id != nil {
  38123. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38124. }
  38125. if m.ai_response != nil {
  38126. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  38127. }
  38128. if m.sop_run != nil {
  38129. fields = append(fields, usagestatisticmonth.FieldSopRun)
  38130. }
  38131. if m.total_friend != nil {
  38132. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  38133. }
  38134. if m.total_group != nil {
  38135. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  38136. }
  38137. if m.account_balance != nil {
  38138. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  38139. }
  38140. if m.consume_token != nil {
  38141. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  38142. }
  38143. if m.active_user != nil {
  38144. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  38145. }
  38146. if m.new_user != nil {
  38147. fields = append(fields, usagestatisticmonth.FieldNewUser)
  38148. }
  38149. if m.label_dist != nil {
  38150. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  38151. }
  38152. return fields
  38153. }
  38154. // Field returns the value of a field with the given name. The second boolean
  38155. // return value indicates that this field was not set, or was not defined in the
  38156. // schema.
  38157. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  38158. switch name {
  38159. case usagestatisticmonth.FieldCreatedAt:
  38160. return m.CreatedAt()
  38161. case usagestatisticmonth.FieldUpdatedAt:
  38162. return m.UpdatedAt()
  38163. case usagestatisticmonth.FieldStatus:
  38164. return m.Status()
  38165. case usagestatisticmonth.FieldDeletedAt:
  38166. return m.DeletedAt()
  38167. case usagestatisticmonth.FieldAddtime:
  38168. return m.Addtime()
  38169. case usagestatisticmonth.FieldType:
  38170. return m.GetType()
  38171. case usagestatisticmonth.FieldBotID:
  38172. return m.BotID()
  38173. case usagestatisticmonth.FieldOrganizationID:
  38174. return m.OrganizationID()
  38175. case usagestatisticmonth.FieldAiResponse:
  38176. return m.AiResponse()
  38177. case usagestatisticmonth.FieldSopRun:
  38178. return m.SopRun()
  38179. case usagestatisticmonth.FieldTotalFriend:
  38180. return m.TotalFriend()
  38181. case usagestatisticmonth.FieldTotalGroup:
  38182. return m.TotalGroup()
  38183. case usagestatisticmonth.FieldAccountBalance:
  38184. return m.AccountBalance()
  38185. case usagestatisticmonth.FieldConsumeToken:
  38186. return m.ConsumeToken()
  38187. case usagestatisticmonth.FieldActiveUser:
  38188. return m.ActiveUser()
  38189. case usagestatisticmonth.FieldNewUser:
  38190. return m.NewUser()
  38191. case usagestatisticmonth.FieldLabelDist:
  38192. return m.LabelDist()
  38193. }
  38194. return nil, false
  38195. }
  38196. // OldField returns the old value of the field from the database. An error is
  38197. // returned if the mutation operation is not UpdateOne, or the query to the
  38198. // database failed.
  38199. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38200. switch name {
  38201. case usagestatisticmonth.FieldCreatedAt:
  38202. return m.OldCreatedAt(ctx)
  38203. case usagestatisticmonth.FieldUpdatedAt:
  38204. return m.OldUpdatedAt(ctx)
  38205. case usagestatisticmonth.FieldStatus:
  38206. return m.OldStatus(ctx)
  38207. case usagestatisticmonth.FieldDeletedAt:
  38208. return m.OldDeletedAt(ctx)
  38209. case usagestatisticmonth.FieldAddtime:
  38210. return m.OldAddtime(ctx)
  38211. case usagestatisticmonth.FieldType:
  38212. return m.OldType(ctx)
  38213. case usagestatisticmonth.FieldBotID:
  38214. return m.OldBotID(ctx)
  38215. case usagestatisticmonth.FieldOrganizationID:
  38216. return m.OldOrganizationID(ctx)
  38217. case usagestatisticmonth.FieldAiResponse:
  38218. return m.OldAiResponse(ctx)
  38219. case usagestatisticmonth.FieldSopRun:
  38220. return m.OldSopRun(ctx)
  38221. case usagestatisticmonth.FieldTotalFriend:
  38222. return m.OldTotalFriend(ctx)
  38223. case usagestatisticmonth.FieldTotalGroup:
  38224. return m.OldTotalGroup(ctx)
  38225. case usagestatisticmonth.FieldAccountBalance:
  38226. return m.OldAccountBalance(ctx)
  38227. case usagestatisticmonth.FieldConsumeToken:
  38228. return m.OldConsumeToken(ctx)
  38229. case usagestatisticmonth.FieldActiveUser:
  38230. return m.OldActiveUser(ctx)
  38231. case usagestatisticmonth.FieldNewUser:
  38232. return m.OldNewUser(ctx)
  38233. case usagestatisticmonth.FieldLabelDist:
  38234. return m.OldLabelDist(ctx)
  38235. }
  38236. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38237. }
  38238. // SetField sets the value of a field with the given name. It returns an error if
  38239. // the field is not defined in the schema, or if the type mismatched the field
  38240. // type.
  38241. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  38242. switch name {
  38243. case usagestatisticmonth.FieldCreatedAt:
  38244. v, ok := value.(time.Time)
  38245. if !ok {
  38246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38247. }
  38248. m.SetCreatedAt(v)
  38249. return nil
  38250. case usagestatisticmonth.FieldUpdatedAt:
  38251. v, ok := value.(time.Time)
  38252. if !ok {
  38253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38254. }
  38255. m.SetUpdatedAt(v)
  38256. return nil
  38257. case usagestatisticmonth.FieldStatus:
  38258. v, ok := value.(uint8)
  38259. if !ok {
  38260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38261. }
  38262. m.SetStatus(v)
  38263. return nil
  38264. case usagestatisticmonth.FieldDeletedAt:
  38265. v, ok := value.(time.Time)
  38266. if !ok {
  38267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38268. }
  38269. m.SetDeletedAt(v)
  38270. return nil
  38271. case usagestatisticmonth.FieldAddtime:
  38272. v, ok := value.(uint64)
  38273. if !ok {
  38274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38275. }
  38276. m.SetAddtime(v)
  38277. return nil
  38278. case usagestatisticmonth.FieldType:
  38279. v, ok := value.(int)
  38280. if !ok {
  38281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38282. }
  38283. m.SetType(v)
  38284. return nil
  38285. case usagestatisticmonth.FieldBotID:
  38286. v, ok := value.(string)
  38287. if !ok {
  38288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38289. }
  38290. m.SetBotID(v)
  38291. return nil
  38292. case usagestatisticmonth.FieldOrganizationID:
  38293. v, ok := value.(uint64)
  38294. if !ok {
  38295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38296. }
  38297. m.SetOrganizationID(v)
  38298. return nil
  38299. case usagestatisticmonth.FieldAiResponse:
  38300. v, ok := value.(uint64)
  38301. if !ok {
  38302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38303. }
  38304. m.SetAiResponse(v)
  38305. return nil
  38306. case usagestatisticmonth.FieldSopRun:
  38307. v, ok := value.(uint64)
  38308. if !ok {
  38309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38310. }
  38311. m.SetSopRun(v)
  38312. return nil
  38313. case usagestatisticmonth.FieldTotalFriend:
  38314. v, ok := value.(uint64)
  38315. if !ok {
  38316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38317. }
  38318. m.SetTotalFriend(v)
  38319. return nil
  38320. case usagestatisticmonth.FieldTotalGroup:
  38321. v, ok := value.(uint64)
  38322. if !ok {
  38323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38324. }
  38325. m.SetTotalGroup(v)
  38326. return nil
  38327. case usagestatisticmonth.FieldAccountBalance:
  38328. v, ok := value.(uint64)
  38329. if !ok {
  38330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38331. }
  38332. m.SetAccountBalance(v)
  38333. return nil
  38334. case usagestatisticmonth.FieldConsumeToken:
  38335. v, ok := value.(uint64)
  38336. if !ok {
  38337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38338. }
  38339. m.SetConsumeToken(v)
  38340. return nil
  38341. case usagestatisticmonth.FieldActiveUser:
  38342. v, ok := value.(uint64)
  38343. if !ok {
  38344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38345. }
  38346. m.SetActiveUser(v)
  38347. return nil
  38348. case usagestatisticmonth.FieldNewUser:
  38349. v, ok := value.(int64)
  38350. if !ok {
  38351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38352. }
  38353. m.SetNewUser(v)
  38354. return nil
  38355. case usagestatisticmonth.FieldLabelDist:
  38356. v, ok := value.([]custom_types.LabelDist)
  38357. if !ok {
  38358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38359. }
  38360. m.SetLabelDist(v)
  38361. return nil
  38362. }
  38363. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38364. }
  38365. // AddedFields returns all numeric fields that were incremented/decremented during
  38366. // this mutation.
  38367. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  38368. var fields []string
  38369. if m.addstatus != nil {
  38370. fields = append(fields, usagestatisticmonth.FieldStatus)
  38371. }
  38372. if m.addaddtime != nil {
  38373. fields = append(fields, usagestatisticmonth.FieldAddtime)
  38374. }
  38375. if m.add_type != nil {
  38376. fields = append(fields, usagestatisticmonth.FieldType)
  38377. }
  38378. if m.addorganization_id != nil {
  38379. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38380. }
  38381. if m.addai_response != nil {
  38382. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  38383. }
  38384. if m.addsop_run != nil {
  38385. fields = append(fields, usagestatisticmonth.FieldSopRun)
  38386. }
  38387. if m.addtotal_friend != nil {
  38388. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  38389. }
  38390. if m.addtotal_group != nil {
  38391. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  38392. }
  38393. if m.addaccount_balance != nil {
  38394. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  38395. }
  38396. if m.addconsume_token != nil {
  38397. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  38398. }
  38399. if m.addactive_user != nil {
  38400. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  38401. }
  38402. if m.addnew_user != nil {
  38403. fields = append(fields, usagestatisticmonth.FieldNewUser)
  38404. }
  38405. return fields
  38406. }
  38407. // AddedField returns the numeric value that was incremented/decremented on a field
  38408. // with the given name. The second boolean return value indicates that this field
  38409. // was not set, or was not defined in the schema.
  38410. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  38411. switch name {
  38412. case usagestatisticmonth.FieldStatus:
  38413. return m.AddedStatus()
  38414. case usagestatisticmonth.FieldAddtime:
  38415. return m.AddedAddtime()
  38416. case usagestatisticmonth.FieldType:
  38417. return m.AddedType()
  38418. case usagestatisticmonth.FieldOrganizationID:
  38419. return m.AddedOrganizationID()
  38420. case usagestatisticmonth.FieldAiResponse:
  38421. return m.AddedAiResponse()
  38422. case usagestatisticmonth.FieldSopRun:
  38423. return m.AddedSopRun()
  38424. case usagestatisticmonth.FieldTotalFriend:
  38425. return m.AddedTotalFriend()
  38426. case usagestatisticmonth.FieldTotalGroup:
  38427. return m.AddedTotalGroup()
  38428. case usagestatisticmonth.FieldAccountBalance:
  38429. return m.AddedAccountBalance()
  38430. case usagestatisticmonth.FieldConsumeToken:
  38431. return m.AddedConsumeToken()
  38432. case usagestatisticmonth.FieldActiveUser:
  38433. return m.AddedActiveUser()
  38434. case usagestatisticmonth.FieldNewUser:
  38435. return m.AddedNewUser()
  38436. }
  38437. return nil, false
  38438. }
  38439. // AddField adds the value to the field with the given name. It returns an error if
  38440. // the field is not defined in the schema, or if the type mismatched the field
  38441. // type.
  38442. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  38443. switch name {
  38444. case usagestatisticmonth.FieldStatus:
  38445. v, ok := value.(int8)
  38446. if !ok {
  38447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38448. }
  38449. m.AddStatus(v)
  38450. return nil
  38451. case usagestatisticmonth.FieldAddtime:
  38452. v, ok := value.(int64)
  38453. if !ok {
  38454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38455. }
  38456. m.AddAddtime(v)
  38457. return nil
  38458. case usagestatisticmonth.FieldType:
  38459. v, ok := value.(int)
  38460. if !ok {
  38461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38462. }
  38463. m.AddType(v)
  38464. return nil
  38465. case usagestatisticmonth.FieldOrganizationID:
  38466. v, ok := value.(int64)
  38467. if !ok {
  38468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38469. }
  38470. m.AddOrganizationID(v)
  38471. return nil
  38472. case usagestatisticmonth.FieldAiResponse:
  38473. v, ok := value.(int64)
  38474. if !ok {
  38475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38476. }
  38477. m.AddAiResponse(v)
  38478. return nil
  38479. case usagestatisticmonth.FieldSopRun:
  38480. v, ok := value.(int64)
  38481. if !ok {
  38482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38483. }
  38484. m.AddSopRun(v)
  38485. return nil
  38486. case usagestatisticmonth.FieldTotalFriend:
  38487. v, ok := value.(int64)
  38488. if !ok {
  38489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38490. }
  38491. m.AddTotalFriend(v)
  38492. return nil
  38493. case usagestatisticmonth.FieldTotalGroup:
  38494. v, ok := value.(int64)
  38495. if !ok {
  38496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38497. }
  38498. m.AddTotalGroup(v)
  38499. return nil
  38500. case usagestatisticmonth.FieldAccountBalance:
  38501. v, ok := value.(int64)
  38502. if !ok {
  38503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38504. }
  38505. m.AddAccountBalance(v)
  38506. return nil
  38507. case usagestatisticmonth.FieldConsumeToken:
  38508. v, ok := value.(int64)
  38509. if !ok {
  38510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38511. }
  38512. m.AddConsumeToken(v)
  38513. return nil
  38514. case usagestatisticmonth.FieldActiveUser:
  38515. v, ok := value.(int64)
  38516. if !ok {
  38517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38518. }
  38519. m.AddActiveUser(v)
  38520. return nil
  38521. case usagestatisticmonth.FieldNewUser:
  38522. v, ok := value.(int64)
  38523. if !ok {
  38524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38525. }
  38526. m.AddNewUser(v)
  38527. return nil
  38528. }
  38529. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  38530. }
  38531. // ClearedFields returns all nullable fields that were cleared during this
  38532. // mutation.
  38533. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  38534. var fields []string
  38535. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  38536. fields = append(fields, usagestatisticmonth.FieldStatus)
  38537. }
  38538. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  38539. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  38540. }
  38541. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  38542. fields = append(fields, usagestatisticmonth.FieldBotID)
  38543. }
  38544. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  38545. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38546. }
  38547. return fields
  38548. }
  38549. // FieldCleared returns a boolean indicating if a field with the given name was
  38550. // cleared in this mutation.
  38551. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  38552. _, ok := m.clearedFields[name]
  38553. return ok
  38554. }
  38555. // ClearField clears the value of the field with the given name. It returns an
  38556. // error if the field is not defined in the schema.
  38557. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  38558. switch name {
  38559. case usagestatisticmonth.FieldStatus:
  38560. m.ClearStatus()
  38561. return nil
  38562. case usagestatisticmonth.FieldDeletedAt:
  38563. m.ClearDeletedAt()
  38564. return nil
  38565. case usagestatisticmonth.FieldBotID:
  38566. m.ClearBotID()
  38567. return nil
  38568. case usagestatisticmonth.FieldOrganizationID:
  38569. m.ClearOrganizationID()
  38570. return nil
  38571. }
  38572. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  38573. }
  38574. // ResetField resets all changes in the mutation for the field with the given name.
  38575. // It returns an error if the field is not defined in the schema.
  38576. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  38577. switch name {
  38578. case usagestatisticmonth.FieldCreatedAt:
  38579. m.ResetCreatedAt()
  38580. return nil
  38581. case usagestatisticmonth.FieldUpdatedAt:
  38582. m.ResetUpdatedAt()
  38583. return nil
  38584. case usagestatisticmonth.FieldStatus:
  38585. m.ResetStatus()
  38586. return nil
  38587. case usagestatisticmonth.FieldDeletedAt:
  38588. m.ResetDeletedAt()
  38589. return nil
  38590. case usagestatisticmonth.FieldAddtime:
  38591. m.ResetAddtime()
  38592. return nil
  38593. case usagestatisticmonth.FieldType:
  38594. m.ResetType()
  38595. return nil
  38596. case usagestatisticmonth.FieldBotID:
  38597. m.ResetBotID()
  38598. return nil
  38599. case usagestatisticmonth.FieldOrganizationID:
  38600. m.ResetOrganizationID()
  38601. return nil
  38602. case usagestatisticmonth.FieldAiResponse:
  38603. m.ResetAiResponse()
  38604. return nil
  38605. case usagestatisticmonth.FieldSopRun:
  38606. m.ResetSopRun()
  38607. return nil
  38608. case usagestatisticmonth.FieldTotalFriend:
  38609. m.ResetTotalFriend()
  38610. return nil
  38611. case usagestatisticmonth.FieldTotalGroup:
  38612. m.ResetTotalGroup()
  38613. return nil
  38614. case usagestatisticmonth.FieldAccountBalance:
  38615. m.ResetAccountBalance()
  38616. return nil
  38617. case usagestatisticmonth.FieldConsumeToken:
  38618. m.ResetConsumeToken()
  38619. return nil
  38620. case usagestatisticmonth.FieldActiveUser:
  38621. m.ResetActiveUser()
  38622. return nil
  38623. case usagestatisticmonth.FieldNewUser:
  38624. m.ResetNewUser()
  38625. return nil
  38626. case usagestatisticmonth.FieldLabelDist:
  38627. m.ResetLabelDist()
  38628. return nil
  38629. }
  38630. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38631. }
  38632. // AddedEdges returns all edge names that were set/added in this mutation.
  38633. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  38634. edges := make([]string, 0, 0)
  38635. return edges
  38636. }
  38637. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38638. // name in this mutation.
  38639. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  38640. return nil
  38641. }
  38642. // RemovedEdges returns all edge names that were removed in this mutation.
  38643. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  38644. edges := make([]string, 0, 0)
  38645. return edges
  38646. }
  38647. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38648. // the given name in this mutation.
  38649. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  38650. return nil
  38651. }
  38652. // ClearedEdges returns all edge names that were cleared in this mutation.
  38653. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  38654. edges := make([]string, 0, 0)
  38655. return edges
  38656. }
  38657. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38658. // was cleared in this mutation.
  38659. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  38660. return false
  38661. }
  38662. // ClearEdge clears the value of the edge with the given name. It returns an error
  38663. // if that edge is not defined in the schema.
  38664. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  38665. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  38666. }
  38667. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38668. // It returns an error if the edge is not defined in the schema.
  38669. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  38670. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  38671. }
  38672. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  38673. type UsageTotalMutation struct {
  38674. config
  38675. op Op
  38676. typ string
  38677. id *uint64
  38678. created_at *time.Time
  38679. updated_at *time.Time
  38680. status *uint8
  38681. addstatus *int8
  38682. _type *int
  38683. add_type *int
  38684. bot_id *string
  38685. total_tokens *uint64
  38686. addtotal_tokens *int64
  38687. start_index *uint64
  38688. addstart_index *int64
  38689. end_index *uint64
  38690. addend_index *int64
  38691. organization_id *uint64
  38692. addorganization_id *int64
  38693. clearedFields map[string]struct{}
  38694. done bool
  38695. oldValue func(context.Context) (*UsageTotal, error)
  38696. predicates []predicate.UsageTotal
  38697. }
  38698. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  38699. // usagetotalOption allows management of the mutation configuration using functional options.
  38700. type usagetotalOption func(*UsageTotalMutation)
  38701. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  38702. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  38703. m := &UsageTotalMutation{
  38704. config: c,
  38705. op: op,
  38706. typ: TypeUsageTotal,
  38707. clearedFields: make(map[string]struct{}),
  38708. }
  38709. for _, opt := range opts {
  38710. opt(m)
  38711. }
  38712. return m
  38713. }
  38714. // withUsageTotalID sets the ID field of the mutation.
  38715. func withUsageTotalID(id uint64) usagetotalOption {
  38716. return func(m *UsageTotalMutation) {
  38717. var (
  38718. err error
  38719. once sync.Once
  38720. value *UsageTotal
  38721. )
  38722. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  38723. once.Do(func() {
  38724. if m.done {
  38725. err = errors.New("querying old values post mutation is not allowed")
  38726. } else {
  38727. value, err = m.Client().UsageTotal.Get(ctx, id)
  38728. }
  38729. })
  38730. return value, err
  38731. }
  38732. m.id = &id
  38733. }
  38734. }
  38735. // withUsageTotal sets the old UsageTotal of the mutation.
  38736. func withUsageTotal(node *UsageTotal) usagetotalOption {
  38737. return func(m *UsageTotalMutation) {
  38738. m.oldValue = func(context.Context) (*UsageTotal, error) {
  38739. return node, nil
  38740. }
  38741. m.id = &node.ID
  38742. }
  38743. }
  38744. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38745. // executed in a transaction (ent.Tx), a transactional client is returned.
  38746. func (m UsageTotalMutation) Client() *Client {
  38747. client := &Client{config: m.config}
  38748. client.init()
  38749. return client
  38750. }
  38751. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38752. // it returns an error otherwise.
  38753. func (m UsageTotalMutation) Tx() (*Tx, error) {
  38754. if _, ok := m.driver.(*txDriver); !ok {
  38755. return nil, errors.New("ent: mutation is not running in a transaction")
  38756. }
  38757. tx := &Tx{config: m.config}
  38758. tx.init()
  38759. return tx, nil
  38760. }
  38761. // SetID sets the value of the id field. Note that this
  38762. // operation is only accepted on creation of UsageTotal entities.
  38763. func (m *UsageTotalMutation) SetID(id uint64) {
  38764. m.id = &id
  38765. }
  38766. // ID returns the ID value in the mutation. Note that the ID is only available
  38767. // if it was provided to the builder or after it was returned from the database.
  38768. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  38769. if m.id == nil {
  38770. return
  38771. }
  38772. return *m.id, true
  38773. }
  38774. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38775. // That means, if the mutation is applied within a transaction with an isolation level such
  38776. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38777. // or updated by the mutation.
  38778. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  38779. switch {
  38780. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38781. id, exists := m.ID()
  38782. if exists {
  38783. return []uint64{id}, nil
  38784. }
  38785. fallthrough
  38786. case m.op.Is(OpUpdate | OpDelete):
  38787. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  38788. default:
  38789. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38790. }
  38791. }
  38792. // SetCreatedAt sets the "created_at" field.
  38793. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  38794. m.created_at = &t
  38795. }
  38796. // CreatedAt returns the value of the "created_at" field in the mutation.
  38797. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  38798. v := m.created_at
  38799. if v == nil {
  38800. return
  38801. }
  38802. return *v, true
  38803. }
  38804. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  38805. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38807. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38808. if !m.op.Is(OpUpdateOne) {
  38809. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38810. }
  38811. if m.id == nil || m.oldValue == nil {
  38812. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38813. }
  38814. oldValue, err := m.oldValue(ctx)
  38815. if err != nil {
  38816. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38817. }
  38818. return oldValue.CreatedAt, nil
  38819. }
  38820. // ResetCreatedAt resets all changes to the "created_at" field.
  38821. func (m *UsageTotalMutation) ResetCreatedAt() {
  38822. m.created_at = nil
  38823. }
  38824. // SetUpdatedAt sets the "updated_at" field.
  38825. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  38826. m.updated_at = &t
  38827. }
  38828. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38829. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  38830. v := m.updated_at
  38831. if v == nil {
  38832. return
  38833. }
  38834. return *v, true
  38835. }
  38836. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  38837. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38839. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38840. if !m.op.Is(OpUpdateOne) {
  38841. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38842. }
  38843. if m.id == nil || m.oldValue == nil {
  38844. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38845. }
  38846. oldValue, err := m.oldValue(ctx)
  38847. if err != nil {
  38848. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38849. }
  38850. return oldValue.UpdatedAt, nil
  38851. }
  38852. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38853. func (m *UsageTotalMutation) ResetUpdatedAt() {
  38854. m.updated_at = nil
  38855. }
  38856. // SetStatus sets the "status" field.
  38857. func (m *UsageTotalMutation) SetStatus(u uint8) {
  38858. m.status = &u
  38859. m.addstatus = nil
  38860. }
  38861. // Status returns the value of the "status" field in the mutation.
  38862. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  38863. v := m.status
  38864. if v == nil {
  38865. return
  38866. }
  38867. return *v, true
  38868. }
  38869. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  38870. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38872. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38873. if !m.op.Is(OpUpdateOne) {
  38874. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38875. }
  38876. if m.id == nil || m.oldValue == nil {
  38877. return v, errors.New("OldStatus requires an ID field in the mutation")
  38878. }
  38879. oldValue, err := m.oldValue(ctx)
  38880. if err != nil {
  38881. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38882. }
  38883. return oldValue.Status, nil
  38884. }
  38885. // AddStatus adds u to the "status" field.
  38886. func (m *UsageTotalMutation) AddStatus(u int8) {
  38887. if m.addstatus != nil {
  38888. *m.addstatus += u
  38889. } else {
  38890. m.addstatus = &u
  38891. }
  38892. }
  38893. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38894. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  38895. v := m.addstatus
  38896. if v == nil {
  38897. return
  38898. }
  38899. return *v, true
  38900. }
  38901. // ClearStatus clears the value of the "status" field.
  38902. func (m *UsageTotalMutation) ClearStatus() {
  38903. m.status = nil
  38904. m.addstatus = nil
  38905. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  38906. }
  38907. // StatusCleared returns if the "status" field was cleared in this mutation.
  38908. func (m *UsageTotalMutation) StatusCleared() bool {
  38909. _, ok := m.clearedFields[usagetotal.FieldStatus]
  38910. return ok
  38911. }
  38912. // ResetStatus resets all changes to the "status" field.
  38913. func (m *UsageTotalMutation) ResetStatus() {
  38914. m.status = nil
  38915. m.addstatus = nil
  38916. delete(m.clearedFields, usagetotal.FieldStatus)
  38917. }
  38918. // SetType sets the "type" field.
  38919. func (m *UsageTotalMutation) SetType(i int) {
  38920. m._type = &i
  38921. m.add_type = nil
  38922. }
  38923. // GetType returns the value of the "type" field in the mutation.
  38924. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  38925. v := m._type
  38926. if v == nil {
  38927. return
  38928. }
  38929. return *v, true
  38930. }
  38931. // OldType returns the old "type" field's value of the UsageTotal entity.
  38932. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38934. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  38935. if !m.op.Is(OpUpdateOne) {
  38936. return v, errors.New("OldType is only allowed on UpdateOne operations")
  38937. }
  38938. if m.id == nil || m.oldValue == nil {
  38939. return v, errors.New("OldType requires an ID field in the mutation")
  38940. }
  38941. oldValue, err := m.oldValue(ctx)
  38942. if err != nil {
  38943. return v, fmt.Errorf("querying old value for OldType: %w", err)
  38944. }
  38945. return oldValue.Type, nil
  38946. }
  38947. // AddType adds i to the "type" field.
  38948. func (m *UsageTotalMutation) AddType(i int) {
  38949. if m.add_type != nil {
  38950. *m.add_type += i
  38951. } else {
  38952. m.add_type = &i
  38953. }
  38954. }
  38955. // AddedType returns the value that was added to the "type" field in this mutation.
  38956. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  38957. v := m.add_type
  38958. if v == nil {
  38959. return
  38960. }
  38961. return *v, true
  38962. }
  38963. // ClearType clears the value of the "type" field.
  38964. func (m *UsageTotalMutation) ClearType() {
  38965. m._type = nil
  38966. m.add_type = nil
  38967. m.clearedFields[usagetotal.FieldType] = struct{}{}
  38968. }
  38969. // TypeCleared returns if the "type" field was cleared in this mutation.
  38970. func (m *UsageTotalMutation) TypeCleared() bool {
  38971. _, ok := m.clearedFields[usagetotal.FieldType]
  38972. return ok
  38973. }
  38974. // ResetType resets all changes to the "type" field.
  38975. func (m *UsageTotalMutation) ResetType() {
  38976. m._type = nil
  38977. m.add_type = nil
  38978. delete(m.clearedFields, usagetotal.FieldType)
  38979. }
  38980. // SetBotID sets the "bot_id" field.
  38981. func (m *UsageTotalMutation) SetBotID(s string) {
  38982. m.bot_id = &s
  38983. }
  38984. // BotID returns the value of the "bot_id" field in the mutation.
  38985. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  38986. v := m.bot_id
  38987. if v == nil {
  38988. return
  38989. }
  38990. return *v, true
  38991. }
  38992. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  38993. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38995. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  38996. if !m.op.Is(OpUpdateOne) {
  38997. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  38998. }
  38999. if m.id == nil || m.oldValue == nil {
  39000. return v, errors.New("OldBotID requires an ID field in the mutation")
  39001. }
  39002. oldValue, err := m.oldValue(ctx)
  39003. if err != nil {
  39004. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39005. }
  39006. return oldValue.BotID, nil
  39007. }
  39008. // ResetBotID resets all changes to the "bot_id" field.
  39009. func (m *UsageTotalMutation) ResetBotID() {
  39010. m.bot_id = nil
  39011. }
  39012. // SetTotalTokens sets the "total_tokens" field.
  39013. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  39014. m.total_tokens = &u
  39015. m.addtotal_tokens = nil
  39016. }
  39017. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  39018. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  39019. v := m.total_tokens
  39020. if v == nil {
  39021. return
  39022. }
  39023. return *v, true
  39024. }
  39025. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  39026. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39028. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  39029. if !m.op.Is(OpUpdateOne) {
  39030. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  39031. }
  39032. if m.id == nil || m.oldValue == nil {
  39033. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  39034. }
  39035. oldValue, err := m.oldValue(ctx)
  39036. if err != nil {
  39037. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  39038. }
  39039. return oldValue.TotalTokens, nil
  39040. }
  39041. // AddTotalTokens adds u to the "total_tokens" field.
  39042. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  39043. if m.addtotal_tokens != nil {
  39044. *m.addtotal_tokens += u
  39045. } else {
  39046. m.addtotal_tokens = &u
  39047. }
  39048. }
  39049. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  39050. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  39051. v := m.addtotal_tokens
  39052. if v == nil {
  39053. return
  39054. }
  39055. return *v, true
  39056. }
  39057. // ClearTotalTokens clears the value of the "total_tokens" field.
  39058. func (m *UsageTotalMutation) ClearTotalTokens() {
  39059. m.total_tokens = nil
  39060. m.addtotal_tokens = nil
  39061. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  39062. }
  39063. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  39064. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  39065. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  39066. return ok
  39067. }
  39068. // ResetTotalTokens resets all changes to the "total_tokens" field.
  39069. func (m *UsageTotalMutation) ResetTotalTokens() {
  39070. m.total_tokens = nil
  39071. m.addtotal_tokens = nil
  39072. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  39073. }
  39074. // SetStartIndex sets the "start_index" field.
  39075. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  39076. m.start_index = &u
  39077. m.addstart_index = nil
  39078. }
  39079. // StartIndex returns the value of the "start_index" field in the mutation.
  39080. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  39081. v := m.start_index
  39082. if v == nil {
  39083. return
  39084. }
  39085. return *v, true
  39086. }
  39087. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  39088. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39090. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  39091. if !m.op.Is(OpUpdateOne) {
  39092. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  39093. }
  39094. if m.id == nil || m.oldValue == nil {
  39095. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  39096. }
  39097. oldValue, err := m.oldValue(ctx)
  39098. if err != nil {
  39099. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  39100. }
  39101. return oldValue.StartIndex, nil
  39102. }
  39103. // AddStartIndex adds u to the "start_index" field.
  39104. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  39105. if m.addstart_index != nil {
  39106. *m.addstart_index += u
  39107. } else {
  39108. m.addstart_index = &u
  39109. }
  39110. }
  39111. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  39112. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  39113. v := m.addstart_index
  39114. if v == nil {
  39115. return
  39116. }
  39117. return *v, true
  39118. }
  39119. // ClearStartIndex clears the value of the "start_index" field.
  39120. func (m *UsageTotalMutation) ClearStartIndex() {
  39121. m.start_index = nil
  39122. m.addstart_index = nil
  39123. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  39124. }
  39125. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  39126. func (m *UsageTotalMutation) StartIndexCleared() bool {
  39127. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  39128. return ok
  39129. }
  39130. // ResetStartIndex resets all changes to the "start_index" field.
  39131. func (m *UsageTotalMutation) ResetStartIndex() {
  39132. m.start_index = nil
  39133. m.addstart_index = nil
  39134. delete(m.clearedFields, usagetotal.FieldStartIndex)
  39135. }
  39136. // SetEndIndex sets the "end_index" field.
  39137. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  39138. m.end_index = &u
  39139. m.addend_index = nil
  39140. }
  39141. // EndIndex returns the value of the "end_index" field in the mutation.
  39142. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  39143. v := m.end_index
  39144. if v == nil {
  39145. return
  39146. }
  39147. return *v, true
  39148. }
  39149. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  39150. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39152. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  39153. if !m.op.Is(OpUpdateOne) {
  39154. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  39155. }
  39156. if m.id == nil || m.oldValue == nil {
  39157. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  39158. }
  39159. oldValue, err := m.oldValue(ctx)
  39160. if err != nil {
  39161. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  39162. }
  39163. return oldValue.EndIndex, nil
  39164. }
  39165. // AddEndIndex adds u to the "end_index" field.
  39166. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  39167. if m.addend_index != nil {
  39168. *m.addend_index += u
  39169. } else {
  39170. m.addend_index = &u
  39171. }
  39172. }
  39173. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  39174. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  39175. v := m.addend_index
  39176. if v == nil {
  39177. return
  39178. }
  39179. return *v, true
  39180. }
  39181. // ClearEndIndex clears the value of the "end_index" field.
  39182. func (m *UsageTotalMutation) ClearEndIndex() {
  39183. m.end_index = nil
  39184. m.addend_index = nil
  39185. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  39186. }
  39187. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  39188. func (m *UsageTotalMutation) EndIndexCleared() bool {
  39189. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  39190. return ok
  39191. }
  39192. // ResetEndIndex resets all changes to the "end_index" field.
  39193. func (m *UsageTotalMutation) ResetEndIndex() {
  39194. m.end_index = nil
  39195. m.addend_index = nil
  39196. delete(m.clearedFields, usagetotal.FieldEndIndex)
  39197. }
  39198. // SetOrganizationID sets the "organization_id" field.
  39199. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  39200. m.organization_id = &u
  39201. m.addorganization_id = nil
  39202. }
  39203. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39204. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  39205. v := m.organization_id
  39206. if v == nil {
  39207. return
  39208. }
  39209. return *v, true
  39210. }
  39211. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  39212. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39214. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39215. if !m.op.Is(OpUpdateOne) {
  39216. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39217. }
  39218. if m.id == nil || m.oldValue == nil {
  39219. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39220. }
  39221. oldValue, err := m.oldValue(ctx)
  39222. if err != nil {
  39223. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39224. }
  39225. return oldValue.OrganizationID, nil
  39226. }
  39227. // AddOrganizationID adds u to the "organization_id" field.
  39228. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  39229. if m.addorganization_id != nil {
  39230. *m.addorganization_id += u
  39231. } else {
  39232. m.addorganization_id = &u
  39233. }
  39234. }
  39235. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39236. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  39237. v := m.addorganization_id
  39238. if v == nil {
  39239. return
  39240. }
  39241. return *v, true
  39242. }
  39243. // ClearOrganizationID clears the value of the "organization_id" field.
  39244. func (m *UsageTotalMutation) ClearOrganizationID() {
  39245. m.organization_id = nil
  39246. m.addorganization_id = nil
  39247. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  39248. }
  39249. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39250. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  39251. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  39252. return ok
  39253. }
  39254. // ResetOrganizationID resets all changes to the "organization_id" field.
  39255. func (m *UsageTotalMutation) ResetOrganizationID() {
  39256. m.organization_id = nil
  39257. m.addorganization_id = nil
  39258. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  39259. }
  39260. // Where appends a list predicates to the UsageTotalMutation builder.
  39261. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  39262. m.predicates = append(m.predicates, ps...)
  39263. }
  39264. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  39265. // users can use type-assertion to append predicates that do not depend on any generated package.
  39266. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  39267. p := make([]predicate.UsageTotal, len(ps))
  39268. for i := range ps {
  39269. p[i] = ps[i]
  39270. }
  39271. m.Where(p...)
  39272. }
  39273. // Op returns the operation name.
  39274. func (m *UsageTotalMutation) Op() Op {
  39275. return m.op
  39276. }
  39277. // SetOp allows setting the mutation operation.
  39278. func (m *UsageTotalMutation) SetOp(op Op) {
  39279. m.op = op
  39280. }
  39281. // Type returns the node type of this mutation (UsageTotal).
  39282. func (m *UsageTotalMutation) Type() string {
  39283. return m.typ
  39284. }
  39285. // Fields returns all fields that were changed during this mutation. Note that in
  39286. // order to get all numeric fields that were incremented/decremented, call
  39287. // AddedFields().
  39288. func (m *UsageTotalMutation) Fields() []string {
  39289. fields := make([]string, 0, 9)
  39290. if m.created_at != nil {
  39291. fields = append(fields, usagetotal.FieldCreatedAt)
  39292. }
  39293. if m.updated_at != nil {
  39294. fields = append(fields, usagetotal.FieldUpdatedAt)
  39295. }
  39296. if m.status != nil {
  39297. fields = append(fields, usagetotal.FieldStatus)
  39298. }
  39299. if m._type != nil {
  39300. fields = append(fields, usagetotal.FieldType)
  39301. }
  39302. if m.bot_id != nil {
  39303. fields = append(fields, usagetotal.FieldBotID)
  39304. }
  39305. if m.total_tokens != nil {
  39306. fields = append(fields, usagetotal.FieldTotalTokens)
  39307. }
  39308. if m.start_index != nil {
  39309. fields = append(fields, usagetotal.FieldStartIndex)
  39310. }
  39311. if m.end_index != nil {
  39312. fields = append(fields, usagetotal.FieldEndIndex)
  39313. }
  39314. if m.organization_id != nil {
  39315. fields = append(fields, usagetotal.FieldOrganizationID)
  39316. }
  39317. return fields
  39318. }
  39319. // Field returns the value of a field with the given name. The second boolean
  39320. // return value indicates that this field was not set, or was not defined in the
  39321. // schema.
  39322. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  39323. switch name {
  39324. case usagetotal.FieldCreatedAt:
  39325. return m.CreatedAt()
  39326. case usagetotal.FieldUpdatedAt:
  39327. return m.UpdatedAt()
  39328. case usagetotal.FieldStatus:
  39329. return m.Status()
  39330. case usagetotal.FieldType:
  39331. return m.GetType()
  39332. case usagetotal.FieldBotID:
  39333. return m.BotID()
  39334. case usagetotal.FieldTotalTokens:
  39335. return m.TotalTokens()
  39336. case usagetotal.FieldStartIndex:
  39337. return m.StartIndex()
  39338. case usagetotal.FieldEndIndex:
  39339. return m.EndIndex()
  39340. case usagetotal.FieldOrganizationID:
  39341. return m.OrganizationID()
  39342. }
  39343. return nil, false
  39344. }
  39345. // OldField returns the old value of the field from the database. An error is
  39346. // returned if the mutation operation is not UpdateOne, or the query to the
  39347. // database failed.
  39348. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39349. switch name {
  39350. case usagetotal.FieldCreatedAt:
  39351. return m.OldCreatedAt(ctx)
  39352. case usagetotal.FieldUpdatedAt:
  39353. return m.OldUpdatedAt(ctx)
  39354. case usagetotal.FieldStatus:
  39355. return m.OldStatus(ctx)
  39356. case usagetotal.FieldType:
  39357. return m.OldType(ctx)
  39358. case usagetotal.FieldBotID:
  39359. return m.OldBotID(ctx)
  39360. case usagetotal.FieldTotalTokens:
  39361. return m.OldTotalTokens(ctx)
  39362. case usagetotal.FieldStartIndex:
  39363. return m.OldStartIndex(ctx)
  39364. case usagetotal.FieldEndIndex:
  39365. return m.OldEndIndex(ctx)
  39366. case usagetotal.FieldOrganizationID:
  39367. return m.OldOrganizationID(ctx)
  39368. }
  39369. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  39370. }
  39371. // SetField sets the value of a field with the given name. It returns an error if
  39372. // the field is not defined in the schema, or if the type mismatched the field
  39373. // type.
  39374. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  39375. switch name {
  39376. case usagetotal.FieldCreatedAt:
  39377. v, ok := value.(time.Time)
  39378. if !ok {
  39379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39380. }
  39381. m.SetCreatedAt(v)
  39382. return nil
  39383. case usagetotal.FieldUpdatedAt:
  39384. v, ok := value.(time.Time)
  39385. if !ok {
  39386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39387. }
  39388. m.SetUpdatedAt(v)
  39389. return nil
  39390. case usagetotal.FieldStatus:
  39391. v, ok := value.(uint8)
  39392. if !ok {
  39393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39394. }
  39395. m.SetStatus(v)
  39396. return nil
  39397. case usagetotal.FieldType:
  39398. v, ok := value.(int)
  39399. if !ok {
  39400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39401. }
  39402. m.SetType(v)
  39403. return nil
  39404. case usagetotal.FieldBotID:
  39405. v, ok := value.(string)
  39406. if !ok {
  39407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39408. }
  39409. m.SetBotID(v)
  39410. return nil
  39411. case usagetotal.FieldTotalTokens:
  39412. v, ok := value.(uint64)
  39413. if !ok {
  39414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39415. }
  39416. m.SetTotalTokens(v)
  39417. return nil
  39418. case usagetotal.FieldStartIndex:
  39419. v, ok := value.(uint64)
  39420. if !ok {
  39421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39422. }
  39423. m.SetStartIndex(v)
  39424. return nil
  39425. case usagetotal.FieldEndIndex:
  39426. v, ok := value.(uint64)
  39427. if !ok {
  39428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39429. }
  39430. m.SetEndIndex(v)
  39431. return nil
  39432. case usagetotal.FieldOrganizationID:
  39433. v, ok := value.(uint64)
  39434. if !ok {
  39435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39436. }
  39437. m.SetOrganizationID(v)
  39438. return nil
  39439. }
  39440. return fmt.Errorf("unknown UsageTotal field %s", name)
  39441. }
  39442. // AddedFields returns all numeric fields that were incremented/decremented during
  39443. // this mutation.
  39444. func (m *UsageTotalMutation) AddedFields() []string {
  39445. var fields []string
  39446. if m.addstatus != nil {
  39447. fields = append(fields, usagetotal.FieldStatus)
  39448. }
  39449. if m.add_type != nil {
  39450. fields = append(fields, usagetotal.FieldType)
  39451. }
  39452. if m.addtotal_tokens != nil {
  39453. fields = append(fields, usagetotal.FieldTotalTokens)
  39454. }
  39455. if m.addstart_index != nil {
  39456. fields = append(fields, usagetotal.FieldStartIndex)
  39457. }
  39458. if m.addend_index != nil {
  39459. fields = append(fields, usagetotal.FieldEndIndex)
  39460. }
  39461. if m.addorganization_id != nil {
  39462. fields = append(fields, usagetotal.FieldOrganizationID)
  39463. }
  39464. return fields
  39465. }
  39466. // AddedField returns the numeric value that was incremented/decremented on a field
  39467. // with the given name. The second boolean return value indicates that this field
  39468. // was not set, or was not defined in the schema.
  39469. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  39470. switch name {
  39471. case usagetotal.FieldStatus:
  39472. return m.AddedStatus()
  39473. case usagetotal.FieldType:
  39474. return m.AddedType()
  39475. case usagetotal.FieldTotalTokens:
  39476. return m.AddedTotalTokens()
  39477. case usagetotal.FieldStartIndex:
  39478. return m.AddedStartIndex()
  39479. case usagetotal.FieldEndIndex:
  39480. return m.AddedEndIndex()
  39481. case usagetotal.FieldOrganizationID:
  39482. return m.AddedOrganizationID()
  39483. }
  39484. return nil, false
  39485. }
  39486. // AddField adds the value to the field with the given name. It returns an error if
  39487. // the field is not defined in the schema, or if the type mismatched the field
  39488. // type.
  39489. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  39490. switch name {
  39491. case usagetotal.FieldStatus:
  39492. v, ok := value.(int8)
  39493. if !ok {
  39494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39495. }
  39496. m.AddStatus(v)
  39497. return nil
  39498. case usagetotal.FieldType:
  39499. v, ok := value.(int)
  39500. if !ok {
  39501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39502. }
  39503. m.AddType(v)
  39504. return nil
  39505. case usagetotal.FieldTotalTokens:
  39506. v, ok := value.(int64)
  39507. if !ok {
  39508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39509. }
  39510. m.AddTotalTokens(v)
  39511. return nil
  39512. case usagetotal.FieldStartIndex:
  39513. v, ok := value.(int64)
  39514. if !ok {
  39515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39516. }
  39517. m.AddStartIndex(v)
  39518. return nil
  39519. case usagetotal.FieldEndIndex:
  39520. v, ok := value.(int64)
  39521. if !ok {
  39522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39523. }
  39524. m.AddEndIndex(v)
  39525. return nil
  39526. case usagetotal.FieldOrganizationID:
  39527. v, ok := value.(int64)
  39528. if !ok {
  39529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39530. }
  39531. m.AddOrganizationID(v)
  39532. return nil
  39533. }
  39534. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  39535. }
  39536. // ClearedFields returns all nullable fields that were cleared during this
  39537. // mutation.
  39538. func (m *UsageTotalMutation) ClearedFields() []string {
  39539. var fields []string
  39540. if m.FieldCleared(usagetotal.FieldStatus) {
  39541. fields = append(fields, usagetotal.FieldStatus)
  39542. }
  39543. if m.FieldCleared(usagetotal.FieldType) {
  39544. fields = append(fields, usagetotal.FieldType)
  39545. }
  39546. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  39547. fields = append(fields, usagetotal.FieldTotalTokens)
  39548. }
  39549. if m.FieldCleared(usagetotal.FieldStartIndex) {
  39550. fields = append(fields, usagetotal.FieldStartIndex)
  39551. }
  39552. if m.FieldCleared(usagetotal.FieldEndIndex) {
  39553. fields = append(fields, usagetotal.FieldEndIndex)
  39554. }
  39555. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  39556. fields = append(fields, usagetotal.FieldOrganizationID)
  39557. }
  39558. return fields
  39559. }
  39560. // FieldCleared returns a boolean indicating if a field with the given name was
  39561. // cleared in this mutation.
  39562. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  39563. _, ok := m.clearedFields[name]
  39564. return ok
  39565. }
  39566. // ClearField clears the value of the field with the given name. It returns an
  39567. // error if the field is not defined in the schema.
  39568. func (m *UsageTotalMutation) ClearField(name string) error {
  39569. switch name {
  39570. case usagetotal.FieldStatus:
  39571. m.ClearStatus()
  39572. return nil
  39573. case usagetotal.FieldType:
  39574. m.ClearType()
  39575. return nil
  39576. case usagetotal.FieldTotalTokens:
  39577. m.ClearTotalTokens()
  39578. return nil
  39579. case usagetotal.FieldStartIndex:
  39580. m.ClearStartIndex()
  39581. return nil
  39582. case usagetotal.FieldEndIndex:
  39583. m.ClearEndIndex()
  39584. return nil
  39585. case usagetotal.FieldOrganizationID:
  39586. m.ClearOrganizationID()
  39587. return nil
  39588. }
  39589. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  39590. }
  39591. // ResetField resets all changes in the mutation for the field with the given name.
  39592. // It returns an error if the field is not defined in the schema.
  39593. func (m *UsageTotalMutation) ResetField(name string) error {
  39594. switch name {
  39595. case usagetotal.FieldCreatedAt:
  39596. m.ResetCreatedAt()
  39597. return nil
  39598. case usagetotal.FieldUpdatedAt:
  39599. m.ResetUpdatedAt()
  39600. return nil
  39601. case usagetotal.FieldStatus:
  39602. m.ResetStatus()
  39603. return nil
  39604. case usagetotal.FieldType:
  39605. m.ResetType()
  39606. return nil
  39607. case usagetotal.FieldBotID:
  39608. m.ResetBotID()
  39609. return nil
  39610. case usagetotal.FieldTotalTokens:
  39611. m.ResetTotalTokens()
  39612. return nil
  39613. case usagetotal.FieldStartIndex:
  39614. m.ResetStartIndex()
  39615. return nil
  39616. case usagetotal.FieldEndIndex:
  39617. m.ResetEndIndex()
  39618. return nil
  39619. case usagetotal.FieldOrganizationID:
  39620. m.ResetOrganizationID()
  39621. return nil
  39622. }
  39623. return fmt.Errorf("unknown UsageTotal field %s", name)
  39624. }
  39625. // AddedEdges returns all edge names that were set/added in this mutation.
  39626. func (m *UsageTotalMutation) AddedEdges() []string {
  39627. edges := make([]string, 0, 0)
  39628. return edges
  39629. }
  39630. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39631. // name in this mutation.
  39632. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  39633. return nil
  39634. }
  39635. // RemovedEdges returns all edge names that were removed in this mutation.
  39636. func (m *UsageTotalMutation) RemovedEdges() []string {
  39637. edges := make([]string, 0, 0)
  39638. return edges
  39639. }
  39640. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39641. // the given name in this mutation.
  39642. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  39643. return nil
  39644. }
  39645. // ClearedEdges returns all edge names that were cleared in this mutation.
  39646. func (m *UsageTotalMutation) ClearedEdges() []string {
  39647. edges := make([]string, 0, 0)
  39648. return edges
  39649. }
  39650. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39651. // was cleared in this mutation.
  39652. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  39653. return false
  39654. }
  39655. // ClearEdge clears the value of the edge with the given name. It returns an error
  39656. // if that edge is not defined in the schema.
  39657. func (m *UsageTotalMutation) ClearEdge(name string) error {
  39658. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  39659. }
  39660. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39661. // It returns an error if the edge is not defined in the schema.
  39662. func (m *UsageTotalMutation) ResetEdge(name string) error {
  39663. return fmt.Errorf("unknown UsageTotal edge %s", name)
  39664. }
  39665. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  39666. type WhatsappMutation struct {
  39667. config
  39668. op Op
  39669. typ string
  39670. id *uint64
  39671. created_at *time.Time
  39672. updated_at *time.Time
  39673. status *uint8
  39674. addstatus *int8
  39675. deleted_at *time.Time
  39676. wa_id *string
  39677. wa_name *string
  39678. callback *string
  39679. account *string
  39680. cc *string
  39681. phone *string
  39682. cc_phone *string
  39683. phone_name *string
  39684. phone_status *int8
  39685. addphone_status *int8
  39686. organization_id *uint64
  39687. addorganization_id *int64
  39688. api_base *string
  39689. api_key *string
  39690. allow_list *[]string
  39691. appendallow_list []string
  39692. group_allow_list *[]string
  39693. appendgroup_allow_list []string
  39694. block_list *[]string
  39695. appendblock_list []string
  39696. group_block_list *[]string
  39697. appendgroup_block_list []string
  39698. clearedFields map[string]struct{}
  39699. agent *uint64
  39700. clearedagent bool
  39701. done bool
  39702. oldValue func(context.Context) (*Whatsapp, error)
  39703. predicates []predicate.Whatsapp
  39704. }
  39705. var _ ent.Mutation = (*WhatsappMutation)(nil)
  39706. // whatsappOption allows management of the mutation configuration using functional options.
  39707. type whatsappOption func(*WhatsappMutation)
  39708. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  39709. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  39710. m := &WhatsappMutation{
  39711. config: c,
  39712. op: op,
  39713. typ: TypeWhatsapp,
  39714. clearedFields: make(map[string]struct{}),
  39715. }
  39716. for _, opt := range opts {
  39717. opt(m)
  39718. }
  39719. return m
  39720. }
  39721. // withWhatsappID sets the ID field of the mutation.
  39722. func withWhatsappID(id uint64) whatsappOption {
  39723. return func(m *WhatsappMutation) {
  39724. var (
  39725. err error
  39726. once sync.Once
  39727. value *Whatsapp
  39728. )
  39729. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  39730. once.Do(func() {
  39731. if m.done {
  39732. err = errors.New("querying old values post mutation is not allowed")
  39733. } else {
  39734. value, err = m.Client().Whatsapp.Get(ctx, id)
  39735. }
  39736. })
  39737. return value, err
  39738. }
  39739. m.id = &id
  39740. }
  39741. }
  39742. // withWhatsapp sets the old Whatsapp of the mutation.
  39743. func withWhatsapp(node *Whatsapp) whatsappOption {
  39744. return func(m *WhatsappMutation) {
  39745. m.oldValue = func(context.Context) (*Whatsapp, error) {
  39746. return node, nil
  39747. }
  39748. m.id = &node.ID
  39749. }
  39750. }
  39751. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39752. // executed in a transaction (ent.Tx), a transactional client is returned.
  39753. func (m WhatsappMutation) Client() *Client {
  39754. client := &Client{config: m.config}
  39755. client.init()
  39756. return client
  39757. }
  39758. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39759. // it returns an error otherwise.
  39760. func (m WhatsappMutation) Tx() (*Tx, error) {
  39761. if _, ok := m.driver.(*txDriver); !ok {
  39762. return nil, errors.New("ent: mutation is not running in a transaction")
  39763. }
  39764. tx := &Tx{config: m.config}
  39765. tx.init()
  39766. return tx, nil
  39767. }
  39768. // SetID sets the value of the id field. Note that this
  39769. // operation is only accepted on creation of Whatsapp entities.
  39770. func (m *WhatsappMutation) SetID(id uint64) {
  39771. m.id = &id
  39772. }
  39773. // ID returns the ID value in the mutation. Note that the ID is only available
  39774. // if it was provided to the builder or after it was returned from the database.
  39775. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  39776. if m.id == nil {
  39777. return
  39778. }
  39779. return *m.id, true
  39780. }
  39781. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39782. // That means, if the mutation is applied within a transaction with an isolation level such
  39783. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39784. // or updated by the mutation.
  39785. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  39786. switch {
  39787. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39788. id, exists := m.ID()
  39789. if exists {
  39790. return []uint64{id}, nil
  39791. }
  39792. fallthrough
  39793. case m.op.Is(OpUpdate | OpDelete):
  39794. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  39795. default:
  39796. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39797. }
  39798. }
  39799. // SetCreatedAt sets the "created_at" field.
  39800. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  39801. m.created_at = &t
  39802. }
  39803. // CreatedAt returns the value of the "created_at" field in the mutation.
  39804. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  39805. v := m.created_at
  39806. if v == nil {
  39807. return
  39808. }
  39809. return *v, true
  39810. }
  39811. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  39812. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39814. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39815. if !m.op.Is(OpUpdateOne) {
  39816. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39817. }
  39818. if m.id == nil || m.oldValue == nil {
  39819. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39820. }
  39821. oldValue, err := m.oldValue(ctx)
  39822. if err != nil {
  39823. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39824. }
  39825. return oldValue.CreatedAt, nil
  39826. }
  39827. // ResetCreatedAt resets all changes to the "created_at" field.
  39828. func (m *WhatsappMutation) ResetCreatedAt() {
  39829. m.created_at = nil
  39830. }
  39831. // SetUpdatedAt sets the "updated_at" field.
  39832. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  39833. m.updated_at = &t
  39834. }
  39835. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39836. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  39837. v := m.updated_at
  39838. if v == nil {
  39839. return
  39840. }
  39841. return *v, true
  39842. }
  39843. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  39844. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39846. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39847. if !m.op.Is(OpUpdateOne) {
  39848. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39849. }
  39850. if m.id == nil || m.oldValue == nil {
  39851. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39852. }
  39853. oldValue, err := m.oldValue(ctx)
  39854. if err != nil {
  39855. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39856. }
  39857. return oldValue.UpdatedAt, nil
  39858. }
  39859. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39860. func (m *WhatsappMutation) ResetUpdatedAt() {
  39861. m.updated_at = nil
  39862. }
  39863. // SetStatus sets the "status" field.
  39864. func (m *WhatsappMutation) SetStatus(u uint8) {
  39865. m.status = &u
  39866. m.addstatus = nil
  39867. }
  39868. // Status returns the value of the "status" field in the mutation.
  39869. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  39870. v := m.status
  39871. if v == nil {
  39872. return
  39873. }
  39874. return *v, true
  39875. }
  39876. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  39877. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39879. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39880. if !m.op.Is(OpUpdateOne) {
  39881. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39882. }
  39883. if m.id == nil || m.oldValue == nil {
  39884. return v, errors.New("OldStatus requires an ID field in the mutation")
  39885. }
  39886. oldValue, err := m.oldValue(ctx)
  39887. if err != nil {
  39888. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39889. }
  39890. return oldValue.Status, nil
  39891. }
  39892. // AddStatus adds u to the "status" field.
  39893. func (m *WhatsappMutation) AddStatus(u int8) {
  39894. if m.addstatus != nil {
  39895. *m.addstatus += u
  39896. } else {
  39897. m.addstatus = &u
  39898. }
  39899. }
  39900. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39901. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  39902. v := m.addstatus
  39903. if v == nil {
  39904. return
  39905. }
  39906. return *v, true
  39907. }
  39908. // ClearStatus clears the value of the "status" field.
  39909. func (m *WhatsappMutation) ClearStatus() {
  39910. m.status = nil
  39911. m.addstatus = nil
  39912. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  39913. }
  39914. // StatusCleared returns if the "status" field was cleared in this mutation.
  39915. func (m *WhatsappMutation) StatusCleared() bool {
  39916. _, ok := m.clearedFields[whatsapp.FieldStatus]
  39917. return ok
  39918. }
  39919. // ResetStatus resets all changes to the "status" field.
  39920. func (m *WhatsappMutation) ResetStatus() {
  39921. m.status = nil
  39922. m.addstatus = nil
  39923. delete(m.clearedFields, whatsapp.FieldStatus)
  39924. }
  39925. // SetDeletedAt sets the "deleted_at" field.
  39926. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  39927. m.deleted_at = &t
  39928. }
  39929. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39930. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  39931. v := m.deleted_at
  39932. if v == nil {
  39933. return
  39934. }
  39935. return *v, true
  39936. }
  39937. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  39938. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39940. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39941. if !m.op.Is(OpUpdateOne) {
  39942. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39943. }
  39944. if m.id == nil || m.oldValue == nil {
  39945. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39946. }
  39947. oldValue, err := m.oldValue(ctx)
  39948. if err != nil {
  39949. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39950. }
  39951. return oldValue.DeletedAt, nil
  39952. }
  39953. // ClearDeletedAt clears the value of the "deleted_at" field.
  39954. func (m *WhatsappMutation) ClearDeletedAt() {
  39955. m.deleted_at = nil
  39956. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  39957. }
  39958. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39959. func (m *WhatsappMutation) DeletedAtCleared() bool {
  39960. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  39961. return ok
  39962. }
  39963. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39964. func (m *WhatsappMutation) ResetDeletedAt() {
  39965. m.deleted_at = nil
  39966. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  39967. }
  39968. // SetWaID sets the "wa_id" field.
  39969. func (m *WhatsappMutation) SetWaID(s string) {
  39970. m.wa_id = &s
  39971. }
  39972. // WaID returns the value of the "wa_id" field in the mutation.
  39973. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  39974. v := m.wa_id
  39975. if v == nil {
  39976. return
  39977. }
  39978. return *v, true
  39979. }
  39980. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  39981. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39983. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  39984. if !m.op.Is(OpUpdateOne) {
  39985. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39986. }
  39987. if m.id == nil || m.oldValue == nil {
  39988. return v, errors.New("OldWaID requires an ID field in the mutation")
  39989. }
  39990. oldValue, err := m.oldValue(ctx)
  39991. if err != nil {
  39992. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39993. }
  39994. return oldValue.WaID, nil
  39995. }
  39996. // ClearWaID clears the value of the "wa_id" field.
  39997. func (m *WhatsappMutation) ClearWaID() {
  39998. m.wa_id = nil
  39999. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  40000. }
  40001. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  40002. func (m *WhatsappMutation) WaIDCleared() bool {
  40003. _, ok := m.clearedFields[whatsapp.FieldWaID]
  40004. return ok
  40005. }
  40006. // ResetWaID resets all changes to the "wa_id" field.
  40007. func (m *WhatsappMutation) ResetWaID() {
  40008. m.wa_id = nil
  40009. delete(m.clearedFields, whatsapp.FieldWaID)
  40010. }
  40011. // SetWaName sets the "wa_name" field.
  40012. func (m *WhatsappMutation) SetWaName(s string) {
  40013. m.wa_name = &s
  40014. }
  40015. // WaName returns the value of the "wa_name" field in the mutation.
  40016. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  40017. v := m.wa_name
  40018. if v == nil {
  40019. return
  40020. }
  40021. return *v, true
  40022. }
  40023. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  40024. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40026. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  40027. if !m.op.Is(OpUpdateOne) {
  40028. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  40029. }
  40030. if m.id == nil || m.oldValue == nil {
  40031. return v, errors.New("OldWaName requires an ID field in the mutation")
  40032. }
  40033. oldValue, err := m.oldValue(ctx)
  40034. if err != nil {
  40035. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  40036. }
  40037. return oldValue.WaName, nil
  40038. }
  40039. // ClearWaName clears the value of the "wa_name" field.
  40040. func (m *WhatsappMutation) ClearWaName() {
  40041. m.wa_name = nil
  40042. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  40043. }
  40044. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  40045. func (m *WhatsappMutation) WaNameCleared() bool {
  40046. _, ok := m.clearedFields[whatsapp.FieldWaName]
  40047. return ok
  40048. }
  40049. // ResetWaName resets all changes to the "wa_name" field.
  40050. func (m *WhatsappMutation) ResetWaName() {
  40051. m.wa_name = nil
  40052. delete(m.clearedFields, whatsapp.FieldWaName)
  40053. }
  40054. // SetCallback sets the "callback" field.
  40055. func (m *WhatsappMutation) SetCallback(s string) {
  40056. m.callback = &s
  40057. }
  40058. // Callback returns the value of the "callback" field in the mutation.
  40059. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  40060. v := m.callback
  40061. if v == nil {
  40062. return
  40063. }
  40064. return *v, true
  40065. }
  40066. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  40067. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40069. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  40070. if !m.op.Is(OpUpdateOne) {
  40071. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40072. }
  40073. if m.id == nil || m.oldValue == nil {
  40074. return v, errors.New("OldCallback requires an ID field in the mutation")
  40075. }
  40076. oldValue, err := m.oldValue(ctx)
  40077. if err != nil {
  40078. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40079. }
  40080. return oldValue.Callback, nil
  40081. }
  40082. // ClearCallback clears the value of the "callback" field.
  40083. func (m *WhatsappMutation) ClearCallback() {
  40084. m.callback = nil
  40085. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  40086. }
  40087. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  40088. func (m *WhatsappMutation) CallbackCleared() bool {
  40089. _, ok := m.clearedFields[whatsapp.FieldCallback]
  40090. return ok
  40091. }
  40092. // ResetCallback resets all changes to the "callback" field.
  40093. func (m *WhatsappMutation) ResetCallback() {
  40094. m.callback = nil
  40095. delete(m.clearedFields, whatsapp.FieldCallback)
  40096. }
  40097. // SetAgentID sets the "agent_id" field.
  40098. func (m *WhatsappMutation) SetAgentID(u uint64) {
  40099. m.agent = &u
  40100. }
  40101. // AgentID returns the value of the "agent_id" field in the mutation.
  40102. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  40103. v := m.agent
  40104. if v == nil {
  40105. return
  40106. }
  40107. return *v, true
  40108. }
  40109. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  40110. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40112. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40113. if !m.op.Is(OpUpdateOne) {
  40114. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40115. }
  40116. if m.id == nil || m.oldValue == nil {
  40117. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40118. }
  40119. oldValue, err := m.oldValue(ctx)
  40120. if err != nil {
  40121. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40122. }
  40123. return oldValue.AgentID, nil
  40124. }
  40125. // ResetAgentID resets all changes to the "agent_id" field.
  40126. func (m *WhatsappMutation) ResetAgentID() {
  40127. m.agent = nil
  40128. }
  40129. // SetAccount sets the "account" field.
  40130. func (m *WhatsappMutation) SetAccount(s string) {
  40131. m.account = &s
  40132. }
  40133. // Account returns the value of the "account" field in the mutation.
  40134. func (m *WhatsappMutation) Account() (r string, exists bool) {
  40135. v := m.account
  40136. if v == nil {
  40137. return
  40138. }
  40139. return *v, true
  40140. }
  40141. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  40142. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40144. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  40145. if !m.op.Is(OpUpdateOne) {
  40146. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40147. }
  40148. if m.id == nil || m.oldValue == nil {
  40149. return v, errors.New("OldAccount requires an ID field in the mutation")
  40150. }
  40151. oldValue, err := m.oldValue(ctx)
  40152. if err != nil {
  40153. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40154. }
  40155. return oldValue.Account, nil
  40156. }
  40157. // ClearAccount clears the value of the "account" field.
  40158. func (m *WhatsappMutation) ClearAccount() {
  40159. m.account = nil
  40160. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  40161. }
  40162. // AccountCleared returns if the "account" field was cleared in this mutation.
  40163. func (m *WhatsappMutation) AccountCleared() bool {
  40164. _, ok := m.clearedFields[whatsapp.FieldAccount]
  40165. return ok
  40166. }
  40167. // ResetAccount resets all changes to the "account" field.
  40168. func (m *WhatsappMutation) ResetAccount() {
  40169. m.account = nil
  40170. delete(m.clearedFields, whatsapp.FieldAccount)
  40171. }
  40172. // SetCc sets the "cc" field.
  40173. func (m *WhatsappMutation) SetCc(s string) {
  40174. m.cc = &s
  40175. }
  40176. // Cc returns the value of the "cc" field in the mutation.
  40177. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  40178. v := m.cc
  40179. if v == nil {
  40180. return
  40181. }
  40182. return *v, true
  40183. }
  40184. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  40185. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40187. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  40188. if !m.op.Is(OpUpdateOne) {
  40189. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  40190. }
  40191. if m.id == nil || m.oldValue == nil {
  40192. return v, errors.New("OldCc requires an ID field in the mutation")
  40193. }
  40194. oldValue, err := m.oldValue(ctx)
  40195. if err != nil {
  40196. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  40197. }
  40198. return oldValue.Cc, nil
  40199. }
  40200. // ResetCc resets all changes to the "cc" field.
  40201. func (m *WhatsappMutation) ResetCc() {
  40202. m.cc = nil
  40203. }
  40204. // SetPhone sets the "phone" field.
  40205. func (m *WhatsappMutation) SetPhone(s string) {
  40206. m.phone = &s
  40207. }
  40208. // Phone returns the value of the "phone" field in the mutation.
  40209. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  40210. v := m.phone
  40211. if v == nil {
  40212. return
  40213. }
  40214. return *v, true
  40215. }
  40216. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  40217. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40219. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  40220. if !m.op.Is(OpUpdateOne) {
  40221. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40222. }
  40223. if m.id == nil || m.oldValue == nil {
  40224. return v, errors.New("OldPhone requires an ID field in the mutation")
  40225. }
  40226. oldValue, err := m.oldValue(ctx)
  40227. if err != nil {
  40228. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40229. }
  40230. return oldValue.Phone, nil
  40231. }
  40232. // ResetPhone resets all changes to the "phone" field.
  40233. func (m *WhatsappMutation) ResetPhone() {
  40234. m.phone = nil
  40235. }
  40236. // SetCcPhone sets the "cc_phone" field.
  40237. func (m *WhatsappMutation) SetCcPhone(s string) {
  40238. m.cc_phone = &s
  40239. }
  40240. // CcPhone returns the value of the "cc_phone" field in the mutation.
  40241. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  40242. v := m.cc_phone
  40243. if v == nil {
  40244. return
  40245. }
  40246. return *v, true
  40247. }
  40248. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  40249. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40251. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  40252. if !m.op.Is(OpUpdateOne) {
  40253. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  40254. }
  40255. if m.id == nil || m.oldValue == nil {
  40256. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  40257. }
  40258. oldValue, err := m.oldValue(ctx)
  40259. if err != nil {
  40260. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  40261. }
  40262. return oldValue.CcPhone, nil
  40263. }
  40264. // ResetCcPhone resets all changes to the "cc_phone" field.
  40265. func (m *WhatsappMutation) ResetCcPhone() {
  40266. m.cc_phone = nil
  40267. }
  40268. // SetPhoneName sets the "phone_name" field.
  40269. func (m *WhatsappMutation) SetPhoneName(s string) {
  40270. m.phone_name = &s
  40271. }
  40272. // PhoneName returns the value of the "phone_name" field in the mutation.
  40273. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  40274. v := m.phone_name
  40275. if v == nil {
  40276. return
  40277. }
  40278. return *v, true
  40279. }
  40280. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  40281. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40283. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  40284. if !m.op.Is(OpUpdateOne) {
  40285. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  40286. }
  40287. if m.id == nil || m.oldValue == nil {
  40288. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  40289. }
  40290. oldValue, err := m.oldValue(ctx)
  40291. if err != nil {
  40292. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  40293. }
  40294. return oldValue.PhoneName, nil
  40295. }
  40296. // ResetPhoneName resets all changes to the "phone_name" field.
  40297. func (m *WhatsappMutation) ResetPhoneName() {
  40298. m.phone_name = nil
  40299. }
  40300. // SetPhoneStatus sets the "phone_status" field.
  40301. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  40302. m.phone_status = &i
  40303. m.addphone_status = nil
  40304. }
  40305. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  40306. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  40307. v := m.phone_status
  40308. if v == nil {
  40309. return
  40310. }
  40311. return *v, true
  40312. }
  40313. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  40314. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40316. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  40317. if !m.op.Is(OpUpdateOne) {
  40318. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  40319. }
  40320. if m.id == nil || m.oldValue == nil {
  40321. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  40322. }
  40323. oldValue, err := m.oldValue(ctx)
  40324. if err != nil {
  40325. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  40326. }
  40327. return oldValue.PhoneStatus, nil
  40328. }
  40329. // AddPhoneStatus adds i to the "phone_status" field.
  40330. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  40331. if m.addphone_status != nil {
  40332. *m.addphone_status += i
  40333. } else {
  40334. m.addphone_status = &i
  40335. }
  40336. }
  40337. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  40338. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  40339. v := m.addphone_status
  40340. if v == nil {
  40341. return
  40342. }
  40343. return *v, true
  40344. }
  40345. // ResetPhoneStatus resets all changes to the "phone_status" field.
  40346. func (m *WhatsappMutation) ResetPhoneStatus() {
  40347. m.phone_status = nil
  40348. m.addphone_status = nil
  40349. }
  40350. // SetOrganizationID sets the "organization_id" field.
  40351. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  40352. m.organization_id = &u
  40353. m.addorganization_id = nil
  40354. }
  40355. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40356. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  40357. v := m.organization_id
  40358. if v == nil {
  40359. return
  40360. }
  40361. return *v, true
  40362. }
  40363. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  40364. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40366. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40367. if !m.op.Is(OpUpdateOne) {
  40368. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40369. }
  40370. if m.id == nil || m.oldValue == nil {
  40371. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40372. }
  40373. oldValue, err := m.oldValue(ctx)
  40374. if err != nil {
  40375. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40376. }
  40377. return oldValue.OrganizationID, nil
  40378. }
  40379. // AddOrganizationID adds u to the "organization_id" field.
  40380. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  40381. if m.addorganization_id != nil {
  40382. *m.addorganization_id += u
  40383. } else {
  40384. m.addorganization_id = &u
  40385. }
  40386. }
  40387. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40388. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  40389. v := m.addorganization_id
  40390. if v == nil {
  40391. return
  40392. }
  40393. return *v, true
  40394. }
  40395. // ClearOrganizationID clears the value of the "organization_id" field.
  40396. func (m *WhatsappMutation) ClearOrganizationID() {
  40397. m.organization_id = nil
  40398. m.addorganization_id = nil
  40399. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  40400. }
  40401. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40402. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  40403. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  40404. return ok
  40405. }
  40406. // ResetOrganizationID resets all changes to the "organization_id" field.
  40407. func (m *WhatsappMutation) ResetOrganizationID() {
  40408. m.organization_id = nil
  40409. m.addorganization_id = nil
  40410. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  40411. }
  40412. // SetAPIBase sets the "api_base" field.
  40413. func (m *WhatsappMutation) SetAPIBase(s string) {
  40414. m.api_base = &s
  40415. }
  40416. // APIBase returns the value of the "api_base" field in the mutation.
  40417. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  40418. v := m.api_base
  40419. if v == nil {
  40420. return
  40421. }
  40422. return *v, true
  40423. }
  40424. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  40425. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40427. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40428. if !m.op.Is(OpUpdateOne) {
  40429. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40430. }
  40431. if m.id == nil || m.oldValue == nil {
  40432. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40433. }
  40434. oldValue, err := m.oldValue(ctx)
  40435. if err != nil {
  40436. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40437. }
  40438. return oldValue.APIBase, nil
  40439. }
  40440. // ClearAPIBase clears the value of the "api_base" field.
  40441. func (m *WhatsappMutation) ClearAPIBase() {
  40442. m.api_base = nil
  40443. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  40444. }
  40445. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40446. func (m *WhatsappMutation) APIBaseCleared() bool {
  40447. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  40448. return ok
  40449. }
  40450. // ResetAPIBase resets all changes to the "api_base" field.
  40451. func (m *WhatsappMutation) ResetAPIBase() {
  40452. m.api_base = nil
  40453. delete(m.clearedFields, whatsapp.FieldAPIBase)
  40454. }
  40455. // SetAPIKey sets the "api_key" field.
  40456. func (m *WhatsappMutation) SetAPIKey(s string) {
  40457. m.api_key = &s
  40458. }
  40459. // APIKey returns the value of the "api_key" field in the mutation.
  40460. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  40461. v := m.api_key
  40462. if v == nil {
  40463. return
  40464. }
  40465. return *v, true
  40466. }
  40467. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  40468. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40470. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40471. if !m.op.Is(OpUpdateOne) {
  40472. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40473. }
  40474. if m.id == nil || m.oldValue == nil {
  40475. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40476. }
  40477. oldValue, err := m.oldValue(ctx)
  40478. if err != nil {
  40479. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40480. }
  40481. return oldValue.APIKey, nil
  40482. }
  40483. // ClearAPIKey clears the value of the "api_key" field.
  40484. func (m *WhatsappMutation) ClearAPIKey() {
  40485. m.api_key = nil
  40486. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  40487. }
  40488. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40489. func (m *WhatsappMutation) APIKeyCleared() bool {
  40490. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  40491. return ok
  40492. }
  40493. // ResetAPIKey resets all changes to the "api_key" field.
  40494. func (m *WhatsappMutation) ResetAPIKey() {
  40495. m.api_key = nil
  40496. delete(m.clearedFields, whatsapp.FieldAPIKey)
  40497. }
  40498. // SetAllowList sets the "allow_list" field.
  40499. func (m *WhatsappMutation) SetAllowList(s []string) {
  40500. m.allow_list = &s
  40501. m.appendallow_list = nil
  40502. }
  40503. // AllowList returns the value of the "allow_list" field in the mutation.
  40504. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  40505. v := m.allow_list
  40506. if v == nil {
  40507. return
  40508. }
  40509. return *v, true
  40510. }
  40511. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  40512. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40514. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40515. if !m.op.Is(OpUpdateOne) {
  40516. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40517. }
  40518. if m.id == nil || m.oldValue == nil {
  40519. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40520. }
  40521. oldValue, err := m.oldValue(ctx)
  40522. if err != nil {
  40523. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40524. }
  40525. return oldValue.AllowList, nil
  40526. }
  40527. // AppendAllowList adds s to the "allow_list" field.
  40528. func (m *WhatsappMutation) AppendAllowList(s []string) {
  40529. m.appendallow_list = append(m.appendallow_list, s...)
  40530. }
  40531. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40532. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  40533. if len(m.appendallow_list) == 0 {
  40534. return nil, false
  40535. }
  40536. return m.appendallow_list, true
  40537. }
  40538. // ClearAllowList clears the value of the "allow_list" field.
  40539. func (m *WhatsappMutation) ClearAllowList() {
  40540. m.allow_list = nil
  40541. m.appendallow_list = nil
  40542. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  40543. }
  40544. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  40545. func (m *WhatsappMutation) AllowListCleared() bool {
  40546. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  40547. return ok
  40548. }
  40549. // ResetAllowList resets all changes to the "allow_list" field.
  40550. func (m *WhatsappMutation) ResetAllowList() {
  40551. m.allow_list = nil
  40552. m.appendallow_list = nil
  40553. delete(m.clearedFields, whatsapp.FieldAllowList)
  40554. }
  40555. // SetGroupAllowList sets the "group_allow_list" field.
  40556. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  40557. m.group_allow_list = &s
  40558. m.appendgroup_allow_list = nil
  40559. }
  40560. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40561. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  40562. v := m.group_allow_list
  40563. if v == nil {
  40564. return
  40565. }
  40566. return *v, true
  40567. }
  40568. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  40569. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40571. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40572. if !m.op.Is(OpUpdateOne) {
  40573. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40574. }
  40575. if m.id == nil || m.oldValue == nil {
  40576. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40577. }
  40578. oldValue, err := m.oldValue(ctx)
  40579. if err != nil {
  40580. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40581. }
  40582. return oldValue.GroupAllowList, nil
  40583. }
  40584. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40585. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  40586. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40587. }
  40588. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40589. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  40590. if len(m.appendgroup_allow_list) == 0 {
  40591. return nil, false
  40592. }
  40593. return m.appendgroup_allow_list, true
  40594. }
  40595. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  40596. func (m *WhatsappMutation) ClearGroupAllowList() {
  40597. m.group_allow_list = nil
  40598. m.appendgroup_allow_list = nil
  40599. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  40600. }
  40601. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  40602. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  40603. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  40604. return ok
  40605. }
  40606. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40607. func (m *WhatsappMutation) ResetGroupAllowList() {
  40608. m.group_allow_list = nil
  40609. m.appendgroup_allow_list = nil
  40610. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  40611. }
  40612. // SetBlockList sets the "block_list" field.
  40613. func (m *WhatsappMutation) SetBlockList(s []string) {
  40614. m.block_list = &s
  40615. m.appendblock_list = nil
  40616. }
  40617. // BlockList returns the value of the "block_list" field in the mutation.
  40618. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  40619. v := m.block_list
  40620. if v == nil {
  40621. return
  40622. }
  40623. return *v, true
  40624. }
  40625. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  40626. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40628. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40629. if !m.op.Is(OpUpdateOne) {
  40630. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40631. }
  40632. if m.id == nil || m.oldValue == nil {
  40633. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40634. }
  40635. oldValue, err := m.oldValue(ctx)
  40636. if err != nil {
  40637. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40638. }
  40639. return oldValue.BlockList, nil
  40640. }
  40641. // AppendBlockList adds s to the "block_list" field.
  40642. func (m *WhatsappMutation) AppendBlockList(s []string) {
  40643. m.appendblock_list = append(m.appendblock_list, s...)
  40644. }
  40645. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40646. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  40647. if len(m.appendblock_list) == 0 {
  40648. return nil, false
  40649. }
  40650. return m.appendblock_list, true
  40651. }
  40652. // ClearBlockList clears the value of the "block_list" field.
  40653. func (m *WhatsappMutation) ClearBlockList() {
  40654. m.block_list = nil
  40655. m.appendblock_list = nil
  40656. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  40657. }
  40658. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  40659. func (m *WhatsappMutation) BlockListCleared() bool {
  40660. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  40661. return ok
  40662. }
  40663. // ResetBlockList resets all changes to the "block_list" field.
  40664. func (m *WhatsappMutation) ResetBlockList() {
  40665. m.block_list = nil
  40666. m.appendblock_list = nil
  40667. delete(m.clearedFields, whatsapp.FieldBlockList)
  40668. }
  40669. // SetGroupBlockList sets the "group_block_list" field.
  40670. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  40671. m.group_block_list = &s
  40672. m.appendgroup_block_list = nil
  40673. }
  40674. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40675. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  40676. v := m.group_block_list
  40677. if v == nil {
  40678. return
  40679. }
  40680. return *v, true
  40681. }
  40682. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  40683. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40685. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40686. if !m.op.Is(OpUpdateOne) {
  40687. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40688. }
  40689. if m.id == nil || m.oldValue == nil {
  40690. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40691. }
  40692. oldValue, err := m.oldValue(ctx)
  40693. if err != nil {
  40694. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40695. }
  40696. return oldValue.GroupBlockList, nil
  40697. }
  40698. // AppendGroupBlockList adds s to the "group_block_list" field.
  40699. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  40700. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40701. }
  40702. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40703. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  40704. if len(m.appendgroup_block_list) == 0 {
  40705. return nil, false
  40706. }
  40707. return m.appendgroup_block_list, true
  40708. }
  40709. // ClearGroupBlockList clears the value of the "group_block_list" field.
  40710. func (m *WhatsappMutation) ClearGroupBlockList() {
  40711. m.group_block_list = nil
  40712. m.appendgroup_block_list = nil
  40713. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  40714. }
  40715. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  40716. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  40717. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  40718. return ok
  40719. }
  40720. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40721. func (m *WhatsappMutation) ResetGroupBlockList() {
  40722. m.group_block_list = nil
  40723. m.appendgroup_block_list = nil
  40724. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  40725. }
  40726. // ClearAgent clears the "agent" edge to the Agent entity.
  40727. func (m *WhatsappMutation) ClearAgent() {
  40728. m.clearedagent = true
  40729. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  40730. }
  40731. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40732. func (m *WhatsappMutation) AgentCleared() bool {
  40733. return m.clearedagent
  40734. }
  40735. // AgentIDs returns the "agent" edge IDs in the mutation.
  40736. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40737. // AgentID instead. It exists only for internal usage by the builders.
  40738. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  40739. if id := m.agent; id != nil {
  40740. ids = append(ids, *id)
  40741. }
  40742. return
  40743. }
  40744. // ResetAgent resets all changes to the "agent" edge.
  40745. func (m *WhatsappMutation) ResetAgent() {
  40746. m.agent = nil
  40747. m.clearedagent = false
  40748. }
  40749. // Where appends a list predicates to the WhatsappMutation builder.
  40750. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  40751. m.predicates = append(m.predicates, ps...)
  40752. }
  40753. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  40754. // users can use type-assertion to append predicates that do not depend on any generated package.
  40755. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  40756. p := make([]predicate.Whatsapp, len(ps))
  40757. for i := range ps {
  40758. p[i] = ps[i]
  40759. }
  40760. m.Where(p...)
  40761. }
  40762. // Op returns the operation name.
  40763. func (m *WhatsappMutation) Op() Op {
  40764. return m.op
  40765. }
  40766. // SetOp allows setting the mutation operation.
  40767. func (m *WhatsappMutation) SetOp(op Op) {
  40768. m.op = op
  40769. }
  40770. // Type returns the node type of this mutation (Whatsapp).
  40771. func (m *WhatsappMutation) Type() string {
  40772. return m.typ
  40773. }
  40774. // Fields returns all fields that were changed during this mutation. Note that in
  40775. // order to get all numeric fields that were incremented/decremented, call
  40776. // AddedFields().
  40777. func (m *WhatsappMutation) Fields() []string {
  40778. fields := make([]string, 0, 21)
  40779. if m.created_at != nil {
  40780. fields = append(fields, whatsapp.FieldCreatedAt)
  40781. }
  40782. if m.updated_at != nil {
  40783. fields = append(fields, whatsapp.FieldUpdatedAt)
  40784. }
  40785. if m.status != nil {
  40786. fields = append(fields, whatsapp.FieldStatus)
  40787. }
  40788. if m.deleted_at != nil {
  40789. fields = append(fields, whatsapp.FieldDeletedAt)
  40790. }
  40791. if m.wa_id != nil {
  40792. fields = append(fields, whatsapp.FieldWaID)
  40793. }
  40794. if m.wa_name != nil {
  40795. fields = append(fields, whatsapp.FieldWaName)
  40796. }
  40797. if m.callback != nil {
  40798. fields = append(fields, whatsapp.FieldCallback)
  40799. }
  40800. if m.agent != nil {
  40801. fields = append(fields, whatsapp.FieldAgentID)
  40802. }
  40803. if m.account != nil {
  40804. fields = append(fields, whatsapp.FieldAccount)
  40805. }
  40806. if m.cc != nil {
  40807. fields = append(fields, whatsapp.FieldCc)
  40808. }
  40809. if m.phone != nil {
  40810. fields = append(fields, whatsapp.FieldPhone)
  40811. }
  40812. if m.cc_phone != nil {
  40813. fields = append(fields, whatsapp.FieldCcPhone)
  40814. }
  40815. if m.phone_name != nil {
  40816. fields = append(fields, whatsapp.FieldPhoneName)
  40817. }
  40818. if m.phone_status != nil {
  40819. fields = append(fields, whatsapp.FieldPhoneStatus)
  40820. }
  40821. if m.organization_id != nil {
  40822. fields = append(fields, whatsapp.FieldOrganizationID)
  40823. }
  40824. if m.api_base != nil {
  40825. fields = append(fields, whatsapp.FieldAPIBase)
  40826. }
  40827. if m.api_key != nil {
  40828. fields = append(fields, whatsapp.FieldAPIKey)
  40829. }
  40830. if m.allow_list != nil {
  40831. fields = append(fields, whatsapp.FieldAllowList)
  40832. }
  40833. if m.group_allow_list != nil {
  40834. fields = append(fields, whatsapp.FieldGroupAllowList)
  40835. }
  40836. if m.block_list != nil {
  40837. fields = append(fields, whatsapp.FieldBlockList)
  40838. }
  40839. if m.group_block_list != nil {
  40840. fields = append(fields, whatsapp.FieldGroupBlockList)
  40841. }
  40842. return fields
  40843. }
  40844. // Field returns the value of a field with the given name. The second boolean
  40845. // return value indicates that this field was not set, or was not defined in the
  40846. // schema.
  40847. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  40848. switch name {
  40849. case whatsapp.FieldCreatedAt:
  40850. return m.CreatedAt()
  40851. case whatsapp.FieldUpdatedAt:
  40852. return m.UpdatedAt()
  40853. case whatsapp.FieldStatus:
  40854. return m.Status()
  40855. case whatsapp.FieldDeletedAt:
  40856. return m.DeletedAt()
  40857. case whatsapp.FieldWaID:
  40858. return m.WaID()
  40859. case whatsapp.FieldWaName:
  40860. return m.WaName()
  40861. case whatsapp.FieldCallback:
  40862. return m.Callback()
  40863. case whatsapp.FieldAgentID:
  40864. return m.AgentID()
  40865. case whatsapp.FieldAccount:
  40866. return m.Account()
  40867. case whatsapp.FieldCc:
  40868. return m.Cc()
  40869. case whatsapp.FieldPhone:
  40870. return m.Phone()
  40871. case whatsapp.FieldCcPhone:
  40872. return m.CcPhone()
  40873. case whatsapp.FieldPhoneName:
  40874. return m.PhoneName()
  40875. case whatsapp.FieldPhoneStatus:
  40876. return m.PhoneStatus()
  40877. case whatsapp.FieldOrganizationID:
  40878. return m.OrganizationID()
  40879. case whatsapp.FieldAPIBase:
  40880. return m.APIBase()
  40881. case whatsapp.FieldAPIKey:
  40882. return m.APIKey()
  40883. case whatsapp.FieldAllowList:
  40884. return m.AllowList()
  40885. case whatsapp.FieldGroupAllowList:
  40886. return m.GroupAllowList()
  40887. case whatsapp.FieldBlockList:
  40888. return m.BlockList()
  40889. case whatsapp.FieldGroupBlockList:
  40890. return m.GroupBlockList()
  40891. }
  40892. return nil, false
  40893. }
  40894. // OldField returns the old value of the field from the database. An error is
  40895. // returned if the mutation operation is not UpdateOne, or the query to the
  40896. // database failed.
  40897. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40898. switch name {
  40899. case whatsapp.FieldCreatedAt:
  40900. return m.OldCreatedAt(ctx)
  40901. case whatsapp.FieldUpdatedAt:
  40902. return m.OldUpdatedAt(ctx)
  40903. case whatsapp.FieldStatus:
  40904. return m.OldStatus(ctx)
  40905. case whatsapp.FieldDeletedAt:
  40906. return m.OldDeletedAt(ctx)
  40907. case whatsapp.FieldWaID:
  40908. return m.OldWaID(ctx)
  40909. case whatsapp.FieldWaName:
  40910. return m.OldWaName(ctx)
  40911. case whatsapp.FieldCallback:
  40912. return m.OldCallback(ctx)
  40913. case whatsapp.FieldAgentID:
  40914. return m.OldAgentID(ctx)
  40915. case whatsapp.FieldAccount:
  40916. return m.OldAccount(ctx)
  40917. case whatsapp.FieldCc:
  40918. return m.OldCc(ctx)
  40919. case whatsapp.FieldPhone:
  40920. return m.OldPhone(ctx)
  40921. case whatsapp.FieldCcPhone:
  40922. return m.OldCcPhone(ctx)
  40923. case whatsapp.FieldPhoneName:
  40924. return m.OldPhoneName(ctx)
  40925. case whatsapp.FieldPhoneStatus:
  40926. return m.OldPhoneStatus(ctx)
  40927. case whatsapp.FieldOrganizationID:
  40928. return m.OldOrganizationID(ctx)
  40929. case whatsapp.FieldAPIBase:
  40930. return m.OldAPIBase(ctx)
  40931. case whatsapp.FieldAPIKey:
  40932. return m.OldAPIKey(ctx)
  40933. case whatsapp.FieldAllowList:
  40934. return m.OldAllowList(ctx)
  40935. case whatsapp.FieldGroupAllowList:
  40936. return m.OldGroupAllowList(ctx)
  40937. case whatsapp.FieldBlockList:
  40938. return m.OldBlockList(ctx)
  40939. case whatsapp.FieldGroupBlockList:
  40940. return m.OldGroupBlockList(ctx)
  40941. }
  40942. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  40943. }
  40944. // SetField sets the value of a field with the given name. It returns an error if
  40945. // the field is not defined in the schema, or if the type mismatched the field
  40946. // type.
  40947. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  40948. switch name {
  40949. case whatsapp.FieldCreatedAt:
  40950. v, ok := value.(time.Time)
  40951. if !ok {
  40952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40953. }
  40954. m.SetCreatedAt(v)
  40955. return nil
  40956. case whatsapp.FieldUpdatedAt:
  40957. v, ok := value.(time.Time)
  40958. if !ok {
  40959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40960. }
  40961. m.SetUpdatedAt(v)
  40962. return nil
  40963. case whatsapp.FieldStatus:
  40964. v, ok := value.(uint8)
  40965. if !ok {
  40966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40967. }
  40968. m.SetStatus(v)
  40969. return nil
  40970. case whatsapp.FieldDeletedAt:
  40971. v, ok := value.(time.Time)
  40972. if !ok {
  40973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40974. }
  40975. m.SetDeletedAt(v)
  40976. return nil
  40977. case whatsapp.FieldWaID:
  40978. v, ok := value.(string)
  40979. if !ok {
  40980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40981. }
  40982. m.SetWaID(v)
  40983. return nil
  40984. case whatsapp.FieldWaName:
  40985. v, ok := value.(string)
  40986. if !ok {
  40987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40988. }
  40989. m.SetWaName(v)
  40990. return nil
  40991. case whatsapp.FieldCallback:
  40992. v, ok := value.(string)
  40993. if !ok {
  40994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40995. }
  40996. m.SetCallback(v)
  40997. return nil
  40998. case whatsapp.FieldAgentID:
  40999. v, ok := value.(uint64)
  41000. if !ok {
  41001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41002. }
  41003. m.SetAgentID(v)
  41004. return nil
  41005. case whatsapp.FieldAccount:
  41006. v, ok := value.(string)
  41007. if !ok {
  41008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41009. }
  41010. m.SetAccount(v)
  41011. return nil
  41012. case whatsapp.FieldCc:
  41013. v, ok := value.(string)
  41014. if !ok {
  41015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41016. }
  41017. m.SetCc(v)
  41018. return nil
  41019. case whatsapp.FieldPhone:
  41020. v, ok := value.(string)
  41021. if !ok {
  41022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41023. }
  41024. m.SetPhone(v)
  41025. return nil
  41026. case whatsapp.FieldCcPhone:
  41027. v, ok := value.(string)
  41028. if !ok {
  41029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41030. }
  41031. m.SetCcPhone(v)
  41032. return nil
  41033. case whatsapp.FieldPhoneName:
  41034. v, ok := value.(string)
  41035. if !ok {
  41036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41037. }
  41038. m.SetPhoneName(v)
  41039. return nil
  41040. case whatsapp.FieldPhoneStatus:
  41041. v, ok := value.(int8)
  41042. if !ok {
  41043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41044. }
  41045. m.SetPhoneStatus(v)
  41046. return nil
  41047. case whatsapp.FieldOrganizationID:
  41048. v, ok := value.(uint64)
  41049. if !ok {
  41050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41051. }
  41052. m.SetOrganizationID(v)
  41053. return nil
  41054. case whatsapp.FieldAPIBase:
  41055. v, ok := value.(string)
  41056. if !ok {
  41057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41058. }
  41059. m.SetAPIBase(v)
  41060. return nil
  41061. case whatsapp.FieldAPIKey:
  41062. v, ok := value.(string)
  41063. if !ok {
  41064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41065. }
  41066. m.SetAPIKey(v)
  41067. return nil
  41068. case whatsapp.FieldAllowList:
  41069. v, ok := value.([]string)
  41070. if !ok {
  41071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41072. }
  41073. m.SetAllowList(v)
  41074. return nil
  41075. case whatsapp.FieldGroupAllowList:
  41076. v, ok := value.([]string)
  41077. if !ok {
  41078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41079. }
  41080. m.SetGroupAllowList(v)
  41081. return nil
  41082. case whatsapp.FieldBlockList:
  41083. v, ok := value.([]string)
  41084. if !ok {
  41085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41086. }
  41087. m.SetBlockList(v)
  41088. return nil
  41089. case whatsapp.FieldGroupBlockList:
  41090. v, ok := value.([]string)
  41091. if !ok {
  41092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41093. }
  41094. m.SetGroupBlockList(v)
  41095. return nil
  41096. }
  41097. return fmt.Errorf("unknown Whatsapp field %s", name)
  41098. }
  41099. // AddedFields returns all numeric fields that were incremented/decremented during
  41100. // this mutation.
  41101. func (m *WhatsappMutation) AddedFields() []string {
  41102. var fields []string
  41103. if m.addstatus != nil {
  41104. fields = append(fields, whatsapp.FieldStatus)
  41105. }
  41106. if m.addphone_status != nil {
  41107. fields = append(fields, whatsapp.FieldPhoneStatus)
  41108. }
  41109. if m.addorganization_id != nil {
  41110. fields = append(fields, whatsapp.FieldOrganizationID)
  41111. }
  41112. return fields
  41113. }
  41114. // AddedField returns the numeric value that was incremented/decremented on a field
  41115. // with the given name. The second boolean return value indicates that this field
  41116. // was not set, or was not defined in the schema.
  41117. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  41118. switch name {
  41119. case whatsapp.FieldStatus:
  41120. return m.AddedStatus()
  41121. case whatsapp.FieldPhoneStatus:
  41122. return m.AddedPhoneStatus()
  41123. case whatsapp.FieldOrganizationID:
  41124. return m.AddedOrganizationID()
  41125. }
  41126. return nil, false
  41127. }
  41128. // AddField adds the value to the field with the given name. It returns an error if
  41129. // the field is not defined in the schema, or if the type mismatched the field
  41130. // type.
  41131. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  41132. switch name {
  41133. case whatsapp.FieldStatus:
  41134. v, ok := value.(int8)
  41135. if !ok {
  41136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41137. }
  41138. m.AddStatus(v)
  41139. return nil
  41140. case whatsapp.FieldPhoneStatus:
  41141. v, ok := value.(int8)
  41142. if !ok {
  41143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41144. }
  41145. m.AddPhoneStatus(v)
  41146. return nil
  41147. case whatsapp.FieldOrganizationID:
  41148. v, ok := value.(int64)
  41149. if !ok {
  41150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41151. }
  41152. m.AddOrganizationID(v)
  41153. return nil
  41154. }
  41155. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  41156. }
  41157. // ClearedFields returns all nullable fields that were cleared during this
  41158. // mutation.
  41159. func (m *WhatsappMutation) ClearedFields() []string {
  41160. var fields []string
  41161. if m.FieldCleared(whatsapp.FieldStatus) {
  41162. fields = append(fields, whatsapp.FieldStatus)
  41163. }
  41164. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  41165. fields = append(fields, whatsapp.FieldDeletedAt)
  41166. }
  41167. if m.FieldCleared(whatsapp.FieldWaID) {
  41168. fields = append(fields, whatsapp.FieldWaID)
  41169. }
  41170. if m.FieldCleared(whatsapp.FieldWaName) {
  41171. fields = append(fields, whatsapp.FieldWaName)
  41172. }
  41173. if m.FieldCleared(whatsapp.FieldCallback) {
  41174. fields = append(fields, whatsapp.FieldCallback)
  41175. }
  41176. if m.FieldCleared(whatsapp.FieldAccount) {
  41177. fields = append(fields, whatsapp.FieldAccount)
  41178. }
  41179. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  41180. fields = append(fields, whatsapp.FieldOrganizationID)
  41181. }
  41182. if m.FieldCleared(whatsapp.FieldAPIBase) {
  41183. fields = append(fields, whatsapp.FieldAPIBase)
  41184. }
  41185. if m.FieldCleared(whatsapp.FieldAPIKey) {
  41186. fields = append(fields, whatsapp.FieldAPIKey)
  41187. }
  41188. if m.FieldCleared(whatsapp.FieldAllowList) {
  41189. fields = append(fields, whatsapp.FieldAllowList)
  41190. }
  41191. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  41192. fields = append(fields, whatsapp.FieldGroupAllowList)
  41193. }
  41194. if m.FieldCleared(whatsapp.FieldBlockList) {
  41195. fields = append(fields, whatsapp.FieldBlockList)
  41196. }
  41197. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  41198. fields = append(fields, whatsapp.FieldGroupBlockList)
  41199. }
  41200. return fields
  41201. }
  41202. // FieldCleared returns a boolean indicating if a field with the given name was
  41203. // cleared in this mutation.
  41204. func (m *WhatsappMutation) FieldCleared(name string) bool {
  41205. _, ok := m.clearedFields[name]
  41206. return ok
  41207. }
  41208. // ClearField clears the value of the field with the given name. It returns an
  41209. // error if the field is not defined in the schema.
  41210. func (m *WhatsappMutation) ClearField(name string) error {
  41211. switch name {
  41212. case whatsapp.FieldStatus:
  41213. m.ClearStatus()
  41214. return nil
  41215. case whatsapp.FieldDeletedAt:
  41216. m.ClearDeletedAt()
  41217. return nil
  41218. case whatsapp.FieldWaID:
  41219. m.ClearWaID()
  41220. return nil
  41221. case whatsapp.FieldWaName:
  41222. m.ClearWaName()
  41223. return nil
  41224. case whatsapp.FieldCallback:
  41225. m.ClearCallback()
  41226. return nil
  41227. case whatsapp.FieldAccount:
  41228. m.ClearAccount()
  41229. return nil
  41230. case whatsapp.FieldOrganizationID:
  41231. m.ClearOrganizationID()
  41232. return nil
  41233. case whatsapp.FieldAPIBase:
  41234. m.ClearAPIBase()
  41235. return nil
  41236. case whatsapp.FieldAPIKey:
  41237. m.ClearAPIKey()
  41238. return nil
  41239. case whatsapp.FieldAllowList:
  41240. m.ClearAllowList()
  41241. return nil
  41242. case whatsapp.FieldGroupAllowList:
  41243. m.ClearGroupAllowList()
  41244. return nil
  41245. case whatsapp.FieldBlockList:
  41246. m.ClearBlockList()
  41247. return nil
  41248. case whatsapp.FieldGroupBlockList:
  41249. m.ClearGroupBlockList()
  41250. return nil
  41251. }
  41252. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  41253. }
  41254. // ResetField resets all changes in the mutation for the field with the given name.
  41255. // It returns an error if the field is not defined in the schema.
  41256. func (m *WhatsappMutation) ResetField(name string) error {
  41257. switch name {
  41258. case whatsapp.FieldCreatedAt:
  41259. m.ResetCreatedAt()
  41260. return nil
  41261. case whatsapp.FieldUpdatedAt:
  41262. m.ResetUpdatedAt()
  41263. return nil
  41264. case whatsapp.FieldStatus:
  41265. m.ResetStatus()
  41266. return nil
  41267. case whatsapp.FieldDeletedAt:
  41268. m.ResetDeletedAt()
  41269. return nil
  41270. case whatsapp.FieldWaID:
  41271. m.ResetWaID()
  41272. return nil
  41273. case whatsapp.FieldWaName:
  41274. m.ResetWaName()
  41275. return nil
  41276. case whatsapp.FieldCallback:
  41277. m.ResetCallback()
  41278. return nil
  41279. case whatsapp.FieldAgentID:
  41280. m.ResetAgentID()
  41281. return nil
  41282. case whatsapp.FieldAccount:
  41283. m.ResetAccount()
  41284. return nil
  41285. case whatsapp.FieldCc:
  41286. m.ResetCc()
  41287. return nil
  41288. case whatsapp.FieldPhone:
  41289. m.ResetPhone()
  41290. return nil
  41291. case whatsapp.FieldCcPhone:
  41292. m.ResetCcPhone()
  41293. return nil
  41294. case whatsapp.FieldPhoneName:
  41295. m.ResetPhoneName()
  41296. return nil
  41297. case whatsapp.FieldPhoneStatus:
  41298. m.ResetPhoneStatus()
  41299. return nil
  41300. case whatsapp.FieldOrganizationID:
  41301. m.ResetOrganizationID()
  41302. return nil
  41303. case whatsapp.FieldAPIBase:
  41304. m.ResetAPIBase()
  41305. return nil
  41306. case whatsapp.FieldAPIKey:
  41307. m.ResetAPIKey()
  41308. return nil
  41309. case whatsapp.FieldAllowList:
  41310. m.ResetAllowList()
  41311. return nil
  41312. case whatsapp.FieldGroupAllowList:
  41313. m.ResetGroupAllowList()
  41314. return nil
  41315. case whatsapp.FieldBlockList:
  41316. m.ResetBlockList()
  41317. return nil
  41318. case whatsapp.FieldGroupBlockList:
  41319. m.ResetGroupBlockList()
  41320. return nil
  41321. }
  41322. return fmt.Errorf("unknown Whatsapp field %s", name)
  41323. }
  41324. // AddedEdges returns all edge names that were set/added in this mutation.
  41325. func (m *WhatsappMutation) AddedEdges() []string {
  41326. edges := make([]string, 0, 1)
  41327. if m.agent != nil {
  41328. edges = append(edges, whatsapp.EdgeAgent)
  41329. }
  41330. return edges
  41331. }
  41332. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41333. // name in this mutation.
  41334. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  41335. switch name {
  41336. case whatsapp.EdgeAgent:
  41337. if id := m.agent; id != nil {
  41338. return []ent.Value{*id}
  41339. }
  41340. }
  41341. return nil
  41342. }
  41343. // RemovedEdges returns all edge names that were removed in this mutation.
  41344. func (m *WhatsappMutation) RemovedEdges() []string {
  41345. edges := make([]string, 0, 1)
  41346. return edges
  41347. }
  41348. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41349. // the given name in this mutation.
  41350. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  41351. return nil
  41352. }
  41353. // ClearedEdges returns all edge names that were cleared in this mutation.
  41354. func (m *WhatsappMutation) ClearedEdges() []string {
  41355. edges := make([]string, 0, 1)
  41356. if m.clearedagent {
  41357. edges = append(edges, whatsapp.EdgeAgent)
  41358. }
  41359. return edges
  41360. }
  41361. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41362. // was cleared in this mutation.
  41363. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  41364. switch name {
  41365. case whatsapp.EdgeAgent:
  41366. return m.clearedagent
  41367. }
  41368. return false
  41369. }
  41370. // ClearEdge clears the value of the edge with the given name. It returns an error
  41371. // if that edge is not defined in the schema.
  41372. func (m *WhatsappMutation) ClearEdge(name string) error {
  41373. switch name {
  41374. case whatsapp.EdgeAgent:
  41375. m.ClearAgent()
  41376. return nil
  41377. }
  41378. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  41379. }
  41380. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41381. // It returns an error if the edge is not defined in the schema.
  41382. func (m *WhatsappMutation) ResetEdge(name string) error {
  41383. switch name {
  41384. case whatsapp.EdgeAgent:
  41385. m.ResetAgent()
  41386. return nil
  41387. }
  41388. return fmt.Errorf("unknown Whatsapp edge %s", name)
  41389. }
  41390. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  41391. type WhatsappChannelMutation struct {
  41392. config
  41393. op Op
  41394. typ string
  41395. id *uint64
  41396. created_at *time.Time
  41397. updated_at *time.Time
  41398. status *uint8
  41399. addstatus *int8
  41400. deleted_at *time.Time
  41401. ak *string
  41402. sk *string
  41403. wa_id *string
  41404. wa_name *string
  41405. waba_id *uint64
  41406. addwaba_id *int64
  41407. business_id *uint64
  41408. addbusiness_id *int64
  41409. organization_id *uint64
  41410. addorganization_id *int64
  41411. verify_account *string
  41412. clearedFields map[string]struct{}
  41413. done bool
  41414. oldValue func(context.Context) (*WhatsappChannel, error)
  41415. predicates []predicate.WhatsappChannel
  41416. }
  41417. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  41418. // whatsappchannelOption allows management of the mutation configuration using functional options.
  41419. type whatsappchannelOption func(*WhatsappChannelMutation)
  41420. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  41421. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  41422. m := &WhatsappChannelMutation{
  41423. config: c,
  41424. op: op,
  41425. typ: TypeWhatsappChannel,
  41426. clearedFields: make(map[string]struct{}),
  41427. }
  41428. for _, opt := range opts {
  41429. opt(m)
  41430. }
  41431. return m
  41432. }
  41433. // withWhatsappChannelID sets the ID field of the mutation.
  41434. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  41435. return func(m *WhatsappChannelMutation) {
  41436. var (
  41437. err error
  41438. once sync.Once
  41439. value *WhatsappChannel
  41440. )
  41441. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  41442. once.Do(func() {
  41443. if m.done {
  41444. err = errors.New("querying old values post mutation is not allowed")
  41445. } else {
  41446. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  41447. }
  41448. })
  41449. return value, err
  41450. }
  41451. m.id = &id
  41452. }
  41453. }
  41454. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  41455. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  41456. return func(m *WhatsappChannelMutation) {
  41457. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  41458. return node, nil
  41459. }
  41460. m.id = &node.ID
  41461. }
  41462. }
  41463. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41464. // executed in a transaction (ent.Tx), a transactional client is returned.
  41465. func (m WhatsappChannelMutation) Client() *Client {
  41466. client := &Client{config: m.config}
  41467. client.init()
  41468. return client
  41469. }
  41470. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41471. // it returns an error otherwise.
  41472. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  41473. if _, ok := m.driver.(*txDriver); !ok {
  41474. return nil, errors.New("ent: mutation is not running in a transaction")
  41475. }
  41476. tx := &Tx{config: m.config}
  41477. tx.init()
  41478. return tx, nil
  41479. }
  41480. // SetID sets the value of the id field. Note that this
  41481. // operation is only accepted on creation of WhatsappChannel entities.
  41482. func (m *WhatsappChannelMutation) SetID(id uint64) {
  41483. m.id = &id
  41484. }
  41485. // ID returns the ID value in the mutation. Note that the ID is only available
  41486. // if it was provided to the builder or after it was returned from the database.
  41487. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  41488. if m.id == nil {
  41489. return
  41490. }
  41491. return *m.id, true
  41492. }
  41493. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41494. // That means, if the mutation is applied within a transaction with an isolation level such
  41495. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41496. // or updated by the mutation.
  41497. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  41498. switch {
  41499. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41500. id, exists := m.ID()
  41501. if exists {
  41502. return []uint64{id}, nil
  41503. }
  41504. fallthrough
  41505. case m.op.Is(OpUpdate | OpDelete):
  41506. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  41507. default:
  41508. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41509. }
  41510. }
  41511. // SetCreatedAt sets the "created_at" field.
  41512. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  41513. m.created_at = &t
  41514. }
  41515. // CreatedAt returns the value of the "created_at" field in the mutation.
  41516. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  41517. v := m.created_at
  41518. if v == nil {
  41519. return
  41520. }
  41521. return *v, true
  41522. }
  41523. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  41524. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41526. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41527. if !m.op.Is(OpUpdateOne) {
  41528. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41529. }
  41530. if m.id == nil || m.oldValue == nil {
  41531. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41532. }
  41533. oldValue, err := m.oldValue(ctx)
  41534. if err != nil {
  41535. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41536. }
  41537. return oldValue.CreatedAt, nil
  41538. }
  41539. // ResetCreatedAt resets all changes to the "created_at" field.
  41540. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  41541. m.created_at = nil
  41542. }
  41543. // SetUpdatedAt sets the "updated_at" field.
  41544. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  41545. m.updated_at = &t
  41546. }
  41547. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41548. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  41549. v := m.updated_at
  41550. if v == nil {
  41551. return
  41552. }
  41553. return *v, true
  41554. }
  41555. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  41556. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41558. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41559. if !m.op.Is(OpUpdateOne) {
  41560. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41561. }
  41562. if m.id == nil || m.oldValue == nil {
  41563. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41564. }
  41565. oldValue, err := m.oldValue(ctx)
  41566. if err != nil {
  41567. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41568. }
  41569. return oldValue.UpdatedAt, nil
  41570. }
  41571. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41572. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  41573. m.updated_at = nil
  41574. }
  41575. // SetStatus sets the "status" field.
  41576. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  41577. m.status = &u
  41578. m.addstatus = nil
  41579. }
  41580. // Status returns the value of the "status" field in the mutation.
  41581. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  41582. v := m.status
  41583. if v == nil {
  41584. return
  41585. }
  41586. return *v, true
  41587. }
  41588. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  41589. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41591. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41592. if !m.op.Is(OpUpdateOne) {
  41593. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41594. }
  41595. if m.id == nil || m.oldValue == nil {
  41596. return v, errors.New("OldStatus requires an ID field in the mutation")
  41597. }
  41598. oldValue, err := m.oldValue(ctx)
  41599. if err != nil {
  41600. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41601. }
  41602. return oldValue.Status, nil
  41603. }
  41604. // AddStatus adds u to the "status" field.
  41605. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  41606. if m.addstatus != nil {
  41607. *m.addstatus += u
  41608. } else {
  41609. m.addstatus = &u
  41610. }
  41611. }
  41612. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41613. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  41614. v := m.addstatus
  41615. if v == nil {
  41616. return
  41617. }
  41618. return *v, true
  41619. }
  41620. // ClearStatus clears the value of the "status" field.
  41621. func (m *WhatsappChannelMutation) ClearStatus() {
  41622. m.status = nil
  41623. m.addstatus = nil
  41624. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  41625. }
  41626. // StatusCleared returns if the "status" field was cleared in this mutation.
  41627. func (m *WhatsappChannelMutation) StatusCleared() bool {
  41628. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  41629. return ok
  41630. }
  41631. // ResetStatus resets all changes to the "status" field.
  41632. func (m *WhatsappChannelMutation) ResetStatus() {
  41633. m.status = nil
  41634. m.addstatus = nil
  41635. delete(m.clearedFields, whatsappchannel.FieldStatus)
  41636. }
  41637. // SetDeletedAt sets the "deleted_at" field.
  41638. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  41639. m.deleted_at = &t
  41640. }
  41641. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41642. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  41643. v := m.deleted_at
  41644. if v == nil {
  41645. return
  41646. }
  41647. return *v, true
  41648. }
  41649. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  41650. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41652. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41653. if !m.op.Is(OpUpdateOne) {
  41654. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41655. }
  41656. if m.id == nil || m.oldValue == nil {
  41657. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41658. }
  41659. oldValue, err := m.oldValue(ctx)
  41660. if err != nil {
  41661. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41662. }
  41663. return oldValue.DeletedAt, nil
  41664. }
  41665. // ClearDeletedAt clears the value of the "deleted_at" field.
  41666. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  41667. m.deleted_at = nil
  41668. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  41669. }
  41670. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41671. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  41672. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  41673. return ok
  41674. }
  41675. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41676. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  41677. m.deleted_at = nil
  41678. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  41679. }
  41680. // SetAk sets the "ak" field.
  41681. func (m *WhatsappChannelMutation) SetAk(s string) {
  41682. m.ak = &s
  41683. }
  41684. // Ak returns the value of the "ak" field in the mutation.
  41685. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  41686. v := m.ak
  41687. if v == nil {
  41688. return
  41689. }
  41690. return *v, true
  41691. }
  41692. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  41693. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41695. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  41696. if !m.op.Is(OpUpdateOne) {
  41697. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  41698. }
  41699. if m.id == nil || m.oldValue == nil {
  41700. return v, errors.New("OldAk requires an ID field in the mutation")
  41701. }
  41702. oldValue, err := m.oldValue(ctx)
  41703. if err != nil {
  41704. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  41705. }
  41706. return oldValue.Ak, nil
  41707. }
  41708. // ClearAk clears the value of the "ak" field.
  41709. func (m *WhatsappChannelMutation) ClearAk() {
  41710. m.ak = nil
  41711. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  41712. }
  41713. // AkCleared returns if the "ak" field was cleared in this mutation.
  41714. func (m *WhatsappChannelMutation) AkCleared() bool {
  41715. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  41716. return ok
  41717. }
  41718. // ResetAk resets all changes to the "ak" field.
  41719. func (m *WhatsappChannelMutation) ResetAk() {
  41720. m.ak = nil
  41721. delete(m.clearedFields, whatsappchannel.FieldAk)
  41722. }
  41723. // SetSk sets the "sk" field.
  41724. func (m *WhatsappChannelMutation) SetSk(s string) {
  41725. m.sk = &s
  41726. }
  41727. // Sk returns the value of the "sk" field in the mutation.
  41728. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  41729. v := m.sk
  41730. if v == nil {
  41731. return
  41732. }
  41733. return *v, true
  41734. }
  41735. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  41736. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41738. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  41739. if !m.op.Is(OpUpdateOne) {
  41740. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  41741. }
  41742. if m.id == nil || m.oldValue == nil {
  41743. return v, errors.New("OldSk requires an ID field in the mutation")
  41744. }
  41745. oldValue, err := m.oldValue(ctx)
  41746. if err != nil {
  41747. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  41748. }
  41749. return oldValue.Sk, nil
  41750. }
  41751. // ResetSk resets all changes to the "sk" field.
  41752. func (m *WhatsappChannelMutation) ResetSk() {
  41753. m.sk = nil
  41754. }
  41755. // SetWaID sets the "wa_id" field.
  41756. func (m *WhatsappChannelMutation) SetWaID(s string) {
  41757. m.wa_id = &s
  41758. }
  41759. // WaID returns the value of the "wa_id" field in the mutation.
  41760. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  41761. v := m.wa_id
  41762. if v == nil {
  41763. return
  41764. }
  41765. return *v, true
  41766. }
  41767. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  41768. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41770. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  41771. if !m.op.Is(OpUpdateOne) {
  41772. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41773. }
  41774. if m.id == nil || m.oldValue == nil {
  41775. return v, errors.New("OldWaID requires an ID field in the mutation")
  41776. }
  41777. oldValue, err := m.oldValue(ctx)
  41778. if err != nil {
  41779. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  41780. }
  41781. return oldValue.WaID, nil
  41782. }
  41783. // ClearWaID clears the value of the "wa_id" field.
  41784. func (m *WhatsappChannelMutation) ClearWaID() {
  41785. m.wa_id = nil
  41786. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  41787. }
  41788. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  41789. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  41790. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  41791. return ok
  41792. }
  41793. // ResetWaID resets all changes to the "wa_id" field.
  41794. func (m *WhatsappChannelMutation) ResetWaID() {
  41795. m.wa_id = nil
  41796. delete(m.clearedFields, whatsappchannel.FieldWaID)
  41797. }
  41798. // SetWaName sets the "wa_name" field.
  41799. func (m *WhatsappChannelMutation) SetWaName(s string) {
  41800. m.wa_name = &s
  41801. }
  41802. // WaName returns the value of the "wa_name" field in the mutation.
  41803. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  41804. v := m.wa_name
  41805. if v == nil {
  41806. return
  41807. }
  41808. return *v, true
  41809. }
  41810. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  41811. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41813. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  41814. if !m.op.Is(OpUpdateOne) {
  41815. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  41816. }
  41817. if m.id == nil || m.oldValue == nil {
  41818. return v, errors.New("OldWaName requires an ID field in the mutation")
  41819. }
  41820. oldValue, err := m.oldValue(ctx)
  41821. if err != nil {
  41822. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  41823. }
  41824. return oldValue.WaName, nil
  41825. }
  41826. // ClearWaName clears the value of the "wa_name" field.
  41827. func (m *WhatsappChannelMutation) ClearWaName() {
  41828. m.wa_name = nil
  41829. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  41830. }
  41831. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  41832. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  41833. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  41834. return ok
  41835. }
  41836. // ResetWaName resets all changes to the "wa_name" field.
  41837. func (m *WhatsappChannelMutation) ResetWaName() {
  41838. m.wa_name = nil
  41839. delete(m.clearedFields, whatsappchannel.FieldWaName)
  41840. }
  41841. // SetWabaID sets the "waba_id" field.
  41842. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  41843. m.waba_id = &u
  41844. m.addwaba_id = nil
  41845. }
  41846. // WabaID returns the value of the "waba_id" field in the mutation.
  41847. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  41848. v := m.waba_id
  41849. if v == nil {
  41850. return
  41851. }
  41852. return *v, true
  41853. }
  41854. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  41855. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41857. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  41858. if !m.op.Is(OpUpdateOne) {
  41859. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  41860. }
  41861. if m.id == nil || m.oldValue == nil {
  41862. return v, errors.New("OldWabaID requires an ID field in the mutation")
  41863. }
  41864. oldValue, err := m.oldValue(ctx)
  41865. if err != nil {
  41866. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  41867. }
  41868. return oldValue.WabaID, nil
  41869. }
  41870. // AddWabaID adds u to the "waba_id" field.
  41871. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  41872. if m.addwaba_id != nil {
  41873. *m.addwaba_id += u
  41874. } else {
  41875. m.addwaba_id = &u
  41876. }
  41877. }
  41878. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  41879. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  41880. v := m.addwaba_id
  41881. if v == nil {
  41882. return
  41883. }
  41884. return *v, true
  41885. }
  41886. // ResetWabaID resets all changes to the "waba_id" field.
  41887. func (m *WhatsappChannelMutation) ResetWabaID() {
  41888. m.waba_id = nil
  41889. m.addwaba_id = nil
  41890. }
  41891. // SetBusinessID sets the "business_id" field.
  41892. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  41893. m.business_id = &u
  41894. m.addbusiness_id = nil
  41895. }
  41896. // BusinessID returns the value of the "business_id" field in the mutation.
  41897. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  41898. v := m.business_id
  41899. if v == nil {
  41900. return
  41901. }
  41902. return *v, true
  41903. }
  41904. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  41905. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41907. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  41908. if !m.op.Is(OpUpdateOne) {
  41909. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  41910. }
  41911. if m.id == nil || m.oldValue == nil {
  41912. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  41913. }
  41914. oldValue, err := m.oldValue(ctx)
  41915. if err != nil {
  41916. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  41917. }
  41918. return oldValue.BusinessID, nil
  41919. }
  41920. // AddBusinessID adds u to the "business_id" field.
  41921. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  41922. if m.addbusiness_id != nil {
  41923. *m.addbusiness_id += u
  41924. } else {
  41925. m.addbusiness_id = &u
  41926. }
  41927. }
  41928. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  41929. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  41930. v := m.addbusiness_id
  41931. if v == nil {
  41932. return
  41933. }
  41934. return *v, true
  41935. }
  41936. // ResetBusinessID resets all changes to the "business_id" field.
  41937. func (m *WhatsappChannelMutation) ResetBusinessID() {
  41938. m.business_id = nil
  41939. m.addbusiness_id = nil
  41940. }
  41941. // SetOrganizationID sets the "organization_id" field.
  41942. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  41943. m.organization_id = &u
  41944. m.addorganization_id = nil
  41945. }
  41946. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41947. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  41948. v := m.organization_id
  41949. if v == nil {
  41950. return
  41951. }
  41952. return *v, true
  41953. }
  41954. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  41955. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41957. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41958. if !m.op.Is(OpUpdateOne) {
  41959. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41960. }
  41961. if m.id == nil || m.oldValue == nil {
  41962. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41963. }
  41964. oldValue, err := m.oldValue(ctx)
  41965. if err != nil {
  41966. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41967. }
  41968. return oldValue.OrganizationID, nil
  41969. }
  41970. // AddOrganizationID adds u to the "organization_id" field.
  41971. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  41972. if m.addorganization_id != nil {
  41973. *m.addorganization_id += u
  41974. } else {
  41975. m.addorganization_id = &u
  41976. }
  41977. }
  41978. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41979. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  41980. v := m.addorganization_id
  41981. if v == nil {
  41982. return
  41983. }
  41984. return *v, true
  41985. }
  41986. // ClearOrganizationID clears the value of the "organization_id" field.
  41987. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  41988. m.organization_id = nil
  41989. m.addorganization_id = nil
  41990. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  41991. }
  41992. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41993. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  41994. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  41995. return ok
  41996. }
  41997. // ResetOrganizationID resets all changes to the "organization_id" field.
  41998. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  41999. m.organization_id = nil
  42000. m.addorganization_id = nil
  42001. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  42002. }
  42003. // SetVerifyAccount sets the "verify_account" field.
  42004. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  42005. m.verify_account = &s
  42006. }
  42007. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  42008. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  42009. v := m.verify_account
  42010. if v == nil {
  42011. return
  42012. }
  42013. return *v, true
  42014. }
  42015. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  42016. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  42017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42018. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  42019. if !m.op.Is(OpUpdateOne) {
  42020. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  42021. }
  42022. if m.id == nil || m.oldValue == nil {
  42023. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  42024. }
  42025. oldValue, err := m.oldValue(ctx)
  42026. if err != nil {
  42027. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  42028. }
  42029. return oldValue.VerifyAccount, nil
  42030. }
  42031. // ResetVerifyAccount resets all changes to the "verify_account" field.
  42032. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  42033. m.verify_account = nil
  42034. }
  42035. // Where appends a list predicates to the WhatsappChannelMutation builder.
  42036. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  42037. m.predicates = append(m.predicates, ps...)
  42038. }
  42039. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  42040. // users can use type-assertion to append predicates that do not depend on any generated package.
  42041. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  42042. p := make([]predicate.WhatsappChannel, len(ps))
  42043. for i := range ps {
  42044. p[i] = ps[i]
  42045. }
  42046. m.Where(p...)
  42047. }
  42048. // Op returns the operation name.
  42049. func (m *WhatsappChannelMutation) Op() Op {
  42050. return m.op
  42051. }
  42052. // SetOp allows setting the mutation operation.
  42053. func (m *WhatsappChannelMutation) SetOp(op Op) {
  42054. m.op = op
  42055. }
  42056. // Type returns the node type of this mutation (WhatsappChannel).
  42057. func (m *WhatsappChannelMutation) Type() string {
  42058. return m.typ
  42059. }
  42060. // Fields returns all fields that were changed during this mutation. Note that in
  42061. // order to get all numeric fields that were incremented/decremented, call
  42062. // AddedFields().
  42063. func (m *WhatsappChannelMutation) Fields() []string {
  42064. fields := make([]string, 0, 12)
  42065. if m.created_at != nil {
  42066. fields = append(fields, whatsappchannel.FieldCreatedAt)
  42067. }
  42068. if m.updated_at != nil {
  42069. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  42070. }
  42071. if m.status != nil {
  42072. fields = append(fields, whatsappchannel.FieldStatus)
  42073. }
  42074. if m.deleted_at != nil {
  42075. fields = append(fields, whatsappchannel.FieldDeletedAt)
  42076. }
  42077. if m.ak != nil {
  42078. fields = append(fields, whatsappchannel.FieldAk)
  42079. }
  42080. if m.sk != nil {
  42081. fields = append(fields, whatsappchannel.FieldSk)
  42082. }
  42083. if m.wa_id != nil {
  42084. fields = append(fields, whatsappchannel.FieldWaID)
  42085. }
  42086. if m.wa_name != nil {
  42087. fields = append(fields, whatsappchannel.FieldWaName)
  42088. }
  42089. if m.waba_id != nil {
  42090. fields = append(fields, whatsappchannel.FieldWabaID)
  42091. }
  42092. if m.business_id != nil {
  42093. fields = append(fields, whatsappchannel.FieldBusinessID)
  42094. }
  42095. if m.organization_id != nil {
  42096. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42097. }
  42098. if m.verify_account != nil {
  42099. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  42100. }
  42101. return fields
  42102. }
  42103. // Field returns the value of a field with the given name. The second boolean
  42104. // return value indicates that this field was not set, or was not defined in the
  42105. // schema.
  42106. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  42107. switch name {
  42108. case whatsappchannel.FieldCreatedAt:
  42109. return m.CreatedAt()
  42110. case whatsappchannel.FieldUpdatedAt:
  42111. return m.UpdatedAt()
  42112. case whatsappchannel.FieldStatus:
  42113. return m.Status()
  42114. case whatsappchannel.FieldDeletedAt:
  42115. return m.DeletedAt()
  42116. case whatsappchannel.FieldAk:
  42117. return m.Ak()
  42118. case whatsappchannel.FieldSk:
  42119. return m.Sk()
  42120. case whatsappchannel.FieldWaID:
  42121. return m.WaID()
  42122. case whatsappchannel.FieldWaName:
  42123. return m.WaName()
  42124. case whatsappchannel.FieldWabaID:
  42125. return m.WabaID()
  42126. case whatsappchannel.FieldBusinessID:
  42127. return m.BusinessID()
  42128. case whatsappchannel.FieldOrganizationID:
  42129. return m.OrganizationID()
  42130. case whatsappchannel.FieldVerifyAccount:
  42131. return m.VerifyAccount()
  42132. }
  42133. return nil, false
  42134. }
  42135. // OldField returns the old value of the field from the database. An error is
  42136. // returned if the mutation operation is not UpdateOne, or the query to the
  42137. // database failed.
  42138. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42139. switch name {
  42140. case whatsappchannel.FieldCreatedAt:
  42141. return m.OldCreatedAt(ctx)
  42142. case whatsappchannel.FieldUpdatedAt:
  42143. return m.OldUpdatedAt(ctx)
  42144. case whatsappchannel.FieldStatus:
  42145. return m.OldStatus(ctx)
  42146. case whatsappchannel.FieldDeletedAt:
  42147. return m.OldDeletedAt(ctx)
  42148. case whatsappchannel.FieldAk:
  42149. return m.OldAk(ctx)
  42150. case whatsappchannel.FieldSk:
  42151. return m.OldSk(ctx)
  42152. case whatsappchannel.FieldWaID:
  42153. return m.OldWaID(ctx)
  42154. case whatsappchannel.FieldWaName:
  42155. return m.OldWaName(ctx)
  42156. case whatsappchannel.FieldWabaID:
  42157. return m.OldWabaID(ctx)
  42158. case whatsappchannel.FieldBusinessID:
  42159. return m.OldBusinessID(ctx)
  42160. case whatsappchannel.FieldOrganizationID:
  42161. return m.OldOrganizationID(ctx)
  42162. case whatsappchannel.FieldVerifyAccount:
  42163. return m.OldVerifyAccount(ctx)
  42164. }
  42165. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  42166. }
  42167. // SetField sets the value of a field with the given name. It returns an error if
  42168. // the field is not defined in the schema, or if the type mismatched the field
  42169. // type.
  42170. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  42171. switch name {
  42172. case whatsappchannel.FieldCreatedAt:
  42173. v, ok := value.(time.Time)
  42174. if !ok {
  42175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42176. }
  42177. m.SetCreatedAt(v)
  42178. return nil
  42179. case whatsappchannel.FieldUpdatedAt:
  42180. v, ok := value.(time.Time)
  42181. if !ok {
  42182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42183. }
  42184. m.SetUpdatedAt(v)
  42185. return nil
  42186. case whatsappchannel.FieldStatus:
  42187. v, ok := value.(uint8)
  42188. if !ok {
  42189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42190. }
  42191. m.SetStatus(v)
  42192. return nil
  42193. case whatsappchannel.FieldDeletedAt:
  42194. v, ok := value.(time.Time)
  42195. if !ok {
  42196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42197. }
  42198. m.SetDeletedAt(v)
  42199. return nil
  42200. case whatsappchannel.FieldAk:
  42201. v, ok := value.(string)
  42202. if !ok {
  42203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42204. }
  42205. m.SetAk(v)
  42206. return nil
  42207. case whatsappchannel.FieldSk:
  42208. v, ok := value.(string)
  42209. if !ok {
  42210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42211. }
  42212. m.SetSk(v)
  42213. return nil
  42214. case whatsappchannel.FieldWaID:
  42215. v, ok := value.(string)
  42216. if !ok {
  42217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42218. }
  42219. m.SetWaID(v)
  42220. return nil
  42221. case whatsappchannel.FieldWaName:
  42222. v, ok := value.(string)
  42223. if !ok {
  42224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42225. }
  42226. m.SetWaName(v)
  42227. return nil
  42228. case whatsappchannel.FieldWabaID:
  42229. v, ok := value.(uint64)
  42230. if !ok {
  42231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42232. }
  42233. m.SetWabaID(v)
  42234. return nil
  42235. case whatsappchannel.FieldBusinessID:
  42236. v, ok := value.(uint64)
  42237. if !ok {
  42238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42239. }
  42240. m.SetBusinessID(v)
  42241. return nil
  42242. case whatsappchannel.FieldOrganizationID:
  42243. v, ok := value.(uint64)
  42244. if !ok {
  42245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42246. }
  42247. m.SetOrganizationID(v)
  42248. return nil
  42249. case whatsappchannel.FieldVerifyAccount:
  42250. v, ok := value.(string)
  42251. if !ok {
  42252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42253. }
  42254. m.SetVerifyAccount(v)
  42255. return nil
  42256. }
  42257. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  42258. }
  42259. // AddedFields returns all numeric fields that were incremented/decremented during
  42260. // this mutation.
  42261. func (m *WhatsappChannelMutation) AddedFields() []string {
  42262. var fields []string
  42263. if m.addstatus != nil {
  42264. fields = append(fields, whatsappchannel.FieldStatus)
  42265. }
  42266. if m.addwaba_id != nil {
  42267. fields = append(fields, whatsappchannel.FieldWabaID)
  42268. }
  42269. if m.addbusiness_id != nil {
  42270. fields = append(fields, whatsappchannel.FieldBusinessID)
  42271. }
  42272. if m.addorganization_id != nil {
  42273. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42274. }
  42275. return fields
  42276. }
  42277. // AddedField returns the numeric value that was incremented/decremented on a field
  42278. // with the given name. The second boolean return value indicates that this field
  42279. // was not set, or was not defined in the schema.
  42280. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  42281. switch name {
  42282. case whatsappchannel.FieldStatus:
  42283. return m.AddedStatus()
  42284. case whatsappchannel.FieldWabaID:
  42285. return m.AddedWabaID()
  42286. case whatsappchannel.FieldBusinessID:
  42287. return m.AddedBusinessID()
  42288. case whatsappchannel.FieldOrganizationID:
  42289. return m.AddedOrganizationID()
  42290. }
  42291. return nil, false
  42292. }
  42293. // AddField adds the value to the field with the given name. It returns an error if
  42294. // the field is not defined in the schema, or if the type mismatched the field
  42295. // type.
  42296. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  42297. switch name {
  42298. case whatsappchannel.FieldStatus:
  42299. v, ok := value.(int8)
  42300. if !ok {
  42301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42302. }
  42303. m.AddStatus(v)
  42304. return nil
  42305. case whatsappchannel.FieldWabaID:
  42306. v, ok := value.(int64)
  42307. if !ok {
  42308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42309. }
  42310. m.AddWabaID(v)
  42311. return nil
  42312. case whatsappchannel.FieldBusinessID:
  42313. v, ok := value.(int64)
  42314. if !ok {
  42315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42316. }
  42317. m.AddBusinessID(v)
  42318. return nil
  42319. case whatsappchannel.FieldOrganizationID:
  42320. v, ok := value.(int64)
  42321. if !ok {
  42322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42323. }
  42324. m.AddOrganizationID(v)
  42325. return nil
  42326. }
  42327. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  42328. }
  42329. // ClearedFields returns all nullable fields that were cleared during this
  42330. // mutation.
  42331. func (m *WhatsappChannelMutation) ClearedFields() []string {
  42332. var fields []string
  42333. if m.FieldCleared(whatsappchannel.FieldStatus) {
  42334. fields = append(fields, whatsappchannel.FieldStatus)
  42335. }
  42336. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  42337. fields = append(fields, whatsappchannel.FieldDeletedAt)
  42338. }
  42339. if m.FieldCleared(whatsappchannel.FieldAk) {
  42340. fields = append(fields, whatsappchannel.FieldAk)
  42341. }
  42342. if m.FieldCleared(whatsappchannel.FieldWaID) {
  42343. fields = append(fields, whatsappchannel.FieldWaID)
  42344. }
  42345. if m.FieldCleared(whatsappchannel.FieldWaName) {
  42346. fields = append(fields, whatsappchannel.FieldWaName)
  42347. }
  42348. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  42349. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42350. }
  42351. return fields
  42352. }
  42353. // FieldCleared returns a boolean indicating if a field with the given name was
  42354. // cleared in this mutation.
  42355. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  42356. _, ok := m.clearedFields[name]
  42357. return ok
  42358. }
  42359. // ClearField clears the value of the field with the given name. It returns an
  42360. // error if the field is not defined in the schema.
  42361. func (m *WhatsappChannelMutation) ClearField(name string) error {
  42362. switch name {
  42363. case whatsappchannel.FieldStatus:
  42364. m.ClearStatus()
  42365. return nil
  42366. case whatsappchannel.FieldDeletedAt:
  42367. m.ClearDeletedAt()
  42368. return nil
  42369. case whatsappchannel.FieldAk:
  42370. m.ClearAk()
  42371. return nil
  42372. case whatsappchannel.FieldWaID:
  42373. m.ClearWaID()
  42374. return nil
  42375. case whatsappchannel.FieldWaName:
  42376. m.ClearWaName()
  42377. return nil
  42378. case whatsappchannel.FieldOrganizationID:
  42379. m.ClearOrganizationID()
  42380. return nil
  42381. }
  42382. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  42383. }
  42384. // ResetField resets all changes in the mutation for the field with the given name.
  42385. // It returns an error if the field is not defined in the schema.
  42386. func (m *WhatsappChannelMutation) ResetField(name string) error {
  42387. switch name {
  42388. case whatsappchannel.FieldCreatedAt:
  42389. m.ResetCreatedAt()
  42390. return nil
  42391. case whatsappchannel.FieldUpdatedAt:
  42392. m.ResetUpdatedAt()
  42393. return nil
  42394. case whatsappchannel.FieldStatus:
  42395. m.ResetStatus()
  42396. return nil
  42397. case whatsappchannel.FieldDeletedAt:
  42398. m.ResetDeletedAt()
  42399. return nil
  42400. case whatsappchannel.FieldAk:
  42401. m.ResetAk()
  42402. return nil
  42403. case whatsappchannel.FieldSk:
  42404. m.ResetSk()
  42405. return nil
  42406. case whatsappchannel.FieldWaID:
  42407. m.ResetWaID()
  42408. return nil
  42409. case whatsappchannel.FieldWaName:
  42410. m.ResetWaName()
  42411. return nil
  42412. case whatsappchannel.FieldWabaID:
  42413. m.ResetWabaID()
  42414. return nil
  42415. case whatsappchannel.FieldBusinessID:
  42416. m.ResetBusinessID()
  42417. return nil
  42418. case whatsappchannel.FieldOrganizationID:
  42419. m.ResetOrganizationID()
  42420. return nil
  42421. case whatsappchannel.FieldVerifyAccount:
  42422. m.ResetVerifyAccount()
  42423. return nil
  42424. }
  42425. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  42426. }
  42427. // AddedEdges returns all edge names that were set/added in this mutation.
  42428. func (m *WhatsappChannelMutation) AddedEdges() []string {
  42429. edges := make([]string, 0, 0)
  42430. return edges
  42431. }
  42432. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42433. // name in this mutation.
  42434. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  42435. return nil
  42436. }
  42437. // RemovedEdges returns all edge names that were removed in this mutation.
  42438. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  42439. edges := make([]string, 0, 0)
  42440. return edges
  42441. }
  42442. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42443. // the given name in this mutation.
  42444. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  42445. return nil
  42446. }
  42447. // ClearedEdges returns all edge names that were cleared in this mutation.
  42448. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  42449. edges := make([]string, 0, 0)
  42450. return edges
  42451. }
  42452. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42453. // was cleared in this mutation.
  42454. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  42455. return false
  42456. }
  42457. // ClearEdge clears the value of the edge with the given name. It returns an error
  42458. // if that edge is not defined in the schema.
  42459. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  42460. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  42461. }
  42462. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42463. // It returns an error if the edge is not defined in the schema.
  42464. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  42465. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  42466. }
  42467. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  42468. type WorkExperienceMutation struct {
  42469. config
  42470. op Op
  42471. typ string
  42472. id *uint64
  42473. created_at *time.Time
  42474. updated_at *time.Time
  42475. deleted_at *time.Time
  42476. start_date *time.Time
  42477. end_date *time.Time
  42478. company *string
  42479. experience *string
  42480. organization_id *uint64
  42481. addorganization_id *int64
  42482. clearedFields map[string]struct{}
  42483. employee *uint64
  42484. clearedemployee bool
  42485. done bool
  42486. oldValue func(context.Context) (*WorkExperience, error)
  42487. predicates []predicate.WorkExperience
  42488. }
  42489. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  42490. // workexperienceOption allows management of the mutation configuration using functional options.
  42491. type workexperienceOption func(*WorkExperienceMutation)
  42492. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  42493. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  42494. m := &WorkExperienceMutation{
  42495. config: c,
  42496. op: op,
  42497. typ: TypeWorkExperience,
  42498. clearedFields: make(map[string]struct{}),
  42499. }
  42500. for _, opt := range opts {
  42501. opt(m)
  42502. }
  42503. return m
  42504. }
  42505. // withWorkExperienceID sets the ID field of the mutation.
  42506. func withWorkExperienceID(id uint64) workexperienceOption {
  42507. return func(m *WorkExperienceMutation) {
  42508. var (
  42509. err error
  42510. once sync.Once
  42511. value *WorkExperience
  42512. )
  42513. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  42514. once.Do(func() {
  42515. if m.done {
  42516. err = errors.New("querying old values post mutation is not allowed")
  42517. } else {
  42518. value, err = m.Client().WorkExperience.Get(ctx, id)
  42519. }
  42520. })
  42521. return value, err
  42522. }
  42523. m.id = &id
  42524. }
  42525. }
  42526. // withWorkExperience sets the old WorkExperience of the mutation.
  42527. func withWorkExperience(node *WorkExperience) workexperienceOption {
  42528. return func(m *WorkExperienceMutation) {
  42529. m.oldValue = func(context.Context) (*WorkExperience, error) {
  42530. return node, nil
  42531. }
  42532. m.id = &node.ID
  42533. }
  42534. }
  42535. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42536. // executed in a transaction (ent.Tx), a transactional client is returned.
  42537. func (m WorkExperienceMutation) Client() *Client {
  42538. client := &Client{config: m.config}
  42539. client.init()
  42540. return client
  42541. }
  42542. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42543. // it returns an error otherwise.
  42544. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  42545. if _, ok := m.driver.(*txDriver); !ok {
  42546. return nil, errors.New("ent: mutation is not running in a transaction")
  42547. }
  42548. tx := &Tx{config: m.config}
  42549. tx.init()
  42550. return tx, nil
  42551. }
  42552. // SetID sets the value of the id field. Note that this
  42553. // operation is only accepted on creation of WorkExperience entities.
  42554. func (m *WorkExperienceMutation) SetID(id uint64) {
  42555. m.id = &id
  42556. }
  42557. // ID returns the ID value in the mutation. Note that the ID is only available
  42558. // if it was provided to the builder or after it was returned from the database.
  42559. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  42560. if m.id == nil {
  42561. return
  42562. }
  42563. return *m.id, true
  42564. }
  42565. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42566. // That means, if the mutation is applied within a transaction with an isolation level such
  42567. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42568. // or updated by the mutation.
  42569. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  42570. switch {
  42571. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42572. id, exists := m.ID()
  42573. if exists {
  42574. return []uint64{id}, nil
  42575. }
  42576. fallthrough
  42577. case m.op.Is(OpUpdate | OpDelete):
  42578. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  42579. default:
  42580. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42581. }
  42582. }
  42583. // SetCreatedAt sets the "created_at" field.
  42584. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  42585. m.created_at = &t
  42586. }
  42587. // CreatedAt returns the value of the "created_at" field in the mutation.
  42588. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  42589. v := m.created_at
  42590. if v == nil {
  42591. return
  42592. }
  42593. return *v, true
  42594. }
  42595. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  42596. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42598. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42599. if !m.op.Is(OpUpdateOne) {
  42600. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42601. }
  42602. if m.id == nil || m.oldValue == nil {
  42603. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42604. }
  42605. oldValue, err := m.oldValue(ctx)
  42606. if err != nil {
  42607. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42608. }
  42609. return oldValue.CreatedAt, nil
  42610. }
  42611. // ResetCreatedAt resets all changes to the "created_at" field.
  42612. func (m *WorkExperienceMutation) ResetCreatedAt() {
  42613. m.created_at = nil
  42614. }
  42615. // SetUpdatedAt sets the "updated_at" field.
  42616. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  42617. m.updated_at = &t
  42618. }
  42619. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42620. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  42621. v := m.updated_at
  42622. if v == nil {
  42623. return
  42624. }
  42625. return *v, true
  42626. }
  42627. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  42628. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42630. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42631. if !m.op.Is(OpUpdateOne) {
  42632. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42633. }
  42634. if m.id == nil || m.oldValue == nil {
  42635. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42636. }
  42637. oldValue, err := m.oldValue(ctx)
  42638. if err != nil {
  42639. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42640. }
  42641. return oldValue.UpdatedAt, nil
  42642. }
  42643. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42644. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  42645. m.updated_at = nil
  42646. }
  42647. // SetDeletedAt sets the "deleted_at" field.
  42648. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  42649. m.deleted_at = &t
  42650. }
  42651. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42652. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  42653. v := m.deleted_at
  42654. if v == nil {
  42655. return
  42656. }
  42657. return *v, true
  42658. }
  42659. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  42660. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42662. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42663. if !m.op.Is(OpUpdateOne) {
  42664. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42665. }
  42666. if m.id == nil || m.oldValue == nil {
  42667. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42668. }
  42669. oldValue, err := m.oldValue(ctx)
  42670. if err != nil {
  42671. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42672. }
  42673. return oldValue.DeletedAt, nil
  42674. }
  42675. // ClearDeletedAt clears the value of the "deleted_at" field.
  42676. func (m *WorkExperienceMutation) ClearDeletedAt() {
  42677. m.deleted_at = nil
  42678. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  42679. }
  42680. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42681. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  42682. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  42683. return ok
  42684. }
  42685. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42686. func (m *WorkExperienceMutation) ResetDeletedAt() {
  42687. m.deleted_at = nil
  42688. delete(m.clearedFields, workexperience.FieldDeletedAt)
  42689. }
  42690. // SetEmployeeID sets the "employee_id" field.
  42691. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  42692. m.employee = &u
  42693. }
  42694. // EmployeeID returns the value of the "employee_id" field in the mutation.
  42695. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  42696. v := m.employee
  42697. if v == nil {
  42698. return
  42699. }
  42700. return *v, true
  42701. }
  42702. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  42703. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42705. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  42706. if !m.op.Is(OpUpdateOne) {
  42707. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  42708. }
  42709. if m.id == nil || m.oldValue == nil {
  42710. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  42711. }
  42712. oldValue, err := m.oldValue(ctx)
  42713. if err != nil {
  42714. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  42715. }
  42716. return oldValue.EmployeeID, nil
  42717. }
  42718. // ResetEmployeeID resets all changes to the "employee_id" field.
  42719. func (m *WorkExperienceMutation) ResetEmployeeID() {
  42720. m.employee = nil
  42721. }
  42722. // SetStartDate sets the "start_date" field.
  42723. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  42724. m.start_date = &t
  42725. }
  42726. // StartDate returns the value of the "start_date" field in the mutation.
  42727. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  42728. v := m.start_date
  42729. if v == nil {
  42730. return
  42731. }
  42732. return *v, true
  42733. }
  42734. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  42735. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42737. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  42738. if !m.op.Is(OpUpdateOne) {
  42739. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  42740. }
  42741. if m.id == nil || m.oldValue == nil {
  42742. return v, errors.New("OldStartDate requires an ID field in the mutation")
  42743. }
  42744. oldValue, err := m.oldValue(ctx)
  42745. if err != nil {
  42746. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  42747. }
  42748. return oldValue.StartDate, nil
  42749. }
  42750. // ResetStartDate resets all changes to the "start_date" field.
  42751. func (m *WorkExperienceMutation) ResetStartDate() {
  42752. m.start_date = nil
  42753. }
  42754. // SetEndDate sets the "end_date" field.
  42755. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  42756. m.end_date = &t
  42757. }
  42758. // EndDate returns the value of the "end_date" field in the mutation.
  42759. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  42760. v := m.end_date
  42761. if v == nil {
  42762. return
  42763. }
  42764. return *v, true
  42765. }
  42766. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  42767. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42769. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  42770. if !m.op.Is(OpUpdateOne) {
  42771. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  42772. }
  42773. if m.id == nil || m.oldValue == nil {
  42774. return v, errors.New("OldEndDate requires an ID field in the mutation")
  42775. }
  42776. oldValue, err := m.oldValue(ctx)
  42777. if err != nil {
  42778. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  42779. }
  42780. return oldValue.EndDate, nil
  42781. }
  42782. // ResetEndDate resets all changes to the "end_date" field.
  42783. func (m *WorkExperienceMutation) ResetEndDate() {
  42784. m.end_date = nil
  42785. }
  42786. // SetCompany sets the "company" field.
  42787. func (m *WorkExperienceMutation) SetCompany(s string) {
  42788. m.company = &s
  42789. }
  42790. // Company returns the value of the "company" field in the mutation.
  42791. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  42792. v := m.company
  42793. if v == nil {
  42794. return
  42795. }
  42796. return *v, true
  42797. }
  42798. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  42799. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42801. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  42802. if !m.op.Is(OpUpdateOne) {
  42803. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  42804. }
  42805. if m.id == nil || m.oldValue == nil {
  42806. return v, errors.New("OldCompany requires an ID field in the mutation")
  42807. }
  42808. oldValue, err := m.oldValue(ctx)
  42809. if err != nil {
  42810. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  42811. }
  42812. return oldValue.Company, nil
  42813. }
  42814. // ResetCompany resets all changes to the "company" field.
  42815. func (m *WorkExperienceMutation) ResetCompany() {
  42816. m.company = nil
  42817. }
  42818. // SetExperience sets the "experience" field.
  42819. func (m *WorkExperienceMutation) SetExperience(s string) {
  42820. m.experience = &s
  42821. }
  42822. // Experience returns the value of the "experience" field in the mutation.
  42823. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  42824. v := m.experience
  42825. if v == nil {
  42826. return
  42827. }
  42828. return *v, true
  42829. }
  42830. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  42831. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42833. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  42834. if !m.op.Is(OpUpdateOne) {
  42835. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  42836. }
  42837. if m.id == nil || m.oldValue == nil {
  42838. return v, errors.New("OldExperience requires an ID field in the mutation")
  42839. }
  42840. oldValue, err := m.oldValue(ctx)
  42841. if err != nil {
  42842. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  42843. }
  42844. return oldValue.Experience, nil
  42845. }
  42846. // ResetExperience resets all changes to the "experience" field.
  42847. func (m *WorkExperienceMutation) ResetExperience() {
  42848. m.experience = nil
  42849. }
  42850. // SetOrganizationID sets the "organization_id" field.
  42851. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  42852. m.organization_id = &u
  42853. m.addorganization_id = nil
  42854. }
  42855. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42856. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  42857. v := m.organization_id
  42858. if v == nil {
  42859. return
  42860. }
  42861. return *v, true
  42862. }
  42863. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  42864. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42866. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42867. if !m.op.Is(OpUpdateOne) {
  42868. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42869. }
  42870. if m.id == nil || m.oldValue == nil {
  42871. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42872. }
  42873. oldValue, err := m.oldValue(ctx)
  42874. if err != nil {
  42875. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42876. }
  42877. return oldValue.OrganizationID, nil
  42878. }
  42879. // AddOrganizationID adds u to the "organization_id" field.
  42880. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  42881. if m.addorganization_id != nil {
  42882. *m.addorganization_id += u
  42883. } else {
  42884. m.addorganization_id = &u
  42885. }
  42886. }
  42887. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42888. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  42889. v := m.addorganization_id
  42890. if v == nil {
  42891. return
  42892. }
  42893. return *v, true
  42894. }
  42895. // ResetOrganizationID resets all changes to the "organization_id" field.
  42896. func (m *WorkExperienceMutation) ResetOrganizationID() {
  42897. m.organization_id = nil
  42898. m.addorganization_id = nil
  42899. }
  42900. // ClearEmployee clears the "employee" edge to the Employee entity.
  42901. func (m *WorkExperienceMutation) ClearEmployee() {
  42902. m.clearedemployee = true
  42903. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  42904. }
  42905. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  42906. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  42907. return m.clearedemployee
  42908. }
  42909. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  42910. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42911. // EmployeeID instead. It exists only for internal usage by the builders.
  42912. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  42913. if id := m.employee; id != nil {
  42914. ids = append(ids, *id)
  42915. }
  42916. return
  42917. }
  42918. // ResetEmployee resets all changes to the "employee" edge.
  42919. func (m *WorkExperienceMutation) ResetEmployee() {
  42920. m.employee = nil
  42921. m.clearedemployee = false
  42922. }
  42923. // Where appends a list predicates to the WorkExperienceMutation builder.
  42924. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  42925. m.predicates = append(m.predicates, ps...)
  42926. }
  42927. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  42928. // users can use type-assertion to append predicates that do not depend on any generated package.
  42929. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  42930. p := make([]predicate.WorkExperience, len(ps))
  42931. for i := range ps {
  42932. p[i] = ps[i]
  42933. }
  42934. m.Where(p...)
  42935. }
  42936. // Op returns the operation name.
  42937. func (m *WorkExperienceMutation) Op() Op {
  42938. return m.op
  42939. }
  42940. // SetOp allows setting the mutation operation.
  42941. func (m *WorkExperienceMutation) SetOp(op Op) {
  42942. m.op = op
  42943. }
  42944. // Type returns the node type of this mutation (WorkExperience).
  42945. func (m *WorkExperienceMutation) Type() string {
  42946. return m.typ
  42947. }
  42948. // Fields returns all fields that were changed during this mutation. Note that in
  42949. // order to get all numeric fields that were incremented/decremented, call
  42950. // AddedFields().
  42951. func (m *WorkExperienceMutation) Fields() []string {
  42952. fields := make([]string, 0, 9)
  42953. if m.created_at != nil {
  42954. fields = append(fields, workexperience.FieldCreatedAt)
  42955. }
  42956. if m.updated_at != nil {
  42957. fields = append(fields, workexperience.FieldUpdatedAt)
  42958. }
  42959. if m.deleted_at != nil {
  42960. fields = append(fields, workexperience.FieldDeletedAt)
  42961. }
  42962. if m.employee != nil {
  42963. fields = append(fields, workexperience.FieldEmployeeID)
  42964. }
  42965. if m.start_date != nil {
  42966. fields = append(fields, workexperience.FieldStartDate)
  42967. }
  42968. if m.end_date != nil {
  42969. fields = append(fields, workexperience.FieldEndDate)
  42970. }
  42971. if m.company != nil {
  42972. fields = append(fields, workexperience.FieldCompany)
  42973. }
  42974. if m.experience != nil {
  42975. fields = append(fields, workexperience.FieldExperience)
  42976. }
  42977. if m.organization_id != nil {
  42978. fields = append(fields, workexperience.FieldOrganizationID)
  42979. }
  42980. return fields
  42981. }
  42982. // Field returns the value of a field with the given name. The second boolean
  42983. // return value indicates that this field was not set, or was not defined in the
  42984. // schema.
  42985. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  42986. switch name {
  42987. case workexperience.FieldCreatedAt:
  42988. return m.CreatedAt()
  42989. case workexperience.FieldUpdatedAt:
  42990. return m.UpdatedAt()
  42991. case workexperience.FieldDeletedAt:
  42992. return m.DeletedAt()
  42993. case workexperience.FieldEmployeeID:
  42994. return m.EmployeeID()
  42995. case workexperience.FieldStartDate:
  42996. return m.StartDate()
  42997. case workexperience.FieldEndDate:
  42998. return m.EndDate()
  42999. case workexperience.FieldCompany:
  43000. return m.Company()
  43001. case workexperience.FieldExperience:
  43002. return m.Experience()
  43003. case workexperience.FieldOrganizationID:
  43004. return m.OrganizationID()
  43005. }
  43006. return nil, false
  43007. }
  43008. // OldField returns the old value of the field from the database. An error is
  43009. // returned if the mutation operation is not UpdateOne, or the query to the
  43010. // database failed.
  43011. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43012. switch name {
  43013. case workexperience.FieldCreatedAt:
  43014. return m.OldCreatedAt(ctx)
  43015. case workexperience.FieldUpdatedAt:
  43016. return m.OldUpdatedAt(ctx)
  43017. case workexperience.FieldDeletedAt:
  43018. return m.OldDeletedAt(ctx)
  43019. case workexperience.FieldEmployeeID:
  43020. return m.OldEmployeeID(ctx)
  43021. case workexperience.FieldStartDate:
  43022. return m.OldStartDate(ctx)
  43023. case workexperience.FieldEndDate:
  43024. return m.OldEndDate(ctx)
  43025. case workexperience.FieldCompany:
  43026. return m.OldCompany(ctx)
  43027. case workexperience.FieldExperience:
  43028. return m.OldExperience(ctx)
  43029. case workexperience.FieldOrganizationID:
  43030. return m.OldOrganizationID(ctx)
  43031. }
  43032. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  43033. }
  43034. // SetField sets the value of a field with the given name. It returns an error if
  43035. // the field is not defined in the schema, or if the type mismatched the field
  43036. // type.
  43037. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  43038. switch name {
  43039. case workexperience.FieldCreatedAt:
  43040. v, ok := value.(time.Time)
  43041. if !ok {
  43042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43043. }
  43044. m.SetCreatedAt(v)
  43045. return nil
  43046. case workexperience.FieldUpdatedAt:
  43047. v, ok := value.(time.Time)
  43048. if !ok {
  43049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43050. }
  43051. m.SetUpdatedAt(v)
  43052. return nil
  43053. case workexperience.FieldDeletedAt:
  43054. v, ok := value.(time.Time)
  43055. if !ok {
  43056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43057. }
  43058. m.SetDeletedAt(v)
  43059. return nil
  43060. case workexperience.FieldEmployeeID:
  43061. v, ok := value.(uint64)
  43062. if !ok {
  43063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43064. }
  43065. m.SetEmployeeID(v)
  43066. return nil
  43067. case workexperience.FieldStartDate:
  43068. v, ok := value.(time.Time)
  43069. if !ok {
  43070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43071. }
  43072. m.SetStartDate(v)
  43073. return nil
  43074. case workexperience.FieldEndDate:
  43075. v, ok := value.(time.Time)
  43076. if !ok {
  43077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43078. }
  43079. m.SetEndDate(v)
  43080. return nil
  43081. case workexperience.FieldCompany:
  43082. v, ok := value.(string)
  43083. if !ok {
  43084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43085. }
  43086. m.SetCompany(v)
  43087. return nil
  43088. case workexperience.FieldExperience:
  43089. v, ok := value.(string)
  43090. if !ok {
  43091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43092. }
  43093. m.SetExperience(v)
  43094. return nil
  43095. case workexperience.FieldOrganizationID:
  43096. v, ok := value.(uint64)
  43097. if !ok {
  43098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43099. }
  43100. m.SetOrganizationID(v)
  43101. return nil
  43102. }
  43103. return fmt.Errorf("unknown WorkExperience field %s", name)
  43104. }
  43105. // AddedFields returns all numeric fields that were incremented/decremented during
  43106. // this mutation.
  43107. func (m *WorkExperienceMutation) AddedFields() []string {
  43108. var fields []string
  43109. if m.addorganization_id != nil {
  43110. fields = append(fields, workexperience.FieldOrganizationID)
  43111. }
  43112. return fields
  43113. }
  43114. // AddedField returns the numeric value that was incremented/decremented on a field
  43115. // with the given name. The second boolean return value indicates that this field
  43116. // was not set, or was not defined in the schema.
  43117. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  43118. switch name {
  43119. case workexperience.FieldOrganizationID:
  43120. return m.AddedOrganizationID()
  43121. }
  43122. return nil, false
  43123. }
  43124. // AddField adds the value to the field with the given name. It returns an error if
  43125. // the field is not defined in the schema, or if the type mismatched the field
  43126. // type.
  43127. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  43128. switch name {
  43129. case workexperience.FieldOrganizationID:
  43130. v, ok := value.(int64)
  43131. if !ok {
  43132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43133. }
  43134. m.AddOrganizationID(v)
  43135. return nil
  43136. }
  43137. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  43138. }
  43139. // ClearedFields returns all nullable fields that were cleared during this
  43140. // mutation.
  43141. func (m *WorkExperienceMutation) ClearedFields() []string {
  43142. var fields []string
  43143. if m.FieldCleared(workexperience.FieldDeletedAt) {
  43144. fields = append(fields, workexperience.FieldDeletedAt)
  43145. }
  43146. return fields
  43147. }
  43148. // FieldCleared returns a boolean indicating if a field with the given name was
  43149. // cleared in this mutation.
  43150. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  43151. _, ok := m.clearedFields[name]
  43152. return ok
  43153. }
  43154. // ClearField clears the value of the field with the given name. It returns an
  43155. // error if the field is not defined in the schema.
  43156. func (m *WorkExperienceMutation) ClearField(name string) error {
  43157. switch name {
  43158. case workexperience.FieldDeletedAt:
  43159. m.ClearDeletedAt()
  43160. return nil
  43161. }
  43162. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  43163. }
  43164. // ResetField resets all changes in the mutation for the field with the given name.
  43165. // It returns an error if the field is not defined in the schema.
  43166. func (m *WorkExperienceMutation) ResetField(name string) error {
  43167. switch name {
  43168. case workexperience.FieldCreatedAt:
  43169. m.ResetCreatedAt()
  43170. return nil
  43171. case workexperience.FieldUpdatedAt:
  43172. m.ResetUpdatedAt()
  43173. return nil
  43174. case workexperience.FieldDeletedAt:
  43175. m.ResetDeletedAt()
  43176. return nil
  43177. case workexperience.FieldEmployeeID:
  43178. m.ResetEmployeeID()
  43179. return nil
  43180. case workexperience.FieldStartDate:
  43181. m.ResetStartDate()
  43182. return nil
  43183. case workexperience.FieldEndDate:
  43184. m.ResetEndDate()
  43185. return nil
  43186. case workexperience.FieldCompany:
  43187. m.ResetCompany()
  43188. return nil
  43189. case workexperience.FieldExperience:
  43190. m.ResetExperience()
  43191. return nil
  43192. case workexperience.FieldOrganizationID:
  43193. m.ResetOrganizationID()
  43194. return nil
  43195. }
  43196. return fmt.Errorf("unknown WorkExperience field %s", name)
  43197. }
  43198. // AddedEdges returns all edge names that were set/added in this mutation.
  43199. func (m *WorkExperienceMutation) AddedEdges() []string {
  43200. edges := make([]string, 0, 1)
  43201. if m.employee != nil {
  43202. edges = append(edges, workexperience.EdgeEmployee)
  43203. }
  43204. return edges
  43205. }
  43206. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43207. // name in this mutation.
  43208. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  43209. switch name {
  43210. case workexperience.EdgeEmployee:
  43211. if id := m.employee; id != nil {
  43212. return []ent.Value{*id}
  43213. }
  43214. }
  43215. return nil
  43216. }
  43217. // RemovedEdges returns all edge names that were removed in this mutation.
  43218. func (m *WorkExperienceMutation) RemovedEdges() []string {
  43219. edges := make([]string, 0, 1)
  43220. return edges
  43221. }
  43222. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43223. // the given name in this mutation.
  43224. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  43225. return nil
  43226. }
  43227. // ClearedEdges returns all edge names that were cleared in this mutation.
  43228. func (m *WorkExperienceMutation) ClearedEdges() []string {
  43229. edges := make([]string, 0, 1)
  43230. if m.clearedemployee {
  43231. edges = append(edges, workexperience.EdgeEmployee)
  43232. }
  43233. return edges
  43234. }
  43235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43236. // was cleared in this mutation.
  43237. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  43238. switch name {
  43239. case workexperience.EdgeEmployee:
  43240. return m.clearedemployee
  43241. }
  43242. return false
  43243. }
  43244. // ClearEdge clears the value of the edge with the given name. It returns an error
  43245. // if that edge is not defined in the schema.
  43246. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  43247. switch name {
  43248. case workexperience.EdgeEmployee:
  43249. m.ClearEmployee()
  43250. return nil
  43251. }
  43252. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  43253. }
  43254. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43255. // It returns an error if the edge is not defined in the schema.
  43256. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  43257. switch name {
  43258. case workexperience.EdgeEmployee:
  43259. m.ResetEmployee()
  43260. return nil
  43261. }
  43262. return fmt.Errorf("unknown WorkExperience edge %s", name)
  43263. }
  43264. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  43265. type WpChatroomMutation struct {
  43266. config
  43267. op Op
  43268. typ string
  43269. id *uint64
  43270. created_at *time.Time
  43271. updated_at *time.Time
  43272. status *uint8
  43273. addstatus *int8
  43274. wx_wxid *string
  43275. chatroom_id *string
  43276. nickname *string
  43277. owner *string
  43278. avatar *string
  43279. member_list *[]string
  43280. appendmember_list []string
  43281. clearedFields map[string]struct{}
  43282. done bool
  43283. oldValue func(context.Context) (*WpChatroom, error)
  43284. predicates []predicate.WpChatroom
  43285. }
  43286. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  43287. // wpchatroomOption allows management of the mutation configuration using functional options.
  43288. type wpchatroomOption func(*WpChatroomMutation)
  43289. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  43290. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  43291. m := &WpChatroomMutation{
  43292. config: c,
  43293. op: op,
  43294. typ: TypeWpChatroom,
  43295. clearedFields: make(map[string]struct{}),
  43296. }
  43297. for _, opt := range opts {
  43298. opt(m)
  43299. }
  43300. return m
  43301. }
  43302. // withWpChatroomID sets the ID field of the mutation.
  43303. func withWpChatroomID(id uint64) wpchatroomOption {
  43304. return func(m *WpChatroomMutation) {
  43305. var (
  43306. err error
  43307. once sync.Once
  43308. value *WpChatroom
  43309. )
  43310. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  43311. once.Do(func() {
  43312. if m.done {
  43313. err = errors.New("querying old values post mutation is not allowed")
  43314. } else {
  43315. value, err = m.Client().WpChatroom.Get(ctx, id)
  43316. }
  43317. })
  43318. return value, err
  43319. }
  43320. m.id = &id
  43321. }
  43322. }
  43323. // withWpChatroom sets the old WpChatroom of the mutation.
  43324. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  43325. return func(m *WpChatroomMutation) {
  43326. m.oldValue = func(context.Context) (*WpChatroom, error) {
  43327. return node, nil
  43328. }
  43329. m.id = &node.ID
  43330. }
  43331. }
  43332. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43333. // executed in a transaction (ent.Tx), a transactional client is returned.
  43334. func (m WpChatroomMutation) Client() *Client {
  43335. client := &Client{config: m.config}
  43336. client.init()
  43337. return client
  43338. }
  43339. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43340. // it returns an error otherwise.
  43341. func (m WpChatroomMutation) Tx() (*Tx, error) {
  43342. if _, ok := m.driver.(*txDriver); !ok {
  43343. return nil, errors.New("ent: mutation is not running in a transaction")
  43344. }
  43345. tx := &Tx{config: m.config}
  43346. tx.init()
  43347. return tx, nil
  43348. }
  43349. // SetID sets the value of the id field. Note that this
  43350. // operation is only accepted on creation of WpChatroom entities.
  43351. func (m *WpChatroomMutation) SetID(id uint64) {
  43352. m.id = &id
  43353. }
  43354. // ID returns the ID value in the mutation. Note that the ID is only available
  43355. // if it was provided to the builder or after it was returned from the database.
  43356. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  43357. if m.id == nil {
  43358. return
  43359. }
  43360. return *m.id, true
  43361. }
  43362. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43363. // That means, if the mutation is applied within a transaction with an isolation level such
  43364. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43365. // or updated by the mutation.
  43366. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  43367. switch {
  43368. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43369. id, exists := m.ID()
  43370. if exists {
  43371. return []uint64{id}, nil
  43372. }
  43373. fallthrough
  43374. case m.op.Is(OpUpdate | OpDelete):
  43375. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  43376. default:
  43377. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43378. }
  43379. }
  43380. // SetCreatedAt sets the "created_at" field.
  43381. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  43382. m.created_at = &t
  43383. }
  43384. // CreatedAt returns the value of the "created_at" field in the mutation.
  43385. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  43386. v := m.created_at
  43387. if v == nil {
  43388. return
  43389. }
  43390. return *v, true
  43391. }
  43392. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  43393. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43395. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43396. if !m.op.Is(OpUpdateOne) {
  43397. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43398. }
  43399. if m.id == nil || m.oldValue == nil {
  43400. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43401. }
  43402. oldValue, err := m.oldValue(ctx)
  43403. if err != nil {
  43404. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43405. }
  43406. return oldValue.CreatedAt, nil
  43407. }
  43408. // ResetCreatedAt resets all changes to the "created_at" field.
  43409. func (m *WpChatroomMutation) ResetCreatedAt() {
  43410. m.created_at = nil
  43411. }
  43412. // SetUpdatedAt sets the "updated_at" field.
  43413. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  43414. m.updated_at = &t
  43415. }
  43416. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43417. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  43418. v := m.updated_at
  43419. if v == nil {
  43420. return
  43421. }
  43422. return *v, true
  43423. }
  43424. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  43425. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43427. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43428. if !m.op.Is(OpUpdateOne) {
  43429. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43430. }
  43431. if m.id == nil || m.oldValue == nil {
  43432. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43433. }
  43434. oldValue, err := m.oldValue(ctx)
  43435. if err != nil {
  43436. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43437. }
  43438. return oldValue.UpdatedAt, nil
  43439. }
  43440. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43441. func (m *WpChatroomMutation) ResetUpdatedAt() {
  43442. m.updated_at = nil
  43443. }
  43444. // SetStatus sets the "status" field.
  43445. func (m *WpChatroomMutation) SetStatus(u uint8) {
  43446. m.status = &u
  43447. m.addstatus = nil
  43448. }
  43449. // Status returns the value of the "status" field in the mutation.
  43450. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  43451. v := m.status
  43452. if v == nil {
  43453. return
  43454. }
  43455. return *v, true
  43456. }
  43457. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  43458. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43460. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43461. if !m.op.Is(OpUpdateOne) {
  43462. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43463. }
  43464. if m.id == nil || m.oldValue == nil {
  43465. return v, errors.New("OldStatus requires an ID field in the mutation")
  43466. }
  43467. oldValue, err := m.oldValue(ctx)
  43468. if err != nil {
  43469. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43470. }
  43471. return oldValue.Status, nil
  43472. }
  43473. // AddStatus adds u to the "status" field.
  43474. func (m *WpChatroomMutation) AddStatus(u int8) {
  43475. if m.addstatus != nil {
  43476. *m.addstatus += u
  43477. } else {
  43478. m.addstatus = &u
  43479. }
  43480. }
  43481. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43482. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  43483. v := m.addstatus
  43484. if v == nil {
  43485. return
  43486. }
  43487. return *v, true
  43488. }
  43489. // ClearStatus clears the value of the "status" field.
  43490. func (m *WpChatroomMutation) ClearStatus() {
  43491. m.status = nil
  43492. m.addstatus = nil
  43493. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  43494. }
  43495. // StatusCleared returns if the "status" field was cleared in this mutation.
  43496. func (m *WpChatroomMutation) StatusCleared() bool {
  43497. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  43498. return ok
  43499. }
  43500. // ResetStatus resets all changes to the "status" field.
  43501. func (m *WpChatroomMutation) ResetStatus() {
  43502. m.status = nil
  43503. m.addstatus = nil
  43504. delete(m.clearedFields, wpchatroom.FieldStatus)
  43505. }
  43506. // SetWxWxid sets the "wx_wxid" field.
  43507. func (m *WpChatroomMutation) SetWxWxid(s string) {
  43508. m.wx_wxid = &s
  43509. }
  43510. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  43511. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  43512. v := m.wx_wxid
  43513. if v == nil {
  43514. return
  43515. }
  43516. return *v, true
  43517. }
  43518. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  43519. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43521. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  43522. if !m.op.Is(OpUpdateOne) {
  43523. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  43524. }
  43525. if m.id == nil || m.oldValue == nil {
  43526. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  43527. }
  43528. oldValue, err := m.oldValue(ctx)
  43529. if err != nil {
  43530. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  43531. }
  43532. return oldValue.WxWxid, nil
  43533. }
  43534. // ResetWxWxid resets all changes to the "wx_wxid" field.
  43535. func (m *WpChatroomMutation) ResetWxWxid() {
  43536. m.wx_wxid = nil
  43537. }
  43538. // SetChatroomID sets the "chatroom_id" field.
  43539. func (m *WpChatroomMutation) SetChatroomID(s string) {
  43540. m.chatroom_id = &s
  43541. }
  43542. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  43543. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  43544. v := m.chatroom_id
  43545. if v == nil {
  43546. return
  43547. }
  43548. return *v, true
  43549. }
  43550. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  43551. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43553. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  43554. if !m.op.Is(OpUpdateOne) {
  43555. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  43556. }
  43557. if m.id == nil || m.oldValue == nil {
  43558. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  43559. }
  43560. oldValue, err := m.oldValue(ctx)
  43561. if err != nil {
  43562. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  43563. }
  43564. return oldValue.ChatroomID, nil
  43565. }
  43566. // ResetChatroomID resets all changes to the "chatroom_id" field.
  43567. func (m *WpChatroomMutation) ResetChatroomID() {
  43568. m.chatroom_id = nil
  43569. }
  43570. // SetNickname sets the "nickname" field.
  43571. func (m *WpChatroomMutation) SetNickname(s string) {
  43572. m.nickname = &s
  43573. }
  43574. // Nickname returns the value of the "nickname" field in the mutation.
  43575. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  43576. v := m.nickname
  43577. if v == nil {
  43578. return
  43579. }
  43580. return *v, true
  43581. }
  43582. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  43583. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43585. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  43586. if !m.op.Is(OpUpdateOne) {
  43587. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43588. }
  43589. if m.id == nil || m.oldValue == nil {
  43590. return v, errors.New("OldNickname requires an ID field in the mutation")
  43591. }
  43592. oldValue, err := m.oldValue(ctx)
  43593. if err != nil {
  43594. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43595. }
  43596. return oldValue.Nickname, nil
  43597. }
  43598. // ResetNickname resets all changes to the "nickname" field.
  43599. func (m *WpChatroomMutation) ResetNickname() {
  43600. m.nickname = nil
  43601. }
  43602. // SetOwner sets the "owner" field.
  43603. func (m *WpChatroomMutation) SetOwner(s string) {
  43604. m.owner = &s
  43605. }
  43606. // Owner returns the value of the "owner" field in the mutation.
  43607. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  43608. v := m.owner
  43609. if v == nil {
  43610. return
  43611. }
  43612. return *v, true
  43613. }
  43614. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  43615. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43617. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  43618. if !m.op.Is(OpUpdateOne) {
  43619. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  43620. }
  43621. if m.id == nil || m.oldValue == nil {
  43622. return v, errors.New("OldOwner requires an ID field in the mutation")
  43623. }
  43624. oldValue, err := m.oldValue(ctx)
  43625. if err != nil {
  43626. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  43627. }
  43628. return oldValue.Owner, nil
  43629. }
  43630. // ResetOwner resets all changes to the "owner" field.
  43631. func (m *WpChatroomMutation) ResetOwner() {
  43632. m.owner = nil
  43633. }
  43634. // SetAvatar sets the "avatar" field.
  43635. func (m *WpChatroomMutation) SetAvatar(s string) {
  43636. m.avatar = &s
  43637. }
  43638. // Avatar returns the value of the "avatar" field in the mutation.
  43639. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  43640. v := m.avatar
  43641. if v == nil {
  43642. return
  43643. }
  43644. return *v, true
  43645. }
  43646. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  43647. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43649. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43650. if !m.op.Is(OpUpdateOne) {
  43651. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43652. }
  43653. if m.id == nil || m.oldValue == nil {
  43654. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43655. }
  43656. oldValue, err := m.oldValue(ctx)
  43657. if err != nil {
  43658. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43659. }
  43660. return oldValue.Avatar, nil
  43661. }
  43662. // ResetAvatar resets all changes to the "avatar" field.
  43663. func (m *WpChatroomMutation) ResetAvatar() {
  43664. m.avatar = nil
  43665. }
  43666. // SetMemberList sets the "member_list" field.
  43667. func (m *WpChatroomMutation) SetMemberList(s []string) {
  43668. m.member_list = &s
  43669. m.appendmember_list = nil
  43670. }
  43671. // MemberList returns the value of the "member_list" field in the mutation.
  43672. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  43673. v := m.member_list
  43674. if v == nil {
  43675. return
  43676. }
  43677. return *v, true
  43678. }
  43679. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  43680. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43682. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  43683. if !m.op.Is(OpUpdateOne) {
  43684. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  43685. }
  43686. if m.id == nil || m.oldValue == nil {
  43687. return v, errors.New("OldMemberList requires an ID field in the mutation")
  43688. }
  43689. oldValue, err := m.oldValue(ctx)
  43690. if err != nil {
  43691. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  43692. }
  43693. return oldValue.MemberList, nil
  43694. }
  43695. // AppendMemberList adds s to the "member_list" field.
  43696. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  43697. m.appendmember_list = append(m.appendmember_list, s...)
  43698. }
  43699. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  43700. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  43701. if len(m.appendmember_list) == 0 {
  43702. return nil, false
  43703. }
  43704. return m.appendmember_list, true
  43705. }
  43706. // ResetMemberList resets all changes to the "member_list" field.
  43707. func (m *WpChatroomMutation) ResetMemberList() {
  43708. m.member_list = nil
  43709. m.appendmember_list = nil
  43710. }
  43711. // Where appends a list predicates to the WpChatroomMutation builder.
  43712. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  43713. m.predicates = append(m.predicates, ps...)
  43714. }
  43715. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  43716. // users can use type-assertion to append predicates that do not depend on any generated package.
  43717. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  43718. p := make([]predicate.WpChatroom, len(ps))
  43719. for i := range ps {
  43720. p[i] = ps[i]
  43721. }
  43722. m.Where(p...)
  43723. }
  43724. // Op returns the operation name.
  43725. func (m *WpChatroomMutation) Op() Op {
  43726. return m.op
  43727. }
  43728. // SetOp allows setting the mutation operation.
  43729. func (m *WpChatroomMutation) SetOp(op Op) {
  43730. m.op = op
  43731. }
  43732. // Type returns the node type of this mutation (WpChatroom).
  43733. func (m *WpChatroomMutation) Type() string {
  43734. return m.typ
  43735. }
  43736. // Fields returns all fields that were changed during this mutation. Note that in
  43737. // order to get all numeric fields that were incremented/decremented, call
  43738. // AddedFields().
  43739. func (m *WpChatroomMutation) Fields() []string {
  43740. fields := make([]string, 0, 9)
  43741. if m.created_at != nil {
  43742. fields = append(fields, wpchatroom.FieldCreatedAt)
  43743. }
  43744. if m.updated_at != nil {
  43745. fields = append(fields, wpchatroom.FieldUpdatedAt)
  43746. }
  43747. if m.status != nil {
  43748. fields = append(fields, wpchatroom.FieldStatus)
  43749. }
  43750. if m.wx_wxid != nil {
  43751. fields = append(fields, wpchatroom.FieldWxWxid)
  43752. }
  43753. if m.chatroom_id != nil {
  43754. fields = append(fields, wpchatroom.FieldChatroomID)
  43755. }
  43756. if m.nickname != nil {
  43757. fields = append(fields, wpchatroom.FieldNickname)
  43758. }
  43759. if m.owner != nil {
  43760. fields = append(fields, wpchatroom.FieldOwner)
  43761. }
  43762. if m.avatar != nil {
  43763. fields = append(fields, wpchatroom.FieldAvatar)
  43764. }
  43765. if m.member_list != nil {
  43766. fields = append(fields, wpchatroom.FieldMemberList)
  43767. }
  43768. return fields
  43769. }
  43770. // Field returns the value of a field with the given name. The second boolean
  43771. // return value indicates that this field was not set, or was not defined in the
  43772. // schema.
  43773. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  43774. switch name {
  43775. case wpchatroom.FieldCreatedAt:
  43776. return m.CreatedAt()
  43777. case wpchatroom.FieldUpdatedAt:
  43778. return m.UpdatedAt()
  43779. case wpchatroom.FieldStatus:
  43780. return m.Status()
  43781. case wpchatroom.FieldWxWxid:
  43782. return m.WxWxid()
  43783. case wpchatroom.FieldChatroomID:
  43784. return m.ChatroomID()
  43785. case wpchatroom.FieldNickname:
  43786. return m.Nickname()
  43787. case wpchatroom.FieldOwner:
  43788. return m.Owner()
  43789. case wpchatroom.FieldAvatar:
  43790. return m.Avatar()
  43791. case wpchatroom.FieldMemberList:
  43792. return m.MemberList()
  43793. }
  43794. return nil, false
  43795. }
  43796. // OldField returns the old value of the field from the database. An error is
  43797. // returned if the mutation operation is not UpdateOne, or the query to the
  43798. // database failed.
  43799. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43800. switch name {
  43801. case wpchatroom.FieldCreatedAt:
  43802. return m.OldCreatedAt(ctx)
  43803. case wpchatroom.FieldUpdatedAt:
  43804. return m.OldUpdatedAt(ctx)
  43805. case wpchatroom.FieldStatus:
  43806. return m.OldStatus(ctx)
  43807. case wpchatroom.FieldWxWxid:
  43808. return m.OldWxWxid(ctx)
  43809. case wpchatroom.FieldChatroomID:
  43810. return m.OldChatroomID(ctx)
  43811. case wpchatroom.FieldNickname:
  43812. return m.OldNickname(ctx)
  43813. case wpchatroom.FieldOwner:
  43814. return m.OldOwner(ctx)
  43815. case wpchatroom.FieldAvatar:
  43816. return m.OldAvatar(ctx)
  43817. case wpchatroom.FieldMemberList:
  43818. return m.OldMemberList(ctx)
  43819. }
  43820. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  43821. }
  43822. // SetField sets the value of a field with the given name. It returns an error if
  43823. // the field is not defined in the schema, or if the type mismatched the field
  43824. // type.
  43825. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  43826. switch name {
  43827. case wpchatroom.FieldCreatedAt:
  43828. v, ok := value.(time.Time)
  43829. if !ok {
  43830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43831. }
  43832. m.SetCreatedAt(v)
  43833. return nil
  43834. case wpchatroom.FieldUpdatedAt:
  43835. v, ok := value.(time.Time)
  43836. if !ok {
  43837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43838. }
  43839. m.SetUpdatedAt(v)
  43840. return nil
  43841. case wpchatroom.FieldStatus:
  43842. v, ok := value.(uint8)
  43843. if !ok {
  43844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43845. }
  43846. m.SetStatus(v)
  43847. return nil
  43848. case wpchatroom.FieldWxWxid:
  43849. v, ok := value.(string)
  43850. if !ok {
  43851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43852. }
  43853. m.SetWxWxid(v)
  43854. return nil
  43855. case wpchatroom.FieldChatroomID:
  43856. v, ok := value.(string)
  43857. if !ok {
  43858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43859. }
  43860. m.SetChatroomID(v)
  43861. return nil
  43862. case wpchatroom.FieldNickname:
  43863. v, ok := value.(string)
  43864. if !ok {
  43865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43866. }
  43867. m.SetNickname(v)
  43868. return nil
  43869. case wpchatroom.FieldOwner:
  43870. v, ok := value.(string)
  43871. if !ok {
  43872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43873. }
  43874. m.SetOwner(v)
  43875. return nil
  43876. case wpchatroom.FieldAvatar:
  43877. v, ok := value.(string)
  43878. if !ok {
  43879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43880. }
  43881. m.SetAvatar(v)
  43882. return nil
  43883. case wpchatroom.FieldMemberList:
  43884. v, ok := value.([]string)
  43885. if !ok {
  43886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43887. }
  43888. m.SetMemberList(v)
  43889. return nil
  43890. }
  43891. return fmt.Errorf("unknown WpChatroom field %s", name)
  43892. }
  43893. // AddedFields returns all numeric fields that were incremented/decremented during
  43894. // this mutation.
  43895. func (m *WpChatroomMutation) AddedFields() []string {
  43896. var fields []string
  43897. if m.addstatus != nil {
  43898. fields = append(fields, wpchatroom.FieldStatus)
  43899. }
  43900. return fields
  43901. }
  43902. // AddedField returns the numeric value that was incremented/decremented on a field
  43903. // with the given name. The second boolean return value indicates that this field
  43904. // was not set, or was not defined in the schema.
  43905. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  43906. switch name {
  43907. case wpchatroom.FieldStatus:
  43908. return m.AddedStatus()
  43909. }
  43910. return nil, false
  43911. }
  43912. // AddField adds the value to the field with the given name. It returns an error if
  43913. // the field is not defined in the schema, or if the type mismatched the field
  43914. // type.
  43915. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  43916. switch name {
  43917. case wpchatroom.FieldStatus:
  43918. v, ok := value.(int8)
  43919. if !ok {
  43920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43921. }
  43922. m.AddStatus(v)
  43923. return nil
  43924. }
  43925. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  43926. }
  43927. // ClearedFields returns all nullable fields that were cleared during this
  43928. // mutation.
  43929. func (m *WpChatroomMutation) ClearedFields() []string {
  43930. var fields []string
  43931. if m.FieldCleared(wpchatroom.FieldStatus) {
  43932. fields = append(fields, wpchatroom.FieldStatus)
  43933. }
  43934. return fields
  43935. }
  43936. // FieldCleared returns a boolean indicating if a field with the given name was
  43937. // cleared in this mutation.
  43938. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  43939. _, ok := m.clearedFields[name]
  43940. return ok
  43941. }
  43942. // ClearField clears the value of the field with the given name. It returns an
  43943. // error if the field is not defined in the schema.
  43944. func (m *WpChatroomMutation) ClearField(name string) error {
  43945. switch name {
  43946. case wpchatroom.FieldStatus:
  43947. m.ClearStatus()
  43948. return nil
  43949. }
  43950. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  43951. }
  43952. // ResetField resets all changes in the mutation for the field with the given name.
  43953. // It returns an error if the field is not defined in the schema.
  43954. func (m *WpChatroomMutation) ResetField(name string) error {
  43955. switch name {
  43956. case wpchatroom.FieldCreatedAt:
  43957. m.ResetCreatedAt()
  43958. return nil
  43959. case wpchatroom.FieldUpdatedAt:
  43960. m.ResetUpdatedAt()
  43961. return nil
  43962. case wpchatroom.FieldStatus:
  43963. m.ResetStatus()
  43964. return nil
  43965. case wpchatroom.FieldWxWxid:
  43966. m.ResetWxWxid()
  43967. return nil
  43968. case wpchatroom.FieldChatroomID:
  43969. m.ResetChatroomID()
  43970. return nil
  43971. case wpchatroom.FieldNickname:
  43972. m.ResetNickname()
  43973. return nil
  43974. case wpchatroom.FieldOwner:
  43975. m.ResetOwner()
  43976. return nil
  43977. case wpchatroom.FieldAvatar:
  43978. m.ResetAvatar()
  43979. return nil
  43980. case wpchatroom.FieldMemberList:
  43981. m.ResetMemberList()
  43982. return nil
  43983. }
  43984. return fmt.Errorf("unknown WpChatroom field %s", name)
  43985. }
  43986. // AddedEdges returns all edge names that were set/added in this mutation.
  43987. func (m *WpChatroomMutation) AddedEdges() []string {
  43988. edges := make([]string, 0, 0)
  43989. return edges
  43990. }
  43991. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43992. // name in this mutation.
  43993. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  43994. return nil
  43995. }
  43996. // RemovedEdges returns all edge names that were removed in this mutation.
  43997. func (m *WpChatroomMutation) RemovedEdges() []string {
  43998. edges := make([]string, 0, 0)
  43999. return edges
  44000. }
  44001. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44002. // the given name in this mutation.
  44003. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  44004. return nil
  44005. }
  44006. // ClearedEdges returns all edge names that were cleared in this mutation.
  44007. func (m *WpChatroomMutation) ClearedEdges() []string {
  44008. edges := make([]string, 0, 0)
  44009. return edges
  44010. }
  44011. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44012. // was cleared in this mutation.
  44013. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  44014. return false
  44015. }
  44016. // ClearEdge clears the value of the edge with the given name. It returns an error
  44017. // if that edge is not defined in the schema.
  44018. func (m *WpChatroomMutation) ClearEdge(name string) error {
  44019. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  44020. }
  44021. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44022. // It returns an error if the edge is not defined in the schema.
  44023. func (m *WpChatroomMutation) ResetEdge(name string) error {
  44024. return fmt.Errorf("unknown WpChatroom edge %s", name)
  44025. }
  44026. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  44027. type WpChatroomMemberMutation struct {
  44028. config
  44029. op Op
  44030. typ string
  44031. id *uint64
  44032. created_at *time.Time
  44033. updated_at *time.Time
  44034. status *uint8
  44035. addstatus *int8
  44036. wx_wxid *string
  44037. wxid *string
  44038. nickname *string
  44039. avatar *string
  44040. clearedFields map[string]struct{}
  44041. done bool
  44042. oldValue func(context.Context) (*WpChatroomMember, error)
  44043. predicates []predicate.WpChatroomMember
  44044. }
  44045. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  44046. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  44047. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  44048. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  44049. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  44050. m := &WpChatroomMemberMutation{
  44051. config: c,
  44052. op: op,
  44053. typ: TypeWpChatroomMember,
  44054. clearedFields: make(map[string]struct{}),
  44055. }
  44056. for _, opt := range opts {
  44057. opt(m)
  44058. }
  44059. return m
  44060. }
  44061. // withWpChatroomMemberID sets the ID field of the mutation.
  44062. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  44063. return func(m *WpChatroomMemberMutation) {
  44064. var (
  44065. err error
  44066. once sync.Once
  44067. value *WpChatroomMember
  44068. )
  44069. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  44070. once.Do(func() {
  44071. if m.done {
  44072. err = errors.New("querying old values post mutation is not allowed")
  44073. } else {
  44074. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  44075. }
  44076. })
  44077. return value, err
  44078. }
  44079. m.id = &id
  44080. }
  44081. }
  44082. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  44083. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  44084. return func(m *WpChatroomMemberMutation) {
  44085. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  44086. return node, nil
  44087. }
  44088. m.id = &node.ID
  44089. }
  44090. }
  44091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44092. // executed in a transaction (ent.Tx), a transactional client is returned.
  44093. func (m WpChatroomMemberMutation) Client() *Client {
  44094. client := &Client{config: m.config}
  44095. client.init()
  44096. return client
  44097. }
  44098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44099. // it returns an error otherwise.
  44100. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  44101. if _, ok := m.driver.(*txDriver); !ok {
  44102. return nil, errors.New("ent: mutation is not running in a transaction")
  44103. }
  44104. tx := &Tx{config: m.config}
  44105. tx.init()
  44106. return tx, nil
  44107. }
  44108. // SetID sets the value of the id field. Note that this
  44109. // operation is only accepted on creation of WpChatroomMember entities.
  44110. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  44111. m.id = &id
  44112. }
  44113. // ID returns the ID value in the mutation. Note that the ID is only available
  44114. // if it was provided to the builder or after it was returned from the database.
  44115. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  44116. if m.id == nil {
  44117. return
  44118. }
  44119. return *m.id, true
  44120. }
  44121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44122. // That means, if the mutation is applied within a transaction with an isolation level such
  44123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44124. // or updated by the mutation.
  44125. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  44126. switch {
  44127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44128. id, exists := m.ID()
  44129. if exists {
  44130. return []uint64{id}, nil
  44131. }
  44132. fallthrough
  44133. case m.op.Is(OpUpdate | OpDelete):
  44134. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  44135. default:
  44136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44137. }
  44138. }
  44139. // SetCreatedAt sets the "created_at" field.
  44140. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  44141. m.created_at = &t
  44142. }
  44143. // CreatedAt returns the value of the "created_at" field in the mutation.
  44144. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  44145. v := m.created_at
  44146. if v == nil {
  44147. return
  44148. }
  44149. return *v, true
  44150. }
  44151. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  44152. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44154. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44155. if !m.op.Is(OpUpdateOne) {
  44156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44157. }
  44158. if m.id == nil || m.oldValue == nil {
  44159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44160. }
  44161. oldValue, err := m.oldValue(ctx)
  44162. if err != nil {
  44163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44164. }
  44165. return oldValue.CreatedAt, nil
  44166. }
  44167. // ResetCreatedAt resets all changes to the "created_at" field.
  44168. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  44169. m.created_at = nil
  44170. }
  44171. // SetUpdatedAt sets the "updated_at" field.
  44172. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  44173. m.updated_at = &t
  44174. }
  44175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44176. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  44177. v := m.updated_at
  44178. if v == nil {
  44179. return
  44180. }
  44181. return *v, true
  44182. }
  44183. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  44184. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44186. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44187. if !m.op.Is(OpUpdateOne) {
  44188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44189. }
  44190. if m.id == nil || m.oldValue == nil {
  44191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44192. }
  44193. oldValue, err := m.oldValue(ctx)
  44194. if err != nil {
  44195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44196. }
  44197. return oldValue.UpdatedAt, nil
  44198. }
  44199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44200. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  44201. m.updated_at = nil
  44202. }
  44203. // SetStatus sets the "status" field.
  44204. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  44205. m.status = &u
  44206. m.addstatus = nil
  44207. }
  44208. // Status returns the value of the "status" field in the mutation.
  44209. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  44210. v := m.status
  44211. if v == nil {
  44212. return
  44213. }
  44214. return *v, true
  44215. }
  44216. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  44217. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44219. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44220. if !m.op.Is(OpUpdateOne) {
  44221. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44222. }
  44223. if m.id == nil || m.oldValue == nil {
  44224. return v, errors.New("OldStatus requires an ID field in the mutation")
  44225. }
  44226. oldValue, err := m.oldValue(ctx)
  44227. if err != nil {
  44228. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44229. }
  44230. return oldValue.Status, nil
  44231. }
  44232. // AddStatus adds u to the "status" field.
  44233. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  44234. if m.addstatus != nil {
  44235. *m.addstatus += u
  44236. } else {
  44237. m.addstatus = &u
  44238. }
  44239. }
  44240. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44241. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  44242. v := m.addstatus
  44243. if v == nil {
  44244. return
  44245. }
  44246. return *v, true
  44247. }
  44248. // ClearStatus clears the value of the "status" field.
  44249. func (m *WpChatroomMemberMutation) ClearStatus() {
  44250. m.status = nil
  44251. m.addstatus = nil
  44252. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  44253. }
  44254. // StatusCleared returns if the "status" field was cleared in this mutation.
  44255. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  44256. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  44257. return ok
  44258. }
  44259. // ResetStatus resets all changes to the "status" field.
  44260. func (m *WpChatroomMemberMutation) ResetStatus() {
  44261. m.status = nil
  44262. m.addstatus = nil
  44263. delete(m.clearedFields, wpchatroommember.FieldStatus)
  44264. }
  44265. // SetWxWxid sets the "wx_wxid" field.
  44266. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  44267. m.wx_wxid = &s
  44268. }
  44269. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  44270. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  44271. v := m.wx_wxid
  44272. if v == nil {
  44273. return
  44274. }
  44275. return *v, true
  44276. }
  44277. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  44278. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44280. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  44281. if !m.op.Is(OpUpdateOne) {
  44282. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  44283. }
  44284. if m.id == nil || m.oldValue == nil {
  44285. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  44286. }
  44287. oldValue, err := m.oldValue(ctx)
  44288. if err != nil {
  44289. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  44290. }
  44291. return oldValue.WxWxid, nil
  44292. }
  44293. // ResetWxWxid resets all changes to the "wx_wxid" field.
  44294. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  44295. m.wx_wxid = nil
  44296. }
  44297. // SetWxid sets the "wxid" field.
  44298. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  44299. m.wxid = &s
  44300. }
  44301. // Wxid returns the value of the "wxid" field in the mutation.
  44302. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  44303. v := m.wxid
  44304. if v == nil {
  44305. return
  44306. }
  44307. return *v, true
  44308. }
  44309. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  44310. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44312. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  44313. if !m.op.Is(OpUpdateOne) {
  44314. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44315. }
  44316. if m.id == nil || m.oldValue == nil {
  44317. return v, errors.New("OldWxid requires an ID field in the mutation")
  44318. }
  44319. oldValue, err := m.oldValue(ctx)
  44320. if err != nil {
  44321. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44322. }
  44323. return oldValue.Wxid, nil
  44324. }
  44325. // ResetWxid resets all changes to the "wxid" field.
  44326. func (m *WpChatroomMemberMutation) ResetWxid() {
  44327. m.wxid = nil
  44328. }
  44329. // SetNickname sets the "nickname" field.
  44330. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  44331. m.nickname = &s
  44332. }
  44333. // Nickname returns the value of the "nickname" field in the mutation.
  44334. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  44335. v := m.nickname
  44336. if v == nil {
  44337. return
  44338. }
  44339. return *v, true
  44340. }
  44341. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  44342. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44344. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  44345. if !m.op.Is(OpUpdateOne) {
  44346. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44347. }
  44348. if m.id == nil || m.oldValue == nil {
  44349. return v, errors.New("OldNickname requires an ID field in the mutation")
  44350. }
  44351. oldValue, err := m.oldValue(ctx)
  44352. if err != nil {
  44353. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44354. }
  44355. return oldValue.Nickname, nil
  44356. }
  44357. // ResetNickname resets all changes to the "nickname" field.
  44358. func (m *WpChatroomMemberMutation) ResetNickname() {
  44359. m.nickname = nil
  44360. }
  44361. // SetAvatar sets the "avatar" field.
  44362. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  44363. m.avatar = &s
  44364. }
  44365. // Avatar returns the value of the "avatar" field in the mutation.
  44366. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  44367. v := m.avatar
  44368. if v == nil {
  44369. return
  44370. }
  44371. return *v, true
  44372. }
  44373. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  44374. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44376. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44377. if !m.op.Is(OpUpdateOne) {
  44378. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44379. }
  44380. if m.id == nil || m.oldValue == nil {
  44381. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44382. }
  44383. oldValue, err := m.oldValue(ctx)
  44384. if err != nil {
  44385. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44386. }
  44387. return oldValue.Avatar, nil
  44388. }
  44389. // ResetAvatar resets all changes to the "avatar" field.
  44390. func (m *WpChatroomMemberMutation) ResetAvatar() {
  44391. m.avatar = nil
  44392. }
  44393. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  44394. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  44395. m.predicates = append(m.predicates, ps...)
  44396. }
  44397. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  44398. // users can use type-assertion to append predicates that do not depend on any generated package.
  44399. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  44400. p := make([]predicate.WpChatroomMember, len(ps))
  44401. for i := range ps {
  44402. p[i] = ps[i]
  44403. }
  44404. m.Where(p...)
  44405. }
  44406. // Op returns the operation name.
  44407. func (m *WpChatroomMemberMutation) Op() Op {
  44408. return m.op
  44409. }
  44410. // SetOp allows setting the mutation operation.
  44411. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  44412. m.op = op
  44413. }
  44414. // Type returns the node type of this mutation (WpChatroomMember).
  44415. func (m *WpChatroomMemberMutation) Type() string {
  44416. return m.typ
  44417. }
  44418. // Fields returns all fields that were changed during this mutation. Note that in
  44419. // order to get all numeric fields that were incremented/decremented, call
  44420. // AddedFields().
  44421. func (m *WpChatroomMemberMutation) Fields() []string {
  44422. fields := make([]string, 0, 7)
  44423. if m.created_at != nil {
  44424. fields = append(fields, wpchatroommember.FieldCreatedAt)
  44425. }
  44426. if m.updated_at != nil {
  44427. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  44428. }
  44429. if m.status != nil {
  44430. fields = append(fields, wpchatroommember.FieldStatus)
  44431. }
  44432. if m.wx_wxid != nil {
  44433. fields = append(fields, wpchatroommember.FieldWxWxid)
  44434. }
  44435. if m.wxid != nil {
  44436. fields = append(fields, wpchatroommember.FieldWxid)
  44437. }
  44438. if m.nickname != nil {
  44439. fields = append(fields, wpchatroommember.FieldNickname)
  44440. }
  44441. if m.avatar != nil {
  44442. fields = append(fields, wpchatroommember.FieldAvatar)
  44443. }
  44444. return fields
  44445. }
  44446. // Field returns the value of a field with the given name. The second boolean
  44447. // return value indicates that this field was not set, or was not defined in the
  44448. // schema.
  44449. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  44450. switch name {
  44451. case wpchatroommember.FieldCreatedAt:
  44452. return m.CreatedAt()
  44453. case wpchatroommember.FieldUpdatedAt:
  44454. return m.UpdatedAt()
  44455. case wpchatroommember.FieldStatus:
  44456. return m.Status()
  44457. case wpchatroommember.FieldWxWxid:
  44458. return m.WxWxid()
  44459. case wpchatroommember.FieldWxid:
  44460. return m.Wxid()
  44461. case wpchatroommember.FieldNickname:
  44462. return m.Nickname()
  44463. case wpchatroommember.FieldAvatar:
  44464. return m.Avatar()
  44465. }
  44466. return nil, false
  44467. }
  44468. // OldField returns the old value of the field from the database. An error is
  44469. // returned if the mutation operation is not UpdateOne, or the query to the
  44470. // database failed.
  44471. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44472. switch name {
  44473. case wpchatroommember.FieldCreatedAt:
  44474. return m.OldCreatedAt(ctx)
  44475. case wpchatroommember.FieldUpdatedAt:
  44476. return m.OldUpdatedAt(ctx)
  44477. case wpchatroommember.FieldStatus:
  44478. return m.OldStatus(ctx)
  44479. case wpchatroommember.FieldWxWxid:
  44480. return m.OldWxWxid(ctx)
  44481. case wpchatroommember.FieldWxid:
  44482. return m.OldWxid(ctx)
  44483. case wpchatroommember.FieldNickname:
  44484. return m.OldNickname(ctx)
  44485. case wpchatroommember.FieldAvatar:
  44486. return m.OldAvatar(ctx)
  44487. }
  44488. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  44489. }
  44490. // SetField sets the value of a field with the given name. It returns an error if
  44491. // the field is not defined in the schema, or if the type mismatched the field
  44492. // type.
  44493. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  44494. switch name {
  44495. case wpchatroommember.FieldCreatedAt:
  44496. v, ok := value.(time.Time)
  44497. if !ok {
  44498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44499. }
  44500. m.SetCreatedAt(v)
  44501. return nil
  44502. case wpchatroommember.FieldUpdatedAt:
  44503. v, ok := value.(time.Time)
  44504. if !ok {
  44505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44506. }
  44507. m.SetUpdatedAt(v)
  44508. return nil
  44509. case wpchatroommember.FieldStatus:
  44510. v, ok := value.(uint8)
  44511. if !ok {
  44512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44513. }
  44514. m.SetStatus(v)
  44515. return nil
  44516. case wpchatroommember.FieldWxWxid:
  44517. v, ok := value.(string)
  44518. if !ok {
  44519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44520. }
  44521. m.SetWxWxid(v)
  44522. return nil
  44523. case wpchatroommember.FieldWxid:
  44524. v, ok := value.(string)
  44525. if !ok {
  44526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44527. }
  44528. m.SetWxid(v)
  44529. return nil
  44530. case wpchatroommember.FieldNickname:
  44531. v, ok := value.(string)
  44532. if !ok {
  44533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44534. }
  44535. m.SetNickname(v)
  44536. return nil
  44537. case wpchatroommember.FieldAvatar:
  44538. v, ok := value.(string)
  44539. if !ok {
  44540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44541. }
  44542. m.SetAvatar(v)
  44543. return nil
  44544. }
  44545. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  44546. }
  44547. // AddedFields returns all numeric fields that were incremented/decremented during
  44548. // this mutation.
  44549. func (m *WpChatroomMemberMutation) AddedFields() []string {
  44550. var fields []string
  44551. if m.addstatus != nil {
  44552. fields = append(fields, wpchatroommember.FieldStatus)
  44553. }
  44554. return fields
  44555. }
  44556. // AddedField returns the numeric value that was incremented/decremented on a field
  44557. // with the given name. The second boolean return value indicates that this field
  44558. // was not set, or was not defined in the schema.
  44559. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  44560. switch name {
  44561. case wpchatroommember.FieldStatus:
  44562. return m.AddedStatus()
  44563. }
  44564. return nil, false
  44565. }
  44566. // AddField adds the value to the field with the given name. It returns an error if
  44567. // the field is not defined in the schema, or if the type mismatched the field
  44568. // type.
  44569. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  44570. switch name {
  44571. case wpchatroommember.FieldStatus:
  44572. v, ok := value.(int8)
  44573. if !ok {
  44574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44575. }
  44576. m.AddStatus(v)
  44577. return nil
  44578. }
  44579. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  44580. }
  44581. // ClearedFields returns all nullable fields that were cleared during this
  44582. // mutation.
  44583. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  44584. var fields []string
  44585. if m.FieldCleared(wpchatroommember.FieldStatus) {
  44586. fields = append(fields, wpchatroommember.FieldStatus)
  44587. }
  44588. return fields
  44589. }
  44590. // FieldCleared returns a boolean indicating if a field with the given name was
  44591. // cleared in this mutation.
  44592. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  44593. _, ok := m.clearedFields[name]
  44594. return ok
  44595. }
  44596. // ClearField clears the value of the field with the given name. It returns an
  44597. // error if the field is not defined in the schema.
  44598. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  44599. switch name {
  44600. case wpchatroommember.FieldStatus:
  44601. m.ClearStatus()
  44602. return nil
  44603. }
  44604. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  44605. }
  44606. // ResetField resets all changes in the mutation for the field with the given name.
  44607. // It returns an error if the field is not defined in the schema.
  44608. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  44609. switch name {
  44610. case wpchatroommember.FieldCreatedAt:
  44611. m.ResetCreatedAt()
  44612. return nil
  44613. case wpchatroommember.FieldUpdatedAt:
  44614. m.ResetUpdatedAt()
  44615. return nil
  44616. case wpchatroommember.FieldStatus:
  44617. m.ResetStatus()
  44618. return nil
  44619. case wpchatroommember.FieldWxWxid:
  44620. m.ResetWxWxid()
  44621. return nil
  44622. case wpchatroommember.FieldWxid:
  44623. m.ResetWxid()
  44624. return nil
  44625. case wpchatroommember.FieldNickname:
  44626. m.ResetNickname()
  44627. return nil
  44628. case wpchatroommember.FieldAvatar:
  44629. m.ResetAvatar()
  44630. return nil
  44631. }
  44632. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  44633. }
  44634. // AddedEdges returns all edge names that were set/added in this mutation.
  44635. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  44636. edges := make([]string, 0, 0)
  44637. return edges
  44638. }
  44639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44640. // name in this mutation.
  44641. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  44642. return nil
  44643. }
  44644. // RemovedEdges returns all edge names that were removed in this mutation.
  44645. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  44646. edges := make([]string, 0, 0)
  44647. return edges
  44648. }
  44649. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44650. // the given name in this mutation.
  44651. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  44652. return nil
  44653. }
  44654. // ClearedEdges returns all edge names that were cleared in this mutation.
  44655. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  44656. edges := make([]string, 0, 0)
  44657. return edges
  44658. }
  44659. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44660. // was cleared in this mutation.
  44661. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  44662. return false
  44663. }
  44664. // ClearEdge clears the value of the edge with the given name. It returns an error
  44665. // if that edge is not defined in the schema.
  44666. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  44667. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  44668. }
  44669. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44670. // It returns an error if the edge is not defined in the schema.
  44671. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  44672. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  44673. }
  44674. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  44675. type WxMutation struct {
  44676. config
  44677. op Op
  44678. typ string
  44679. id *uint64
  44680. created_at *time.Time
  44681. updated_at *time.Time
  44682. status *uint8
  44683. addstatus *int8
  44684. deleted_at *time.Time
  44685. port *string
  44686. process_id *string
  44687. callback *string
  44688. wxid *string
  44689. account *string
  44690. nickname *string
  44691. tel *string
  44692. head_big *string
  44693. organization_id *uint64
  44694. addorganization_id *int64
  44695. api_base *string
  44696. api_key *string
  44697. allow_list *[]string
  44698. appendallow_list []string
  44699. group_allow_list *[]string
  44700. appendgroup_allow_list []string
  44701. block_list *[]string
  44702. appendblock_list []string
  44703. group_block_list *[]string
  44704. appendgroup_block_list []string
  44705. ctype *uint64
  44706. addctype *int64
  44707. clearedFields map[string]struct{}
  44708. server *uint64
  44709. clearedserver bool
  44710. agent *uint64
  44711. clearedagent bool
  44712. done bool
  44713. oldValue func(context.Context) (*Wx, error)
  44714. predicates []predicate.Wx
  44715. }
  44716. var _ ent.Mutation = (*WxMutation)(nil)
  44717. // wxOption allows management of the mutation configuration using functional options.
  44718. type wxOption func(*WxMutation)
  44719. // newWxMutation creates new mutation for the Wx entity.
  44720. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  44721. m := &WxMutation{
  44722. config: c,
  44723. op: op,
  44724. typ: TypeWx,
  44725. clearedFields: make(map[string]struct{}),
  44726. }
  44727. for _, opt := range opts {
  44728. opt(m)
  44729. }
  44730. return m
  44731. }
  44732. // withWxID sets the ID field of the mutation.
  44733. func withWxID(id uint64) wxOption {
  44734. return func(m *WxMutation) {
  44735. var (
  44736. err error
  44737. once sync.Once
  44738. value *Wx
  44739. )
  44740. m.oldValue = func(ctx context.Context) (*Wx, error) {
  44741. once.Do(func() {
  44742. if m.done {
  44743. err = errors.New("querying old values post mutation is not allowed")
  44744. } else {
  44745. value, err = m.Client().Wx.Get(ctx, id)
  44746. }
  44747. })
  44748. return value, err
  44749. }
  44750. m.id = &id
  44751. }
  44752. }
  44753. // withWx sets the old Wx of the mutation.
  44754. func withWx(node *Wx) wxOption {
  44755. return func(m *WxMutation) {
  44756. m.oldValue = func(context.Context) (*Wx, error) {
  44757. return node, nil
  44758. }
  44759. m.id = &node.ID
  44760. }
  44761. }
  44762. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44763. // executed in a transaction (ent.Tx), a transactional client is returned.
  44764. func (m WxMutation) Client() *Client {
  44765. client := &Client{config: m.config}
  44766. client.init()
  44767. return client
  44768. }
  44769. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44770. // it returns an error otherwise.
  44771. func (m WxMutation) Tx() (*Tx, error) {
  44772. if _, ok := m.driver.(*txDriver); !ok {
  44773. return nil, errors.New("ent: mutation is not running in a transaction")
  44774. }
  44775. tx := &Tx{config: m.config}
  44776. tx.init()
  44777. return tx, nil
  44778. }
  44779. // SetID sets the value of the id field. Note that this
  44780. // operation is only accepted on creation of Wx entities.
  44781. func (m *WxMutation) SetID(id uint64) {
  44782. m.id = &id
  44783. }
  44784. // ID returns the ID value in the mutation. Note that the ID is only available
  44785. // if it was provided to the builder or after it was returned from the database.
  44786. func (m *WxMutation) ID() (id uint64, exists bool) {
  44787. if m.id == nil {
  44788. return
  44789. }
  44790. return *m.id, true
  44791. }
  44792. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44793. // That means, if the mutation is applied within a transaction with an isolation level such
  44794. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44795. // or updated by the mutation.
  44796. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  44797. switch {
  44798. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44799. id, exists := m.ID()
  44800. if exists {
  44801. return []uint64{id}, nil
  44802. }
  44803. fallthrough
  44804. case m.op.Is(OpUpdate | OpDelete):
  44805. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  44806. default:
  44807. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44808. }
  44809. }
  44810. // SetCreatedAt sets the "created_at" field.
  44811. func (m *WxMutation) SetCreatedAt(t time.Time) {
  44812. m.created_at = &t
  44813. }
  44814. // CreatedAt returns the value of the "created_at" field in the mutation.
  44815. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  44816. v := m.created_at
  44817. if v == nil {
  44818. return
  44819. }
  44820. return *v, true
  44821. }
  44822. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  44823. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44825. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44826. if !m.op.Is(OpUpdateOne) {
  44827. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44828. }
  44829. if m.id == nil || m.oldValue == nil {
  44830. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44831. }
  44832. oldValue, err := m.oldValue(ctx)
  44833. if err != nil {
  44834. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44835. }
  44836. return oldValue.CreatedAt, nil
  44837. }
  44838. // ResetCreatedAt resets all changes to the "created_at" field.
  44839. func (m *WxMutation) ResetCreatedAt() {
  44840. m.created_at = nil
  44841. }
  44842. // SetUpdatedAt sets the "updated_at" field.
  44843. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  44844. m.updated_at = &t
  44845. }
  44846. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44847. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  44848. v := m.updated_at
  44849. if v == nil {
  44850. return
  44851. }
  44852. return *v, true
  44853. }
  44854. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  44855. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44857. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44858. if !m.op.Is(OpUpdateOne) {
  44859. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44860. }
  44861. if m.id == nil || m.oldValue == nil {
  44862. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44863. }
  44864. oldValue, err := m.oldValue(ctx)
  44865. if err != nil {
  44866. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44867. }
  44868. return oldValue.UpdatedAt, nil
  44869. }
  44870. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44871. func (m *WxMutation) ResetUpdatedAt() {
  44872. m.updated_at = nil
  44873. }
  44874. // SetStatus sets the "status" field.
  44875. func (m *WxMutation) SetStatus(u uint8) {
  44876. m.status = &u
  44877. m.addstatus = nil
  44878. }
  44879. // Status returns the value of the "status" field in the mutation.
  44880. func (m *WxMutation) Status() (r uint8, exists bool) {
  44881. v := m.status
  44882. if v == nil {
  44883. return
  44884. }
  44885. return *v, true
  44886. }
  44887. // OldStatus returns the old "status" field's value of the Wx entity.
  44888. // If the Wx 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 *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44891. if !m.op.Is(OpUpdateOne) {
  44892. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44893. }
  44894. if m.id == nil || m.oldValue == nil {
  44895. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  44900. }
  44901. return oldValue.Status, nil
  44902. }
  44903. // AddStatus adds u to the "status" field.
  44904. func (m *WxMutation) AddStatus(u int8) {
  44905. if m.addstatus != nil {
  44906. *m.addstatus += u
  44907. } else {
  44908. m.addstatus = &u
  44909. }
  44910. }
  44911. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44912. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  44913. v := m.addstatus
  44914. if v == nil {
  44915. return
  44916. }
  44917. return *v, true
  44918. }
  44919. // ClearStatus clears the value of the "status" field.
  44920. func (m *WxMutation) ClearStatus() {
  44921. m.status = nil
  44922. m.addstatus = nil
  44923. m.clearedFields[wx.FieldStatus] = struct{}{}
  44924. }
  44925. // StatusCleared returns if the "status" field was cleared in this mutation.
  44926. func (m *WxMutation) StatusCleared() bool {
  44927. _, ok := m.clearedFields[wx.FieldStatus]
  44928. return ok
  44929. }
  44930. // ResetStatus resets all changes to the "status" field.
  44931. func (m *WxMutation) ResetStatus() {
  44932. m.status = nil
  44933. m.addstatus = nil
  44934. delete(m.clearedFields, wx.FieldStatus)
  44935. }
  44936. // SetDeletedAt sets the "deleted_at" field.
  44937. func (m *WxMutation) SetDeletedAt(t time.Time) {
  44938. m.deleted_at = &t
  44939. }
  44940. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44941. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  44942. v := m.deleted_at
  44943. if v == nil {
  44944. return
  44945. }
  44946. return *v, true
  44947. }
  44948. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  44949. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44951. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44952. if !m.op.Is(OpUpdateOne) {
  44953. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44954. }
  44955. if m.id == nil || m.oldValue == nil {
  44956. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44957. }
  44958. oldValue, err := m.oldValue(ctx)
  44959. if err != nil {
  44960. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44961. }
  44962. return oldValue.DeletedAt, nil
  44963. }
  44964. // ClearDeletedAt clears the value of the "deleted_at" field.
  44965. func (m *WxMutation) ClearDeletedAt() {
  44966. m.deleted_at = nil
  44967. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  44968. }
  44969. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44970. func (m *WxMutation) DeletedAtCleared() bool {
  44971. _, ok := m.clearedFields[wx.FieldDeletedAt]
  44972. return ok
  44973. }
  44974. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44975. func (m *WxMutation) ResetDeletedAt() {
  44976. m.deleted_at = nil
  44977. delete(m.clearedFields, wx.FieldDeletedAt)
  44978. }
  44979. // SetServerID sets the "server_id" field.
  44980. func (m *WxMutation) SetServerID(u uint64) {
  44981. m.server = &u
  44982. }
  44983. // ServerID returns the value of the "server_id" field in the mutation.
  44984. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  44985. v := m.server
  44986. if v == nil {
  44987. return
  44988. }
  44989. return *v, true
  44990. }
  44991. // OldServerID returns the old "server_id" field's value of the Wx entity.
  44992. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44994. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  44995. if !m.op.Is(OpUpdateOne) {
  44996. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  44997. }
  44998. if m.id == nil || m.oldValue == nil {
  44999. return v, errors.New("OldServerID requires an ID field in the mutation")
  45000. }
  45001. oldValue, err := m.oldValue(ctx)
  45002. if err != nil {
  45003. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  45004. }
  45005. return oldValue.ServerID, nil
  45006. }
  45007. // ClearServerID clears the value of the "server_id" field.
  45008. func (m *WxMutation) ClearServerID() {
  45009. m.server = nil
  45010. m.clearedFields[wx.FieldServerID] = struct{}{}
  45011. }
  45012. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  45013. func (m *WxMutation) ServerIDCleared() bool {
  45014. _, ok := m.clearedFields[wx.FieldServerID]
  45015. return ok
  45016. }
  45017. // ResetServerID resets all changes to the "server_id" field.
  45018. func (m *WxMutation) ResetServerID() {
  45019. m.server = nil
  45020. delete(m.clearedFields, wx.FieldServerID)
  45021. }
  45022. // SetPort sets the "port" field.
  45023. func (m *WxMutation) SetPort(s string) {
  45024. m.port = &s
  45025. }
  45026. // Port returns the value of the "port" field in the mutation.
  45027. func (m *WxMutation) Port() (r string, exists bool) {
  45028. v := m.port
  45029. if v == nil {
  45030. return
  45031. }
  45032. return *v, true
  45033. }
  45034. // OldPort returns the old "port" field's value of the Wx entity.
  45035. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45037. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  45038. if !m.op.Is(OpUpdateOne) {
  45039. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  45040. }
  45041. if m.id == nil || m.oldValue == nil {
  45042. return v, errors.New("OldPort requires an ID field in the mutation")
  45043. }
  45044. oldValue, err := m.oldValue(ctx)
  45045. if err != nil {
  45046. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  45047. }
  45048. return oldValue.Port, nil
  45049. }
  45050. // ResetPort resets all changes to the "port" field.
  45051. func (m *WxMutation) ResetPort() {
  45052. m.port = nil
  45053. }
  45054. // SetProcessID sets the "process_id" field.
  45055. func (m *WxMutation) SetProcessID(s string) {
  45056. m.process_id = &s
  45057. }
  45058. // ProcessID returns the value of the "process_id" field in the mutation.
  45059. func (m *WxMutation) ProcessID() (r string, exists bool) {
  45060. v := m.process_id
  45061. if v == nil {
  45062. return
  45063. }
  45064. return *v, true
  45065. }
  45066. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  45067. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45069. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  45070. if !m.op.Is(OpUpdateOne) {
  45071. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  45072. }
  45073. if m.id == nil || m.oldValue == nil {
  45074. return v, errors.New("OldProcessID requires an ID field in the mutation")
  45075. }
  45076. oldValue, err := m.oldValue(ctx)
  45077. if err != nil {
  45078. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  45079. }
  45080. return oldValue.ProcessID, nil
  45081. }
  45082. // ResetProcessID resets all changes to the "process_id" field.
  45083. func (m *WxMutation) ResetProcessID() {
  45084. m.process_id = nil
  45085. }
  45086. // SetCallback sets the "callback" field.
  45087. func (m *WxMutation) SetCallback(s string) {
  45088. m.callback = &s
  45089. }
  45090. // Callback returns the value of the "callback" field in the mutation.
  45091. func (m *WxMutation) Callback() (r string, exists bool) {
  45092. v := m.callback
  45093. if v == nil {
  45094. return
  45095. }
  45096. return *v, true
  45097. }
  45098. // OldCallback returns the old "callback" field's value of the Wx entity.
  45099. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45101. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  45102. if !m.op.Is(OpUpdateOne) {
  45103. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  45104. }
  45105. if m.id == nil || m.oldValue == nil {
  45106. return v, errors.New("OldCallback requires an ID field in the mutation")
  45107. }
  45108. oldValue, err := m.oldValue(ctx)
  45109. if err != nil {
  45110. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  45111. }
  45112. return oldValue.Callback, nil
  45113. }
  45114. // ResetCallback resets all changes to the "callback" field.
  45115. func (m *WxMutation) ResetCallback() {
  45116. m.callback = nil
  45117. }
  45118. // SetWxid sets the "wxid" field.
  45119. func (m *WxMutation) SetWxid(s string) {
  45120. m.wxid = &s
  45121. }
  45122. // Wxid returns the value of the "wxid" field in the mutation.
  45123. func (m *WxMutation) Wxid() (r string, exists bool) {
  45124. v := m.wxid
  45125. if v == nil {
  45126. return
  45127. }
  45128. return *v, true
  45129. }
  45130. // OldWxid returns the old "wxid" field's value of the Wx entity.
  45131. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45133. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  45134. if !m.op.Is(OpUpdateOne) {
  45135. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45136. }
  45137. if m.id == nil || m.oldValue == nil {
  45138. return v, errors.New("OldWxid requires an ID field in the mutation")
  45139. }
  45140. oldValue, err := m.oldValue(ctx)
  45141. if err != nil {
  45142. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45143. }
  45144. return oldValue.Wxid, nil
  45145. }
  45146. // ResetWxid resets all changes to the "wxid" field.
  45147. func (m *WxMutation) ResetWxid() {
  45148. m.wxid = nil
  45149. }
  45150. // SetAccount sets the "account" field.
  45151. func (m *WxMutation) SetAccount(s string) {
  45152. m.account = &s
  45153. }
  45154. // Account returns the value of the "account" field in the mutation.
  45155. func (m *WxMutation) Account() (r string, exists bool) {
  45156. v := m.account
  45157. if v == nil {
  45158. return
  45159. }
  45160. return *v, true
  45161. }
  45162. // OldAccount returns the old "account" field's value of the Wx entity.
  45163. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45165. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  45166. if !m.op.Is(OpUpdateOne) {
  45167. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  45168. }
  45169. if m.id == nil || m.oldValue == nil {
  45170. return v, errors.New("OldAccount requires an ID field in the mutation")
  45171. }
  45172. oldValue, err := m.oldValue(ctx)
  45173. if err != nil {
  45174. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  45175. }
  45176. return oldValue.Account, nil
  45177. }
  45178. // ResetAccount resets all changes to the "account" field.
  45179. func (m *WxMutation) ResetAccount() {
  45180. m.account = nil
  45181. }
  45182. // SetNickname sets the "nickname" field.
  45183. func (m *WxMutation) SetNickname(s string) {
  45184. m.nickname = &s
  45185. }
  45186. // Nickname returns the value of the "nickname" field in the mutation.
  45187. func (m *WxMutation) Nickname() (r string, exists bool) {
  45188. v := m.nickname
  45189. if v == nil {
  45190. return
  45191. }
  45192. return *v, true
  45193. }
  45194. // OldNickname returns the old "nickname" field's value of the Wx entity.
  45195. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45197. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  45198. if !m.op.Is(OpUpdateOne) {
  45199. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45200. }
  45201. if m.id == nil || m.oldValue == nil {
  45202. return v, errors.New("OldNickname requires an ID field in the mutation")
  45203. }
  45204. oldValue, err := m.oldValue(ctx)
  45205. if err != nil {
  45206. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45207. }
  45208. return oldValue.Nickname, nil
  45209. }
  45210. // ResetNickname resets all changes to the "nickname" field.
  45211. func (m *WxMutation) ResetNickname() {
  45212. m.nickname = nil
  45213. }
  45214. // SetTel sets the "tel" field.
  45215. func (m *WxMutation) SetTel(s string) {
  45216. m.tel = &s
  45217. }
  45218. // Tel returns the value of the "tel" field in the mutation.
  45219. func (m *WxMutation) Tel() (r string, exists bool) {
  45220. v := m.tel
  45221. if v == nil {
  45222. return
  45223. }
  45224. return *v, true
  45225. }
  45226. // OldTel returns the old "tel" field's value of the Wx entity.
  45227. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45229. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  45230. if !m.op.Is(OpUpdateOne) {
  45231. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  45232. }
  45233. if m.id == nil || m.oldValue == nil {
  45234. return v, errors.New("OldTel requires an ID field in the mutation")
  45235. }
  45236. oldValue, err := m.oldValue(ctx)
  45237. if err != nil {
  45238. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  45239. }
  45240. return oldValue.Tel, nil
  45241. }
  45242. // ResetTel resets all changes to the "tel" field.
  45243. func (m *WxMutation) ResetTel() {
  45244. m.tel = nil
  45245. }
  45246. // SetHeadBig sets the "head_big" field.
  45247. func (m *WxMutation) SetHeadBig(s string) {
  45248. m.head_big = &s
  45249. }
  45250. // HeadBig returns the value of the "head_big" field in the mutation.
  45251. func (m *WxMutation) HeadBig() (r string, exists bool) {
  45252. v := m.head_big
  45253. if v == nil {
  45254. return
  45255. }
  45256. return *v, true
  45257. }
  45258. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  45259. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45261. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  45262. if !m.op.Is(OpUpdateOne) {
  45263. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  45264. }
  45265. if m.id == nil || m.oldValue == nil {
  45266. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  45267. }
  45268. oldValue, err := m.oldValue(ctx)
  45269. if err != nil {
  45270. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  45271. }
  45272. return oldValue.HeadBig, nil
  45273. }
  45274. // ResetHeadBig resets all changes to the "head_big" field.
  45275. func (m *WxMutation) ResetHeadBig() {
  45276. m.head_big = nil
  45277. }
  45278. // SetOrganizationID sets the "organization_id" field.
  45279. func (m *WxMutation) SetOrganizationID(u uint64) {
  45280. m.organization_id = &u
  45281. m.addorganization_id = nil
  45282. }
  45283. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45284. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  45285. v := m.organization_id
  45286. if v == nil {
  45287. return
  45288. }
  45289. return *v, true
  45290. }
  45291. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  45292. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45294. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45295. if !m.op.Is(OpUpdateOne) {
  45296. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45297. }
  45298. if m.id == nil || m.oldValue == nil {
  45299. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45300. }
  45301. oldValue, err := m.oldValue(ctx)
  45302. if err != nil {
  45303. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45304. }
  45305. return oldValue.OrganizationID, nil
  45306. }
  45307. // AddOrganizationID adds u to the "organization_id" field.
  45308. func (m *WxMutation) AddOrganizationID(u int64) {
  45309. if m.addorganization_id != nil {
  45310. *m.addorganization_id += u
  45311. } else {
  45312. m.addorganization_id = &u
  45313. }
  45314. }
  45315. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45316. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  45317. v := m.addorganization_id
  45318. if v == nil {
  45319. return
  45320. }
  45321. return *v, true
  45322. }
  45323. // ClearOrganizationID clears the value of the "organization_id" field.
  45324. func (m *WxMutation) ClearOrganizationID() {
  45325. m.organization_id = nil
  45326. m.addorganization_id = nil
  45327. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  45328. }
  45329. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  45330. func (m *WxMutation) OrganizationIDCleared() bool {
  45331. _, ok := m.clearedFields[wx.FieldOrganizationID]
  45332. return ok
  45333. }
  45334. // ResetOrganizationID resets all changes to the "organization_id" field.
  45335. func (m *WxMutation) ResetOrganizationID() {
  45336. m.organization_id = nil
  45337. m.addorganization_id = nil
  45338. delete(m.clearedFields, wx.FieldOrganizationID)
  45339. }
  45340. // SetAgentID sets the "agent_id" field.
  45341. func (m *WxMutation) SetAgentID(u uint64) {
  45342. m.agent = &u
  45343. }
  45344. // AgentID returns the value of the "agent_id" field in the mutation.
  45345. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  45346. v := m.agent
  45347. if v == nil {
  45348. return
  45349. }
  45350. return *v, true
  45351. }
  45352. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  45353. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45355. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  45356. if !m.op.Is(OpUpdateOne) {
  45357. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  45358. }
  45359. if m.id == nil || m.oldValue == nil {
  45360. return v, errors.New("OldAgentID requires an ID field in the mutation")
  45361. }
  45362. oldValue, err := m.oldValue(ctx)
  45363. if err != nil {
  45364. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  45365. }
  45366. return oldValue.AgentID, nil
  45367. }
  45368. // ResetAgentID resets all changes to the "agent_id" field.
  45369. func (m *WxMutation) ResetAgentID() {
  45370. m.agent = nil
  45371. }
  45372. // SetAPIBase sets the "api_base" field.
  45373. func (m *WxMutation) SetAPIBase(s string) {
  45374. m.api_base = &s
  45375. }
  45376. // APIBase returns the value of the "api_base" field in the mutation.
  45377. func (m *WxMutation) APIBase() (r string, exists bool) {
  45378. v := m.api_base
  45379. if v == nil {
  45380. return
  45381. }
  45382. return *v, true
  45383. }
  45384. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  45385. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45387. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45388. if !m.op.Is(OpUpdateOne) {
  45389. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45390. }
  45391. if m.id == nil || m.oldValue == nil {
  45392. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45393. }
  45394. oldValue, err := m.oldValue(ctx)
  45395. if err != nil {
  45396. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45397. }
  45398. return oldValue.APIBase, nil
  45399. }
  45400. // ClearAPIBase clears the value of the "api_base" field.
  45401. func (m *WxMutation) ClearAPIBase() {
  45402. m.api_base = nil
  45403. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  45404. }
  45405. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45406. func (m *WxMutation) APIBaseCleared() bool {
  45407. _, ok := m.clearedFields[wx.FieldAPIBase]
  45408. return ok
  45409. }
  45410. // ResetAPIBase resets all changes to the "api_base" field.
  45411. func (m *WxMutation) ResetAPIBase() {
  45412. m.api_base = nil
  45413. delete(m.clearedFields, wx.FieldAPIBase)
  45414. }
  45415. // SetAPIKey sets the "api_key" field.
  45416. func (m *WxMutation) SetAPIKey(s string) {
  45417. m.api_key = &s
  45418. }
  45419. // APIKey returns the value of the "api_key" field in the mutation.
  45420. func (m *WxMutation) APIKey() (r string, exists bool) {
  45421. v := m.api_key
  45422. if v == nil {
  45423. return
  45424. }
  45425. return *v, true
  45426. }
  45427. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  45428. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45430. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45431. if !m.op.Is(OpUpdateOne) {
  45432. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45433. }
  45434. if m.id == nil || m.oldValue == nil {
  45435. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45436. }
  45437. oldValue, err := m.oldValue(ctx)
  45438. if err != nil {
  45439. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45440. }
  45441. return oldValue.APIKey, nil
  45442. }
  45443. // ClearAPIKey clears the value of the "api_key" field.
  45444. func (m *WxMutation) ClearAPIKey() {
  45445. m.api_key = nil
  45446. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  45447. }
  45448. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45449. func (m *WxMutation) APIKeyCleared() bool {
  45450. _, ok := m.clearedFields[wx.FieldAPIKey]
  45451. return ok
  45452. }
  45453. // ResetAPIKey resets all changes to the "api_key" field.
  45454. func (m *WxMutation) ResetAPIKey() {
  45455. m.api_key = nil
  45456. delete(m.clearedFields, wx.FieldAPIKey)
  45457. }
  45458. // SetAllowList sets the "allow_list" field.
  45459. func (m *WxMutation) SetAllowList(s []string) {
  45460. m.allow_list = &s
  45461. m.appendallow_list = nil
  45462. }
  45463. // AllowList returns the value of the "allow_list" field in the mutation.
  45464. func (m *WxMutation) AllowList() (r []string, exists bool) {
  45465. v := m.allow_list
  45466. if v == nil {
  45467. return
  45468. }
  45469. return *v, true
  45470. }
  45471. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  45472. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45474. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  45475. if !m.op.Is(OpUpdateOne) {
  45476. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  45477. }
  45478. if m.id == nil || m.oldValue == nil {
  45479. return v, errors.New("OldAllowList requires an ID field in the mutation")
  45480. }
  45481. oldValue, err := m.oldValue(ctx)
  45482. if err != nil {
  45483. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  45484. }
  45485. return oldValue.AllowList, nil
  45486. }
  45487. // AppendAllowList adds s to the "allow_list" field.
  45488. func (m *WxMutation) AppendAllowList(s []string) {
  45489. m.appendallow_list = append(m.appendallow_list, s...)
  45490. }
  45491. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  45492. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  45493. if len(m.appendallow_list) == 0 {
  45494. return nil, false
  45495. }
  45496. return m.appendallow_list, true
  45497. }
  45498. // ResetAllowList resets all changes to the "allow_list" field.
  45499. func (m *WxMutation) ResetAllowList() {
  45500. m.allow_list = nil
  45501. m.appendallow_list = nil
  45502. }
  45503. // SetGroupAllowList sets the "group_allow_list" field.
  45504. func (m *WxMutation) SetGroupAllowList(s []string) {
  45505. m.group_allow_list = &s
  45506. m.appendgroup_allow_list = nil
  45507. }
  45508. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  45509. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  45510. v := m.group_allow_list
  45511. if v == nil {
  45512. return
  45513. }
  45514. return *v, true
  45515. }
  45516. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  45517. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45519. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  45520. if !m.op.Is(OpUpdateOne) {
  45521. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  45522. }
  45523. if m.id == nil || m.oldValue == nil {
  45524. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  45525. }
  45526. oldValue, err := m.oldValue(ctx)
  45527. if err != nil {
  45528. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  45529. }
  45530. return oldValue.GroupAllowList, nil
  45531. }
  45532. // AppendGroupAllowList adds s to the "group_allow_list" field.
  45533. func (m *WxMutation) AppendGroupAllowList(s []string) {
  45534. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  45535. }
  45536. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  45537. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  45538. if len(m.appendgroup_allow_list) == 0 {
  45539. return nil, false
  45540. }
  45541. return m.appendgroup_allow_list, true
  45542. }
  45543. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  45544. func (m *WxMutation) ResetGroupAllowList() {
  45545. m.group_allow_list = nil
  45546. m.appendgroup_allow_list = nil
  45547. }
  45548. // SetBlockList sets the "block_list" field.
  45549. func (m *WxMutation) SetBlockList(s []string) {
  45550. m.block_list = &s
  45551. m.appendblock_list = nil
  45552. }
  45553. // BlockList returns the value of the "block_list" field in the mutation.
  45554. func (m *WxMutation) BlockList() (r []string, exists bool) {
  45555. v := m.block_list
  45556. if v == nil {
  45557. return
  45558. }
  45559. return *v, true
  45560. }
  45561. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  45562. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45564. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  45565. if !m.op.Is(OpUpdateOne) {
  45566. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  45567. }
  45568. if m.id == nil || m.oldValue == nil {
  45569. return v, errors.New("OldBlockList requires an ID field in the mutation")
  45570. }
  45571. oldValue, err := m.oldValue(ctx)
  45572. if err != nil {
  45573. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  45574. }
  45575. return oldValue.BlockList, nil
  45576. }
  45577. // AppendBlockList adds s to the "block_list" field.
  45578. func (m *WxMutation) AppendBlockList(s []string) {
  45579. m.appendblock_list = append(m.appendblock_list, s...)
  45580. }
  45581. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  45582. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  45583. if len(m.appendblock_list) == 0 {
  45584. return nil, false
  45585. }
  45586. return m.appendblock_list, true
  45587. }
  45588. // ResetBlockList resets all changes to the "block_list" field.
  45589. func (m *WxMutation) ResetBlockList() {
  45590. m.block_list = nil
  45591. m.appendblock_list = nil
  45592. }
  45593. // SetGroupBlockList sets the "group_block_list" field.
  45594. func (m *WxMutation) SetGroupBlockList(s []string) {
  45595. m.group_block_list = &s
  45596. m.appendgroup_block_list = nil
  45597. }
  45598. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  45599. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  45600. v := m.group_block_list
  45601. if v == nil {
  45602. return
  45603. }
  45604. return *v, true
  45605. }
  45606. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  45607. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45609. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  45610. if !m.op.Is(OpUpdateOne) {
  45611. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  45612. }
  45613. if m.id == nil || m.oldValue == nil {
  45614. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  45615. }
  45616. oldValue, err := m.oldValue(ctx)
  45617. if err != nil {
  45618. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  45619. }
  45620. return oldValue.GroupBlockList, nil
  45621. }
  45622. // AppendGroupBlockList adds s to the "group_block_list" field.
  45623. func (m *WxMutation) AppendGroupBlockList(s []string) {
  45624. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  45625. }
  45626. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  45627. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  45628. if len(m.appendgroup_block_list) == 0 {
  45629. return nil, false
  45630. }
  45631. return m.appendgroup_block_list, true
  45632. }
  45633. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  45634. func (m *WxMutation) ResetGroupBlockList() {
  45635. m.group_block_list = nil
  45636. m.appendgroup_block_list = nil
  45637. }
  45638. // SetCtype sets the "ctype" field.
  45639. func (m *WxMutation) SetCtype(u uint64) {
  45640. m.ctype = &u
  45641. m.addctype = nil
  45642. }
  45643. // Ctype returns the value of the "ctype" field in the mutation.
  45644. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  45645. v := m.ctype
  45646. if v == nil {
  45647. return
  45648. }
  45649. return *v, true
  45650. }
  45651. // OldCtype returns the old "ctype" field's value of the Wx entity.
  45652. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45654. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  45655. if !m.op.Is(OpUpdateOne) {
  45656. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  45657. }
  45658. if m.id == nil || m.oldValue == nil {
  45659. return v, errors.New("OldCtype requires an ID field in the mutation")
  45660. }
  45661. oldValue, err := m.oldValue(ctx)
  45662. if err != nil {
  45663. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  45664. }
  45665. return oldValue.Ctype, nil
  45666. }
  45667. // AddCtype adds u to the "ctype" field.
  45668. func (m *WxMutation) AddCtype(u int64) {
  45669. if m.addctype != nil {
  45670. *m.addctype += u
  45671. } else {
  45672. m.addctype = &u
  45673. }
  45674. }
  45675. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  45676. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  45677. v := m.addctype
  45678. if v == nil {
  45679. return
  45680. }
  45681. return *v, true
  45682. }
  45683. // ClearCtype clears the value of the "ctype" field.
  45684. func (m *WxMutation) ClearCtype() {
  45685. m.ctype = nil
  45686. m.addctype = nil
  45687. m.clearedFields[wx.FieldCtype] = struct{}{}
  45688. }
  45689. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  45690. func (m *WxMutation) CtypeCleared() bool {
  45691. _, ok := m.clearedFields[wx.FieldCtype]
  45692. return ok
  45693. }
  45694. // ResetCtype resets all changes to the "ctype" field.
  45695. func (m *WxMutation) ResetCtype() {
  45696. m.ctype = nil
  45697. m.addctype = nil
  45698. delete(m.clearedFields, wx.FieldCtype)
  45699. }
  45700. // ClearServer clears the "server" edge to the Server entity.
  45701. func (m *WxMutation) ClearServer() {
  45702. m.clearedserver = true
  45703. m.clearedFields[wx.FieldServerID] = struct{}{}
  45704. }
  45705. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  45706. func (m *WxMutation) ServerCleared() bool {
  45707. return m.ServerIDCleared() || m.clearedserver
  45708. }
  45709. // ServerIDs returns the "server" edge IDs in the mutation.
  45710. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45711. // ServerID instead. It exists only for internal usage by the builders.
  45712. func (m *WxMutation) ServerIDs() (ids []uint64) {
  45713. if id := m.server; id != nil {
  45714. ids = append(ids, *id)
  45715. }
  45716. return
  45717. }
  45718. // ResetServer resets all changes to the "server" edge.
  45719. func (m *WxMutation) ResetServer() {
  45720. m.server = nil
  45721. m.clearedserver = false
  45722. }
  45723. // ClearAgent clears the "agent" edge to the Agent entity.
  45724. func (m *WxMutation) ClearAgent() {
  45725. m.clearedagent = true
  45726. m.clearedFields[wx.FieldAgentID] = struct{}{}
  45727. }
  45728. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  45729. func (m *WxMutation) AgentCleared() bool {
  45730. return m.clearedagent
  45731. }
  45732. // AgentIDs returns the "agent" edge IDs in the mutation.
  45733. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45734. // AgentID instead. It exists only for internal usage by the builders.
  45735. func (m *WxMutation) AgentIDs() (ids []uint64) {
  45736. if id := m.agent; id != nil {
  45737. ids = append(ids, *id)
  45738. }
  45739. return
  45740. }
  45741. // ResetAgent resets all changes to the "agent" edge.
  45742. func (m *WxMutation) ResetAgent() {
  45743. m.agent = nil
  45744. m.clearedagent = false
  45745. }
  45746. // Where appends a list predicates to the WxMutation builder.
  45747. func (m *WxMutation) Where(ps ...predicate.Wx) {
  45748. m.predicates = append(m.predicates, ps...)
  45749. }
  45750. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  45751. // users can use type-assertion to append predicates that do not depend on any generated package.
  45752. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  45753. p := make([]predicate.Wx, len(ps))
  45754. for i := range ps {
  45755. p[i] = ps[i]
  45756. }
  45757. m.Where(p...)
  45758. }
  45759. // Op returns the operation name.
  45760. func (m *WxMutation) Op() Op {
  45761. return m.op
  45762. }
  45763. // SetOp allows setting the mutation operation.
  45764. func (m *WxMutation) SetOp(op Op) {
  45765. m.op = op
  45766. }
  45767. // Type returns the node type of this mutation (Wx).
  45768. func (m *WxMutation) Type() string {
  45769. return m.typ
  45770. }
  45771. // Fields returns all fields that were changed during this mutation. Note that in
  45772. // order to get all numeric fields that were incremented/decremented, call
  45773. // AddedFields().
  45774. func (m *WxMutation) Fields() []string {
  45775. fields := make([]string, 0, 22)
  45776. if m.created_at != nil {
  45777. fields = append(fields, wx.FieldCreatedAt)
  45778. }
  45779. if m.updated_at != nil {
  45780. fields = append(fields, wx.FieldUpdatedAt)
  45781. }
  45782. if m.status != nil {
  45783. fields = append(fields, wx.FieldStatus)
  45784. }
  45785. if m.deleted_at != nil {
  45786. fields = append(fields, wx.FieldDeletedAt)
  45787. }
  45788. if m.server != nil {
  45789. fields = append(fields, wx.FieldServerID)
  45790. }
  45791. if m.port != nil {
  45792. fields = append(fields, wx.FieldPort)
  45793. }
  45794. if m.process_id != nil {
  45795. fields = append(fields, wx.FieldProcessID)
  45796. }
  45797. if m.callback != nil {
  45798. fields = append(fields, wx.FieldCallback)
  45799. }
  45800. if m.wxid != nil {
  45801. fields = append(fields, wx.FieldWxid)
  45802. }
  45803. if m.account != nil {
  45804. fields = append(fields, wx.FieldAccount)
  45805. }
  45806. if m.nickname != nil {
  45807. fields = append(fields, wx.FieldNickname)
  45808. }
  45809. if m.tel != nil {
  45810. fields = append(fields, wx.FieldTel)
  45811. }
  45812. if m.head_big != nil {
  45813. fields = append(fields, wx.FieldHeadBig)
  45814. }
  45815. if m.organization_id != nil {
  45816. fields = append(fields, wx.FieldOrganizationID)
  45817. }
  45818. if m.agent != nil {
  45819. fields = append(fields, wx.FieldAgentID)
  45820. }
  45821. if m.api_base != nil {
  45822. fields = append(fields, wx.FieldAPIBase)
  45823. }
  45824. if m.api_key != nil {
  45825. fields = append(fields, wx.FieldAPIKey)
  45826. }
  45827. if m.allow_list != nil {
  45828. fields = append(fields, wx.FieldAllowList)
  45829. }
  45830. if m.group_allow_list != nil {
  45831. fields = append(fields, wx.FieldGroupAllowList)
  45832. }
  45833. if m.block_list != nil {
  45834. fields = append(fields, wx.FieldBlockList)
  45835. }
  45836. if m.group_block_list != nil {
  45837. fields = append(fields, wx.FieldGroupBlockList)
  45838. }
  45839. if m.ctype != nil {
  45840. fields = append(fields, wx.FieldCtype)
  45841. }
  45842. return fields
  45843. }
  45844. // Field returns the value of a field with the given name. The second boolean
  45845. // return value indicates that this field was not set, or was not defined in the
  45846. // schema.
  45847. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  45848. switch name {
  45849. case wx.FieldCreatedAt:
  45850. return m.CreatedAt()
  45851. case wx.FieldUpdatedAt:
  45852. return m.UpdatedAt()
  45853. case wx.FieldStatus:
  45854. return m.Status()
  45855. case wx.FieldDeletedAt:
  45856. return m.DeletedAt()
  45857. case wx.FieldServerID:
  45858. return m.ServerID()
  45859. case wx.FieldPort:
  45860. return m.Port()
  45861. case wx.FieldProcessID:
  45862. return m.ProcessID()
  45863. case wx.FieldCallback:
  45864. return m.Callback()
  45865. case wx.FieldWxid:
  45866. return m.Wxid()
  45867. case wx.FieldAccount:
  45868. return m.Account()
  45869. case wx.FieldNickname:
  45870. return m.Nickname()
  45871. case wx.FieldTel:
  45872. return m.Tel()
  45873. case wx.FieldHeadBig:
  45874. return m.HeadBig()
  45875. case wx.FieldOrganizationID:
  45876. return m.OrganizationID()
  45877. case wx.FieldAgentID:
  45878. return m.AgentID()
  45879. case wx.FieldAPIBase:
  45880. return m.APIBase()
  45881. case wx.FieldAPIKey:
  45882. return m.APIKey()
  45883. case wx.FieldAllowList:
  45884. return m.AllowList()
  45885. case wx.FieldGroupAllowList:
  45886. return m.GroupAllowList()
  45887. case wx.FieldBlockList:
  45888. return m.BlockList()
  45889. case wx.FieldGroupBlockList:
  45890. return m.GroupBlockList()
  45891. case wx.FieldCtype:
  45892. return m.Ctype()
  45893. }
  45894. return nil, false
  45895. }
  45896. // OldField returns the old value of the field from the database. An error is
  45897. // returned if the mutation operation is not UpdateOne, or the query to the
  45898. // database failed.
  45899. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45900. switch name {
  45901. case wx.FieldCreatedAt:
  45902. return m.OldCreatedAt(ctx)
  45903. case wx.FieldUpdatedAt:
  45904. return m.OldUpdatedAt(ctx)
  45905. case wx.FieldStatus:
  45906. return m.OldStatus(ctx)
  45907. case wx.FieldDeletedAt:
  45908. return m.OldDeletedAt(ctx)
  45909. case wx.FieldServerID:
  45910. return m.OldServerID(ctx)
  45911. case wx.FieldPort:
  45912. return m.OldPort(ctx)
  45913. case wx.FieldProcessID:
  45914. return m.OldProcessID(ctx)
  45915. case wx.FieldCallback:
  45916. return m.OldCallback(ctx)
  45917. case wx.FieldWxid:
  45918. return m.OldWxid(ctx)
  45919. case wx.FieldAccount:
  45920. return m.OldAccount(ctx)
  45921. case wx.FieldNickname:
  45922. return m.OldNickname(ctx)
  45923. case wx.FieldTel:
  45924. return m.OldTel(ctx)
  45925. case wx.FieldHeadBig:
  45926. return m.OldHeadBig(ctx)
  45927. case wx.FieldOrganizationID:
  45928. return m.OldOrganizationID(ctx)
  45929. case wx.FieldAgentID:
  45930. return m.OldAgentID(ctx)
  45931. case wx.FieldAPIBase:
  45932. return m.OldAPIBase(ctx)
  45933. case wx.FieldAPIKey:
  45934. return m.OldAPIKey(ctx)
  45935. case wx.FieldAllowList:
  45936. return m.OldAllowList(ctx)
  45937. case wx.FieldGroupAllowList:
  45938. return m.OldGroupAllowList(ctx)
  45939. case wx.FieldBlockList:
  45940. return m.OldBlockList(ctx)
  45941. case wx.FieldGroupBlockList:
  45942. return m.OldGroupBlockList(ctx)
  45943. case wx.FieldCtype:
  45944. return m.OldCtype(ctx)
  45945. }
  45946. return nil, fmt.Errorf("unknown Wx field %s", name)
  45947. }
  45948. // SetField sets the value of a field with the given name. It returns an error if
  45949. // the field is not defined in the schema, or if the type mismatched the field
  45950. // type.
  45951. func (m *WxMutation) SetField(name string, value ent.Value) error {
  45952. switch name {
  45953. case wx.FieldCreatedAt:
  45954. v, ok := value.(time.Time)
  45955. if !ok {
  45956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45957. }
  45958. m.SetCreatedAt(v)
  45959. return nil
  45960. case wx.FieldUpdatedAt:
  45961. v, ok := value.(time.Time)
  45962. if !ok {
  45963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45964. }
  45965. m.SetUpdatedAt(v)
  45966. return nil
  45967. case wx.FieldStatus:
  45968. v, ok := value.(uint8)
  45969. if !ok {
  45970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45971. }
  45972. m.SetStatus(v)
  45973. return nil
  45974. case wx.FieldDeletedAt:
  45975. v, ok := value.(time.Time)
  45976. if !ok {
  45977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45978. }
  45979. m.SetDeletedAt(v)
  45980. return nil
  45981. case wx.FieldServerID:
  45982. v, ok := value.(uint64)
  45983. if !ok {
  45984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45985. }
  45986. m.SetServerID(v)
  45987. return nil
  45988. case wx.FieldPort:
  45989. v, ok := value.(string)
  45990. if !ok {
  45991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45992. }
  45993. m.SetPort(v)
  45994. return nil
  45995. case wx.FieldProcessID:
  45996. v, ok := value.(string)
  45997. if !ok {
  45998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45999. }
  46000. m.SetProcessID(v)
  46001. return nil
  46002. case wx.FieldCallback:
  46003. v, ok := value.(string)
  46004. if !ok {
  46005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46006. }
  46007. m.SetCallback(v)
  46008. return nil
  46009. case wx.FieldWxid:
  46010. v, ok := value.(string)
  46011. if !ok {
  46012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46013. }
  46014. m.SetWxid(v)
  46015. return nil
  46016. case wx.FieldAccount:
  46017. v, ok := value.(string)
  46018. if !ok {
  46019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46020. }
  46021. m.SetAccount(v)
  46022. return nil
  46023. case wx.FieldNickname:
  46024. v, ok := value.(string)
  46025. if !ok {
  46026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46027. }
  46028. m.SetNickname(v)
  46029. return nil
  46030. case wx.FieldTel:
  46031. v, ok := value.(string)
  46032. if !ok {
  46033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46034. }
  46035. m.SetTel(v)
  46036. return nil
  46037. case wx.FieldHeadBig:
  46038. v, ok := value.(string)
  46039. if !ok {
  46040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46041. }
  46042. m.SetHeadBig(v)
  46043. return nil
  46044. case wx.FieldOrganizationID:
  46045. v, ok := value.(uint64)
  46046. if !ok {
  46047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46048. }
  46049. m.SetOrganizationID(v)
  46050. return nil
  46051. case wx.FieldAgentID:
  46052. v, ok := value.(uint64)
  46053. if !ok {
  46054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46055. }
  46056. m.SetAgentID(v)
  46057. return nil
  46058. case wx.FieldAPIBase:
  46059. v, ok := value.(string)
  46060. if !ok {
  46061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46062. }
  46063. m.SetAPIBase(v)
  46064. return nil
  46065. case wx.FieldAPIKey:
  46066. v, ok := value.(string)
  46067. if !ok {
  46068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46069. }
  46070. m.SetAPIKey(v)
  46071. return nil
  46072. case wx.FieldAllowList:
  46073. v, ok := value.([]string)
  46074. if !ok {
  46075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46076. }
  46077. m.SetAllowList(v)
  46078. return nil
  46079. case wx.FieldGroupAllowList:
  46080. v, ok := value.([]string)
  46081. if !ok {
  46082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46083. }
  46084. m.SetGroupAllowList(v)
  46085. return nil
  46086. case wx.FieldBlockList:
  46087. v, ok := value.([]string)
  46088. if !ok {
  46089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46090. }
  46091. m.SetBlockList(v)
  46092. return nil
  46093. case wx.FieldGroupBlockList:
  46094. v, ok := value.([]string)
  46095. if !ok {
  46096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46097. }
  46098. m.SetGroupBlockList(v)
  46099. return nil
  46100. case wx.FieldCtype:
  46101. v, ok := value.(uint64)
  46102. if !ok {
  46103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46104. }
  46105. m.SetCtype(v)
  46106. return nil
  46107. }
  46108. return fmt.Errorf("unknown Wx field %s", name)
  46109. }
  46110. // AddedFields returns all numeric fields that were incremented/decremented during
  46111. // this mutation.
  46112. func (m *WxMutation) AddedFields() []string {
  46113. var fields []string
  46114. if m.addstatus != nil {
  46115. fields = append(fields, wx.FieldStatus)
  46116. }
  46117. if m.addorganization_id != nil {
  46118. fields = append(fields, wx.FieldOrganizationID)
  46119. }
  46120. if m.addctype != nil {
  46121. fields = append(fields, wx.FieldCtype)
  46122. }
  46123. return fields
  46124. }
  46125. // AddedField returns the numeric value that was incremented/decremented on a field
  46126. // with the given name. The second boolean return value indicates that this field
  46127. // was not set, or was not defined in the schema.
  46128. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  46129. switch name {
  46130. case wx.FieldStatus:
  46131. return m.AddedStatus()
  46132. case wx.FieldOrganizationID:
  46133. return m.AddedOrganizationID()
  46134. case wx.FieldCtype:
  46135. return m.AddedCtype()
  46136. }
  46137. return nil, false
  46138. }
  46139. // AddField adds the value to the field with the given name. It returns an error if
  46140. // the field is not defined in the schema, or if the type mismatched the field
  46141. // type.
  46142. func (m *WxMutation) AddField(name string, value ent.Value) error {
  46143. switch name {
  46144. case wx.FieldStatus:
  46145. v, ok := value.(int8)
  46146. if !ok {
  46147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46148. }
  46149. m.AddStatus(v)
  46150. return nil
  46151. case wx.FieldOrganizationID:
  46152. v, ok := value.(int64)
  46153. if !ok {
  46154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46155. }
  46156. m.AddOrganizationID(v)
  46157. return nil
  46158. case wx.FieldCtype:
  46159. v, ok := value.(int64)
  46160. if !ok {
  46161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46162. }
  46163. m.AddCtype(v)
  46164. return nil
  46165. }
  46166. return fmt.Errorf("unknown Wx numeric field %s", name)
  46167. }
  46168. // ClearedFields returns all nullable fields that were cleared during this
  46169. // mutation.
  46170. func (m *WxMutation) ClearedFields() []string {
  46171. var fields []string
  46172. if m.FieldCleared(wx.FieldStatus) {
  46173. fields = append(fields, wx.FieldStatus)
  46174. }
  46175. if m.FieldCleared(wx.FieldDeletedAt) {
  46176. fields = append(fields, wx.FieldDeletedAt)
  46177. }
  46178. if m.FieldCleared(wx.FieldServerID) {
  46179. fields = append(fields, wx.FieldServerID)
  46180. }
  46181. if m.FieldCleared(wx.FieldOrganizationID) {
  46182. fields = append(fields, wx.FieldOrganizationID)
  46183. }
  46184. if m.FieldCleared(wx.FieldAPIBase) {
  46185. fields = append(fields, wx.FieldAPIBase)
  46186. }
  46187. if m.FieldCleared(wx.FieldAPIKey) {
  46188. fields = append(fields, wx.FieldAPIKey)
  46189. }
  46190. if m.FieldCleared(wx.FieldCtype) {
  46191. fields = append(fields, wx.FieldCtype)
  46192. }
  46193. return fields
  46194. }
  46195. // FieldCleared returns a boolean indicating if a field with the given name was
  46196. // cleared in this mutation.
  46197. func (m *WxMutation) FieldCleared(name string) bool {
  46198. _, ok := m.clearedFields[name]
  46199. return ok
  46200. }
  46201. // ClearField clears the value of the field with the given name. It returns an
  46202. // error if the field is not defined in the schema.
  46203. func (m *WxMutation) ClearField(name string) error {
  46204. switch name {
  46205. case wx.FieldStatus:
  46206. m.ClearStatus()
  46207. return nil
  46208. case wx.FieldDeletedAt:
  46209. m.ClearDeletedAt()
  46210. return nil
  46211. case wx.FieldServerID:
  46212. m.ClearServerID()
  46213. return nil
  46214. case wx.FieldOrganizationID:
  46215. m.ClearOrganizationID()
  46216. return nil
  46217. case wx.FieldAPIBase:
  46218. m.ClearAPIBase()
  46219. return nil
  46220. case wx.FieldAPIKey:
  46221. m.ClearAPIKey()
  46222. return nil
  46223. case wx.FieldCtype:
  46224. m.ClearCtype()
  46225. return nil
  46226. }
  46227. return fmt.Errorf("unknown Wx nullable field %s", name)
  46228. }
  46229. // ResetField resets all changes in the mutation for the field with the given name.
  46230. // It returns an error if the field is not defined in the schema.
  46231. func (m *WxMutation) ResetField(name string) error {
  46232. switch name {
  46233. case wx.FieldCreatedAt:
  46234. m.ResetCreatedAt()
  46235. return nil
  46236. case wx.FieldUpdatedAt:
  46237. m.ResetUpdatedAt()
  46238. return nil
  46239. case wx.FieldStatus:
  46240. m.ResetStatus()
  46241. return nil
  46242. case wx.FieldDeletedAt:
  46243. m.ResetDeletedAt()
  46244. return nil
  46245. case wx.FieldServerID:
  46246. m.ResetServerID()
  46247. return nil
  46248. case wx.FieldPort:
  46249. m.ResetPort()
  46250. return nil
  46251. case wx.FieldProcessID:
  46252. m.ResetProcessID()
  46253. return nil
  46254. case wx.FieldCallback:
  46255. m.ResetCallback()
  46256. return nil
  46257. case wx.FieldWxid:
  46258. m.ResetWxid()
  46259. return nil
  46260. case wx.FieldAccount:
  46261. m.ResetAccount()
  46262. return nil
  46263. case wx.FieldNickname:
  46264. m.ResetNickname()
  46265. return nil
  46266. case wx.FieldTel:
  46267. m.ResetTel()
  46268. return nil
  46269. case wx.FieldHeadBig:
  46270. m.ResetHeadBig()
  46271. return nil
  46272. case wx.FieldOrganizationID:
  46273. m.ResetOrganizationID()
  46274. return nil
  46275. case wx.FieldAgentID:
  46276. m.ResetAgentID()
  46277. return nil
  46278. case wx.FieldAPIBase:
  46279. m.ResetAPIBase()
  46280. return nil
  46281. case wx.FieldAPIKey:
  46282. m.ResetAPIKey()
  46283. return nil
  46284. case wx.FieldAllowList:
  46285. m.ResetAllowList()
  46286. return nil
  46287. case wx.FieldGroupAllowList:
  46288. m.ResetGroupAllowList()
  46289. return nil
  46290. case wx.FieldBlockList:
  46291. m.ResetBlockList()
  46292. return nil
  46293. case wx.FieldGroupBlockList:
  46294. m.ResetGroupBlockList()
  46295. return nil
  46296. case wx.FieldCtype:
  46297. m.ResetCtype()
  46298. return nil
  46299. }
  46300. return fmt.Errorf("unknown Wx field %s", name)
  46301. }
  46302. // AddedEdges returns all edge names that were set/added in this mutation.
  46303. func (m *WxMutation) AddedEdges() []string {
  46304. edges := make([]string, 0, 2)
  46305. if m.server != nil {
  46306. edges = append(edges, wx.EdgeServer)
  46307. }
  46308. if m.agent != nil {
  46309. edges = append(edges, wx.EdgeAgent)
  46310. }
  46311. return edges
  46312. }
  46313. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46314. // name in this mutation.
  46315. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  46316. switch name {
  46317. case wx.EdgeServer:
  46318. if id := m.server; id != nil {
  46319. return []ent.Value{*id}
  46320. }
  46321. case wx.EdgeAgent:
  46322. if id := m.agent; id != nil {
  46323. return []ent.Value{*id}
  46324. }
  46325. }
  46326. return nil
  46327. }
  46328. // RemovedEdges returns all edge names that were removed in this mutation.
  46329. func (m *WxMutation) RemovedEdges() []string {
  46330. edges := make([]string, 0, 2)
  46331. return edges
  46332. }
  46333. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46334. // the given name in this mutation.
  46335. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  46336. return nil
  46337. }
  46338. // ClearedEdges returns all edge names that were cleared in this mutation.
  46339. func (m *WxMutation) ClearedEdges() []string {
  46340. edges := make([]string, 0, 2)
  46341. if m.clearedserver {
  46342. edges = append(edges, wx.EdgeServer)
  46343. }
  46344. if m.clearedagent {
  46345. edges = append(edges, wx.EdgeAgent)
  46346. }
  46347. return edges
  46348. }
  46349. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46350. // was cleared in this mutation.
  46351. func (m *WxMutation) EdgeCleared(name string) bool {
  46352. switch name {
  46353. case wx.EdgeServer:
  46354. return m.clearedserver
  46355. case wx.EdgeAgent:
  46356. return m.clearedagent
  46357. }
  46358. return false
  46359. }
  46360. // ClearEdge clears the value of the edge with the given name. It returns an error
  46361. // if that edge is not defined in the schema.
  46362. func (m *WxMutation) ClearEdge(name string) error {
  46363. switch name {
  46364. case wx.EdgeServer:
  46365. m.ClearServer()
  46366. return nil
  46367. case wx.EdgeAgent:
  46368. m.ClearAgent()
  46369. return nil
  46370. }
  46371. return fmt.Errorf("unknown Wx unique edge %s", name)
  46372. }
  46373. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46374. // It returns an error if the edge is not defined in the schema.
  46375. func (m *WxMutation) ResetEdge(name string) error {
  46376. switch name {
  46377. case wx.EdgeServer:
  46378. m.ResetServer()
  46379. return nil
  46380. case wx.EdgeAgent:
  46381. m.ResetAgent()
  46382. return nil
  46383. }
  46384. return fmt.Errorf("unknown Wx edge %s", name)
  46385. }
  46386. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  46387. type WxCardMutation struct {
  46388. config
  46389. op Op
  46390. typ string
  46391. id *uint64
  46392. created_at *time.Time
  46393. updated_at *time.Time
  46394. deleted_at *time.Time
  46395. user_id *uint64
  46396. adduser_id *int64
  46397. wx_user_id *uint64
  46398. addwx_user_id *int64
  46399. avatar *string
  46400. logo *string
  46401. name *string
  46402. company *string
  46403. address *string
  46404. phone *string
  46405. official_account *string
  46406. wechat_account *string
  46407. email *string
  46408. api_base *string
  46409. api_key *string
  46410. ai_info *string
  46411. intro *string
  46412. clearedFields map[string]struct{}
  46413. done bool
  46414. oldValue func(context.Context) (*WxCard, error)
  46415. predicates []predicate.WxCard
  46416. }
  46417. var _ ent.Mutation = (*WxCardMutation)(nil)
  46418. // wxcardOption allows management of the mutation configuration using functional options.
  46419. type wxcardOption func(*WxCardMutation)
  46420. // newWxCardMutation creates new mutation for the WxCard entity.
  46421. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  46422. m := &WxCardMutation{
  46423. config: c,
  46424. op: op,
  46425. typ: TypeWxCard,
  46426. clearedFields: make(map[string]struct{}),
  46427. }
  46428. for _, opt := range opts {
  46429. opt(m)
  46430. }
  46431. return m
  46432. }
  46433. // withWxCardID sets the ID field of the mutation.
  46434. func withWxCardID(id uint64) wxcardOption {
  46435. return func(m *WxCardMutation) {
  46436. var (
  46437. err error
  46438. once sync.Once
  46439. value *WxCard
  46440. )
  46441. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  46442. once.Do(func() {
  46443. if m.done {
  46444. err = errors.New("querying old values post mutation is not allowed")
  46445. } else {
  46446. value, err = m.Client().WxCard.Get(ctx, id)
  46447. }
  46448. })
  46449. return value, err
  46450. }
  46451. m.id = &id
  46452. }
  46453. }
  46454. // withWxCard sets the old WxCard of the mutation.
  46455. func withWxCard(node *WxCard) wxcardOption {
  46456. return func(m *WxCardMutation) {
  46457. m.oldValue = func(context.Context) (*WxCard, error) {
  46458. return node, nil
  46459. }
  46460. m.id = &node.ID
  46461. }
  46462. }
  46463. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46464. // executed in a transaction (ent.Tx), a transactional client is returned.
  46465. func (m WxCardMutation) Client() *Client {
  46466. client := &Client{config: m.config}
  46467. client.init()
  46468. return client
  46469. }
  46470. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46471. // it returns an error otherwise.
  46472. func (m WxCardMutation) Tx() (*Tx, error) {
  46473. if _, ok := m.driver.(*txDriver); !ok {
  46474. return nil, errors.New("ent: mutation is not running in a transaction")
  46475. }
  46476. tx := &Tx{config: m.config}
  46477. tx.init()
  46478. return tx, nil
  46479. }
  46480. // SetID sets the value of the id field. Note that this
  46481. // operation is only accepted on creation of WxCard entities.
  46482. func (m *WxCardMutation) SetID(id uint64) {
  46483. m.id = &id
  46484. }
  46485. // ID returns the ID value in the mutation. Note that the ID is only available
  46486. // if it was provided to the builder or after it was returned from the database.
  46487. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  46488. if m.id == nil {
  46489. return
  46490. }
  46491. return *m.id, true
  46492. }
  46493. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46494. // That means, if the mutation is applied within a transaction with an isolation level such
  46495. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46496. // or updated by the mutation.
  46497. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  46498. switch {
  46499. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46500. id, exists := m.ID()
  46501. if exists {
  46502. return []uint64{id}, nil
  46503. }
  46504. fallthrough
  46505. case m.op.Is(OpUpdate | OpDelete):
  46506. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  46507. default:
  46508. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46509. }
  46510. }
  46511. // SetCreatedAt sets the "created_at" field.
  46512. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  46513. m.created_at = &t
  46514. }
  46515. // CreatedAt returns the value of the "created_at" field in the mutation.
  46516. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  46517. v := m.created_at
  46518. if v == nil {
  46519. return
  46520. }
  46521. return *v, true
  46522. }
  46523. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  46524. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46526. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46527. if !m.op.Is(OpUpdateOne) {
  46528. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46529. }
  46530. if m.id == nil || m.oldValue == nil {
  46531. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46532. }
  46533. oldValue, err := m.oldValue(ctx)
  46534. if err != nil {
  46535. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46536. }
  46537. return oldValue.CreatedAt, nil
  46538. }
  46539. // ResetCreatedAt resets all changes to the "created_at" field.
  46540. func (m *WxCardMutation) ResetCreatedAt() {
  46541. m.created_at = nil
  46542. }
  46543. // SetUpdatedAt sets the "updated_at" field.
  46544. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  46545. m.updated_at = &t
  46546. }
  46547. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46548. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  46549. v := m.updated_at
  46550. if v == nil {
  46551. return
  46552. }
  46553. return *v, true
  46554. }
  46555. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  46556. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46558. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46559. if !m.op.Is(OpUpdateOne) {
  46560. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46561. }
  46562. if m.id == nil || m.oldValue == nil {
  46563. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46564. }
  46565. oldValue, err := m.oldValue(ctx)
  46566. if err != nil {
  46567. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46568. }
  46569. return oldValue.UpdatedAt, nil
  46570. }
  46571. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46572. func (m *WxCardMutation) ResetUpdatedAt() {
  46573. m.updated_at = nil
  46574. }
  46575. // SetDeletedAt sets the "deleted_at" field.
  46576. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  46577. m.deleted_at = &t
  46578. }
  46579. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46580. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  46581. v := m.deleted_at
  46582. if v == nil {
  46583. return
  46584. }
  46585. return *v, true
  46586. }
  46587. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  46588. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46590. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46591. if !m.op.Is(OpUpdateOne) {
  46592. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46593. }
  46594. if m.id == nil || m.oldValue == nil {
  46595. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46596. }
  46597. oldValue, err := m.oldValue(ctx)
  46598. if err != nil {
  46599. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46600. }
  46601. return oldValue.DeletedAt, nil
  46602. }
  46603. // ClearDeletedAt clears the value of the "deleted_at" field.
  46604. func (m *WxCardMutation) ClearDeletedAt() {
  46605. m.deleted_at = nil
  46606. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  46607. }
  46608. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46609. func (m *WxCardMutation) DeletedAtCleared() bool {
  46610. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  46611. return ok
  46612. }
  46613. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46614. func (m *WxCardMutation) ResetDeletedAt() {
  46615. m.deleted_at = nil
  46616. delete(m.clearedFields, wxcard.FieldDeletedAt)
  46617. }
  46618. // SetUserID sets the "user_id" field.
  46619. func (m *WxCardMutation) SetUserID(u uint64) {
  46620. m.user_id = &u
  46621. m.adduser_id = nil
  46622. }
  46623. // UserID returns the value of the "user_id" field in the mutation.
  46624. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  46625. v := m.user_id
  46626. if v == nil {
  46627. return
  46628. }
  46629. return *v, true
  46630. }
  46631. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  46632. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46634. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46635. if !m.op.Is(OpUpdateOne) {
  46636. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46637. }
  46638. if m.id == nil || m.oldValue == nil {
  46639. return v, errors.New("OldUserID requires an ID field in the mutation")
  46640. }
  46641. oldValue, err := m.oldValue(ctx)
  46642. if err != nil {
  46643. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46644. }
  46645. return oldValue.UserID, nil
  46646. }
  46647. // AddUserID adds u to the "user_id" field.
  46648. func (m *WxCardMutation) AddUserID(u int64) {
  46649. if m.adduser_id != nil {
  46650. *m.adduser_id += u
  46651. } else {
  46652. m.adduser_id = &u
  46653. }
  46654. }
  46655. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46656. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  46657. v := m.adduser_id
  46658. if v == nil {
  46659. return
  46660. }
  46661. return *v, true
  46662. }
  46663. // ClearUserID clears the value of the "user_id" field.
  46664. func (m *WxCardMutation) ClearUserID() {
  46665. m.user_id = nil
  46666. m.adduser_id = nil
  46667. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  46668. }
  46669. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46670. func (m *WxCardMutation) UserIDCleared() bool {
  46671. _, ok := m.clearedFields[wxcard.FieldUserID]
  46672. return ok
  46673. }
  46674. // ResetUserID resets all changes to the "user_id" field.
  46675. func (m *WxCardMutation) ResetUserID() {
  46676. m.user_id = nil
  46677. m.adduser_id = nil
  46678. delete(m.clearedFields, wxcard.FieldUserID)
  46679. }
  46680. // SetWxUserID sets the "wx_user_id" field.
  46681. func (m *WxCardMutation) SetWxUserID(u uint64) {
  46682. m.wx_user_id = &u
  46683. m.addwx_user_id = nil
  46684. }
  46685. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  46686. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  46687. v := m.wx_user_id
  46688. if v == nil {
  46689. return
  46690. }
  46691. return *v, true
  46692. }
  46693. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  46694. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46696. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  46697. if !m.op.Is(OpUpdateOne) {
  46698. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  46699. }
  46700. if m.id == nil || m.oldValue == nil {
  46701. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  46702. }
  46703. oldValue, err := m.oldValue(ctx)
  46704. if err != nil {
  46705. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  46706. }
  46707. return oldValue.WxUserID, nil
  46708. }
  46709. // AddWxUserID adds u to the "wx_user_id" field.
  46710. func (m *WxCardMutation) AddWxUserID(u int64) {
  46711. if m.addwx_user_id != nil {
  46712. *m.addwx_user_id += u
  46713. } else {
  46714. m.addwx_user_id = &u
  46715. }
  46716. }
  46717. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  46718. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  46719. v := m.addwx_user_id
  46720. if v == nil {
  46721. return
  46722. }
  46723. return *v, true
  46724. }
  46725. // ClearWxUserID clears the value of the "wx_user_id" field.
  46726. func (m *WxCardMutation) ClearWxUserID() {
  46727. m.wx_user_id = nil
  46728. m.addwx_user_id = nil
  46729. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  46730. }
  46731. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  46732. func (m *WxCardMutation) WxUserIDCleared() bool {
  46733. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  46734. return ok
  46735. }
  46736. // ResetWxUserID resets all changes to the "wx_user_id" field.
  46737. func (m *WxCardMutation) ResetWxUserID() {
  46738. m.wx_user_id = nil
  46739. m.addwx_user_id = nil
  46740. delete(m.clearedFields, wxcard.FieldWxUserID)
  46741. }
  46742. // SetAvatar sets the "avatar" field.
  46743. func (m *WxCardMutation) SetAvatar(s string) {
  46744. m.avatar = &s
  46745. }
  46746. // Avatar returns the value of the "avatar" field in the mutation.
  46747. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  46748. v := m.avatar
  46749. if v == nil {
  46750. return
  46751. }
  46752. return *v, true
  46753. }
  46754. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  46755. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46757. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46758. if !m.op.Is(OpUpdateOne) {
  46759. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46760. }
  46761. if m.id == nil || m.oldValue == nil {
  46762. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46763. }
  46764. oldValue, err := m.oldValue(ctx)
  46765. if err != nil {
  46766. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46767. }
  46768. return oldValue.Avatar, nil
  46769. }
  46770. // ResetAvatar resets all changes to the "avatar" field.
  46771. func (m *WxCardMutation) ResetAvatar() {
  46772. m.avatar = nil
  46773. }
  46774. // SetLogo sets the "logo" field.
  46775. func (m *WxCardMutation) SetLogo(s string) {
  46776. m.logo = &s
  46777. }
  46778. // Logo returns the value of the "logo" field in the mutation.
  46779. func (m *WxCardMutation) Logo() (r string, exists bool) {
  46780. v := m.logo
  46781. if v == nil {
  46782. return
  46783. }
  46784. return *v, true
  46785. }
  46786. // OldLogo returns the old "logo" field's value of the WxCard entity.
  46787. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46789. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  46790. if !m.op.Is(OpUpdateOne) {
  46791. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  46792. }
  46793. if m.id == nil || m.oldValue == nil {
  46794. return v, errors.New("OldLogo requires an ID field in the mutation")
  46795. }
  46796. oldValue, err := m.oldValue(ctx)
  46797. if err != nil {
  46798. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  46799. }
  46800. return oldValue.Logo, nil
  46801. }
  46802. // ResetLogo resets all changes to the "logo" field.
  46803. func (m *WxCardMutation) ResetLogo() {
  46804. m.logo = nil
  46805. }
  46806. // SetName sets the "name" field.
  46807. func (m *WxCardMutation) SetName(s string) {
  46808. m.name = &s
  46809. }
  46810. // Name returns the value of the "name" field in the mutation.
  46811. func (m *WxCardMutation) Name() (r string, exists bool) {
  46812. v := m.name
  46813. if v == nil {
  46814. return
  46815. }
  46816. return *v, true
  46817. }
  46818. // OldName returns the old "name" field's value of the WxCard entity.
  46819. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46821. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  46822. if !m.op.Is(OpUpdateOne) {
  46823. return v, errors.New("OldName is only allowed on UpdateOne operations")
  46824. }
  46825. if m.id == nil || m.oldValue == nil {
  46826. return v, errors.New("OldName requires an ID field in the mutation")
  46827. }
  46828. oldValue, err := m.oldValue(ctx)
  46829. if err != nil {
  46830. return v, fmt.Errorf("querying old value for OldName: %w", err)
  46831. }
  46832. return oldValue.Name, nil
  46833. }
  46834. // ResetName resets all changes to the "name" field.
  46835. func (m *WxCardMutation) ResetName() {
  46836. m.name = nil
  46837. }
  46838. // SetCompany sets the "company" field.
  46839. func (m *WxCardMutation) SetCompany(s string) {
  46840. m.company = &s
  46841. }
  46842. // Company returns the value of the "company" field in the mutation.
  46843. func (m *WxCardMutation) Company() (r string, exists bool) {
  46844. v := m.company
  46845. if v == nil {
  46846. return
  46847. }
  46848. return *v, true
  46849. }
  46850. // OldCompany returns the old "company" field's value of the WxCard entity.
  46851. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46853. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  46854. if !m.op.Is(OpUpdateOne) {
  46855. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  46856. }
  46857. if m.id == nil || m.oldValue == nil {
  46858. return v, errors.New("OldCompany requires an ID field in the mutation")
  46859. }
  46860. oldValue, err := m.oldValue(ctx)
  46861. if err != nil {
  46862. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  46863. }
  46864. return oldValue.Company, nil
  46865. }
  46866. // ResetCompany resets all changes to the "company" field.
  46867. func (m *WxCardMutation) ResetCompany() {
  46868. m.company = nil
  46869. }
  46870. // SetAddress sets the "address" field.
  46871. func (m *WxCardMutation) SetAddress(s string) {
  46872. m.address = &s
  46873. }
  46874. // Address returns the value of the "address" field in the mutation.
  46875. func (m *WxCardMutation) Address() (r string, exists bool) {
  46876. v := m.address
  46877. if v == nil {
  46878. return
  46879. }
  46880. return *v, true
  46881. }
  46882. // OldAddress returns the old "address" field's value of the WxCard entity.
  46883. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46885. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  46886. if !m.op.Is(OpUpdateOne) {
  46887. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  46888. }
  46889. if m.id == nil || m.oldValue == nil {
  46890. return v, errors.New("OldAddress requires an ID field in the mutation")
  46891. }
  46892. oldValue, err := m.oldValue(ctx)
  46893. if err != nil {
  46894. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  46895. }
  46896. return oldValue.Address, nil
  46897. }
  46898. // ResetAddress resets all changes to the "address" field.
  46899. func (m *WxCardMutation) ResetAddress() {
  46900. m.address = nil
  46901. }
  46902. // SetPhone sets the "phone" field.
  46903. func (m *WxCardMutation) SetPhone(s string) {
  46904. m.phone = &s
  46905. }
  46906. // Phone returns the value of the "phone" field in the mutation.
  46907. func (m *WxCardMutation) Phone() (r string, exists bool) {
  46908. v := m.phone
  46909. if v == nil {
  46910. return
  46911. }
  46912. return *v, true
  46913. }
  46914. // OldPhone returns the old "phone" field's value of the WxCard entity.
  46915. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46917. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  46918. if !m.op.Is(OpUpdateOne) {
  46919. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46920. }
  46921. if m.id == nil || m.oldValue == nil {
  46922. return v, errors.New("OldPhone requires an ID field in the mutation")
  46923. }
  46924. oldValue, err := m.oldValue(ctx)
  46925. if err != nil {
  46926. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  46927. }
  46928. return oldValue.Phone, nil
  46929. }
  46930. // ResetPhone resets all changes to the "phone" field.
  46931. func (m *WxCardMutation) ResetPhone() {
  46932. m.phone = nil
  46933. }
  46934. // SetOfficialAccount sets the "official_account" field.
  46935. func (m *WxCardMutation) SetOfficialAccount(s string) {
  46936. m.official_account = &s
  46937. }
  46938. // OfficialAccount returns the value of the "official_account" field in the mutation.
  46939. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  46940. v := m.official_account
  46941. if v == nil {
  46942. return
  46943. }
  46944. return *v, true
  46945. }
  46946. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  46947. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46949. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  46950. if !m.op.Is(OpUpdateOne) {
  46951. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  46952. }
  46953. if m.id == nil || m.oldValue == nil {
  46954. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  46955. }
  46956. oldValue, err := m.oldValue(ctx)
  46957. if err != nil {
  46958. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  46959. }
  46960. return oldValue.OfficialAccount, nil
  46961. }
  46962. // ResetOfficialAccount resets all changes to the "official_account" field.
  46963. func (m *WxCardMutation) ResetOfficialAccount() {
  46964. m.official_account = nil
  46965. }
  46966. // SetWechatAccount sets the "wechat_account" field.
  46967. func (m *WxCardMutation) SetWechatAccount(s string) {
  46968. m.wechat_account = &s
  46969. }
  46970. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  46971. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  46972. v := m.wechat_account
  46973. if v == nil {
  46974. return
  46975. }
  46976. return *v, true
  46977. }
  46978. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  46979. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46981. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  46982. if !m.op.Is(OpUpdateOne) {
  46983. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  46984. }
  46985. if m.id == nil || m.oldValue == nil {
  46986. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  46987. }
  46988. oldValue, err := m.oldValue(ctx)
  46989. if err != nil {
  46990. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  46991. }
  46992. return oldValue.WechatAccount, nil
  46993. }
  46994. // ResetWechatAccount resets all changes to the "wechat_account" field.
  46995. func (m *WxCardMutation) ResetWechatAccount() {
  46996. m.wechat_account = nil
  46997. }
  46998. // SetEmail sets the "email" field.
  46999. func (m *WxCardMutation) SetEmail(s string) {
  47000. m.email = &s
  47001. }
  47002. // Email returns the value of the "email" field in the mutation.
  47003. func (m *WxCardMutation) Email() (r string, exists bool) {
  47004. v := m.email
  47005. if v == nil {
  47006. return
  47007. }
  47008. return *v, true
  47009. }
  47010. // OldEmail returns the old "email" field's value of the WxCard entity.
  47011. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47013. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  47014. if !m.op.Is(OpUpdateOne) {
  47015. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  47016. }
  47017. if m.id == nil || m.oldValue == nil {
  47018. return v, errors.New("OldEmail requires an ID field in the mutation")
  47019. }
  47020. oldValue, err := m.oldValue(ctx)
  47021. if err != nil {
  47022. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  47023. }
  47024. return oldValue.Email, nil
  47025. }
  47026. // ClearEmail clears the value of the "email" field.
  47027. func (m *WxCardMutation) ClearEmail() {
  47028. m.email = nil
  47029. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  47030. }
  47031. // EmailCleared returns if the "email" field was cleared in this mutation.
  47032. func (m *WxCardMutation) EmailCleared() bool {
  47033. _, ok := m.clearedFields[wxcard.FieldEmail]
  47034. return ok
  47035. }
  47036. // ResetEmail resets all changes to the "email" field.
  47037. func (m *WxCardMutation) ResetEmail() {
  47038. m.email = nil
  47039. delete(m.clearedFields, wxcard.FieldEmail)
  47040. }
  47041. // SetAPIBase sets the "api_base" field.
  47042. func (m *WxCardMutation) SetAPIBase(s string) {
  47043. m.api_base = &s
  47044. }
  47045. // APIBase returns the value of the "api_base" field in the mutation.
  47046. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  47047. v := m.api_base
  47048. if v == nil {
  47049. return
  47050. }
  47051. return *v, true
  47052. }
  47053. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  47054. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47056. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47057. if !m.op.Is(OpUpdateOne) {
  47058. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47059. }
  47060. if m.id == nil || m.oldValue == nil {
  47061. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47062. }
  47063. oldValue, err := m.oldValue(ctx)
  47064. if err != nil {
  47065. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47066. }
  47067. return oldValue.APIBase, nil
  47068. }
  47069. // ClearAPIBase clears the value of the "api_base" field.
  47070. func (m *WxCardMutation) ClearAPIBase() {
  47071. m.api_base = nil
  47072. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  47073. }
  47074. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47075. func (m *WxCardMutation) APIBaseCleared() bool {
  47076. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  47077. return ok
  47078. }
  47079. // ResetAPIBase resets all changes to the "api_base" field.
  47080. func (m *WxCardMutation) ResetAPIBase() {
  47081. m.api_base = nil
  47082. delete(m.clearedFields, wxcard.FieldAPIBase)
  47083. }
  47084. // SetAPIKey sets the "api_key" field.
  47085. func (m *WxCardMutation) SetAPIKey(s string) {
  47086. m.api_key = &s
  47087. }
  47088. // APIKey returns the value of the "api_key" field in the mutation.
  47089. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  47090. v := m.api_key
  47091. if v == nil {
  47092. return
  47093. }
  47094. return *v, true
  47095. }
  47096. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  47097. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47099. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47100. if !m.op.Is(OpUpdateOne) {
  47101. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47102. }
  47103. if m.id == nil || m.oldValue == nil {
  47104. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47105. }
  47106. oldValue, err := m.oldValue(ctx)
  47107. if err != nil {
  47108. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47109. }
  47110. return oldValue.APIKey, nil
  47111. }
  47112. // ClearAPIKey clears the value of the "api_key" field.
  47113. func (m *WxCardMutation) ClearAPIKey() {
  47114. m.api_key = nil
  47115. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  47116. }
  47117. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47118. func (m *WxCardMutation) APIKeyCleared() bool {
  47119. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  47120. return ok
  47121. }
  47122. // ResetAPIKey resets all changes to the "api_key" field.
  47123. func (m *WxCardMutation) ResetAPIKey() {
  47124. m.api_key = nil
  47125. delete(m.clearedFields, wxcard.FieldAPIKey)
  47126. }
  47127. // SetAiInfo sets the "ai_info" field.
  47128. func (m *WxCardMutation) SetAiInfo(s string) {
  47129. m.ai_info = &s
  47130. }
  47131. // AiInfo returns the value of the "ai_info" field in the mutation.
  47132. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  47133. v := m.ai_info
  47134. if v == nil {
  47135. return
  47136. }
  47137. return *v, true
  47138. }
  47139. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  47140. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47142. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  47143. if !m.op.Is(OpUpdateOne) {
  47144. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  47145. }
  47146. if m.id == nil || m.oldValue == nil {
  47147. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  47148. }
  47149. oldValue, err := m.oldValue(ctx)
  47150. if err != nil {
  47151. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  47152. }
  47153. return oldValue.AiInfo, nil
  47154. }
  47155. // ClearAiInfo clears the value of the "ai_info" field.
  47156. func (m *WxCardMutation) ClearAiInfo() {
  47157. m.ai_info = nil
  47158. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  47159. }
  47160. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  47161. func (m *WxCardMutation) AiInfoCleared() bool {
  47162. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  47163. return ok
  47164. }
  47165. // ResetAiInfo resets all changes to the "ai_info" field.
  47166. func (m *WxCardMutation) ResetAiInfo() {
  47167. m.ai_info = nil
  47168. delete(m.clearedFields, wxcard.FieldAiInfo)
  47169. }
  47170. // SetIntro sets the "intro" field.
  47171. func (m *WxCardMutation) SetIntro(s string) {
  47172. m.intro = &s
  47173. }
  47174. // Intro returns the value of the "intro" field in the mutation.
  47175. func (m *WxCardMutation) Intro() (r string, exists bool) {
  47176. v := m.intro
  47177. if v == nil {
  47178. return
  47179. }
  47180. return *v, true
  47181. }
  47182. // OldIntro returns the old "intro" field's value of the WxCard entity.
  47183. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47185. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  47186. if !m.op.Is(OpUpdateOne) {
  47187. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  47188. }
  47189. if m.id == nil || m.oldValue == nil {
  47190. return v, errors.New("OldIntro requires an ID field in the mutation")
  47191. }
  47192. oldValue, err := m.oldValue(ctx)
  47193. if err != nil {
  47194. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  47195. }
  47196. return oldValue.Intro, nil
  47197. }
  47198. // ClearIntro clears the value of the "intro" field.
  47199. func (m *WxCardMutation) ClearIntro() {
  47200. m.intro = nil
  47201. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  47202. }
  47203. // IntroCleared returns if the "intro" field was cleared in this mutation.
  47204. func (m *WxCardMutation) IntroCleared() bool {
  47205. _, ok := m.clearedFields[wxcard.FieldIntro]
  47206. return ok
  47207. }
  47208. // ResetIntro resets all changes to the "intro" field.
  47209. func (m *WxCardMutation) ResetIntro() {
  47210. m.intro = nil
  47211. delete(m.clearedFields, wxcard.FieldIntro)
  47212. }
  47213. // Where appends a list predicates to the WxCardMutation builder.
  47214. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  47215. m.predicates = append(m.predicates, ps...)
  47216. }
  47217. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  47218. // users can use type-assertion to append predicates that do not depend on any generated package.
  47219. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  47220. p := make([]predicate.WxCard, len(ps))
  47221. for i := range ps {
  47222. p[i] = ps[i]
  47223. }
  47224. m.Where(p...)
  47225. }
  47226. // Op returns the operation name.
  47227. func (m *WxCardMutation) Op() Op {
  47228. return m.op
  47229. }
  47230. // SetOp allows setting the mutation operation.
  47231. func (m *WxCardMutation) SetOp(op Op) {
  47232. m.op = op
  47233. }
  47234. // Type returns the node type of this mutation (WxCard).
  47235. func (m *WxCardMutation) Type() string {
  47236. return m.typ
  47237. }
  47238. // Fields returns all fields that were changed during this mutation. Note that in
  47239. // order to get all numeric fields that were incremented/decremented, call
  47240. // AddedFields().
  47241. func (m *WxCardMutation) Fields() []string {
  47242. fields := make([]string, 0, 18)
  47243. if m.created_at != nil {
  47244. fields = append(fields, wxcard.FieldCreatedAt)
  47245. }
  47246. if m.updated_at != nil {
  47247. fields = append(fields, wxcard.FieldUpdatedAt)
  47248. }
  47249. if m.deleted_at != nil {
  47250. fields = append(fields, wxcard.FieldDeletedAt)
  47251. }
  47252. if m.user_id != nil {
  47253. fields = append(fields, wxcard.FieldUserID)
  47254. }
  47255. if m.wx_user_id != nil {
  47256. fields = append(fields, wxcard.FieldWxUserID)
  47257. }
  47258. if m.avatar != nil {
  47259. fields = append(fields, wxcard.FieldAvatar)
  47260. }
  47261. if m.logo != nil {
  47262. fields = append(fields, wxcard.FieldLogo)
  47263. }
  47264. if m.name != nil {
  47265. fields = append(fields, wxcard.FieldName)
  47266. }
  47267. if m.company != nil {
  47268. fields = append(fields, wxcard.FieldCompany)
  47269. }
  47270. if m.address != nil {
  47271. fields = append(fields, wxcard.FieldAddress)
  47272. }
  47273. if m.phone != nil {
  47274. fields = append(fields, wxcard.FieldPhone)
  47275. }
  47276. if m.official_account != nil {
  47277. fields = append(fields, wxcard.FieldOfficialAccount)
  47278. }
  47279. if m.wechat_account != nil {
  47280. fields = append(fields, wxcard.FieldWechatAccount)
  47281. }
  47282. if m.email != nil {
  47283. fields = append(fields, wxcard.FieldEmail)
  47284. }
  47285. if m.api_base != nil {
  47286. fields = append(fields, wxcard.FieldAPIBase)
  47287. }
  47288. if m.api_key != nil {
  47289. fields = append(fields, wxcard.FieldAPIKey)
  47290. }
  47291. if m.ai_info != nil {
  47292. fields = append(fields, wxcard.FieldAiInfo)
  47293. }
  47294. if m.intro != nil {
  47295. fields = append(fields, wxcard.FieldIntro)
  47296. }
  47297. return fields
  47298. }
  47299. // Field returns the value of a field with the given name. The second boolean
  47300. // return value indicates that this field was not set, or was not defined in the
  47301. // schema.
  47302. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  47303. switch name {
  47304. case wxcard.FieldCreatedAt:
  47305. return m.CreatedAt()
  47306. case wxcard.FieldUpdatedAt:
  47307. return m.UpdatedAt()
  47308. case wxcard.FieldDeletedAt:
  47309. return m.DeletedAt()
  47310. case wxcard.FieldUserID:
  47311. return m.UserID()
  47312. case wxcard.FieldWxUserID:
  47313. return m.WxUserID()
  47314. case wxcard.FieldAvatar:
  47315. return m.Avatar()
  47316. case wxcard.FieldLogo:
  47317. return m.Logo()
  47318. case wxcard.FieldName:
  47319. return m.Name()
  47320. case wxcard.FieldCompany:
  47321. return m.Company()
  47322. case wxcard.FieldAddress:
  47323. return m.Address()
  47324. case wxcard.FieldPhone:
  47325. return m.Phone()
  47326. case wxcard.FieldOfficialAccount:
  47327. return m.OfficialAccount()
  47328. case wxcard.FieldWechatAccount:
  47329. return m.WechatAccount()
  47330. case wxcard.FieldEmail:
  47331. return m.Email()
  47332. case wxcard.FieldAPIBase:
  47333. return m.APIBase()
  47334. case wxcard.FieldAPIKey:
  47335. return m.APIKey()
  47336. case wxcard.FieldAiInfo:
  47337. return m.AiInfo()
  47338. case wxcard.FieldIntro:
  47339. return m.Intro()
  47340. }
  47341. return nil, false
  47342. }
  47343. // OldField returns the old value of the field from the database. An error is
  47344. // returned if the mutation operation is not UpdateOne, or the query to the
  47345. // database failed.
  47346. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47347. switch name {
  47348. case wxcard.FieldCreatedAt:
  47349. return m.OldCreatedAt(ctx)
  47350. case wxcard.FieldUpdatedAt:
  47351. return m.OldUpdatedAt(ctx)
  47352. case wxcard.FieldDeletedAt:
  47353. return m.OldDeletedAt(ctx)
  47354. case wxcard.FieldUserID:
  47355. return m.OldUserID(ctx)
  47356. case wxcard.FieldWxUserID:
  47357. return m.OldWxUserID(ctx)
  47358. case wxcard.FieldAvatar:
  47359. return m.OldAvatar(ctx)
  47360. case wxcard.FieldLogo:
  47361. return m.OldLogo(ctx)
  47362. case wxcard.FieldName:
  47363. return m.OldName(ctx)
  47364. case wxcard.FieldCompany:
  47365. return m.OldCompany(ctx)
  47366. case wxcard.FieldAddress:
  47367. return m.OldAddress(ctx)
  47368. case wxcard.FieldPhone:
  47369. return m.OldPhone(ctx)
  47370. case wxcard.FieldOfficialAccount:
  47371. return m.OldOfficialAccount(ctx)
  47372. case wxcard.FieldWechatAccount:
  47373. return m.OldWechatAccount(ctx)
  47374. case wxcard.FieldEmail:
  47375. return m.OldEmail(ctx)
  47376. case wxcard.FieldAPIBase:
  47377. return m.OldAPIBase(ctx)
  47378. case wxcard.FieldAPIKey:
  47379. return m.OldAPIKey(ctx)
  47380. case wxcard.FieldAiInfo:
  47381. return m.OldAiInfo(ctx)
  47382. case wxcard.FieldIntro:
  47383. return m.OldIntro(ctx)
  47384. }
  47385. return nil, fmt.Errorf("unknown WxCard field %s", name)
  47386. }
  47387. // SetField sets the value of a field with the given name. It returns an error if
  47388. // the field is not defined in the schema, or if the type mismatched the field
  47389. // type.
  47390. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  47391. switch name {
  47392. case wxcard.FieldCreatedAt:
  47393. v, ok := value.(time.Time)
  47394. if !ok {
  47395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47396. }
  47397. m.SetCreatedAt(v)
  47398. return nil
  47399. case wxcard.FieldUpdatedAt:
  47400. v, ok := value.(time.Time)
  47401. if !ok {
  47402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47403. }
  47404. m.SetUpdatedAt(v)
  47405. return nil
  47406. case wxcard.FieldDeletedAt:
  47407. v, ok := value.(time.Time)
  47408. if !ok {
  47409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47410. }
  47411. m.SetDeletedAt(v)
  47412. return nil
  47413. case wxcard.FieldUserID:
  47414. v, ok := value.(uint64)
  47415. if !ok {
  47416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47417. }
  47418. m.SetUserID(v)
  47419. return nil
  47420. case wxcard.FieldWxUserID:
  47421. v, ok := value.(uint64)
  47422. if !ok {
  47423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47424. }
  47425. m.SetWxUserID(v)
  47426. return nil
  47427. case wxcard.FieldAvatar:
  47428. v, ok := value.(string)
  47429. if !ok {
  47430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47431. }
  47432. m.SetAvatar(v)
  47433. return nil
  47434. case wxcard.FieldLogo:
  47435. v, ok := value.(string)
  47436. if !ok {
  47437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47438. }
  47439. m.SetLogo(v)
  47440. return nil
  47441. case wxcard.FieldName:
  47442. v, ok := value.(string)
  47443. if !ok {
  47444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47445. }
  47446. m.SetName(v)
  47447. return nil
  47448. case wxcard.FieldCompany:
  47449. v, ok := value.(string)
  47450. if !ok {
  47451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47452. }
  47453. m.SetCompany(v)
  47454. return nil
  47455. case wxcard.FieldAddress:
  47456. v, ok := value.(string)
  47457. if !ok {
  47458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47459. }
  47460. m.SetAddress(v)
  47461. return nil
  47462. case wxcard.FieldPhone:
  47463. v, ok := value.(string)
  47464. if !ok {
  47465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47466. }
  47467. m.SetPhone(v)
  47468. return nil
  47469. case wxcard.FieldOfficialAccount:
  47470. v, ok := value.(string)
  47471. if !ok {
  47472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47473. }
  47474. m.SetOfficialAccount(v)
  47475. return nil
  47476. case wxcard.FieldWechatAccount:
  47477. v, ok := value.(string)
  47478. if !ok {
  47479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47480. }
  47481. m.SetWechatAccount(v)
  47482. return nil
  47483. case wxcard.FieldEmail:
  47484. v, ok := value.(string)
  47485. if !ok {
  47486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47487. }
  47488. m.SetEmail(v)
  47489. return nil
  47490. case wxcard.FieldAPIBase:
  47491. v, ok := value.(string)
  47492. if !ok {
  47493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47494. }
  47495. m.SetAPIBase(v)
  47496. return nil
  47497. case wxcard.FieldAPIKey:
  47498. v, ok := value.(string)
  47499. if !ok {
  47500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47501. }
  47502. m.SetAPIKey(v)
  47503. return nil
  47504. case wxcard.FieldAiInfo:
  47505. v, ok := value.(string)
  47506. if !ok {
  47507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47508. }
  47509. m.SetAiInfo(v)
  47510. return nil
  47511. case wxcard.FieldIntro:
  47512. v, ok := value.(string)
  47513. if !ok {
  47514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47515. }
  47516. m.SetIntro(v)
  47517. return nil
  47518. }
  47519. return fmt.Errorf("unknown WxCard field %s", name)
  47520. }
  47521. // AddedFields returns all numeric fields that were incremented/decremented during
  47522. // this mutation.
  47523. func (m *WxCardMutation) AddedFields() []string {
  47524. var fields []string
  47525. if m.adduser_id != nil {
  47526. fields = append(fields, wxcard.FieldUserID)
  47527. }
  47528. if m.addwx_user_id != nil {
  47529. fields = append(fields, wxcard.FieldWxUserID)
  47530. }
  47531. return fields
  47532. }
  47533. // AddedField returns the numeric value that was incremented/decremented on a field
  47534. // with the given name. The second boolean return value indicates that this field
  47535. // was not set, or was not defined in the schema.
  47536. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  47537. switch name {
  47538. case wxcard.FieldUserID:
  47539. return m.AddedUserID()
  47540. case wxcard.FieldWxUserID:
  47541. return m.AddedWxUserID()
  47542. }
  47543. return nil, false
  47544. }
  47545. // AddField adds the value to the field with the given name. It returns an error if
  47546. // the field is not defined in the schema, or if the type mismatched the field
  47547. // type.
  47548. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  47549. switch name {
  47550. case wxcard.FieldUserID:
  47551. v, ok := value.(int64)
  47552. if !ok {
  47553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47554. }
  47555. m.AddUserID(v)
  47556. return nil
  47557. case wxcard.FieldWxUserID:
  47558. v, ok := value.(int64)
  47559. if !ok {
  47560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47561. }
  47562. m.AddWxUserID(v)
  47563. return nil
  47564. }
  47565. return fmt.Errorf("unknown WxCard numeric field %s", name)
  47566. }
  47567. // ClearedFields returns all nullable fields that were cleared during this
  47568. // mutation.
  47569. func (m *WxCardMutation) ClearedFields() []string {
  47570. var fields []string
  47571. if m.FieldCleared(wxcard.FieldDeletedAt) {
  47572. fields = append(fields, wxcard.FieldDeletedAt)
  47573. }
  47574. if m.FieldCleared(wxcard.FieldUserID) {
  47575. fields = append(fields, wxcard.FieldUserID)
  47576. }
  47577. if m.FieldCleared(wxcard.FieldWxUserID) {
  47578. fields = append(fields, wxcard.FieldWxUserID)
  47579. }
  47580. if m.FieldCleared(wxcard.FieldEmail) {
  47581. fields = append(fields, wxcard.FieldEmail)
  47582. }
  47583. if m.FieldCleared(wxcard.FieldAPIBase) {
  47584. fields = append(fields, wxcard.FieldAPIBase)
  47585. }
  47586. if m.FieldCleared(wxcard.FieldAPIKey) {
  47587. fields = append(fields, wxcard.FieldAPIKey)
  47588. }
  47589. if m.FieldCleared(wxcard.FieldAiInfo) {
  47590. fields = append(fields, wxcard.FieldAiInfo)
  47591. }
  47592. if m.FieldCleared(wxcard.FieldIntro) {
  47593. fields = append(fields, wxcard.FieldIntro)
  47594. }
  47595. return fields
  47596. }
  47597. // FieldCleared returns a boolean indicating if a field with the given name was
  47598. // cleared in this mutation.
  47599. func (m *WxCardMutation) FieldCleared(name string) bool {
  47600. _, ok := m.clearedFields[name]
  47601. return ok
  47602. }
  47603. // ClearField clears the value of the field with the given name. It returns an
  47604. // error if the field is not defined in the schema.
  47605. func (m *WxCardMutation) ClearField(name string) error {
  47606. switch name {
  47607. case wxcard.FieldDeletedAt:
  47608. m.ClearDeletedAt()
  47609. return nil
  47610. case wxcard.FieldUserID:
  47611. m.ClearUserID()
  47612. return nil
  47613. case wxcard.FieldWxUserID:
  47614. m.ClearWxUserID()
  47615. return nil
  47616. case wxcard.FieldEmail:
  47617. m.ClearEmail()
  47618. return nil
  47619. case wxcard.FieldAPIBase:
  47620. m.ClearAPIBase()
  47621. return nil
  47622. case wxcard.FieldAPIKey:
  47623. m.ClearAPIKey()
  47624. return nil
  47625. case wxcard.FieldAiInfo:
  47626. m.ClearAiInfo()
  47627. return nil
  47628. case wxcard.FieldIntro:
  47629. m.ClearIntro()
  47630. return nil
  47631. }
  47632. return fmt.Errorf("unknown WxCard nullable field %s", name)
  47633. }
  47634. // ResetField resets all changes in the mutation for the field with the given name.
  47635. // It returns an error if the field is not defined in the schema.
  47636. func (m *WxCardMutation) ResetField(name string) error {
  47637. switch name {
  47638. case wxcard.FieldCreatedAt:
  47639. m.ResetCreatedAt()
  47640. return nil
  47641. case wxcard.FieldUpdatedAt:
  47642. m.ResetUpdatedAt()
  47643. return nil
  47644. case wxcard.FieldDeletedAt:
  47645. m.ResetDeletedAt()
  47646. return nil
  47647. case wxcard.FieldUserID:
  47648. m.ResetUserID()
  47649. return nil
  47650. case wxcard.FieldWxUserID:
  47651. m.ResetWxUserID()
  47652. return nil
  47653. case wxcard.FieldAvatar:
  47654. m.ResetAvatar()
  47655. return nil
  47656. case wxcard.FieldLogo:
  47657. m.ResetLogo()
  47658. return nil
  47659. case wxcard.FieldName:
  47660. m.ResetName()
  47661. return nil
  47662. case wxcard.FieldCompany:
  47663. m.ResetCompany()
  47664. return nil
  47665. case wxcard.FieldAddress:
  47666. m.ResetAddress()
  47667. return nil
  47668. case wxcard.FieldPhone:
  47669. m.ResetPhone()
  47670. return nil
  47671. case wxcard.FieldOfficialAccount:
  47672. m.ResetOfficialAccount()
  47673. return nil
  47674. case wxcard.FieldWechatAccount:
  47675. m.ResetWechatAccount()
  47676. return nil
  47677. case wxcard.FieldEmail:
  47678. m.ResetEmail()
  47679. return nil
  47680. case wxcard.FieldAPIBase:
  47681. m.ResetAPIBase()
  47682. return nil
  47683. case wxcard.FieldAPIKey:
  47684. m.ResetAPIKey()
  47685. return nil
  47686. case wxcard.FieldAiInfo:
  47687. m.ResetAiInfo()
  47688. return nil
  47689. case wxcard.FieldIntro:
  47690. m.ResetIntro()
  47691. return nil
  47692. }
  47693. return fmt.Errorf("unknown WxCard field %s", name)
  47694. }
  47695. // AddedEdges returns all edge names that were set/added in this mutation.
  47696. func (m *WxCardMutation) AddedEdges() []string {
  47697. edges := make([]string, 0, 0)
  47698. return edges
  47699. }
  47700. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47701. // name in this mutation.
  47702. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  47703. return nil
  47704. }
  47705. // RemovedEdges returns all edge names that were removed in this mutation.
  47706. func (m *WxCardMutation) RemovedEdges() []string {
  47707. edges := make([]string, 0, 0)
  47708. return edges
  47709. }
  47710. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47711. // the given name in this mutation.
  47712. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  47713. return nil
  47714. }
  47715. // ClearedEdges returns all edge names that were cleared in this mutation.
  47716. func (m *WxCardMutation) ClearedEdges() []string {
  47717. edges := make([]string, 0, 0)
  47718. return edges
  47719. }
  47720. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47721. // was cleared in this mutation.
  47722. func (m *WxCardMutation) EdgeCleared(name string) bool {
  47723. return false
  47724. }
  47725. // ClearEdge clears the value of the edge with the given name. It returns an error
  47726. // if that edge is not defined in the schema.
  47727. func (m *WxCardMutation) ClearEdge(name string) error {
  47728. return fmt.Errorf("unknown WxCard unique edge %s", name)
  47729. }
  47730. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47731. // It returns an error if the edge is not defined in the schema.
  47732. func (m *WxCardMutation) ResetEdge(name string) error {
  47733. return fmt.Errorf("unknown WxCard edge %s", name)
  47734. }
  47735. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  47736. type WxCardUserMutation struct {
  47737. config
  47738. op Op
  47739. typ string
  47740. id *uint64
  47741. created_at *time.Time
  47742. updated_at *time.Time
  47743. deleted_at *time.Time
  47744. wxid *string
  47745. account *string
  47746. avatar *string
  47747. nickname *string
  47748. remark *string
  47749. phone *string
  47750. open_id *string
  47751. union_id *string
  47752. session_key *string
  47753. is_vip *int
  47754. addis_vip *int
  47755. clearedFields map[string]struct{}
  47756. done bool
  47757. oldValue func(context.Context) (*WxCardUser, error)
  47758. predicates []predicate.WxCardUser
  47759. }
  47760. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  47761. // wxcarduserOption allows management of the mutation configuration using functional options.
  47762. type wxcarduserOption func(*WxCardUserMutation)
  47763. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  47764. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  47765. m := &WxCardUserMutation{
  47766. config: c,
  47767. op: op,
  47768. typ: TypeWxCardUser,
  47769. clearedFields: make(map[string]struct{}),
  47770. }
  47771. for _, opt := range opts {
  47772. opt(m)
  47773. }
  47774. return m
  47775. }
  47776. // withWxCardUserID sets the ID field of the mutation.
  47777. func withWxCardUserID(id uint64) wxcarduserOption {
  47778. return func(m *WxCardUserMutation) {
  47779. var (
  47780. err error
  47781. once sync.Once
  47782. value *WxCardUser
  47783. )
  47784. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  47785. once.Do(func() {
  47786. if m.done {
  47787. err = errors.New("querying old values post mutation is not allowed")
  47788. } else {
  47789. value, err = m.Client().WxCardUser.Get(ctx, id)
  47790. }
  47791. })
  47792. return value, err
  47793. }
  47794. m.id = &id
  47795. }
  47796. }
  47797. // withWxCardUser sets the old WxCardUser of the mutation.
  47798. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  47799. return func(m *WxCardUserMutation) {
  47800. m.oldValue = func(context.Context) (*WxCardUser, error) {
  47801. return node, nil
  47802. }
  47803. m.id = &node.ID
  47804. }
  47805. }
  47806. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47807. // executed in a transaction (ent.Tx), a transactional client is returned.
  47808. func (m WxCardUserMutation) Client() *Client {
  47809. client := &Client{config: m.config}
  47810. client.init()
  47811. return client
  47812. }
  47813. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47814. // it returns an error otherwise.
  47815. func (m WxCardUserMutation) Tx() (*Tx, error) {
  47816. if _, ok := m.driver.(*txDriver); !ok {
  47817. return nil, errors.New("ent: mutation is not running in a transaction")
  47818. }
  47819. tx := &Tx{config: m.config}
  47820. tx.init()
  47821. return tx, nil
  47822. }
  47823. // SetID sets the value of the id field. Note that this
  47824. // operation is only accepted on creation of WxCardUser entities.
  47825. func (m *WxCardUserMutation) SetID(id uint64) {
  47826. m.id = &id
  47827. }
  47828. // ID returns the ID value in the mutation. Note that the ID is only available
  47829. // if it was provided to the builder or after it was returned from the database.
  47830. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  47831. if m.id == nil {
  47832. return
  47833. }
  47834. return *m.id, true
  47835. }
  47836. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47837. // That means, if the mutation is applied within a transaction with an isolation level such
  47838. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47839. // or updated by the mutation.
  47840. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  47841. switch {
  47842. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47843. id, exists := m.ID()
  47844. if exists {
  47845. return []uint64{id}, nil
  47846. }
  47847. fallthrough
  47848. case m.op.Is(OpUpdate | OpDelete):
  47849. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  47850. default:
  47851. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47852. }
  47853. }
  47854. // SetCreatedAt sets the "created_at" field.
  47855. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  47856. m.created_at = &t
  47857. }
  47858. // CreatedAt returns the value of the "created_at" field in the mutation.
  47859. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  47860. v := m.created_at
  47861. if v == nil {
  47862. return
  47863. }
  47864. return *v, true
  47865. }
  47866. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  47867. // If the WxCardUser 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 *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47870. if !m.op.Is(OpUpdateOne) {
  47871. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47872. }
  47873. if m.id == nil || m.oldValue == nil {
  47874. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  47879. }
  47880. return oldValue.CreatedAt, nil
  47881. }
  47882. // ResetCreatedAt resets all changes to the "created_at" field.
  47883. func (m *WxCardUserMutation) ResetCreatedAt() {
  47884. m.created_at = nil
  47885. }
  47886. // SetUpdatedAt sets the "updated_at" field.
  47887. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  47888. m.updated_at = &t
  47889. }
  47890. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47891. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  47892. v := m.updated_at
  47893. if v == nil {
  47894. return
  47895. }
  47896. return *v, true
  47897. }
  47898. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  47899. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47901. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47902. if !m.op.Is(OpUpdateOne) {
  47903. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47904. }
  47905. if m.id == nil || m.oldValue == nil {
  47906. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47907. }
  47908. oldValue, err := m.oldValue(ctx)
  47909. if err != nil {
  47910. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47911. }
  47912. return oldValue.UpdatedAt, nil
  47913. }
  47914. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47915. func (m *WxCardUserMutation) ResetUpdatedAt() {
  47916. m.updated_at = nil
  47917. }
  47918. // SetDeletedAt sets the "deleted_at" field.
  47919. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  47920. m.deleted_at = &t
  47921. }
  47922. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47923. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  47924. v := m.deleted_at
  47925. if v == nil {
  47926. return
  47927. }
  47928. return *v, true
  47929. }
  47930. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  47931. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47933. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47934. if !m.op.Is(OpUpdateOne) {
  47935. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47936. }
  47937. if m.id == nil || m.oldValue == nil {
  47938. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47939. }
  47940. oldValue, err := m.oldValue(ctx)
  47941. if err != nil {
  47942. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47943. }
  47944. return oldValue.DeletedAt, nil
  47945. }
  47946. // ClearDeletedAt clears the value of the "deleted_at" field.
  47947. func (m *WxCardUserMutation) ClearDeletedAt() {
  47948. m.deleted_at = nil
  47949. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  47950. }
  47951. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47952. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  47953. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  47954. return ok
  47955. }
  47956. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47957. func (m *WxCardUserMutation) ResetDeletedAt() {
  47958. m.deleted_at = nil
  47959. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  47960. }
  47961. // SetWxid sets the "wxid" field.
  47962. func (m *WxCardUserMutation) SetWxid(s string) {
  47963. m.wxid = &s
  47964. }
  47965. // Wxid returns the value of the "wxid" field in the mutation.
  47966. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  47967. v := m.wxid
  47968. if v == nil {
  47969. return
  47970. }
  47971. return *v, true
  47972. }
  47973. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  47974. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47976. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  47977. if !m.op.Is(OpUpdateOne) {
  47978. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47979. }
  47980. if m.id == nil || m.oldValue == nil {
  47981. return v, errors.New("OldWxid requires an ID field in the mutation")
  47982. }
  47983. oldValue, err := m.oldValue(ctx)
  47984. if err != nil {
  47985. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47986. }
  47987. return oldValue.Wxid, nil
  47988. }
  47989. // ResetWxid resets all changes to the "wxid" field.
  47990. func (m *WxCardUserMutation) ResetWxid() {
  47991. m.wxid = nil
  47992. }
  47993. // SetAccount sets the "account" field.
  47994. func (m *WxCardUserMutation) SetAccount(s string) {
  47995. m.account = &s
  47996. }
  47997. // Account returns the value of the "account" field in the mutation.
  47998. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  47999. v := m.account
  48000. if v == nil {
  48001. return
  48002. }
  48003. return *v, true
  48004. }
  48005. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  48006. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48008. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  48009. if !m.op.Is(OpUpdateOne) {
  48010. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  48011. }
  48012. if m.id == nil || m.oldValue == nil {
  48013. return v, errors.New("OldAccount requires an ID field in the mutation")
  48014. }
  48015. oldValue, err := m.oldValue(ctx)
  48016. if err != nil {
  48017. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  48018. }
  48019. return oldValue.Account, nil
  48020. }
  48021. // ResetAccount resets all changes to the "account" field.
  48022. func (m *WxCardUserMutation) ResetAccount() {
  48023. m.account = nil
  48024. }
  48025. // SetAvatar sets the "avatar" field.
  48026. func (m *WxCardUserMutation) SetAvatar(s string) {
  48027. m.avatar = &s
  48028. }
  48029. // Avatar returns the value of the "avatar" field in the mutation.
  48030. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  48031. v := m.avatar
  48032. if v == nil {
  48033. return
  48034. }
  48035. return *v, true
  48036. }
  48037. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  48038. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48040. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  48041. if !m.op.Is(OpUpdateOne) {
  48042. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  48043. }
  48044. if m.id == nil || m.oldValue == nil {
  48045. return v, errors.New("OldAvatar requires an ID field in the mutation")
  48046. }
  48047. oldValue, err := m.oldValue(ctx)
  48048. if err != nil {
  48049. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  48050. }
  48051. return oldValue.Avatar, nil
  48052. }
  48053. // ResetAvatar resets all changes to the "avatar" field.
  48054. func (m *WxCardUserMutation) ResetAvatar() {
  48055. m.avatar = nil
  48056. }
  48057. // SetNickname sets the "nickname" field.
  48058. func (m *WxCardUserMutation) SetNickname(s string) {
  48059. m.nickname = &s
  48060. }
  48061. // Nickname returns the value of the "nickname" field in the mutation.
  48062. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  48063. v := m.nickname
  48064. if v == nil {
  48065. return
  48066. }
  48067. return *v, true
  48068. }
  48069. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  48070. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48072. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  48073. if !m.op.Is(OpUpdateOne) {
  48074. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  48075. }
  48076. if m.id == nil || m.oldValue == nil {
  48077. return v, errors.New("OldNickname requires an ID field in the mutation")
  48078. }
  48079. oldValue, err := m.oldValue(ctx)
  48080. if err != nil {
  48081. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  48082. }
  48083. return oldValue.Nickname, nil
  48084. }
  48085. // ResetNickname resets all changes to the "nickname" field.
  48086. func (m *WxCardUserMutation) ResetNickname() {
  48087. m.nickname = nil
  48088. }
  48089. // SetRemark sets the "remark" field.
  48090. func (m *WxCardUserMutation) SetRemark(s string) {
  48091. m.remark = &s
  48092. }
  48093. // Remark returns the value of the "remark" field in the mutation.
  48094. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  48095. v := m.remark
  48096. if v == nil {
  48097. return
  48098. }
  48099. return *v, true
  48100. }
  48101. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  48102. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48104. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  48105. if !m.op.Is(OpUpdateOne) {
  48106. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  48107. }
  48108. if m.id == nil || m.oldValue == nil {
  48109. return v, errors.New("OldRemark requires an ID field in the mutation")
  48110. }
  48111. oldValue, err := m.oldValue(ctx)
  48112. if err != nil {
  48113. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  48114. }
  48115. return oldValue.Remark, nil
  48116. }
  48117. // ResetRemark resets all changes to the "remark" field.
  48118. func (m *WxCardUserMutation) ResetRemark() {
  48119. m.remark = nil
  48120. }
  48121. // SetPhone sets the "phone" field.
  48122. func (m *WxCardUserMutation) SetPhone(s string) {
  48123. m.phone = &s
  48124. }
  48125. // Phone returns the value of the "phone" field in the mutation.
  48126. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  48127. v := m.phone
  48128. if v == nil {
  48129. return
  48130. }
  48131. return *v, true
  48132. }
  48133. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  48134. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48136. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  48137. if !m.op.Is(OpUpdateOne) {
  48138. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  48139. }
  48140. if m.id == nil || m.oldValue == nil {
  48141. return v, errors.New("OldPhone requires an ID field in the mutation")
  48142. }
  48143. oldValue, err := m.oldValue(ctx)
  48144. if err != nil {
  48145. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  48146. }
  48147. return oldValue.Phone, nil
  48148. }
  48149. // ResetPhone resets all changes to the "phone" field.
  48150. func (m *WxCardUserMutation) ResetPhone() {
  48151. m.phone = nil
  48152. }
  48153. // SetOpenID sets the "open_id" field.
  48154. func (m *WxCardUserMutation) SetOpenID(s string) {
  48155. m.open_id = &s
  48156. }
  48157. // OpenID returns the value of the "open_id" field in the mutation.
  48158. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  48159. v := m.open_id
  48160. if v == nil {
  48161. return
  48162. }
  48163. return *v, true
  48164. }
  48165. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  48166. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48168. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  48169. if !m.op.Is(OpUpdateOne) {
  48170. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  48171. }
  48172. if m.id == nil || m.oldValue == nil {
  48173. return v, errors.New("OldOpenID requires an ID field in the mutation")
  48174. }
  48175. oldValue, err := m.oldValue(ctx)
  48176. if err != nil {
  48177. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  48178. }
  48179. return oldValue.OpenID, nil
  48180. }
  48181. // ResetOpenID resets all changes to the "open_id" field.
  48182. func (m *WxCardUserMutation) ResetOpenID() {
  48183. m.open_id = nil
  48184. }
  48185. // SetUnionID sets the "union_id" field.
  48186. func (m *WxCardUserMutation) SetUnionID(s string) {
  48187. m.union_id = &s
  48188. }
  48189. // UnionID returns the value of the "union_id" field in the mutation.
  48190. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  48191. v := m.union_id
  48192. if v == nil {
  48193. return
  48194. }
  48195. return *v, true
  48196. }
  48197. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  48198. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48200. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  48201. if !m.op.Is(OpUpdateOne) {
  48202. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  48203. }
  48204. if m.id == nil || m.oldValue == nil {
  48205. return v, errors.New("OldUnionID requires an ID field in the mutation")
  48206. }
  48207. oldValue, err := m.oldValue(ctx)
  48208. if err != nil {
  48209. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  48210. }
  48211. return oldValue.UnionID, nil
  48212. }
  48213. // ResetUnionID resets all changes to the "union_id" field.
  48214. func (m *WxCardUserMutation) ResetUnionID() {
  48215. m.union_id = nil
  48216. }
  48217. // SetSessionKey sets the "session_key" field.
  48218. func (m *WxCardUserMutation) SetSessionKey(s string) {
  48219. m.session_key = &s
  48220. }
  48221. // SessionKey returns the value of the "session_key" field in the mutation.
  48222. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  48223. v := m.session_key
  48224. if v == nil {
  48225. return
  48226. }
  48227. return *v, true
  48228. }
  48229. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  48230. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48232. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  48233. if !m.op.Is(OpUpdateOne) {
  48234. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  48235. }
  48236. if m.id == nil || m.oldValue == nil {
  48237. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  48238. }
  48239. oldValue, err := m.oldValue(ctx)
  48240. if err != nil {
  48241. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  48242. }
  48243. return oldValue.SessionKey, nil
  48244. }
  48245. // ResetSessionKey resets all changes to the "session_key" field.
  48246. func (m *WxCardUserMutation) ResetSessionKey() {
  48247. m.session_key = nil
  48248. }
  48249. // SetIsVip sets the "is_vip" field.
  48250. func (m *WxCardUserMutation) SetIsVip(i int) {
  48251. m.is_vip = &i
  48252. m.addis_vip = nil
  48253. }
  48254. // IsVip returns the value of the "is_vip" field in the mutation.
  48255. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  48256. v := m.is_vip
  48257. if v == nil {
  48258. return
  48259. }
  48260. return *v, true
  48261. }
  48262. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  48263. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48265. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  48266. if !m.op.Is(OpUpdateOne) {
  48267. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  48268. }
  48269. if m.id == nil || m.oldValue == nil {
  48270. return v, errors.New("OldIsVip requires an ID field in the mutation")
  48271. }
  48272. oldValue, err := m.oldValue(ctx)
  48273. if err != nil {
  48274. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  48275. }
  48276. return oldValue.IsVip, nil
  48277. }
  48278. // AddIsVip adds i to the "is_vip" field.
  48279. func (m *WxCardUserMutation) AddIsVip(i int) {
  48280. if m.addis_vip != nil {
  48281. *m.addis_vip += i
  48282. } else {
  48283. m.addis_vip = &i
  48284. }
  48285. }
  48286. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  48287. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  48288. v := m.addis_vip
  48289. if v == nil {
  48290. return
  48291. }
  48292. return *v, true
  48293. }
  48294. // ResetIsVip resets all changes to the "is_vip" field.
  48295. func (m *WxCardUserMutation) ResetIsVip() {
  48296. m.is_vip = nil
  48297. m.addis_vip = nil
  48298. }
  48299. // Where appends a list predicates to the WxCardUserMutation builder.
  48300. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  48301. m.predicates = append(m.predicates, ps...)
  48302. }
  48303. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  48304. // users can use type-assertion to append predicates that do not depend on any generated package.
  48305. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  48306. p := make([]predicate.WxCardUser, len(ps))
  48307. for i := range ps {
  48308. p[i] = ps[i]
  48309. }
  48310. m.Where(p...)
  48311. }
  48312. // Op returns the operation name.
  48313. func (m *WxCardUserMutation) Op() Op {
  48314. return m.op
  48315. }
  48316. // SetOp allows setting the mutation operation.
  48317. func (m *WxCardUserMutation) SetOp(op Op) {
  48318. m.op = op
  48319. }
  48320. // Type returns the node type of this mutation (WxCardUser).
  48321. func (m *WxCardUserMutation) Type() string {
  48322. return m.typ
  48323. }
  48324. // Fields returns all fields that were changed during this mutation. Note that in
  48325. // order to get all numeric fields that were incremented/decremented, call
  48326. // AddedFields().
  48327. func (m *WxCardUserMutation) Fields() []string {
  48328. fields := make([]string, 0, 13)
  48329. if m.created_at != nil {
  48330. fields = append(fields, wxcarduser.FieldCreatedAt)
  48331. }
  48332. if m.updated_at != nil {
  48333. fields = append(fields, wxcarduser.FieldUpdatedAt)
  48334. }
  48335. if m.deleted_at != nil {
  48336. fields = append(fields, wxcarduser.FieldDeletedAt)
  48337. }
  48338. if m.wxid != nil {
  48339. fields = append(fields, wxcarduser.FieldWxid)
  48340. }
  48341. if m.account != nil {
  48342. fields = append(fields, wxcarduser.FieldAccount)
  48343. }
  48344. if m.avatar != nil {
  48345. fields = append(fields, wxcarduser.FieldAvatar)
  48346. }
  48347. if m.nickname != nil {
  48348. fields = append(fields, wxcarduser.FieldNickname)
  48349. }
  48350. if m.remark != nil {
  48351. fields = append(fields, wxcarduser.FieldRemark)
  48352. }
  48353. if m.phone != nil {
  48354. fields = append(fields, wxcarduser.FieldPhone)
  48355. }
  48356. if m.open_id != nil {
  48357. fields = append(fields, wxcarduser.FieldOpenID)
  48358. }
  48359. if m.union_id != nil {
  48360. fields = append(fields, wxcarduser.FieldUnionID)
  48361. }
  48362. if m.session_key != nil {
  48363. fields = append(fields, wxcarduser.FieldSessionKey)
  48364. }
  48365. if m.is_vip != nil {
  48366. fields = append(fields, wxcarduser.FieldIsVip)
  48367. }
  48368. return fields
  48369. }
  48370. // Field returns the value of a field with the given name. The second boolean
  48371. // return value indicates that this field was not set, or was not defined in the
  48372. // schema.
  48373. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  48374. switch name {
  48375. case wxcarduser.FieldCreatedAt:
  48376. return m.CreatedAt()
  48377. case wxcarduser.FieldUpdatedAt:
  48378. return m.UpdatedAt()
  48379. case wxcarduser.FieldDeletedAt:
  48380. return m.DeletedAt()
  48381. case wxcarduser.FieldWxid:
  48382. return m.Wxid()
  48383. case wxcarduser.FieldAccount:
  48384. return m.Account()
  48385. case wxcarduser.FieldAvatar:
  48386. return m.Avatar()
  48387. case wxcarduser.FieldNickname:
  48388. return m.Nickname()
  48389. case wxcarduser.FieldRemark:
  48390. return m.Remark()
  48391. case wxcarduser.FieldPhone:
  48392. return m.Phone()
  48393. case wxcarduser.FieldOpenID:
  48394. return m.OpenID()
  48395. case wxcarduser.FieldUnionID:
  48396. return m.UnionID()
  48397. case wxcarduser.FieldSessionKey:
  48398. return m.SessionKey()
  48399. case wxcarduser.FieldIsVip:
  48400. return m.IsVip()
  48401. }
  48402. return nil, false
  48403. }
  48404. // OldField returns the old value of the field from the database. An error is
  48405. // returned if the mutation operation is not UpdateOne, or the query to the
  48406. // database failed.
  48407. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48408. switch name {
  48409. case wxcarduser.FieldCreatedAt:
  48410. return m.OldCreatedAt(ctx)
  48411. case wxcarduser.FieldUpdatedAt:
  48412. return m.OldUpdatedAt(ctx)
  48413. case wxcarduser.FieldDeletedAt:
  48414. return m.OldDeletedAt(ctx)
  48415. case wxcarduser.FieldWxid:
  48416. return m.OldWxid(ctx)
  48417. case wxcarduser.FieldAccount:
  48418. return m.OldAccount(ctx)
  48419. case wxcarduser.FieldAvatar:
  48420. return m.OldAvatar(ctx)
  48421. case wxcarduser.FieldNickname:
  48422. return m.OldNickname(ctx)
  48423. case wxcarduser.FieldRemark:
  48424. return m.OldRemark(ctx)
  48425. case wxcarduser.FieldPhone:
  48426. return m.OldPhone(ctx)
  48427. case wxcarduser.FieldOpenID:
  48428. return m.OldOpenID(ctx)
  48429. case wxcarduser.FieldUnionID:
  48430. return m.OldUnionID(ctx)
  48431. case wxcarduser.FieldSessionKey:
  48432. return m.OldSessionKey(ctx)
  48433. case wxcarduser.FieldIsVip:
  48434. return m.OldIsVip(ctx)
  48435. }
  48436. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  48437. }
  48438. // SetField sets the value of a field with the given name. It returns an error if
  48439. // the field is not defined in the schema, or if the type mismatched the field
  48440. // type.
  48441. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  48442. switch name {
  48443. case wxcarduser.FieldCreatedAt:
  48444. v, ok := value.(time.Time)
  48445. if !ok {
  48446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48447. }
  48448. m.SetCreatedAt(v)
  48449. return nil
  48450. case wxcarduser.FieldUpdatedAt:
  48451. v, ok := value.(time.Time)
  48452. if !ok {
  48453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48454. }
  48455. m.SetUpdatedAt(v)
  48456. return nil
  48457. case wxcarduser.FieldDeletedAt:
  48458. v, ok := value.(time.Time)
  48459. if !ok {
  48460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48461. }
  48462. m.SetDeletedAt(v)
  48463. return nil
  48464. case wxcarduser.FieldWxid:
  48465. v, ok := value.(string)
  48466. if !ok {
  48467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48468. }
  48469. m.SetWxid(v)
  48470. return nil
  48471. case wxcarduser.FieldAccount:
  48472. v, ok := value.(string)
  48473. if !ok {
  48474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48475. }
  48476. m.SetAccount(v)
  48477. return nil
  48478. case wxcarduser.FieldAvatar:
  48479. v, ok := value.(string)
  48480. if !ok {
  48481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48482. }
  48483. m.SetAvatar(v)
  48484. return nil
  48485. case wxcarduser.FieldNickname:
  48486. v, ok := value.(string)
  48487. if !ok {
  48488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48489. }
  48490. m.SetNickname(v)
  48491. return nil
  48492. case wxcarduser.FieldRemark:
  48493. v, ok := value.(string)
  48494. if !ok {
  48495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48496. }
  48497. m.SetRemark(v)
  48498. return nil
  48499. case wxcarduser.FieldPhone:
  48500. v, ok := value.(string)
  48501. if !ok {
  48502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48503. }
  48504. m.SetPhone(v)
  48505. return nil
  48506. case wxcarduser.FieldOpenID:
  48507. v, ok := value.(string)
  48508. if !ok {
  48509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48510. }
  48511. m.SetOpenID(v)
  48512. return nil
  48513. case wxcarduser.FieldUnionID:
  48514. v, ok := value.(string)
  48515. if !ok {
  48516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48517. }
  48518. m.SetUnionID(v)
  48519. return nil
  48520. case wxcarduser.FieldSessionKey:
  48521. v, ok := value.(string)
  48522. if !ok {
  48523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48524. }
  48525. m.SetSessionKey(v)
  48526. return nil
  48527. case wxcarduser.FieldIsVip:
  48528. v, ok := value.(int)
  48529. if !ok {
  48530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48531. }
  48532. m.SetIsVip(v)
  48533. return nil
  48534. }
  48535. return fmt.Errorf("unknown WxCardUser field %s", name)
  48536. }
  48537. // AddedFields returns all numeric fields that were incremented/decremented during
  48538. // this mutation.
  48539. func (m *WxCardUserMutation) AddedFields() []string {
  48540. var fields []string
  48541. if m.addis_vip != nil {
  48542. fields = append(fields, wxcarduser.FieldIsVip)
  48543. }
  48544. return fields
  48545. }
  48546. // AddedField returns the numeric value that was incremented/decremented on a field
  48547. // with the given name. The second boolean return value indicates that this field
  48548. // was not set, or was not defined in the schema.
  48549. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  48550. switch name {
  48551. case wxcarduser.FieldIsVip:
  48552. return m.AddedIsVip()
  48553. }
  48554. return nil, false
  48555. }
  48556. // AddField adds the value to the field with the given name. It returns an error if
  48557. // the field is not defined in the schema, or if the type mismatched the field
  48558. // type.
  48559. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  48560. switch name {
  48561. case wxcarduser.FieldIsVip:
  48562. v, ok := value.(int)
  48563. if !ok {
  48564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48565. }
  48566. m.AddIsVip(v)
  48567. return nil
  48568. }
  48569. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  48570. }
  48571. // ClearedFields returns all nullable fields that were cleared during this
  48572. // mutation.
  48573. func (m *WxCardUserMutation) ClearedFields() []string {
  48574. var fields []string
  48575. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  48576. fields = append(fields, wxcarduser.FieldDeletedAt)
  48577. }
  48578. return fields
  48579. }
  48580. // FieldCleared returns a boolean indicating if a field with the given name was
  48581. // cleared in this mutation.
  48582. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  48583. _, ok := m.clearedFields[name]
  48584. return ok
  48585. }
  48586. // ClearField clears the value of the field with the given name. It returns an
  48587. // error if the field is not defined in the schema.
  48588. func (m *WxCardUserMutation) ClearField(name string) error {
  48589. switch name {
  48590. case wxcarduser.FieldDeletedAt:
  48591. m.ClearDeletedAt()
  48592. return nil
  48593. }
  48594. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  48595. }
  48596. // ResetField resets all changes in the mutation for the field with the given name.
  48597. // It returns an error if the field is not defined in the schema.
  48598. func (m *WxCardUserMutation) ResetField(name string) error {
  48599. switch name {
  48600. case wxcarduser.FieldCreatedAt:
  48601. m.ResetCreatedAt()
  48602. return nil
  48603. case wxcarduser.FieldUpdatedAt:
  48604. m.ResetUpdatedAt()
  48605. return nil
  48606. case wxcarduser.FieldDeletedAt:
  48607. m.ResetDeletedAt()
  48608. return nil
  48609. case wxcarduser.FieldWxid:
  48610. m.ResetWxid()
  48611. return nil
  48612. case wxcarduser.FieldAccount:
  48613. m.ResetAccount()
  48614. return nil
  48615. case wxcarduser.FieldAvatar:
  48616. m.ResetAvatar()
  48617. return nil
  48618. case wxcarduser.FieldNickname:
  48619. m.ResetNickname()
  48620. return nil
  48621. case wxcarduser.FieldRemark:
  48622. m.ResetRemark()
  48623. return nil
  48624. case wxcarduser.FieldPhone:
  48625. m.ResetPhone()
  48626. return nil
  48627. case wxcarduser.FieldOpenID:
  48628. m.ResetOpenID()
  48629. return nil
  48630. case wxcarduser.FieldUnionID:
  48631. m.ResetUnionID()
  48632. return nil
  48633. case wxcarduser.FieldSessionKey:
  48634. m.ResetSessionKey()
  48635. return nil
  48636. case wxcarduser.FieldIsVip:
  48637. m.ResetIsVip()
  48638. return nil
  48639. }
  48640. return fmt.Errorf("unknown WxCardUser field %s", name)
  48641. }
  48642. // AddedEdges returns all edge names that were set/added in this mutation.
  48643. func (m *WxCardUserMutation) AddedEdges() []string {
  48644. edges := make([]string, 0, 0)
  48645. return edges
  48646. }
  48647. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48648. // name in this mutation.
  48649. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  48650. return nil
  48651. }
  48652. // RemovedEdges returns all edge names that were removed in this mutation.
  48653. func (m *WxCardUserMutation) RemovedEdges() []string {
  48654. edges := make([]string, 0, 0)
  48655. return edges
  48656. }
  48657. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48658. // the given name in this mutation.
  48659. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  48660. return nil
  48661. }
  48662. // ClearedEdges returns all edge names that were cleared in this mutation.
  48663. func (m *WxCardUserMutation) ClearedEdges() []string {
  48664. edges := make([]string, 0, 0)
  48665. return edges
  48666. }
  48667. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48668. // was cleared in this mutation.
  48669. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  48670. return false
  48671. }
  48672. // ClearEdge clears the value of the edge with the given name. It returns an error
  48673. // if that edge is not defined in the schema.
  48674. func (m *WxCardUserMutation) ClearEdge(name string) error {
  48675. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  48676. }
  48677. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48678. // It returns an error if the edge is not defined in the schema.
  48679. func (m *WxCardUserMutation) ResetEdge(name string) error {
  48680. return fmt.Errorf("unknown WxCardUser edge %s", name)
  48681. }
  48682. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  48683. type WxCardVisitMutation struct {
  48684. config
  48685. op Op
  48686. typ string
  48687. id *uint64
  48688. created_at *time.Time
  48689. updated_at *time.Time
  48690. deleted_at *time.Time
  48691. user_id *uint64
  48692. adduser_id *int64
  48693. bot_id *uint64
  48694. addbot_id *int64
  48695. bot_type *uint8
  48696. addbot_type *int8
  48697. clearedFields map[string]struct{}
  48698. done bool
  48699. oldValue func(context.Context) (*WxCardVisit, error)
  48700. predicates []predicate.WxCardVisit
  48701. }
  48702. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  48703. // wxcardvisitOption allows management of the mutation configuration using functional options.
  48704. type wxcardvisitOption func(*WxCardVisitMutation)
  48705. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  48706. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  48707. m := &WxCardVisitMutation{
  48708. config: c,
  48709. op: op,
  48710. typ: TypeWxCardVisit,
  48711. clearedFields: make(map[string]struct{}),
  48712. }
  48713. for _, opt := range opts {
  48714. opt(m)
  48715. }
  48716. return m
  48717. }
  48718. // withWxCardVisitID sets the ID field of the mutation.
  48719. func withWxCardVisitID(id uint64) wxcardvisitOption {
  48720. return func(m *WxCardVisitMutation) {
  48721. var (
  48722. err error
  48723. once sync.Once
  48724. value *WxCardVisit
  48725. )
  48726. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  48727. once.Do(func() {
  48728. if m.done {
  48729. err = errors.New("querying old values post mutation is not allowed")
  48730. } else {
  48731. value, err = m.Client().WxCardVisit.Get(ctx, id)
  48732. }
  48733. })
  48734. return value, err
  48735. }
  48736. m.id = &id
  48737. }
  48738. }
  48739. // withWxCardVisit sets the old WxCardVisit of the mutation.
  48740. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  48741. return func(m *WxCardVisitMutation) {
  48742. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  48743. return node, nil
  48744. }
  48745. m.id = &node.ID
  48746. }
  48747. }
  48748. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48749. // executed in a transaction (ent.Tx), a transactional client is returned.
  48750. func (m WxCardVisitMutation) Client() *Client {
  48751. client := &Client{config: m.config}
  48752. client.init()
  48753. return client
  48754. }
  48755. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48756. // it returns an error otherwise.
  48757. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  48758. if _, ok := m.driver.(*txDriver); !ok {
  48759. return nil, errors.New("ent: mutation is not running in a transaction")
  48760. }
  48761. tx := &Tx{config: m.config}
  48762. tx.init()
  48763. return tx, nil
  48764. }
  48765. // SetID sets the value of the id field. Note that this
  48766. // operation is only accepted on creation of WxCardVisit entities.
  48767. func (m *WxCardVisitMutation) SetID(id uint64) {
  48768. m.id = &id
  48769. }
  48770. // ID returns the ID value in the mutation. Note that the ID is only available
  48771. // if it was provided to the builder or after it was returned from the database.
  48772. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  48773. if m.id == nil {
  48774. return
  48775. }
  48776. return *m.id, true
  48777. }
  48778. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48779. // That means, if the mutation is applied within a transaction with an isolation level such
  48780. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48781. // or updated by the mutation.
  48782. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  48783. switch {
  48784. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48785. id, exists := m.ID()
  48786. if exists {
  48787. return []uint64{id}, nil
  48788. }
  48789. fallthrough
  48790. case m.op.Is(OpUpdate | OpDelete):
  48791. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  48792. default:
  48793. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48794. }
  48795. }
  48796. // SetCreatedAt sets the "created_at" field.
  48797. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  48798. m.created_at = &t
  48799. }
  48800. // CreatedAt returns the value of the "created_at" field in the mutation.
  48801. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  48802. v := m.created_at
  48803. if v == nil {
  48804. return
  48805. }
  48806. return *v, true
  48807. }
  48808. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  48809. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48811. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48812. if !m.op.Is(OpUpdateOne) {
  48813. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48814. }
  48815. if m.id == nil || m.oldValue == nil {
  48816. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48817. }
  48818. oldValue, err := m.oldValue(ctx)
  48819. if err != nil {
  48820. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48821. }
  48822. return oldValue.CreatedAt, nil
  48823. }
  48824. // ResetCreatedAt resets all changes to the "created_at" field.
  48825. func (m *WxCardVisitMutation) ResetCreatedAt() {
  48826. m.created_at = nil
  48827. }
  48828. // SetUpdatedAt sets the "updated_at" field.
  48829. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  48830. m.updated_at = &t
  48831. }
  48832. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48833. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  48834. v := m.updated_at
  48835. if v == nil {
  48836. return
  48837. }
  48838. return *v, true
  48839. }
  48840. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  48841. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48843. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48844. if !m.op.Is(OpUpdateOne) {
  48845. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48846. }
  48847. if m.id == nil || m.oldValue == nil {
  48848. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48849. }
  48850. oldValue, err := m.oldValue(ctx)
  48851. if err != nil {
  48852. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48853. }
  48854. return oldValue.UpdatedAt, nil
  48855. }
  48856. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48857. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  48858. m.updated_at = nil
  48859. }
  48860. // SetDeletedAt sets the "deleted_at" field.
  48861. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  48862. m.deleted_at = &t
  48863. }
  48864. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48865. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  48866. v := m.deleted_at
  48867. if v == nil {
  48868. return
  48869. }
  48870. return *v, true
  48871. }
  48872. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  48873. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48875. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48876. if !m.op.Is(OpUpdateOne) {
  48877. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48878. }
  48879. if m.id == nil || m.oldValue == nil {
  48880. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48881. }
  48882. oldValue, err := m.oldValue(ctx)
  48883. if err != nil {
  48884. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48885. }
  48886. return oldValue.DeletedAt, nil
  48887. }
  48888. // ClearDeletedAt clears the value of the "deleted_at" field.
  48889. func (m *WxCardVisitMutation) ClearDeletedAt() {
  48890. m.deleted_at = nil
  48891. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  48892. }
  48893. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48894. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  48895. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  48896. return ok
  48897. }
  48898. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48899. func (m *WxCardVisitMutation) ResetDeletedAt() {
  48900. m.deleted_at = nil
  48901. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  48902. }
  48903. // SetUserID sets the "user_id" field.
  48904. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  48905. m.user_id = &u
  48906. m.adduser_id = nil
  48907. }
  48908. // UserID returns the value of the "user_id" field in the mutation.
  48909. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  48910. v := m.user_id
  48911. if v == nil {
  48912. return
  48913. }
  48914. return *v, true
  48915. }
  48916. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  48917. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48919. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48920. if !m.op.Is(OpUpdateOne) {
  48921. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48922. }
  48923. if m.id == nil || m.oldValue == nil {
  48924. return v, errors.New("OldUserID requires an ID field in the mutation")
  48925. }
  48926. oldValue, err := m.oldValue(ctx)
  48927. if err != nil {
  48928. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48929. }
  48930. return oldValue.UserID, nil
  48931. }
  48932. // AddUserID adds u to the "user_id" field.
  48933. func (m *WxCardVisitMutation) AddUserID(u int64) {
  48934. if m.adduser_id != nil {
  48935. *m.adduser_id += u
  48936. } else {
  48937. m.adduser_id = &u
  48938. }
  48939. }
  48940. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48941. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  48942. v := m.adduser_id
  48943. if v == nil {
  48944. return
  48945. }
  48946. return *v, true
  48947. }
  48948. // ClearUserID clears the value of the "user_id" field.
  48949. func (m *WxCardVisitMutation) ClearUserID() {
  48950. m.user_id = nil
  48951. m.adduser_id = nil
  48952. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  48953. }
  48954. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48955. func (m *WxCardVisitMutation) UserIDCleared() bool {
  48956. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  48957. return ok
  48958. }
  48959. // ResetUserID resets all changes to the "user_id" field.
  48960. func (m *WxCardVisitMutation) ResetUserID() {
  48961. m.user_id = nil
  48962. m.adduser_id = nil
  48963. delete(m.clearedFields, wxcardvisit.FieldUserID)
  48964. }
  48965. // SetBotID sets the "bot_id" field.
  48966. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  48967. m.bot_id = &u
  48968. m.addbot_id = nil
  48969. }
  48970. // BotID returns the value of the "bot_id" field in the mutation.
  48971. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  48972. v := m.bot_id
  48973. if v == nil {
  48974. return
  48975. }
  48976. return *v, true
  48977. }
  48978. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  48979. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48981. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  48982. if !m.op.Is(OpUpdateOne) {
  48983. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  48984. }
  48985. if m.id == nil || m.oldValue == nil {
  48986. return v, errors.New("OldBotID requires an ID field in the mutation")
  48987. }
  48988. oldValue, err := m.oldValue(ctx)
  48989. if err != nil {
  48990. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  48991. }
  48992. return oldValue.BotID, nil
  48993. }
  48994. // AddBotID adds u to the "bot_id" field.
  48995. func (m *WxCardVisitMutation) AddBotID(u int64) {
  48996. if m.addbot_id != nil {
  48997. *m.addbot_id += u
  48998. } else {
  48999. m.addbot_id = &u
  49000. }
  49001. }
  49002. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  49003. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  49004. v := m.addbot_id
  49005. if v == nil {
  49006. return
  49007. }
  49008. return *v, true
  49009. }
  49010. // ResetBotID resets all changes to the "bot_id" field.
  49011. func (m *WxCardVisitMutation) ResetBotID() {
  49012. m.bot_id = nil
  49013. m.addbot_id = nil
  49014. }
  49015. // SetBotType sets the "bot_type" field.
  49016. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  49017. m.bot_type = &u
  49018. m.addbot_type = nil
  49019. }
  49020. // BotType returns the value of the "bot_type" field in the mutation.
  49021. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  49022. v := m.bot_type
  49023. if v == nil {
  49024. return
  49025. }
  49026. return *v, true
  49027. }
  49028. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  49029. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  49030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49031. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  49032. if !m.op.Is(OpUpdateOne) {
  49033. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  49034. }
  49035. if m.id == nil || m.oldValue == nil {
  49036. return v, errors.New("OldBotType requires an ID field in the mutation")
  49037. }
  49038. oldValue, err := m.oldValue(ctx)
  49039. if err != nil {
  49040. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  49041. }
  49042. return oldValue.BotType, nil
  49043. }
  49044. // AddBotType adds u to the "bot_type" field.
  49045. func (m *WxCardVisitMutation) AddBotType(u int8) {
  49046. if m.addbot_type != nil {
  49047. *m.addbot_type += u
  49048. } else {
  49049. m.addbot_type = &u
  49050. }
  49051. }
  49052. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  49053. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  49054. v := m.addbot_type
  49055. if v == nil {
  49056. return
  49057. }
  49058. return *v, true
  49059. }
  49060. // ResetBotType resets all changes to the "bot_type" field.
  49061. func (m *WxCardVisitMutation) ResetBotType() {
  49062. m.bot_type = nil
  49063. m.addbot_type = nil
  49064. }
  49065. // Where appends a list predicates to the WxCardVisitMutation builder.
  49066. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  49067. m.predicates = append(m.predicates, ps...)
  49068. }
  49069. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  49070. // users can use type-assertion to append predicates that do not depend on any generated package.
  49071. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  49072. p := make([]predicate.WxCardVisit, len(ps))
  49073. for i := range ps {
  49074. p[i] = ps[i]
  49075. }
  49076. m.Where(p...)
  49077. }
  49078. // Op returns the operation name.
  49079. func (m *WxCardVisitMutation) Op() Op {
  49080. return m.op
  49081. }
  49082. // SetOp allows setting the mutation operation.
  49083. func (m *WxCardVisitMutation) SetOp(op Op) {
  49084. m.op = op
  49085. }
  49086. // Type returns the node type of this mutation (WxCardVisit).
  49087. func (m *WxCardVisitMutation) Type() string {
  49088. return m.typ
  49089. }
  49090. // Fields returns all fields that were changed during this mutation. Note that in
  49091. // order to get all numeric fields that were incremented/decremented, call
  49092. // AddedFields().
  49093. func (m *WxCardVisitMutation) Fields() []string {
  49094. fields := make([]string, 0, 6)
  49095. if m.created_at != nil {
  49096. fields = append(fields, wxcardvisit.FieldCreatedAt)
  49097. }
  49098. if m.updated_at != nil {
  49099. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  49100. }
  49101. if m.deleted_at != nil {
  49102. fields = append(fields, wxcardvisit.FieldDeletedAt)
  49103. }
  49104. if m.user_id != nil {
  49105. fields = append(fields, wxcardvisit.FieldUserID)
  49106. }
  49107. if m.bot_id != nil {
  49108. fields = append(fields, wxcardvisit.FieldBotID)
  49109. }
  49110. if m.bot_type != nil {
  49111. fields = append(fields, wxcardvisit.FieldBotType)
  49112. }
  49113. return fields
  49114. }
  49115. // Field returns the value of a field with the given name. The second boolean
  49116. // return value indicates that this field was not set, or was not defined in the
  49117. // schema.
  49118. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  49119. switch name {
  49120. case wxcardvisit.FieldCreatedAt:
  49121. return m.CreatedAt()
  49122. case wxcardvisit.FieldUpdatedAt:
  49123. return m.UpdatedAt()
  49124. case wxcardvisit.FieldDeletedAt:
  49125. return m.DeletedAt()
  49126. case wxcardvisit.FieldUserID:
  49127. return m.UserID()
  49128. case wxcardvisit.FieldBotID:
  49129. return m.BotID()
  49130. case wxcardvisit.FieldBotType:
  49131. return m.BotType()
  49132. }
  49133. return nil, false
  49134. }
  49135. // OldField returns the old value of the field from the database. An error is
  49136. // returned if the mutation operation is not UpdateOne, or the query to the
  49137. // database failed.
  49138. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49139. switch name {
  49140. case wxcardvisit.FieldCreatedAt:
  49141. return m.OldCreatedAt(ctx)
  49142. case wxcardvisit.FieldUpdatedAt:
  49143. return m.OldUpdatedAt(ctx)
  49144. case wxcardvisit.FieldDeletedAt:
  49145. return m.OldDeletedAt(ctx)
  49146. case wxcardvisit.FieldUserID:
  49147. return m.OldUserID(ctx)
  49148. case wxcardvisit.FieldBotID:
  49149. return m.OldBotID(ctx)
  49150. case wxcardvisit.FieldBotType:
  49151. return m.OldBotType(ctx)
  49152. }
  49153. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  49154. }
  49155. // SetField sets the value of a field with the given name. It returns an error if
  49156. // the field is not defined in the schema, or if the type mismatched the field
  49157. // type.
  49158. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  49159. switch name {
  49160. case wxcardvisit.FieldCreatedAt:
  49161. v, ok := value.(time.Time)
  49162. if !ok {
  49163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49164. }
  49165. m.SetCreatedAt(v)
  49166. return nil
  49167. case wxcardvisit.FieldUpdatedAt:
  49168. v, ok := value.(time.Time)
  49169. if !ok {
  49170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49171. }
  49172. m.SetUpdatedAt(v)
  49173. return nil
  49174. case wxcardvisit.FieldDeletedAt:
  49175. v, ok := value.(time.Time)
  49176. if !ok {
  49177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49178. }
  49179. m.SetDeletedAt(v)
  49180. return nil
  49181. case wxcardvisit.FieldUserID:
  49182. v, ok := value.(uint64)
  49183. if !ok {
  49184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49185. }
  49186. m.SetUserID(v)
  49187. return nil
  49188. case wxcardvisit.FieldBotID:
  49189. v, ok := value.(uint64)
  49190. if !ok {
  49191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49192. }
  49193. m.SetBotID(v)
  49194. return nil
  49195. case wxcardvisit.FieldBotType:
  49196. v, ok := value.(uint8)
  49197. if !ok {
  49198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49199. }
  49200. m.SetBotType(v)
  49201. return nil
  49202. }
  49203. return fmt.Errorf("unknown WxCardVisit field %s", name)
  49204. }
  49205. // AddedFields returns all numeric fields that were incremented/decremented during
  49206. // this mutation.
  49207. func (m *WxCardVisitMutation) AddedFields() []string {
  49208. var fields []string
  49209. if m.adduser_id != nil {
  49210. fields = append(fields, wxcardvisit.FieldUserID)
  49211. }
  49212. if m.addbot_id != nil {
  49213. fields = append(fields, wxcardvisit.FieldBotID)
  49214. }
  49215. if m.addbot_type != nil {
  49216. fields = append(fields, wxcardvisit.FieldBotType)
  49217. }
  49218. return fields
  49219. }
  49220. // AddedField returns the numeric value that was incremented/decremented on a field
  49221. // with the given name. The second boolean return value indicates that this field
  49222. // was not set, or was not defined in the schema.
  49223. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  49224. switch name {
  49225. case wxcardvisit.FieldUserID:
  49226. return m.AddedUserID()
  49227. case wxcardvisit.FieldBotID:
  49228. return m.AddedBotID()
  49229. case wxcardvisit.FieldBotType:
  49230. return m.AddedBotType()
  49231. }
  49232. return nil, false
  49233. }
  49234. // AddField adds the value to the field with the given name. It returns an error if
  49235. // the field is not defined in the schema, or if the type mismatched the field
  49236. // type.
  49237. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  49238. switch name {
  49239. case wxcardvisit.FieldUserID:
  49240. v, ok := value.(int64)
  49241. if !ok {
  49242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49243. }
  49244. m.AddUserID(v)
  49245. return nil
  49246. case wxcardvisit.FieldBotID:
  49247. v, ok := value.(int64)
  49248. if !ok {
  49249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49250. }
  49251. m.AddBotID(v)
  49252. return nil
  49253. case wxcardvisit.FieldBotType:
  49254. v, ok := value.(int8)
  49255. if !ok {
  49256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49257. }
  49258. m.AddBotType(v)
  49259. return nil
  49260. }
  49261. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  49262. }
  49263. // ClearedFields returns all nullable fields that were cleared during this
  49264. // mutation.
  49265. func (m *WxCardVisitMutation) ClearedFields() []string {
  49266. var fields []string
  49267. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  49268. fields = append(fields, wxcardvisit.FieldDeletedAt)
  49269. }
  49270. if m.FieldCleared(wxcardvisit.FieldUserID) {
  49271. fields = append(fields, wxcardvisit.FieldUserID)
  49272. }
  49273. return fields
  49274. }
  49275. // FieldCleared returns a boolean indicating if a field with the given name was
  49276. // cleared in this mutation.
  49277. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  49278. _, ok := m.clearedFields[name]
  49279. return ok
  49280. }
  49281. // ClearField clears the value of the field with the given name. It returns an
  49282. // error if the field is not defined in the schema.
  49283. func (m *WxCardVisitMutation) ClearField(name string) error {
  49284. switch name {
  49285. case wxcardvisit.FieldDeletedAt:
  49286. m.ClearDeletedAt()
  49287. return nil
  49288. case wxcardvisit.FieldUserID:
  49289. m.ClearUserID()
  49290. return nil
  49291. }
  49292. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  49293. }
  49294. // ResetField resets all changes in the mutation for the field with the given name.
  49295. // It returns an error if the field is not defined in the schema.
  49296. func (m *WxCardVisitMutation) ResetField(name string) error {
  49297. switch name {
  49298. case wxcardvisit.FieldCreatedAt:
  49299. m.ResetCreatedAt()
  49300. return nil
  49301. case wxcardvisit.FieldUpdatedAt:
  49302. m.ResetUpdatedAt()
  49303. return nil
  49304. case wxcardvisit.FieldDeletedAt:
  49305. m.ResetDeletedAt()
  49306. return nil
  49307. case wxcardvisit.FieldUserID:
  49308. m.ResetUserID()
  49309. return nil
  49310. case wxcardvisit.FieldBotID:
  49311. m.ResetBotID()
  49312. return nil
  49313. case wxcardvisit.FieldBotType:
  49314. m.ResetBotType()
  49315. return nil
  49316. }
  49317. return fmt.Errorf("unknown WxCardVisit field %s", name)
  49318. }
  49319. // AddedEdges returns all edge names that were set/added in this mutation.
  49320. func (m *WxCardVisitMutation) AddedEdges() []string {
  49321. edges := make([]string, 0, 0)
  49322. return edges
  49323. }
  49324. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49325. // name in this mutation.
  49326. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  49327. return nil
  49328. }
  49329. // RemovedEdges returns all edge names that were removed in this mutation.
  49330. func (m *WxCardVisitMutation) RemovedEdges() []string {
  49331. edges := make([]string, 0, 0)
  49332. return edges
  49333. }
  49334. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49335. // the given name in this mutation.
  49336. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  49337. return nil
  49338. }
  49339. // ClearedEdges returns all edge names that were cleared in this mutation.
  49340. func (m *WxCardVisitMutation) ClearedEdges() []string {
  49341. edges := make([]string, 0, 0)
  49342. return edges
  49343. }
  49344. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49345. // was cleared in this mutation.
  49346. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  49347. return false
  49348. }
  49349. // ClearEdge clears the value of the edge with the given name. It returns an error
  49350. // if that edge is not defined in the schema.
  49351. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  49352. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  49353. }
  49354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49355. // It returns an error if the edge is not defined in the schema.
  49356. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  49357. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  49358. }