mutation.go 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/addwechatfriendlog"
  10. "wechat-api/ent/agent"
  11. "wechat-api/ent/agentbase"
  12. "wechat-api/ent/aliyunavatar"
  13. "wechat-api/ent/allocagent"
  14. "wechat-api/ent/apikey"
  15. "wechat-api/ent/batchmsg"
  16. "wechat-api/ent/category"
  17. "wechat-api/ent/chatrecords"
  18. "wechat-api/ent/chatsession"
  19. "wechat-api/ent/compapiasynctask"
  20. "wechat-api/ent/contact"
  21. "wechat-api/ent/contactfield"
  22. "wechat-api/ent/contactfieldtemplate"
  23. "wechat-api/ent/creditbalance"
  24. "wechat-api/ent/creditusage"
  25. "wechat-api/ent/custom_types"
  26. "wechat-api/ent/employee"
  27. "wechat-api/ent/employeeconfig"
  28. "wechat-api/ent/label"
  29. "wechat-api/ent/labellog"
  30. "wechat-api/ent/labelrelationship"
  31. "wechat-api/ent/labeltagging"
  32. "wechat-api/ent/message"
  33. "wechat-api/ent/messagerecords"
  34. "wechat-api/ent/msg"
  35. "wechat-api/ent/payrecharge"
  36. "wechat-api/ent/predicate"
  37. "wechat-api/ent/server"
  38. "wechat-api/ent/sopnode"
  39. "wechat-api/ent/sopstage"
  40. "wechat-api/ent/soptask"
  41. "wechat-api/ent/token"
  42. "wechat-api/ent/tutorial"
  43. "wechat-api/ent/usagedetail"
  44. "wechat-api/ent/usagestatisticday"
  45. "wechat-api/ent/usagestatistichour"
  46. "wechat-api/ent/usagestatisticmonth"
  47. "wechat-api/ent/usagetotal"
  48. "wechat-api/ent/whatsapp"
  49. "wechat-api/ent/whatsappchannel"
  50. "wechat-api/ent/workexperience"
  51. "wechat-api/ent/wpchatroom"
  52. "wechat-api/ent/wpchatroommember"
  53. "wechat-api/ent/wx"
  54. "wechat-api/ent/wxcard"
  55. "wechat-api/ent/wxcarduser"
  56. "wechat-api/ent/wxcardvisit"
  57. "wechat-api/ent/xunji"
  58. "wechat-api/ent/xunjiservice"
  59. "entgo.io/ent"
  60. "entgo.io/ent/dialect/sql"
  61. )
  62. const (
  63. // Operation types.
  64. OpCreate = ent.OpCreate
  65. OpDelete = ent.OpDelete
  66. OpDeleteOne = ent.OpDeleteOne
  67. OpUpdate = ent.OpUpdate
  68. OpUpdateOne = ent.OpUpdateOne
  69. // Node types.
  70. TypeAddWechatFriendLog = "AddWechatFriendLog"
  71. TypeAgent = "Agent"
  72. TypeAgentBase = "AgentBase"
  73. TypeAliyunAvatar = "AliyunAvatar"
  74. TypeAllocAgent = "AllocAgent"
  75. TypeApiKey = "ApiKey"
  76. TypeBatchMsg = "BatchMsg"
  77. TypeCategory = "Category"
  78. TypeChatRecords = "ChatRecords"
  79. TypeChatSession = "ChatSession"
  80. TypeCompapiAsynctask = "CompapiAsynctask"
  81. TypeContact = "Contact"
  82. TypeContactField = "ContactField"
  83. TypeContactFieldTemplate = "ContactFieldTemplate"
  84. TypeCreditBalance = "CreditBalance"
  85. TypeCreditUsage = "CreditUsage"
  86. TypeEmployee = "Employee"
  87. TypeEmployeeConfig = "EmployeeConfig"
  88. TypeLabel = "Label"
  89. TypeLabelLog = "LabelLog"
  90. TypeLabelRelationship = "LabelRelationship"
  91. TypeLabelTagging = "LabelTagging"
  92. TypeMessage = "Message"
  93. TypeMessageRecords = "MessageRecords"
  94. TypeMsg = "Msg"
  95. TypePayRecharge = "PayRecharge"
  96. TypeServer = "Server"
  97. TypeSopNode = "SopNode"
  98. TypeSopStage = "SopStage"
  99. TypeSopTask = "SopTask"
  100. TypeToken = "Token"
  101. TypeTutorial = "Tutorial"
  102. TypeUsageDetail = "UsageDetail"
  103. TypeUsageStatisticDay = "UsageStatisticDay"
  104. TypeUsageStatisticHour = "UsageStatisticHour"
  105. TypeUsageStatisticMonth = "UsageStatisticMonth"
  106. TypeUsageTotal = "UsageTotal"
  107. TypeWhatsapp = "Whatsapp"
  108. TypeWhatsappChannel = "WhatsappChannel"
  109. TypeWorkExperience = "WorkExperience"
  110. TypeWpChatroom = "WpChatroom"
  111. TypeWpChatroomMember = "WpChatroomMember"
  112. TypeWx = "Wx"
  113. TypeWxCard = "WxCard"
  114. TypeWxCardUser = "WxCardUser"
  115. TypeWxCardVisit = "WxCardVisit"
  116. TypeXunji = "Xunji"
  117. TypeXunjiService = "XunjiService"
  118. )
  119. // AddWechatFriendLogMutation represents an operation that mutates the AddWechatFriendLog nodes in the graph.
  120. type AddWechatFriendLogMutation struct {
  121. config
  122. op Op
  123. typ string
  124. id *int64
  125. owner_wx_id *string
  126. owner_wx_type *int
  127. addowner_wx_type *int
  128. find_content *string
  129. message *string
  130. find_request *map[string]interface{}
  131. find_result *map[string]interface{}
  132. is_can_add *int
  133. addis_can_add *int
  134. task_count *int
  135. addtask_count *int
  136. task_id *int64
  137. addtask_id *int64
  138. add_request *map[string]interface{}
  139. add_result *map[string]interface{}
  140. created_at *int64
  141. addcreated_at *int64
  142. updated_at *int64
  143. addupdated_at *int64
  144. clearedFields map[string]struct{}
  145. done bool
  146. oldValue func(context.Context) (*AddWechatFriendLog, error)
  147. predicates []predicate.AddWechatFriendLog
  148. }
  149. var _ ent.Mutation = (*AddWechatFriendLogMutation)(nil)
  150. // addwechatfriendlogOption allows management of the mutation configuration using functional options.
  151. type addwechatfriendlogOption func(*AddWechatFriendLogMutation)
  152. // newAddWechatFriendLogMutation creates new mutation for the AddWechatFriendLog entity.
  153. func newAddWechatFriendLogMutation(c config, op Op, opts ...addwechatfriendlogOption) *AddWechatFriendLogMutation {
  154. m := &AddWechatFriendLogMutation{
  155. config: c,
  156. op: op,
  157. typ: TypeAddWechatFriendLog,
  158. clearedFields: make(map[string]struct{}),
  159. }
  160. for _, opt := range opts {
  161. opt(m)
  162. }
  163. return m
  164. }
  165. // withAddWechatFriendLogID sets the ID field of the mutation.
  166. func withAddWechatFriendLogID(id int64) addwechatfriendlogOption {
  167. return func(m *AddWechatFriendLogMutation) {
  168. var (
  169. err error
  170. once sync.Once
  171. value *AddWechatFriendLog
  172. )
  173. m.oldValue = func(ctx context.Context) (*AddWechatFriendLog, error) {
  174. once.Do(func() {
  175. if m.done {
  176. err = errors.New("querying old values post mutation is not allowed")
  177. } else {
  178. value, err = m.Client().AddWechatFriendLog.Get(ctx, id)
  179. }
  180. })
  181. return value, err
  182. }
  183. m.id = &id
  184. }
  185. }
  186. // withAddWechatFriendLog sets the old AddWechatFriendLog of the mutation.
  187. func withAddWechatFriendLog(node *AddWechatFriendLog) addwechatfriendlogOption {
  188. return func(m *AddWechatFriendLogMutation) {
  189. m.oldValue = func(context.Context) (*AddWechatFriendLog, error) {
  190. return node, nil
  191. }
  192. m.id = &node.ID
  193. }
  194. }
  195. // Client returns a new `ent.Client` from the mutation. If the mutation was
  196. // executed in a transaction (ent.Tx), a transactional client is returned.
  197. func (m AddWechatFriendLogMutation) Client() *Client {
  198. client := &Client{config: m.config}
  199. client.init()
  200. return client
  201. }
  202. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  203. // it returns an error otherwise.
  204. func (m AddWechatFriendLogMutation) Tx() (*Tx, error) {
  205. if _, ok := m.driver.(*txDriver); !ok {
  206. return nil, errors.New("ent: mutation is not running in a transaction")
  207. }
  208. tx := &Tx{config: m.config}
  209. tx.init()
  210. return tx, nil
  211. }
  212. // SetID sets the value of the id field. Note that this
  213. // operation is only accepted on creation of AddWechatFriendLog entities.
  214. func (m *AddWechatFriendLogMutation) SetID(id int64) {
  215. m.id = &id
  216. }
  217. // ID returns the ID value in the mutation. Note that the ID is only available
  218. // if it was provided to the builder or after it was returned from the database.
  219. func (m *AddWechatFriendLogMutation) ID() (id int64, exists bool) {
  220. if m.id == nil {
  221. return
  222. }
  223. return *m.id, true
  224. }
  225. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  226. // That means, if the mutation is applied within a transaction with an isolation level such
  227. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  228. // or updated by the mutation.
  229. func (m *AddWechatFriendLogMutation) IDs(ctx context.Context) ([]int64, error) {
  230. switch {
  231. case m.op.Is(OpUpdateOne | OpDeleteOne):
  232. id, exists := m.ID()
  233. if exists {
  234. return []int64{id}, nil
  235. }
  236. fallthrough
  237. case m.op.Is(OpUpdate | OpDelete):
  238. return m.Client().AddWechatFriendLog.Query().Where(m.predicates...).IDs(ctx)
  239. default:
  240. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  241. }
  242. }
  243. // SetOwnerWxID sets the "owner_wx_id" field.
  244. func (m *AddWechatFriendLogMutation) SetOwnerWxID(s string) {
  245. m.owner_wx_id = &s
  246. }
  247. // OwnerWxID returns the value of the "owner_wx_id" field in the mutation.
  248. func (m *AddWechatFriendLogMutation) OwnerWxID() (r string, exists bool) {
  249. v := m.owner_wx_id
  250. if v == nil {
  251. return
  252. }
  253. return *v, true
  254. }
  255. // OldOwnerWxID returns the old "owner_wx_id" field's value of the AddWechatFriendLog entity.
  256. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  258. func (m *AddWechatFriendLogMutation) OldOwnerWxID(ctx context.Context) (v string, err error) {
  259. if !m.op.Is(OpUpdateOne) {
  260. return v, errors.New("OldOwnerWxID is only allowed on UpdateOne operations")
  261. }
  262. if m.id == nil || m.oldValue == nil {
  263. return v, errors.New("OldOwnerWxID requires an ID field in the mutation")
  264. }
  265. oldValue, err := m.oldValue(ctx)
  266. if err != nil {
  267. return v, fmt.Errorf("querying old value for OldOwnerWxID: %w", err)
  268. }
  269. return oldValue.OwnerWxID, nil
  270. }
  271. // ResetOwnerWxID resets all changes to the "owner_wx_id" field.
  272. func (m *AddWechatFriendLogMutation) ResetOwnerWxID() {
  273. m.owner_wx_id = nil
  274. }
  275. // SetOwnerWxType sets the "owner_wx_type" field.
  276. func (m *AddWechatFriendLogMutation) SetOwnerWxType(i int) {
  277. m.owner_wx_type = &i
  278. m.addowner_wx_type = nil
  279. }
  280. // OwnerWxType returns the value of the "owner_wx_type" field in the mutation.
  281. func (m *AddWechatFriendLogMutation) OwnerWxType() (r int, exists bool) {
  282. v := m.owner_wx_type
  283. if v == nil {
  284. return
  285. }
  286. return *v, true
  287. }
  288. // OldOwnerWxType returns the old "owner_wx_type" field's value of the AddWechatFriendLog entity.
  289. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  291. func (m *AddWechatFriendLogMutation) OldOwnerWxType(ctx context.Context) (v int, err error) {
  292. if !m.op.Is(OpUpdateOne) {
  293. return v, errors.New("OldOwnerWxType is only allowed on UpdateOne operations")
  294. }
  295. if m.id == nil || m.oldValue == nil {
  296. return v, errors.New("OldOwnerWxType requires an ID field in the mutation")
  297. }
  298. oldValue, err := m.oldValue(ctx)
  299. if err != nil {
  300. return v, fmt.Errorf("querying old value for OldOwnerWxType: %w", err)
  301. }
  302. return oldValue.OwnerWxType, nil
  303. }
  304. // AddOwnerWxType adds i to the "owner_wx_type" field.
  305. func (m *AddWechatFriendLogMutation) AddOwnerWxType(i int) {
  306. if m.addowner_wx_type != nil {
  307. *m.addowner_wx_type += i
  308. } else {
  309. m.addowner_wx_type = &i
  310. }
  311. }
  312. // AddedOwnerWxType returns the value that was added to the "owner_wx_type" field in this mutation.
  313. func (m *AddWechatFriendLogMutation) AddedOwnerWxType() (r int, exists bool) {
  314. v := m.addowner_wx_type
  315. if v == nil {
  316. return
  317. }
  318. return *v, true
  319. }
  320. // ResetOwnerWxType resets all changes to the "owner_wx_type" field.
  321. func (m *AddWechatFriendLogMutation) ResetOwnerWxType() {
  322. m.owner_wx_type = nil
  323. m.addowner_wx_type = nil
  324. }
  325. // SetFindContent sets the "find_content" field.
  326. func (m *AddWechatFriendLogMutation) SetFindContent(s string) {
  327. m.find_content = &s
  328. }
  329. // FindContent returns the value of the "find_content" field in the mutation.
  330. func (m *AddWechatFriendLogMutation) FindContent() (r string, exists bool) {
  331. v := m.find_content
  332. if v == nil {
  333. return
  334. }
  335. return *v, true
  336. }
  337. // OldFindContent returns the old "find_content" field's value of the AddWechatFriendLog entity.
  338. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  340. func (m *AddWechatFriendLogMutation) OldFindContent(ctx context.Context) (v string, err error) {
  341. if !m.op.Is(OpUpdateOne) {
  342. return v, errors.New("OldFindContent is only allowed on UpdateOne operations")
  343. }
  344. if m.id == nil || m.oldValue == nil {
  345. return v, errors.New("OldFindContent requires an ID field in the mutation")
  346. }
  347. oldValue, err := m.oldValue(ctx)
  348. if err != nil {
  349. return v, fmt.Errorf("querying old value for OldFindContent: %w", err)
  350. }
  351. return oldValue.FindContent, nil
  352. }
  353. // ResetFindContent resets all changes to the "find_content" field.
  354. func (m *AddWechatFriendLogMutation) ResetFindContent() {
  355. m.find_content = nil
  356. }
  357. // SetMessage sets the "message" field.
  358. func (m *AddWechatFriendLogMutation) SetMessage(s string) {
  359. m.message = &s
  360. }
  361. // Message returns the value of the "message" field in the mutation.
  362. func (m *AddWechatFriendLogMutation) Message() (r string, exists bool) {
  363. v := m.message
  364. if v == nil {
  365. return
  366. }
  367. return *v, true
  368. }
  369. // OldMessage returns the old "message" field's value of the AddWechatFriendLog entity.
  370. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  372. func (m *AddWechatFriendLogMutation) OldMessage(ctx context.Context) (v string, err error) {
  373. if !m.op.Is(OpUpdateOne) {
  374. return v, errors.New("OldMessage is only allowed on UpdateOne operations")
  375. }
  376. if m.id == nil || m.oldValue == nil {
  377. return v, errors.New("OldMessage requires an ID field in the mutation")
  378. }
  379. oldValue, err := m.oldValue(ctx)
  380. if err != nil {
  381. return v, fmt.Errorf("querying old value for OldMessage: %w", err)
  382. }
  383. return oldValue.Message, nil
  384. }
  385. // ResetMessage resets all changes to the "message" field.
  386. func (m *AddWechatFriendLogMutation) ResetMessage() {
  387. m.message = nil
  388. }
  389. // SetFindRequest sets the "find_request" field.
  390. func (m *AddWechatFriendLogMutation) SetFindRequest(value map[string]interface{}) {
  391. m.find_request = &value
  392. }
  393. // FindRequest returns the value of the "find_request" field in the mutation.
  394. func (m *AddWechatFriendLogMutation) FindRequest() (r map[string]interface{}, exists bool) {
  395. v := m.find_request
  396. if v == nil {
  397. return
  398. }
  399. return *v, true
  400. }
  401. // OldFindRequest returns the old "find_request" field's value of the AddWechatFriendLog entity.
  402. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  404. func (m *AddWechatFriendLogMutation) OldFindRequest(ctx context.Context) (v map[string]interface{}, err error) {
  405. if !m.op.Is(OpUpdateOne) {
  406. return v, errors.New("OldFindRequest is only allowed on UpdateOne operations")
  407. }
  408. if m.id == nil || m.oldValue == nil {
  409. return v, errors.New("OldFindRequest requires an ID field in the mutation")
  410. }
  411. oldValue, err := m.oldValue(ctx)
  412. if err != nil {
  413. return v, fmt.Errorf("querying old value for OldFindRequest: %w", err)
  414. }
  415. return oldValue.FindRequest, nil
  416. }
  417. // ClearFindRequest clears the value of the "find_request" field.
  418. func (m *AddWechatFriendLogMutation) ClearFindRequest() {
  419. m.find_request = nil
  420. m.clearedFields[addwechatfriendlog.FieldFindRequest] = struct{}{}
  421. }
  422. // FindRequestCleared returns if the "find_request" field was cleared in this mutation.
  423. func (m *AddWechatFriendLogMutation) FindRequestCleared() bool {
  424. _, ok := m.clearedFields[addwechatfriendlog.FieldFindRequest]
  425. return ok
  426. }
  427. // ResetFindRequest resets all changes to the "find_request" field.
  428. func (m *AddWechatFriendLogMutation) ResetFindRequest() {
  429. m.find_request = nil
  430. delete(m.clearedFields, addwechatfriendlog.FieldFindRequest)
  431. }
  432. // SetFindResult sets the "find_result" field.
  433. func (m *AddWechatFriendLogMutation) SetFindResult(value map[string]interface{}) {
  434. m.find_result = &value
  435. }
  436. // FindResult returns the value of the "find_result" field in the mutation.
  437. func (m *AddWechatFriendLogMutation) FindResult() (r map[string]interface{}, exists bool) {
  438. v := m.find_result
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // OldFindResult returns the old "find_result" field's value of the AddWechatFriendLog entity.
  445. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  447. func (m *AddWechatFriendLogMutation) OldFindResult(ctx context.Context) (v map[string]interface{}, err error) {
  448. if !m.op.Is(OpUpdateOne) {
  449. return v, errors.New("OldFindResult is only allowed on UpdateOne operations")
  450. }
  451. if m.id == nil || m.oldValue == nil {
  452. return v, errors.New("OldFindResult requires an ID field in the mutation")
  453. }
  454. oldValue, err := m.oldValue(ctx)
  455. if err != nil {
  456. return v, fmt.Errorf("querying old value for OldFindResult: %w", err)
  457. }
  458. return oldValue.FindResult, nil
  459. }
  460. // ClearFindResult clears the value of the "find_result" field.
  461. func (m *AddWechatFriendLogMutation) ClearFindResult() {
  462. m.find_result = nil
  463. m.clearedFields[addwechatfriendlog.FieldFindResult] = struct{}{}
  464. }
  465. // FindResultCleared returns if the "find_result" field was cleared in this mutation.
  466. func (m *AddWechatFriendLogMutation) FindResultCleared() bool {
  467. _, ok := m.clearedFields[addwechatfriendlog.FieldFindResult]
  468. return ok
  469. }
  470. // ResetFindResult resets all changes to the "find_result" field.
  471. func (m *AddWechatFriendLogMutation) ResetFindResult() {
  472. m.find_result = nil
  473. delete(m.clearedFields, addwechatfriendlog.FieldFindResult)
  474. }
  475. // SetIsCanAdd sets the "is_can_add" field.
  476. func (m *AddWechatFriendLogMutation) SetIsCanAdd(i int) {
  477. m.is_can_add = &i
  478. m.addis_can_add = nil
  479. }
  480. // IsCanAdd returns the value of the "is_can_add" field in the mutation.
  481. func (m *AddWechatFriendLogMutation) IsCanAdd() (r int, exists bool) {
  482. v := m.is_can_add
  483. if v == nil {
  484. return
  485. }
  486. return *v, true
  487. }
  488. // OldIsCanAdd returns the old "is_can_add" field's value of the AddWechatFriendLog entity.
  489. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  491. func (m *AddWechatFriendLogMutation) OldIsCanAdd(ctx context.Context) (v int, err error) {
  492. if !m.op.Is(OpUpdateOne) {
  493. return v, errors.New("OldIsCanAdd is only allowed on UpdateOne operations")
  494. }
  495. if m.id == nil || m.oldValue == nil {
  496. return v, errors.New("OldIsCanAdd requires an ID field in the mutation")
  497. }
  498. oldValue, err := m.oldValue(ctx)
  499. if err != nil {
  500. return v, fmt.Errorf("querying old value for OldIsCanAdd: %w", err)
  501. }
  502. return oldValue.IsCanAdd, nil
  503. }
  504. // AddIsCanAdd adds i to the "is_can_add" field.
  505. func (m *AddWechatFriendLogMutation) AddIsCanAdd(i int) {
  506. if m.addis_can_add != nil {
  507. *m.addis_can_add += i
  508. } else {
  509. m.addis_can_add = &i
  510. }
  511. }
  512. // AddedIsCanAdd returns the value that was added to the "is_can_add" field in this mutation.
  513. func (m *AddWechatFriendLogMutation) AddedIsCanAdd() (r int, exists bool) {
  514. v := m.addis_can_add
  515. if v == nil {
  516. return
  517. }
  518. return *v, true
  519. }
  520. // ResetIsCanAdd resets all changes to the "is_can_add" field.
  521. func (m *AddWechatFriendLogMutation) ResetIsCanAdd() {
  522. m.is_can_add = nil
  523. m.addis_can_add = nil
  524. }
  525. // SetTaskCount sets the "task_count" field.
  526. func (m *AddWechatFriendLogMutation) SetTaskCount(i int) {
  527. m.task_count = &i
  528. m.addtask_count = nil
  529. }
  530. // TaskCount returns the value of the "task_count" field in the mutation.
  531. func (m *AddWechatFriendLogMutation) TaskCount() (r int, exists bool) {
  532. v := m.task_count
  533. if v == nil {
  534. return
  535. }
  536. return *v, true
  537. }
  538. // OldTaskCount returns the old "task_count" field's value of the AddWechatFriendLog entity.
  539. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  541. func (m *AddWechatFriendLogMutation) OldTaskCount(ctx context.Context) (v int, err error) {
  542. if !m.op.Is(OpUpdateOne) {
  543. return v, errors.New("OldTaskCount is only allowed on UpdateOne operations")
  544. }
  545. if m.id == nil || m.oldValue == nil {
  546. return v, errors.New("OldTaskCount requires an ID field in the mutation")
  547. }
  548. oldValue, err := m.oldValue(ctx)
  549. if err != nil {
  550. return v, fmt.Errorf("querying old value for OldTaskCount: %w", err)
  551. }
  552. return oldValue.TaskCount, nil
  553. }
  554. // AddTaskCount adds i to the "task_count" field.
  555. func (m *AddWechatFriendLogMutation) AddTaskCount(i int) {
  556. if m.addtask_count != nil {
  557. *m.addtask_count += i
  558. } else {
  559. m.addtask_count = &i
  560. }
  561. }
  562. // AddedTaskCount returns the value that was added to the "task_count" field in this mutation.
  563. func (m *AddWechatFriendLogMutation) AddedTaskCount() (r int, exists bool) {
  564. v := m.addtask_count
  565. if v == nil {
  566. return
  567. }
  568. return *v, true
  569. }
  570. // ResetTaskCount resets all changes to the "task_count" field.
  571. func (m *AddWechatFriendLogMutation) ResetTaskCount() {
  572. m.task_count = nil
  573. m.addtask_count = nil
  574. }
  575. // SetTaskID sets the "task_id" field.
  576. func (m *AddWechatFriendLogMutation) SetTaskID(i int64) {
  577. m.task_id = &i
  578. m.addtask_id = nil
  579. }
  580. // TaskID returns the value of the "task_id" field in the mutation.
  581. func (m *AddWechatFriendLogMutation) TaskID() (r int64, exists bool) {
  582. v := m.task_id
  583. if v == nil {
  584. return
  585. }
  586. return *v, true
  587. }
  588. // OldTaskID returns the old "task_id" field's value of the AddWechatFriendLog entity.
  589. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  591. func (m *AddWechatFriendLogMutation) OldTaskID(ctx context.Context) (v int64, err error) {
  592. if !m.op.Is(OpUpdateOne) {
  593. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  594. }
  595. if m.id == nil || m.oldValue == nil {
  596. return v, errors.New("OldTaskID requires an ID field in the mutation")
  597. }
  598. oldValue, err := m.oldValue(ctx)
  599. if err != nil {
  600. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  601. }
  602. return oldValue.TaskID, nil
  603. }
  604. // AddTaskID adds i to the "task_id" field.
  605. func (m *AddWechatFriendLogMutation) AddTaskID(i int64) {
  606. if m.addtask_id != nil {
  607. *m.addtask_id += i
  608. } else {
  609. m.addtask_id = &i
  610. }
  611. }
  612. // AddedTaskID returns the value that was added to the "task_id" field in this mutation.
  613. func (m *AddWechatFriendLogMutation) AddedTaskID() (r int64, exists bool) {
  614. v := m.addtask_id
  615. if v == nil {
  616. return
  617. }
  618. return *v, true
  619. }
  620. // ResetTaskID resets all changes to the "task_id" field.
  621. func (m *AddWechatFriendLogMutation) ResetTaskID() {
  622. m.task_id = nil
  623. m.addtask_id = nil
  624. }
  625. // SetAddRequest sets the "add_request" field.
  626. func (m *AddWechatFriendLogMutation) SetAddRequest(value map[string]interface{}) {
  627. m.add_request = &value
  628. }
  629. // AddRequest returns the value of the "add_request" field in the mutation.
  630. func (m *AddWechatFriendLogMutation) AddRequest() (r map[string]interface{}, exists bool) {
  631. v := m.add_request
  632. if v == nil {
  633. return
  634. }
  635. return *v, true
  636. }
  637. // OldAddRequest returns the old "add_request" field's value of the AddWechatFriendLog entity.
  638. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  640. func (m *AddWechatFriendLogMutation) OldAddRequest(ctx context.Context) (v map[string]interface{}, err error) {
  641. if !m.op.Is(OpUpdateOne) {
  642. return v, errors.New("OldAddRequest is only allowed on UpdateOne operations")
  643. }
  644. if m.id == nil || m.oldValue == nil {
  645. return v, errors.New("OldAddRequest requires an ID field in the mutation")
  646. }
  647. oldValue, err := m.oldValue(ctx)
  648. if err != nil {
  649. return v, fmt.Errorf("querying old value for OldAddRequest: %w", err)
  650. }
  651. return oldValue.AddRequest, nil
  652. }
  653. // ClearAddRequest clears the value of the "add_request" field.
  654. func (m *AddWechatFriendLogMutation) ClearAddRequest() {
  655. m.add_request = nil
  656. m.clearedFields[addwechatfriendlog.FieldAddRequest] = struct{}{}
  657. }
  658. // AddRequestCleared returns if the "add_request" field was cleared in this mutation.
  659. func (m *AddWechatFriendLogMutation) AddRequestCleared() bool {
  660. _, ok := m.clearedFields[addwechatfriendlog.FieldAddRequest]
  661. return ok
  662. }
  663. // ResetAddRequest resets all changes to the "add_request" field.
  664. func (m *AddWechatFriendLogMutation) ResetAddRequest() {
  665. m.add_request = nil
  666. delete(m.clearedFields, addwechatfriendlog.FieldAddRequest)
  667. }
  668. // SetAddResult sets the "add_result" field.
  669. func (m *AddWechatFriendLogMutation) SetAddResult(value map[string]interface{}) {
  670. m.add_result = &value
  671. }
  672. // AddResult returns the value of the "add_result" field in the mutation.
  673. func (m *AddWechatFriendLogMutation) AddResult() (r map[string]interface{}, exists bool) {
  674. v := m.add_result
  675. if v == nil {
  676. return
  677. }
  678. return *v, true
  679. }
  680. // OldAddResult returns the old "add_result" field's value of the AddWechatFriendLog entity.
  681. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  683. func (m *AddWechatFriendLogMutation) OldAddResult(ctx context.Context) (v map[string]interface{}, err error) {
  684. if !m.op.Is(OpUpdateOne) {
  685. return v, errors.New("OldAddResult is only allowed on UpdateOne operations")
  686. }
  687. if m.id == nil || m.oldValue == nil {
  688. return v, errors.New("OldAddResult requires an ID field in the mutation")
  689. }
  690. oldValue, err := m.oldValue(ctx)
  691. if err != nil {
  692. return v, fmt.Errorf("querying old value for OldAddResult: %w", err)
  693. }
  694. return oldValue.AddResult, nil
  695. }
  696. // ClearAddResult clears the value of the "add_result" field.
  697. func (m *AddWechatFriendLogMutation) ClearAddResult() {
  698. m.add_result = nil
  699. m.clearedFields[addwechatfriendlog.FieldAddResult] = struct{}{}
  700. }
  701. // AddResultCleared returns if the "add_result" field was cleared in this mutation.
  702. func (m *AddWechatFriendLogMutation) AddResultCleared() bool {
  703. _, ok := m.clearedFields[addwechatfriendlog.FieldAddResult]
  704. return ok
  705. }
  706. // ResetAddResult resets all changes to the "add_result" field.
  707. func (m *AddWechatFriendLogMutation) ResetAddResult() {
  708. m.add_result = nil
  709. delete(m.clearedFields, addwechatfriendlog.FieldAddResult)
  710. }
  711. // SetCreatedAt sets the "created_at" field.
  712. func (m *AddWechatFriendLogMutation) SetCreatedAt(i int64) {
  713. m.created_at = &i
  714. m.addcreated_at = nil
  715. }
  716. // CreatedAt returns the value of the "created_at" field in the mutation.
  717. func (m *AddWechatFriendLogMutation) CreatedAt() (r int64, exists bool) {
  718. v := m.created_at
  719. if v == nil {
  720. return
  721. }
  722. return *v, true
  723. }
  724. // OldCreatedAt returns the old "created_at" field's value of the AddWechatFriendLog entity.
  725. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  727. func (m *AddWechatFriendLogMutation) OldCreatedAt(ctx context.Context) (v int64, err error) {
  728. if !m.op.Is(OpUpdateOne) {
  729. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  730. }
  731. if m.id == nil || m.oldValue == nil {
  732. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  733. }
  734. oldValue, err := m.oldValue(ctx)
  735. if err != nil {
  736. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  737. }
  738. return oldValue.CreatedAt, nil
  739. }
  740. // AddCreatedAt adds i to the "created_at" field.
  741. func (m *AddWechatFriendLogMutation) AddCreatedAt(i int64) {
  742. if m.addcreated_at != nil {
  743. *m.addcreated_at += i
  744. } else {
  745. m.addcreated_at = &i
  746. }
  747. }
  748. // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation.
  749. func (m *AddWechatFriendLogMutation) AddedCreatedAt() (r int64, exists bool) {
  750. v := m.addcreated_at
  751. if v == nil {
  752. return
  753. }
  754. return *v, true
  755. }
  756. // ResetCreatedAt resets all changes to the "created_at" field.
  757. func (m *AddWechatFriendLogMutation) ResetCreatedAt() {
  758. m.created_at = nil
  759. m.addcreated_at = nil
  760. }
  761. // SetUpdatedAt sets the "updated_at" field.
  762. func (m *AddWechatFriendLogMutation) SetUpdatedAt(i int64) {
  763. m.updated_at = &i
  764. m.addupdated_at = nil
  765. }
  766. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  767. func (m *AddWechatFriendLogMutation) UpdatedAt() (r int64, exists bool) {
  768. v := m.updated_at
  769. if v == nil {
  770. return
  771. }
  772. return *v, true
  773. }
  774. // OldUpdatedAt returns the old "updated_at" field's value of the AddWechatFriendLog entity.
  775. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  777. func (m *AddWechatFriendLogMutation) OldUpdatedAt(ctx context.Context) (v int64, err error) {
  778. if !m.op.Is(OpUpdateOne) {
  779. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  780. }
  781. if m.id == nil || m.oldValue == nil {
  782. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  783. }
  784. oldValue, err := m.oldValue(ctx)
  785. if err != nil {
  786. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  787. }
  788. return oldValue.UpdatedAt, nil
  789. }
  790. // AddUpdatedAt adds i to the "updated_at" field.
  791. func (m *AddWechatFriendLogMutation) AddUpdatedAt(i int64) {
  792. if m.addupdated_at != nil {
  793. *m.addupdated_at += i
  794. } else {
  795. m.addupdated_at = &i
  796. }
  797. }
  798. // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation.
  799. func (m *AddWechatFriendLogMutation) AddedUpdatedAt() (r int64, exists bool) {
  800. v := m.addupdated_at
  801. if v == nil {
  802. return
  803. }
  804. return *v, true
  805. }
  806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  807. func (m *AddWechatFriendLogMutation) ResetUpdatedAt() {
  808. m.updated_at = nil
  809. m.addupdated_at = nil
  810. }
  811. // Where appends a list predicates to the AddWechatFriendLogMutation builder.
  812. func (m *AddWechatFriendLogMutation) Where(ps ...predicate.AddWechatFriendLog) {
  813. m.predicates = append(m.predicates, ps...)
  814. }
  815. // WhereP appends storage-level predicates to the AddWechatFriendLogMutation builder. Using this method,
  816. // users can use type-assertion to append predicates that do not depend on any generated package.
  817. func (m *AddWechatFriendLogMutation) WhereP(ps ...func(*sql.Selector)) {
  818. p := make([]predicate.AddWechatFriendLog, len(ps))
  819. for i := range ps {
  820. p[i] = ps[i]
  821. }
  822. m.Where(p...)
  823. }
  824. // Op returns the operation name.
  825. func (m *AddWechatFriendLogMutation) Op() Op {
  826. return m.op
  827. }
  828. // SetOp allows setting the mutation operation.
  829. func (m *AddWechatFriendLogMutation) SetOp(op Op) {
  830. m.op = op
  831. }
  832. // Type returns the node type of this mutation (AddWechatFriendLog).
  833. func (m *AddWechatFriendLogMutation) Type() string {
  834. return m.typ
  835. }
  836. // Fields returns all fields that were changed during this mutation. Note that in
  837. // order to get all numeric fields that were incremented/decremented, call
  838. // AddedFields().
  839. func (m *AddWechatFriendLogMutation) Fields() []string {
  840. fields := make([]string, 0, 13)
  841. if m.owner_wx_id != nil {
  842. fields = append(fields, addwechatfriendlog.FieldOwnerWxID)
  843. }
  844. if m.owner_wx_type != nil {
  845. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  846. }
  847. if m.find_content != nil {
  848. fields = append(fields, addwechatfriendlog.FieldFindContent)
  849. }
  850. if m.message != nil {
  851. fields = append(fields, addwechatfriendlog.FieldMessage)
  852. }
  853. if m.find_request != nil {
  854. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  855. }
  856. if m.find_result != nil {
  857. fields = append(fields, addwechatfriendlog.FieldFindResult)
  858. }
  859. if m.is_can_add != nil {
  860. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  861. }
  862. if m.task_count != nil {
  863. fields = append(fields, addwechatfriendlog.FieldTaskCount)
  864. }
  865. if m.task_id != nil {
  866. fields = append(fields, addwechatfriendlog.FieldTaskID)
  867. }
  868. if m.add_request != nil {
  869. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  870. }
  871. if m.add_result != nil {
  872. fields = append(fields, addwechatfriendlog.FieldAddResult)
  873. }
  874. if m.created_at != nil {
  875. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  876. }
  877. if m.updated_at != nil {
  878. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  879. }
  880. return fields
  881. }
  882. // Field returns the value of a field with the given name. The second boolean
  883. // return value indicates that this field was not set, or was not defined in the
  884. // schema.
  885. func (m *AddWechatFriendLogMutation) Field(name string) (ent.Value, bool) {
  886. switch name {
  887. case addwechatfriendlog.FieldOwnerWxID:
  888. return m.OwnerWxID()
  889. case addwechatfriendlog.FieldOwnerWxType:
  890. return m.OwnerWxType()
  891. case addwechatfriendlog.FieldFindContent:
  892. return m.FindContent()
  893. case addwechatfriendlog.FieldMessage:
  894. return m.Message()
  895. case addwechatfriendlog.FieldFindRequest:
  896. return m.FindRequest()
  897. case addwechatfriendlog.FieldFindResult:
  898. return m.FindResult()
  899. case addwechatfriendlog.FieldIsCanAdd:
  900. return m.IsCanAdd()
  901. case addwechatfriendlog.FieldTaskCount:
  902. return m.TaskCount()
  903. case addwechatfriendlog.FieldTaskID:
  904. return m.TaskID()
  905. case addwechatfriendlog.FieldAddRequest:
  906. return m.AddRequest()
  907. case addwechatfriendlog.FieldAddResult:
  908. return m.AddResult()
  909. case addwechatfriendlog.FieldCreatedAt:
  910. return m.CreatedAt()
  911. case addwechatfriendlog.FieldUpdatedAt:
  912. return m.UpdatedAt()
  913. }
  914. return nil, false
  915. }
  916. // OldField returns the old value of the field from the database. An error is
  917. // returned if the mutation operation is not UpdateOne, or the query to the
  918. // database failed.
  919. func (m *AddWechatFriendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  920. switch name {
  921. case addwechatfriendlog.FieldOwnerWxID:
  922. return m.OldOwnerWxID(ctx)
  923. case addwechatfriendlog.FieldOwnerWxType:
  924. return m.OldOwnerWxType(ctx)
  925. case addwechatfriendlog.FieldFindContent:
  926. return m.OldFindContent(ctx)
  927. case addwechatfriendlog.FieldMessage:
  928. return m.OldMessage(ctx)
  929. case addwechatfriendlog.FieldFindRequest:
  930. return m.OldFindRequest(ctx)
  931. case addwechatfriendlog.FieldFindResult:
  932. return m.OldFindResult(ctx)
  933. case addwechatfriendlog.FieldIsCanAdd:
  934. return m.OldIsCanAdd(ctx)
  935. case addwechatfriendlog.FieldTaskCount:
  936. return m.OldTaskCount(ctx)
  937. case addwechatfriendlog.FieldTaskID:
  938. return m.OldTaskID(ctx)
  939. case addwechatfriendlog.FieldAddRequest:
  940. return m.OldAddRequest(ctx)
  941. case addwechatfriendlog.FieldAddResult:
  942. return m.OldAddResult(ctx)
  943. case addwechatfriendlog.FieldCreatedAt:
  944. return m.OldCreatedAt(ctx)
  945. case addwechatfriendlog.FieldUpdatedAt:
  946. return m.OldUpdatedAt(ctx)
  947. }
  948. return nil, fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  949. }
  950. // SetField sets the value of a field with the given name. It returns an error if
  951. // the field is not defined in the schema, or if the type mismatched the field
  952. // type.
  953. func (m *AddWechatFriendLogMutation) SetField(name string, value ent.Value) error {
  954. switch name {
  955. case addwechatfriendlog.FieldOwnerWxID:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetOwnerWxID(v)
  961. return nil
  962. case addwechatfriendlog.FieldOwnerWxType:
  963. v, ok := value.(int)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetOwnerWxType(v)
  968. return nil
  969. case addwechatfriendlog.FieldFindContent:
  970. v, ok := value.(string)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetFindContent(v)
  975. return nil
  976. case addwechatfriendlog.FieldMessage:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetMessage(v)
  982. return nil
  983. case addwechatfriendlog.FieldFindRequest:
  984. v, ok := value.(map[string]interface{})
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetFindRequest(v)
  989. return nil
  990. case addwechatfriendlog.FieldFindResult:
  991. v, ok := value.(map[string]interface{})
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetFindResult(v)
  996. return nil
  997. case addwechatfriendlog.FieldIsCanAdd:
  998. v, ok := value.(int)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetIsCanAdd(v)
  1003. return nil
  1004. case addwechatfriendlog.FieldTaskCount:
  1005. v, ok := value.(int)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetTaskCount(v)
  1010. return nil
  1011. case addwechatfriendlog.FieldTaskID:
  1012. v, ok := value.(int64)
  1013. if !ok {
  1014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1015. }
  1016. m.SetTaskID(v)
  1017. return nil
  1018. case addwechatfriendlog.FieldAddRequest:
  1019. v, ok := value.(map[string]interface{})
  1020. if !ok {
  1021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1022. }
  1023. m.SetAddRequest(v)
  1024. return nil
  1025. case addwechatfriendlog.FieldAddResult:
  1026. v, ok := value.(map[string]interface{})
  1027. if !ok {
  1028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1029. }
  1030. m.SetAddResult(v)
  1031. return nil
  1032. case addwechatfriendlog.FieldCreatedAt:
  1033. v, ok := value.(int64)
  1034. if !ok {
  1035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1036. }
  1037. m.SetCreatedAt(v)
  1038. return nil
  1039. case addwechatfriendlog.FieldUpdatedAt:
  1040. v, ok := value.(int64)
  1041. if !ok {
  1042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1043. }
  1044. m.SetUpdatedAt(v)
  1045. return nil
  1046. }
  1047. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1048. }
  1049. // AddedFields returns all numeric fields that were incremented/decremented during
  1050. // this mutation.
  1051. func (m *AddWechatFriendLogMutation) AddedFields() []string {
  1052. var fields []string
  1053. if m.addowner_wx_type != nil {
  1054. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  1055. }
  1056. if m.addis_can_add != nil {
  1057. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  1058. }
  1059. if m.addtask_count != nil {
  1060. fields = append(fields, addwechatfriendlog.FieldTaskCount)
  1061. }
  1062. if m.addtask_id != nil {
  1063. fields = append(fields, addwechatfriendlog.FieldTaskID)
  1064. }
  1065. if m.addcreated_at != nil {
  1066. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  1067. }
  1068. if m.addupdated_at != nil {
  1069. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  1070. }
  1071. return fields
  1072. }
  1073. // AddedField returns the numeric value that was incremented/decremented on a field
  1074. // with the given name. The second boolean return value indicates that this field
  1075. // was not set, or was not defined in the schema.
  1076. func (m *AddWechatFriendLogMutation) AddedField(name string) (ent.Value, bool) {
  1077. switch name {
  1078. case addwechatfriendlog.FieldOwnerWxType:
  1079. return m.AddedOwnerWxType()
  1080. case addwechatfriendlog.FieldIsCanAdd:
  1081. return m.AddedIsCanAdd()
  1082. case addwechatfriendlog.FieldTaskCount:
  1083. return m.AddedTaskCount()
  1084. case addwechatfriendlog.FieldTaskID:
  1085. return m.AddedTaskID()
  1086. case addwechatfriendlog.FieldCreatedAt:
  1087. return m.AddedCreatedAt()
  1088. case addwechatfriendlog.FieldUpdatedAt:
  1089. return m.AddedUpdatedAt()
  1090. }
  1091. return nil, false
  1092. }
  1093. // AddField adds the value to the field with the given name. It returns an error if
  1094. // the field is not defined in the schema, or if the type mismatched the field
  1095. // type.
  1096. func (m *AddWechatFriendLogMutation) AddField(name string, value ent.Value) error {
  1097. switch name {
  1098. case addwechatfriendlog.FieldOwnerWxType:
  1099. v, ok := value.(int)
  1100. if !ok {
  1101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1102. }
  1103. m.AddOwnerWxType(v)
  1104. return nil
  1105. case addwechatfriendlog.FieldIsCanAdd:
  1106. v, ok := value.(int)
  1107. if !ok {
  1108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1109. }
  1110. m.AddIsCanAdd(v)
  1111. return nil
  1112. case addwechatfriendlog.FieldTaskCount:
  1113. v, ok := value.(int)
  1114. if !ok {
  1115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1116. }
  1117. m.AddTaskCount(v)
  1118. return nil
  1119. case addwechatfriendlog.FieldTaskID:
  1120. v, ok := value.(int64)
  1121. if !ok {
  1122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1123. }
  1124. m.AddTaskID(v)
  1125. return nil
  1126. case addwechatfriendlog.FieldCreatedAt:
  1127. v, ok := value.(int64)
  1128. if !ok {
  1129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1130. }
  1131. m.AddCreatedAt(v)
  1132. return nil
  1133. case addwechatfriendlog.FieldUpdatedAt:
  1134. v, ok := value.(int64)
  1135. if !ok {
  1136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1137. }
  1138. m.AddUpdatedAt(v)
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown AddWechatFriendLog numeric field %s", name)
  1142. }
  1143. // ClearedFields returns all nullable fields that were cleared during this
  1144. // mutation.
  1145. func (m *AddWechatFriendLogMutation) ClearedFields() []string {
  1146. var fields []string
  1147. if m.FieldCleared(addwechatfriendlog.FieldFindRequest) {
  1148. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  1149. }
  1150. if m.FieldCleared(addwechatfriendlog.FieldFindResult) {
  1151. fields = append(fields, addwechatfriendlog.FieldFindResult)
  1152. }
  1153. if m.FieldCleared(addwechatfriendlog.FieldAddRequest) {
  1154. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  1155. }
  1156. if m.FieldCleared(addwechatfriendlog.FieldAddResult) {
  1157. fields = append(fields, addwechatfriendlog.FieldAddResult)
  1158. }
  1159. return fields
  1160. }
  1161. // FieldCleared returns a boolean indicating if a field with the given name was
  1162. // cleared in this mutation.
  1163. func (m *AddWechatFriendLogMutation) FieldCleared(name string) bool {
  1164. _, ok := m.clearedFields[name]
  1165. return ok
  1166. }
  1167. // ClearField clears the value of the field with the given name. It returns an
  1168. // error if the field is not defined in the schema.
  1169. func (m *AddWechatFriendLogMutation) ClearField(name string) error {
  1170. switch name {
  1171. case addwechatfriendlog.FieldFindRequest:
  1172. m.ClearFindRequest()
  1173. return nil
  1174. case addwechatfriendlog.FieldFindResult:
  1175. m.ClearFindResult()
  1176. return nil
  1177. case addwechatfriendlog.FieldAddRequest:
  1178. m.ClearAddRequest()
  1179. return nil
  1180. case addwechatfriendlog.FieldAddResult:
  1181. m.ClearAddResult()
  1182. return nil
  1183. }
  1184. return fmt.Errorf("unknown AddWechatFriendLog nullable field %s", name)
  1185. }
  1186. // ResetField resets all changes in the mutation for the field with the given name.
  1187. // It returns an error if the field is not defined in the schema.
  1188. func (m *AddWechatFriendLogMutation) ResetField(name string) error {
  1189. switch name {
  1190. case addwechatfriendlog.FieldOwnerWxID:
  1191. m.ResetOwnerWxID()
  1192. return nil
  1193. case addwechatfriendlog.FieldOwnerWxType:
  1194. m.ResetOwnerWxType()
  1195. return nil
  1196. case addwechatfriendlog.FieldFindContent:
  1197. m.ResetFindContent()
  1198. return nil
  1199. case addwechatfriendlog.FieldMessage:
  1200. m.ResetMessage()
  1201. return nil
  1202. case addwechatfriendlog.FieldFindRequest:
  1203. m.ResetFindRequest()
  1204. return nil
  1205. case addwechatfriendlog.FieldFindResult:
  1206. m.ResetFindResult()
  1207. return nil
  1208. case addwechatfriendlog.FieldIsCanAdd:
  1209. m.ResetIsCanAdd()
  1210. return nil
  1211. case addwechatfriendlog.FieldTaskCount:
  1212. m.ResetTaskCount()
  1213. return nil
  1214. case addwechatfriendlog.FieldTaskID:
  1215. m.ResetTaskID()
  1216. return nil
  1217. case addwechatfriendlog.FieldAddRequest:
  1218. m.ResetAddRequest()
  1219. return nil
  1220. case addwechatfriendlog.FieldAddResult:
  1221. m.ResetAddResult()
  1222. return nil
  1223. case addwechatfriendlog.FieldCreatedAt:
  1224. m.ResetCreatedAt()
  1225. return nil
  1226. case addwechatfriendlog.FieldUpdatedAt:
  1227. m.ResetUpdatedAt()
  1228. return nil
  1229. }
  1230. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1231. }
  1232. // AddedEdges returns all edge names that were set/added in this mutation.
  1233. func (m *AddWechatFriendLogMutation) AddedEdges() []string {
  1234. edges := make([]string, 0, 0)
  1235. return edges
  1236. }
  1237. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1238. // name in this mutation.
  1239. func (m *AddWechatFriendLogMutation) AddedIDs(name string) []ent.Value {
  1240. return nil
  1241. }
  1242. // RemovedEdges returns all edge names that were removed in this mutation.
  1243. func (m *AddWechatFriendLogMutation) RemovedEdges() []string {
  1244. edges := make([]string, 0, 0)
  1245. return edges
  1246. }
  1247. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1248. // the given name in this mutation.
  1249. func (m *AddWechatFriendLogMutation) RemovedIDs(name string) []ent.Value {
  1250. return nil
  1251. }
  1252. // ClearedEdges returns all edge names that were cleared in this mutation.
  1253. func (m *AddWechatFriendLogMutation) ClearedEdges() []string {
  1254. edges := make([]string, 0, 0)
  1255. return edges
  1256. }
  1257. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1258. // was cleared in this mutation.
  1259. func (m *AddWechatFriendLogMutation) EdgeCleared(name string) bool {
  1260. return false
  1261. }
  1262. // ClearEdge clears the value of the edge with the given name. It returns an error
  1263. // if that edge is not defined in the schema.
  1264. func (m *AddWechatFriendLogMutation) ClearEdge(name string) error {
  1265. return fmt.Errorf("unknown AddWechatFriendLog unique edge %s", name)
  1266. }
  1267. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1268. // It returns an error if the edge is not defined in the schema.
  1269. func (m *AddWechatFriendLogMutation) ResetEdge(name string) error {
  1270. return fmt.Errorf("unknown AddWechatFriendLog edge %s", name)
  1271. }
  1272. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  1273. type AgentMutation struct {
  1274. config
  1275. op Op
  1276. typ string
  1277. id *uint64
  1278. created_at *time.Time
  1279. updated_at *time.Time
  1280. deleted_at *time.Time
  1281. name *string
  1282. role *string
  1283. status *int
  1284. addstatus *int
  1285. background *string
  1286. examples *string
  1287. organization_id *uint64
  1288. addorganization_id *int64
  1289. dataset_id *string
  1290. collection_id *string
  1291. model *string
  1292. api_base *string
  1293. api_key *string
  1294. _type *int
  1295. add_type *int
  1296. clearedFields map[string]struct{}
  1297. wx_agent map[uint64]struct{}
  1298. removedwx_agent map[uint64]struct{}
  1299. clearedwx_agent bool
  1300. token_agent map[uint64]struct{}
  1301. removedtoken_agent map[uint64]struct{}
  1302. clearedtoken_agent bool
  1303. wa_agent map[uint64]struct{}
  1304. removedwa_agent map[uint64]struct{}
  1305. clearedwa_agent bool
  1306. xjs_agent map[uint64]struct{}
  1307. removedxjs_agent map[uint64]struct{}
  1308. clearedxjs_agent bool
  1309. key_agent map[uint64]struct{}
  1310. removedkey_agent map[uint64]struct{}
  1311. clearedkey_agent bool
  1312. done bool
  1313. oldValue func(context.Context) (*Agent, error)
  1314. predicates []predicate.Agent
  1315. }
  1316. var _ ent.Mutation = (*AgentMutation)(nil)
  1317. // agentOption allows management of the mutation configuration using functional options.
  1318. type agentOption func(*AgentMutation)
  1319. // newAgentMutation creates new mutation for the Agent entity.
  1320. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  1321. m := &AgentMutation{
  1322. config: c,
  1323. op: op,
  1324. typ: TypeAgent,
  1325. clearedFields: make(map[string]struct{}),
  1326. }
  1327. for _, opt := range opts {
  1328. opt(m)
  1329. }
  1330. return m
  1331. }
  1332. // withAgentID sets the ID field of the mutation.
  1333. func withAgentID(id uint64) agentOption {
  1334. return func(m *AgentMutation) {
  1335. var (
  1336. err error
  1337. once sync.Once
  1338. value *Agent
  1339. )
  1340. m.oldValue = func(ctx context.Context) (*Agent, error) {
  1341. once.Do(func() {
  1342. if m.done {
  1343. err = errors.New("querying old values post mutation is not allowed")
  1344. } else {
  1345. value, err = m.Client().Agent.Get(ctx, id)
  1346. }
  1347. })
  1348. return value, err
  1349. }
  1350. m.id = &id
  1351. }
  1352. }
  1353. // withAgent sets the old Agent of the mutation.
  1354. func withAgent(node *Agent) agentOption {
  1355. return func(m *AgentMutation) {
  1356. m.oldValue = func(context.Context) (*Agent, error) {
  1357. return node, nil
  1358. }
  1359. m.id = &node.ID
  1360. }
  1361. }
  1362. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1363. // executed in a transaction (ent.Tx), a transactional client is returned.
  1364. func (m AgentMutation) Client() *Client {
  1365. client := &Client{config: m.config}
  1366. client.init()
  1367. return client
  1368. }
  1369. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1370. // it returns an error otherwise.
  1371. func (m AgentMutation) Tx() (*Tx, error) {
  1372. if _, ok := m.driver.(*txDriver); !ok {
  1373. return nil, errors.New("ent: mutation is not running in a transaction")
  1374. }
  1375. tx := &Tx{config: m.config}
  1376. tx.init()
  1377. return tx, nil
  1378. }
  1379. // SetID sets the value of the id field. Note that this
  1380. // operation is only accepted on creation of Agent entities.
  1381. func (m *AgentMutation) SetID(id uint64) {
  1382. m.id = &id
  1383. }
  1384. // ID returns the ID value in the mutation. Note that the ID is only available
  1385. // if it was provided to the builder or after it was returned from the database.
  1386. func (m *AgentMutation) ID() (id uint64, exists bool) {
  1387. if m.id == nil {
  1388. return
  1389. }
  1390. return *m.id, true
  1391. }
  1392. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1393. // That means, if the mutation is applied within a transaction with an isolation level such
  1394. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1395. // or updated by the mutation.
  1396. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  1397. switch {
  1398. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1399. id, exists := m.ID()
  1400. if exists {
  1401. return []uint64{id}, nil
  1402. }
  1403. fallthrough
  1404. case m.op.Is(OpUpdate | OpDelete):
  1405. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  1406. default:
  1407. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1408. }
  1409. }
  1410. // SetCreatedAt sets the "created_at" field.
  1411. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  1412. m.created_at = &t
  1413. }
  1414. // CreatedAt returns the value of the "created_at" field in the mutation.
  1415. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  1416. v := m.created_at
  1417. if v == nil {
  1418. return
  1419. }
  1420. return *v, true
  1421. }
  1422. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  1423. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1425. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1426. if !m.op.Is(OpUpdateOne) {
  1427. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1428. }
  1429. if m.id == nil || m.oldValue == nil {
  1430. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1431. }
  1432. oldValue, err := m.oldValue(ctx)
  1433. if err != nil {
  1434. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1435. }
  1436. return oldValue.CreatedAt, nil
  1437. }
  1438. // ResetCreatedAt resets all changes to the "created_at" field.
  1439. func (m *AgentMutation) ResetCreatedAt() {
  1440. m.created_at = nil
  1441. }
  1442. // SetUpdatedAt sets the "updated_at" field.
  1443. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  1444. m.updated_at = &t
  1445. }
  1446. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1447. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  1448. v := m.updated_at
  1449. if v == nil {
  1450. return
  1451. }
  1452. return *v, true
  1453. }
  1454. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  1455. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1457. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1458. if !m.op.Is(OpUpdateOne) {
  1459. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1460. }
  1461. if m.id == nil || m.oldValue == nil {
  1462. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1463. }
  1464. oldValue, err := m.oldValue(ctx)
  1465. if err != nil {
  1466. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1467. }
  1468. return oldValue.UpdatedAt, nil
  1469. }
  1470. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1471. func (m *AgentMutation) ResetUpdatedAt() {
  1472. m.updated_at = nil
  1473. }
  1474. // SetDeletedAt sets the "deleted_at" field.
  1475. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  1476. m.deleted_at = &t
  1477. }
  1478. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1479. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  1480. v := m.deleted_at
  1481. if v == nil {
  1482. return
  1483. }
  1484. return *v, true
  1485. }
  1486. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  1487. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1489. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1490. if !m.op.Is(OpUpdateOne) {
  1491. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1492. }
  1493. if m.id == nil || m.oldValue == nil {
  1494. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1495. }
  1496. oldValue, err := m.oldValue(ctx)
  1497. if err != nil {
  1498. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1499. }
  1500. return oldValue.DeletedAt, nil
  1501. }
  1502. // ClearDeletedAt clears the value of the "deleted_at" field.
  1503. func (m *AgentMutation) ClearDeletedAt() {
  1504. m.deleted_at = nil
  1505. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  1506. }
  1507. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1508. func (m *AgentMutation) DeletedAtCleared() bool {
  1509. _, ok := m.clearedFields[agent.FieldDeletedAt]
  1510. return ok
  1511. }
  1512. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1513. func (m *AgentMutation) ResetDeletedAt() {
  1514. m.deleted_at = nil
  1515. delete(m.clearedFields, agent.FieldDeletedAt)
  1516. }
  1517. // SetName sets the "name" field.
  1518. func (m *AgentMutation) SetName(s string) {
  1519. m.name = &s
  1520. }
  1521. // Name returns the value of the "name" field in the mutation.
  1522. func (m *AgentMutation) Name() (r string, exists bool) {
  1523. v := m.name
  1524. if v == nil {
  1525. return
  1526. }
  1527. return *v, true
  1528. }
  1529. // OldName returns the old "name" field's value of the Agent entity.
  1530. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1532. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  1533. if !m.op.Is(OpUpdateOne) {
  1534. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1535. }
  1536. if m.id == nil || m.oldValue == nil {
  1537. return v, errors.New("OldName requires an ID field in the mutation")
  1538. }
  1539. oldValue, err := m.oldValue(ctx)
  1540. if err != nil {
  1541. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1542. }
  1543. return oldValue.Name, nil
  1544. }
  1545. // ResetName resets all changes to the "name" field.
  1546. func (m *AgentMutation) ResetName() {
  1547. m.name = nil
  1548. }
  1549. // SetRole sets the "role" field.
  1550. func (m *AgentMutation) SetRole(s string) {
  1551. m.role = &s
  1552. }
  1553. // Role returns the value of the "role" field in the mutation.
  1554. func (m *AgentMutation) Role() (r string, exists bool) {
  1555. v := m.role
  1556. if v == nil {
  1557. return
  1558. }
  1559. return *v, true
  1560. }
  1561. // OldRole returns the old "role" field's value of the Agent entity.
  1562. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1564. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  1565. if !m.op.Is(OpUpdateOne) {
  1566. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  1567. }
  1568. if m.id == nil || m.oldValue == nil {
  1569. return v, errors.New("OldRole requires an ID field in the mutation")
  1570. }
  1571. oldValue, err := m.oldValue(ctx)
  1572. if err != nil {
  1573. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  1574. }
  1575. return oldValue.Role, nil
  1576. }
  1577. // ClearRole clears the value of the "role" field.
  1578. func (m *AgentMutation) ClearRole() {
  1579. m.role = nil
  1580. m.clearedFields[agent.FieldRole] = struct{}{}
  1581. }
  1582. // RoleCleared returns if the "role" field was cleared in this mutation.
  1583. func (m *AgentMutation) RoleCleared() bool {
  1584. _, ok := m.clearedFields[agent.FieldRole]
  1585. return ok
  1586. }
  1587. // ResetRole resets all changes to the "role" field.
  1588. func (m *AgentMutation) ResetRole() {
  1589. m.role = nil
  1590. delete(m.clearedFields, agent.FieldRole)
  1591. }
  1592. // SetStatus sets the "status" field.
  1593. func (m *AgentMutation) SetStatus(i int) {
  1594. m.status = &i
  1595. m.addstatus = nil
  1596. }
  1597. // Status returns the value of the "status" field in the mutation.
  1598. func (m *AgentMutation) Status() (r int, exists bool) {
  1599. v := m.status
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldStatus returns the old "status" field's value of the Agent entity.
  1606. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldStatus requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1618. }
  1619. return oldValue.Status, nil
  1620. }
  1621. // AddStatus adds i to the "status" field.
  1622. func (m *AgentMutation) AddStatus(i int) {
  1623. if m.addstatus != nil {
  1624. *m.addstatus += i
  1625. } else {
  1626. m.addstatus = &i
  1627. }
  1628. }
  1629. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1630. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  1631. v := m.addstatus
  1632. if v == nil {
  1633. return
  1634. }
  1635. return *v, true
  1636. }
  1637. // ClearStatus clears the value of the "status" field.
  1638. func (m *AgentMutation) ClearStatus() {
  1639. m.status = nil
  1640. m.addstatus = nil
  1641. m.clearedFields[agent.FieldStatus] = struct{}{}
  1642. }
  1643. // StatusCleared returns if the "status" field was cleared in this mutation.
  1644. func (m *AgentMutation) StatusCleared() bool {
  1645. _, ok := m.clearedFields[agent.FieldStatus]
  1646. return ok
  1647. }
  1648. // ResetStatus resets all changes to the "status" field.
  1649. func (m *AgentMutation) ResetStatus() {
  1650. m.status = nil
  1651. m.addstatus = nil
  1652. delete(m.clearedFields, agent.FieldStatus)
  1653. }
  1654. // SetBackground sets the "background" field.
  1655. func (m *AgentMutation) SetBackground(s string) {
  1656. m.background = &s
  1657. }
  1658. // Background returns the value of the "background" field in the mutation.
  1659. func (m *AgentMutation) Background() (r string, exists bool) {
  1660. v := m.background
  1661. if v == nil {
  1662. return
  1663. }
  1664. return *v, true
  1665. }
  1666. // OldBackground returns the old "background" field's value of the Agent entity.
  1667. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1669. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  1670. if !m.op.Is(OpUpdateOne) {
  1671. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  1672. }
  1673. if m.id == nil || m.oldValue == nil {
  1674. return v, errors.New("OldBackground requires an ID field in the mutation")
  1675. }
  1676. oldValue, err := m.oldValue(ctx)
  1677. if err != nil {
  1678. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  1679. }
  1680. return oldValue.Background, nil
  1681. }
  1682. // ClearBackground clears the value of the "background" field.
  1683. func (m *AgentMutation) ClearBackground() {
  1684. m.background = nil
  1685. m.clearedFields[agent.FieldBackground] = struct{}{}
  1686. }
  1687. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  1688. func (m *AgentMutation) BackgroundCleared() bool {
  1689. _, ok := m.clearedFields[agent.FieldBackground]
  1690. return ok
  1691. }
  1692. // ResetBackground resets all changes to the "background" field.
  1693. func (m *AgentMutation) ResetBackground() {
  1694. m.background = nil
  1695. delete(m.clearedFields, agent.FieldBackground)
  1696. }
  1697. // SetExamples sets the "examples" field.
  1698. func (m *AgentMutation) SetExamples(s string) {
  1699. m.examples = &s
  1700. }
  1701. // Examples returns the value of the "examples" field in the mutation.
  1702. func (m *AgentMutation) Examples() (r string, exists bool) {
  1703. v := m.examples
  1704. if v == nil {
  1705. return
  1706. }
  1707. return *v, true
  1708. }
  1709. // OldExamples returns the old "examples" field's value of the Agent entity.
  1710. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1712. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  1713. if !m.op.Is(OpUpdateOne) {
  1714. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  1715. }
  1716. if m.id == nil || m.oldValue == nil {
  1717. return v, errors.New("OldExamples requires an ID field in the mutation")
  1718. }
  1719. oldValue, err := m.oldValue(ctx)
  1720. if err != nil {
  1721. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  1722. }
  1723. return oldValue.Examples, nil
  1724. }
  1725. // ClearExamples clears the value of the "examples" field.
  1726. func (m *AgentMutation) ClearExamples() {
  1727. m.examples = nil
  1728. m.clearedFields[agent.FieldExamples] = struct{}{}
  1729. }
  1730. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  1731. func (m *AgentMutation) ExamplesCleared() bool {
  1732. _, ok := m.clearedFields[agent.FieldExamples]
  1733. return ok
  1734. }
  1735. // ResetExamples resets all changes to the "examples" field.
  1736. func (m *AgentMutation) ResetExamples() {
  1737. m.examples = nil
  1738. delete(m.clearedFields, agent.FieldExamples)
  1739. }
  1740. // SetOrganizationID sets the "organization_id" field.
  1741. func (m *AgentMutation) SetOrganizationID(u uint64) {
  1742. m.organization_id = &u
  1743. m.addorganization_id = nil
  1744. }
  1745. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1746. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  1747. v := m.organization_id
  1748. if v == nil {
  1749. return
  1750. }
  1751. return *v, true
  1752. }
  1753. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  1754. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1756. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1757. if !m.op.Is(OpUpdateOne) {
  1758. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1759. }
  1760. if m.id == nil || m.oldValue == nil {
  1761. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1762. }
  1763. oldValue, err := m.oldValue(ctx)
  1764. if err != nil {
  1765. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1766. }
  1767. return oldValue.OrganizationID, nil
  1768. }
  1769. // AddOrganizationID adds u to the "organization_id" field.
  1770. func (m *AgentMutation) AddOrganizationID(u int64) {
  1771. if m.addorganization_id != nil {
  1772. *m.addorganization_id += u
  1773. } else {
  1774. m.addorganization_id = &u
  1775. }
  1776. }
  1777. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1778. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  1779. v := m.addorganization_id
  1780. if v == nil {
  1781. return
  1782. }
  1783. return *v, true
  1784. }
  1785. // ResetOrganizationID resets all changes to the "organization_id" field.
  1786. func (m *AgentMutation) ResetOrganizationID() {
  1787. m.organization_id = nil
  1788. m.addorganization_id = nil
  1789. }
  1790. // SetDatasetID sets the "dataset_id" field.
  1791. func (m *AgentMutation) SetDatasetID(s string) {
  1792. m.dataset_id = &s
  1793. }
  1794. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1795. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  1796. v := m.dataset_id
  1797. if v == nil {
  1798. return
  1799. }
  1800. return *v, true
  1801. }
  1802. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  1803. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1805. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1806. if !m.op.Is(OpUpdateOne) {
  1807. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1808. }
  1809. if m.id == nil || m.oldValue == nil {
  1810. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1811. }
  1812. oldValue, err := m.oldValue(ctx)
  1813. if err != nil {
  1814. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1815. }
  1816. return oldValue.DatasetID, nil
  1817. }
  1818. // ResetDatasetID resets all changes to the "dataset_id" field.
  1819. func (m *AgentMutation) ResetDatasetID() {
  1820. m.dataset_id = nil
  1821. }
  1822. // SetCollectionID sets the "collection_id" field.
  1823. func (m *AgentMutation) SetCollectionID(s string) {
  1824. m.collection_id = &s
  1825. }
  1826. // CollectionID returns the value of the "collection_id" field in the mutation.
  1827. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  1828. v := m.collection_id
  1829. if v == nil {
  1830. return
  1831. }
  1832. return *v, true
  1833. }
  1834. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  1835. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1837. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1838. if !m.op.Is(OpUpdateOne) {
  1839. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1840. }
  1841. if m.id == nil || m.oldValue == nil {
  1842. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1843. }
  1844. oldValue, err := m.oldValue(ctx)
  1845. if err != nil {
  1846. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1847. }
  1848. return oldValue.CollectionID, nil
  1849. }
  1850. // ResetCollectionID resets all changes to the "collection_id" field.
  1851. func (m *AgentMutation) ResetCollectionID() {
  1852. m.collection_id = nil
  1853. }
  1854. // SetModel sets the "model" field.
  1855. func (m *AgentMutation) SetModel(s string) {
  1856. m.model = &s
  1857. }
  1858. // Model returns the value of the "model" field in the mutation.
  1859. func (m *AgentMutation) Model() (r string, exists bool) {
  1860. v := m.model
  1861. if v == nil {
  1862. return
  1863. }
  1864. return *v, true
  1865. }
  1866. // OldModel returns the old "model" field's value of the Agent entity.
  1867. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1869. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  1870. if !m.op.Is(OpUpdateOne) {
  1871. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  1872. }
  1873. if m.id == nil || m.oldValue == nil {
  1874. return v, errors.New("OldModel requires an ID field in the mutation")
  1875. }
  1876. oldValue, err := m.oldValue(ctx)
  1877. if err != nil {
  1878. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  1879. }
  1880. return oldValue.Model, nil
  1881. }
  1882. // ClearModel clears the value of the "model" field.
  1883. func (m *AgentMutation) ClearModel() {
  1884. m.model = nil
  1885. m.clearedFields[agent.FieldModel] = struct{}{}
  1886. }
  1887. // ModelCleared returns if the "model" field was cleared in this mutation.
  1888. func (m *AgentMutation) ModelCleared() bool {
  1889. _, ok := m.clearedFields[agent.FieldModel]
  1890. return ok
  1891. }
  1892. // ResetModel resets all changes to the "model" field.
  1893. func (m *AgentMutation) ResetModel() {
  1894. m.model = nil
  1895. delete(m.clearedFields, agent.FieldModel)
  1896. }
  1897. // SetAPIBase sets the "api_base" field.
  1898. func (m *AgentMutation) SetAPIBase(s string) {
  1899. m.api_base = &s
  1900. }
  1901. // APIBase returns the value of the "api_base" field in the mutation.
  1902. func (m *AgentMutation) APIBase() (r string, exists bool) {
  1903. v := m.api_base
  1904. if v == nil {
  1905. return
  1906. }
  1907. return *v, true
  1908. }
  1909. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  1910. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1912. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  1913. if !m.op.Is(OpUpdateOne) {
  1914. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  1915. }
  1916. if m.id == nil || m.oldValue == nil {
  1917. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  1918. }
  1919. oldValue, err := m.oldValue(ctx)
  1920. if err != nil {
  1921. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  1922. }
  1923. return oldValue.APIBase, nil
  1924. }
  1925. // ClearAPIBase clears the value of the "api_base" field.
  1926. func (m *AgentMutation) ClearAPIBase() {
  1927. m.api_base = nil
  1928. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  1929. }
  1930. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  1931. func (m *AgentMutation) APIBaseCleared() bool {
  1932. _, ok := m.clearedFields[agent.FieldAPIBase]
  1933. return ok
  1934. }
  1935. // ResetAPIBase resets all changes to the "api_base" field.
  1936. func (m *AgentMutation) ResetAPIBase() {
  1937. m.api_base = nil
  1938. delete(m.clearedFields, agent.FieldAPIBase)
  1939. }
  1940. // SetAPIKey sets the "api_key" field.
  1941. func (m *AgentMutation) SetAPIKey(s string) {
  1942. m.api_key = &s
  1943. }
  1944. // APIKey returns the value of the "api_key" field in the mutation.
  1945. func (m *AgentMutation) APIKey() (r string, exists bool) {
  1946. v := m.api_key
  1947. if v == nil {
  1948. return
  1949. }
  1950. return *v, true
  1951. }
  1952. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  1953. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1955. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  1956. if !m.op.Is(OpUpdateOne) {
  1957. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  1958. }
  1959. if m.id == nil || m.oldValue == nil {
  1960. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  1961. }
  1962. oldValue, err := m.oldValue(ctx)
  1963. if err != nil {
  1964. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  1965. }
  1966. return oldValue.APIKey, nil
  1967. }
  1968. // ClearAPIKey clears the value of the "api_key" field.
  1969. func (m *AgentMutation) ClearAPIKey() {
  1970. m.api_key = nil
  1971. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  1972. }
  1973. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  1974. func (m *AgentMutation) APIKeyCleared() bool {
  1975. _, ok := m.clearedFields[agent.FieldAPIKey]
  1976. return ok
  1977. }
  1978. // ResetAPIKey resets all changes to the "api_key" field.
  1979. func (m *AgentMutation) ResetAPIKey() {
  1980. m.api_key = nil
  1981. delete(m.clearedFields, agent.FieldAPIKey)
  1982. }
  1983. // SetType sets the "type" field.
  1984. func (m *AgentMutation) SetType(i int) {
  1985. m._type = &i
  1986. m.add_type = nil
  1987. }
  1988. // GetType returns the value of the "type" field in the mutation.
  1989. func (m *AgentMutation) GetType() (r int, exists bool) {
  1990. v := m._type
  1991. if v == nil {
  1992. return
  1993. }
  1994. return *v, true
  1995. }
  1996. // OldType returns the old "type" field's value of the Agent entity.
  1997. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1999. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  2000. if !m.op.Is(OpUpdateOne) {
  2001. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2002. }
  2003. if m.id == nil || m.oldValue == nil {
  2004. return v, errors.New("OldType requires an ID field in the mutation")
  2005. }
  2006. oldValue, err := m.oldValue(ctx)
  2007. if err != nil {
  2008. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2009. }
  2010. return oldValue.Type, nil
  2011. }
  2012. // AddType adds i to the "type" field.
  2013. func (m *AgentMutation) AddType(i int) {
  2014. if m.add_type != nil {
  2015. *m.add_type += i
  2016. } else {
  2017. m.add_type = &i
  2018. }
  2019. }
  2020. // AddedType returns the value that was added to the "type" field in this mutation.
  2021. func (m *AgentMutation) AddedType() (r int, exists bool) {
  2022. v := m.add_type
  2023. if v == nil {
  2024. return
  2025. }
  2026. return *v, true
  2027. }
  2028. // ClearType clears the value of the "type" field.
  2029. func (m *AgentMutation) ClearType() {
  2030. m._type = nil
  2031. m.add_type = nil
  2032. m.clearedFields[agent.FieldType] = struct{}{}
  2033. }
  2034. // TypeCleared returns if the "type" field was cleared in this mutation.
  2035. func (m *AgentMutation) TypeCleared() bool {
  2036. _, ok := m.clearedFields[agent.FieldType]
  2037. return ok
  2038. }
  2039. // ResetType resets all changes to the "type" field.
  2040. func (m *AgentMutation) ResetType() {
  2041. m._type = nil
  2042. m.add_type = nil
  2043. delete(m.clearedFields, agent.FieldType)
  2044. }
  2045. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2046. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  2047. if m.wx_agent == nil {
  2048. m.wx_agent = make(map[uint64]struct{})
  2049. }
  2050. for i := range ids {
  2051. m.wx_agent[ids[i]] = struct{}{}
  2052. }
  2053. }
  2054. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2055. func (m *AgentMutation) ClearWxAgent() {
  2056. m.clearedwx_agent = true
  2057. }
  2058. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2059. func (m *AgentMutation) WxAgentCleared() bool {
  2060. return m.clearedwx_agent
  2061. }
  2062. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2063. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  2064. if m.removedwx_agent == nil {
  2065. m.removedwx_agent = make(map[uint64]struct{})
  2066. }
  2067. for i := range ids {
  2068. delete(m.wx_agent, ids[i])
  2069. m.removedwx_agent[ids[i]] = struct{}{}
  2070. }
  2071. }
  2072. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2073. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  2074. for id := range m.removedwx_agent {
  2075. ids = append(ids, id)
  2076. }
  2077. return
  2078. }
  2079. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2080. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  2081. for id := range m.wx_agent {
  2082. ids = append(ids, id)
  2083. }
  2084. return
  2085. }
  2086. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2087. func (m *AgentMutation) ResetWxAgent() {
  2088. m.wx_agent = nil
  2089. m.clearedwx_agent = false
  2090. m.removedwx_agent = nil
  2091. }
  2092. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  2093. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  2094. if m.token_agent == nil {
  2095. m.token_agent = make(map[uint64]struct{})
  2096. }
  2097. for i := range ids {
  2098. m.token_agent[ids[i]] = struct{}{}
  2099. }
  2100. }
  2101. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  2102. func (m *AgentMutation) ClearTokenAgent() {
  2103. m.clearedtoken_agent = true
  2104. }
  2105. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  2106. func (m *AgentMutation) TokenAgentCleared() bool {
  2107. return m.clearedtoken_agent
  2108. }
  2109. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  2110. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  2111. if m.removedtoken_agent == nil {
  2112. m.removedtoken_agent = make(map[uint64]struct{})
  2113. }
  2114. for i := range ids {
  2115. delete(m.token_agent, ids[i])
  2116. m.removedtoken_agent[ids[i]] = struct{}{}
  2117. }
  2118. }
  2119. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  2120. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  2121. for id := range m.removedtoken_agent {
  2122. ids = append(ids, id)
  2123. }
  2124. return
  2125. }
  2126. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  2127. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  2128. for id := range m.token_agent {
  2129. ids = append(ids, id)
  2130. }
  2131. return
  2132. }
  2133. // ResetTokenAgent resets all changes to the "token_agent" edge.
  2134. func (m *AgentMutation) ResetTokenAgent() {
  2135. m.token_agent = nil
  2136. m.clearedtoken_agent = false
  2137. m.removedtoken_agent = nil
  2138. }
  2139. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  2140. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  2141. if m.wa_agent == nil {
  2142. m.wa_agent = make(map[uint64]struct{})
  2143. }
  2144. for i := range ids {
  2145. m.wa_agent[ids[i]] = struct{}{}
  2146. }
  2147. }
  2148. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  2149. func (m *AgentMutation) ClearWaAgent() {
  2150. m.clearedwa_agent = true
  2151. }
  2152. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  2153. func (m *AgentMutation) WaAgentCleared() bool {
  2154. return m.clearedwa_agent
  2155. }
  2156. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  2157. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  2158. if m.removedwa_agent == nil {
  2159. m.removedwa_agent = make(map[uint64]struct{})
  2160. }
  2161. for i := range ids {
  2162. delete(m.wa_agent, ids[i])
  2163. m.removedwa_agent[ids[i]] = struct{}{}
  2164. }
  2165. }
  2166. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  2167. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  2168. for id := range m.removedwa_agent {
  2169. ids = append(ids, id)
  2170. }
  2171. return
  2172. }
  2173. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  2174. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  2175. for id := range m.wa_agent {
  2176. ids = append(ids, id)
  2177. }
  2178. return
  2179. }
  2180. // ResetWaAgent resets all changes to the "wa_agent" edge.
  2181. func (m *AgentMutation) ResetWaAgent() {
  2182. m.wa_agent = nil
  2183. m.clearedwa_agent = false
  2184. m.removedwa_agent = nil
  2185. }
  2186. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  2187. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  2188. if m.xjs_agent == nil {
  2189. m.xjs_agent = make(map[uint64]struct{})
  2190. }
  2191. for i := range ids {
  2192. m.xjs_agent[ids[i]] = struct{}{}
  2193. }
  2194. }
  2195. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  2196. func (m *AgentMutation) ClearXjsAgent() {
  2197. m.clearedxjs_agent = true
  2198. }
  2199. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  2200. func (m *AgentMutation) XjsAgentCleared() bool {
  2201. return m.clearedxjs_agent
  2202. }
  2203. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  2204. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  2205. if m.removedxjs_agent == nil {
  2206. m.removedxjs_agent = make(map[uint64]struct{})
  2207. }
  2208. for i := range ids {
  2209. delete(m.xjs_agent, ids[i])
  2210. m.removedxjs_agent[ids[i]] = struct{}{}
  2211. }
  2212. }
  2213. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  2214. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  2215. for id := range m.removedxjs_agent {
  2216. ids = append(ids, id)
  2217. }
  2218. return
  2219. }
  2220. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  2221. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  2222. for id := range m.xjs_agent {
  2223. ids = append(ids, id)
  2224. }
  2225. return
  2226. }
  2227. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  2228. func (m *AgentMutation) ResetXjsAgent() {
  2229. m.xjs_agent = nil
  2230. m.clearedxjs_agent = false
  2231. m.removedxjs_agent = nil
  2232. }
  2233. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  2234. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  2235. if m.key_agent == nil {
  2236. m.key_agent = make(map[uint64]struct{})
  2237. }
  2238. for i := range ids {
  2239. m.key_agent[ids[i]] = struct{}{}
  2240. }
  2241. }
  2242. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  2243. func (m *AgentMutation) ClearKeyAgent() {
  2244. m.clearedkey_agent = true
  2245. }
  2246. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  2247. func (m *AgentMutation) KeyAgentCleared() bool {
  2248. return m.clearedkey_agent
  2249. }
  2250. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  2251. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  2252. if m.removedkey_agent == nil {
  2253. m.removedkey_agent = make(map[uint64]struct{})
  2254. }
  2255. for i := range ids {
  2256. delete(m.key_agent, ids[i])
  2257. m.removedkey_agent[ids[i]] = struct{}{}
  2258. }
  2259. }
  2260. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  2261. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  2262. for id := range m.removedkey_agent {
  2263. ids = append(ids, id)
  2264. }
  2265. return
  2266. }
  2267. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  2268. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  2269. for id := range m.key_agent {
  2270. ids = append(ids, id)
  2271. }
  2272. return
  2273. }
  2274. // ResetKeyAgent resets all changes to the "key_agent" edge.
  2275. func (m *AgentMutation) ResetKeyAgent() {
  2276. m.key_agent = nil
  2277. m.clearedkey_agent = false
  2278. m.removedkey_agent = nil
  2279. }
  2280. // Where appends a list predicates to the AgentMutation builder.
  2281. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  2282. m.predicates = append(m.predicates, ps...)
  2283. }
  2284. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  2285. // users can use type-assertion to append predicates that do not depend on any generated package.
  2286. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  2287. p := make([]predicate.Agent, len(ps))
  2288. for i := range ps {
  2289. p[i] = ps[i]
  2290. }
  2291. m.Where(p...)
  2292. }
  2293. // Op returns the operation name.
  2294. func (m *AgentMutation) Op() Op {
  2295. return m.op
  2296. }
  2297. // SetOp allows setting the mutation operation.
  2298. func (m *AgentMutation) SetOp(op Op) {
  2299. m.op = op
  2300. }
  2301. // Type returns the node type of this mutation (Agent).
  2302. func (m *AgentMutation) Type() string {
  2303. return m.typ
  2304. }
  2305. // Fields returns all fields that were changed during this mutation. Note that in
  2306. // order to get all numeric fields that were incremented/decremented, call
  2307. // AddedFields().
  2308. func (m *AgentMutation) Fields() []string {
  2309. fields := make([]string, 0, 15)
  2310. if m.created_at != nil {
  2311. fields = append(fields, agent.FieldCreatedAt)
  2312. }
  2313. if m.updated_at != nil {
  2314. fields = append(fields, agent.FieldUpdatedAt)
  2315. }
  2316. if m.deleted_at != nil {
  2317. fields = append(fields, agent.FieldDeletedAt)
  2318. }
  2319. if m.name != nil {
  2320. fields = append(fields, agent.FieldName)
  2321. }
  2322. if m.role != nil {
  2323. fields = append(fields, agent.FieldRole)
  2324. }
  2325. if m.status != nil {
  2326. fields = append(fields, agent.FieldStatus)
  2327. }
  2328. if m.background != nil {
  2329. fields = append(fields, agent.FieldBackground)
  2330. }
  2331. if m.examples != nil {
  2332. fields = append(fields, agent.FieldExamples)
  2333. }
  2334. if m.organization_id != nil {
  2335. fields = append(fields, agent.FieldOrganizationID)
  2336. }
  2337. if m.dataset_id != nil {
  2338. fields = append(fields, agent.FieldDatasetID)
  2339. }
  2340. if m.collection_id != nil {
  2341. fields = append(fields, agent.FieldCollectionID)
  2342. }
  2343. if m.model != nil {
  2344. fields = append(fields, agent.FieldModel)
  2345. }
  2346. if m.api_base != nil {
  2347. fields = append(fields, agent.FieldAPIBase)
  2348. }
  2349. if m.api_key != nil {
  2350. fields = append(fields, agent.FieldAPIKey)
  2351. }
  2352. if m._type != nil {
  2353. fields = append(fields, agent.FieldType)
  2354. }
  2355. return fields
  2356. }
  2357. // Field returns the value of a field with the given name. The second boolean
  2358. // return value indicates that this field was not set, or was not defined in the
  2359. // schema.
  2360. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  2361. switch name {
  2362. case agent.FieldCreatedAt:
  2363. return m.CreatedAt()
  2364. case agent.FieldUpdatedAt:
  2365. return m.UpdatedAt()
  2366. case agent.FieldDeletedAt:
  2367. return m.DeletedAt()
  2368. case agent.FieldName:
  2369. return m.Name()
  2370. case agent.FieldRole:
  2371. return m.Role()
  2372. case agent.FieldStatus:
  2373. return m.Status()
  2374. case agent.FieldBackground:
  2375. return m.Background()
  2376. case agent.FieldExamples:
  2377. return m.Examples()
  2378. case agent.FieldOrganizationID:
  2379. return m.OrganizationID()
  2380. case agent.FieldDatasetID:
  2381. return m.DatasetID()
  2382. case agent.FieldCollectionID:
  2383. return m.CollectionID()
  2384. case agent.FieldModel:
  2385. return m.Model()
  2386. case agent.FieldAPIBase:
  2387. return m.APIBase()
  2388. case agent.FieldAPIKey:
  2389. return m.APIKey()
  2390. case agent.FieldType:
  2391. return m.GetType()
  2392. }
  2393. return nil, false
  2394. }
  2395. // OldField returns the old value of the field from the database. An error is
  2396. // returned if the mutation operation is not UpdateOne, or the query to the
  2397. // database failed.
  2398. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2399. switch name {
  2400. case agent.FieldCreatedAt:
  2401. return m.OldCreatedAt(ctx)
  2402. case agent.FieldUpdatedAt:
  2403. return m.OldUpdatedAt(ctx)
  2404. case agent.FieldDeletedAt:
  2405. return m.OldDeletedAt(ctx)
  2406. case agent.FieldName:
  2407. return m.OldName(ctx)
  2408. case agent.FieldRole:
  2409. return m.OldRole(ctx)
  2410. case agent.FieldStatus:
  2411. return m.OldStatus(ctx)
  2412. case agent.FieldBackground:
  2413. return m.OldBackground(ctx)
  2414. case agent.FieldExamples:
  2415. return m.OldExamples(ctx)
  2416. case agent.FieldOrganizationID:
  2417. return m.OldOrganizationID(ctx)
  2418. case agent.FieldDatasetID:
  2419. return m.OldDatasetID(ctx)
  2420. case agent.FieldCollectionID:
  2421. return m.OldCollectionID(ctx)
  2422. case agent.FieldModel:
  2423. return m.OldModel(ctx)
  2424. case agent.FieldAPIBase:
  2425. return m.OldAPIBase(ctx)
  2426. case agent.FieldAPIKey:
  2427. return m.OldAPIKey(ctx)
  2428. case agent.FieldType:
  2429. return m.OldType(ctx)
  2430. }
  2431. return nil, fmt.Errorf("unknown Agent field %s", name)
  2432. }
  2433. // SetField sets the value of a field with the given name. It returns an error if
  2434. // the field is not defined in the schema, or if the type mismatched the field
  2435. // type.
  2436. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  2437. switch name {
  2438. case agent.FieldCreatedAt:
  2439. v, ok := value.(time.Time)
  2440. if !ok {
  2441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2442. }
  2443. m.SetCreatedAt(v)
  2444. return nil
  2445. case agent.FieldUpdatedAt:
  2446. v, ok := value.(time.Time)
  2447. if !ok {
  2448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2449. }
  2450. m.SetUpdatedAt(v)
  2451. return nil
  2452. case agent.FieldDeletedAt:
  2453. v, ok := value.(time.Time)
  2454. if !ok {
  2455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2456. }
  2457. m.SetDeletedAt(v)
  2458. return nil
  2459. case agent.FieldName:
  2460. v, ok := value.(string)
  2461. if !ok {
  2462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2463. }
  2464. m.SetName(v)
  2465. return nil
  2466. case agent.FieldRole:
  2467. v, ok := value.(string)
  2468. if !ok {
  2469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2470. }
  2471. m.SetRole(v)
  2472. return nil
  2473. case agent.FieldStatus:
  2474. v, ok := value.(int)
  2475. if !ok {
  2476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2477. }
  2478. m.SetStatus(v)
  2479. return nil
  2480. case agent.FieldBackground:
  2481. v, ok := value.(string)
  2482. if !ok {
  2483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2484. }
  2485. m.SetBackground(v)
  2486. return nil
  2487. case agent.FieldExamples:
  2488. v, ok := value.(string)
  2489. if !ok {
  2490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2491. }
  2492. m.SetExamples(v)
  2493. return nil
  2494. case agent.FieldOrganizationID:
  2495. v, ok := value.(uint64)
  2496. if !ok {
  2497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2498. }
  2499. m.SetOrganizationID(v)
  2500. return nil
  2501. case agent.FieldDatasetID:
  2502. v, ok := value.(string)
  2503. if !ok {
  2504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2505. }
  2506. m.SetDatasetID(v)
  2507. return nil
  2508. case agent.FieldCollectionID:
  2509. v, ok := value.(string)
  2510. if !ok {
  2511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2512. }
  2513. m.SetCollectionID(v)
  2514. return nil
  2515. case agent.FieldModel:
  2516. v, ok := value.(string)
  2517. if !ok {
  2518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2519. }
  2520. m.SetModel(v)
  2521. return nil
  2522. case agent.FieldAPIBase:
  2523. v, ok := value.(string)
  2524. if !ok {
  2525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2526. }
  2527. m.SetAPIBase(v)
  2528. return nil
  2529. case agent.FieldAPIKey:
  2530. v, ok := value.(string)
  2531. if !ok {
  2532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2533. }
  2534. m.SetAPIKey(v)
  2535. return nil
  2536. case agent.FieldType:
  2537. v, ok := value.(int)
  2538. if !ok {
  2539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2540. }
  2541. m.SetType(v)
  2542. return nil
  2543. }
  2544. return fmt.Errorf("unknown Agent field %s", name)
  2545. }
  2546. // AddedFields returns all numeric fields that were incremented/decremented during
  2547. // this mutation.
  2548. func (m *AgentMutation) AddedFields() []string {
  2549. var fields []string
  2550. if m.addstatus != nil {
  2551. fields = append(fields, agent.FieldStatus)
  2552. }
  2553. if m.addorganization_id != nil {
  2554. fields = append(fields, agent.FieldOrganizationID)
  2555. }
  2556. if m.add_type != nil {
  2557. fields = append(fields, agent.FieldType)
  2558. }
  2559. return fields
  2560. }
  2561. // AddedField returns the numeric value that was incremented/decremented on a field
  2562. // with the given name. The second boolean return value indicates that this field
  2563. // was not set, or was not defined in the schema.
  2564. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  2565. switch name {
  2566. case agent.FieldStatus:
  2567. return m.AddedStatus()
  2568. case agent.FieldOrganizationID:
  2569. return m.AddedOrganizationID()
  2570. case agent.FieldType:
  2571. return m.AddedType()
  2572. }
  2573. return nil, false
  2574. }
  2575. // AddField adds the value to the field with the given name. It returns an error if
  2576. // the field is not defined in the schema, or if the type mismatched the field
  2577. // type.
  2578. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  2579. switch name {
  2580. case agent.FieldStatus:
  2581. v, ok := value.(int)
  2582. if !ok {
  2583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2584. }
  2585. m.AddStatus(v)
  2586. return nil
  2587. case agent.FieldOrganizationID:
  2588. v, ok := value.(int64)
  2589. if !ok {
  2590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2591. }
  2592. m.AddOrganizationID(v)
  2593. return nil
  2594. case agent.FieldType:
  2595. v, ok := value.(int)
  2596. if !ok {
  2597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2598. }
  2599. m.AddType(v)
  2600. return nil
  2601. }
  2602. return fmt.Errorf("unknown Agent numeric field %s", name)
  2603. }
  2604. // ClearedFields returns all nullable fields that were cleared during this
  2605. // mutation.
  2606. func (m *AgentMutation) ClearedFields() []string {
  2607. var fields []string
  2608. if m.FieldCleared(agent.FieldDeletedAt) {
  2609. fields = append(fields, agent.FieldDeletedAt)
  2610. }
  2611. if m.FieldCleared(agent.FieldRole) {
  2612. fields = append(fields, agent.FieldRole)
  2613. }
  2614. if m.FieldCleared(agent.FieldStatus) {
  2615. fields = append(fields, agent.FieldStatus)
  2616. }
  2617. if m.FieldCleared(agent.FieldBackground) {
  2618. fields = append(fields, agent.FieldBackground)
  2619. }
  2620. if m.FieldCleared(agent.FieldExamples) {
  2621. fields = append(fields, agent.FieldExamples)
  2622. }
  2623. if m.FieldCleared(agent.FieldModel) {
  2624. fields = append(fields, agent.FieldModel)
  2625. }
  2626. if m.FieldCleared(agent.FieldAPIBase) {
  2627. fields = append(fields, agent.FieldAPIBase)
  2628. }
  2629. if m.FieldCleared(agent.FieldAPIKey) {
  2630. fields = append(fields, agent.FieldAPIKey)
  2631. }
  2632. if m.FieldCleared(agent.FieldType) {
  2633. fields = append(fields, agent.FieldType)
  2634. }
  2635. return fields
  2636. }
  2637. // FieldCleared returns a boolean indicating if a field with the given name was
  2638. // cleared in this mutation.
  2639. func (m *AgentMutation) FieldCleared(name string) bool {
  2640. _, ok := m.clearedFields[name]
  2641. return ok
  2642. }
  2643. // ClearField clears the value of the field with the given name. It returns an
  2644. // error if the field is not defined in the schema.
  2645. func (m *AgentMutation) ClearField(name string) error {
  2646. switch name {
  2647. case agent.FieldDeletedAt:
  2648. m.ClearDeletedAt()
  2649. return nil
  2650. case agent.FieldRole:
  2651. m.ClearRole()
  2652. return nil
  2653. case agent.FieldStatus:
  2654. m.ClearStatus()
  2655. return nil
  2656. case agent.FieldBackground:
  2657. m.ClearBackground()
  2658. return nil
  2659. case agent.FieldExamples:
  2660. m.ClearExamples()
  2661. return nil
  2662. case agent.FieldModel:
  2663. m.ClearModel()
  2664. return nil
  2665. case agent.FieldAPIBase:
  2666. m.ClearAPIBase()
  2667. return nil
  2668. case agent.FieldAPIKey:
  2669. m.ClearAPIKey()
  2670. return nil
  2671. case agent.FieldType:
  2672. m.ClearType()
  2673. return nil
  2674. }
  2675. return fmt.Errorf("unknown Agent nullable field %s", name)
  2676. }
  2677. // ResetField resets all changes in the mutation for the field with the given name.
  2678. // It returns an error if the field is not defined in the schema.
  2679. func (m *AgentMutation) ResetField(name string) error {
  2680. switch name {
  2681. case agent.FieldCreatedAt:
  2682. m.ResetCreatedAt()
  2683. return nil
  2684. case agent.FieldUpdatedAt:
  2685. m.ResetUpdatedAt()
  2686. return nil
  2687. case agent.FieldDeletedAt:
  2688. m.ResetDeletedAt()
  2689. return nil
  2690. case agent.FieldName:
  2691. m.ResetName()
  2692. return nil
  2693. case agent.FieldRole:
  2694. m.ResetRole()
  2695. return nil
  2696. case agent.FieldStatus:
  2697. m.ResetStatus()
  2698. return nil
  2699. case agent.FieldBackground:
  2700. m.ResetBackground()
  2701. return nil
  2702. case agent.FieldExamples:
  2703. m.ResetExamples()
  2704. return nil
  2705. case agent.FieldOrganizationID:
  2706. m.ResetOrganizationID()
  2707. return nil
  2708. case agent.FieldDatasetID:
  2709. m.ResetDatasetID()
  2710. return nil
  2711. case agent.FieldCollectionID:
  2712. m.ResetCollectionID()
  2713. return nil
  2714. case agent.FieldModel:
  2715. m.ResetModel()
  2716. return nil
  2717. case agent.FieldAPIBase:
  2718. m.ResetAPIBase()
  2719. return nil
  2720. case agent.FieldAPIKey:
  2721. m.ResetAPIKey()
  2722. return nil
  2723. case agent.FieldType:
  2724. m.ResetType()
  2725. return nil
  2726. }
  2727. return fmt.Errorf("unknown Agent field %s", name)
  2728. }
  2729. // AddedEdges returns all edge names that were set/added in this mutation.
  2730. func (m *AgentMutation) AddedEdges() []string {
  2731. edges := make([]string, 0, 5)
  2732. if m.wx_agent != nil {
  2733. edges = append(edges, agent.EdgeWxAgent)
  2734. }
  2735. if m.token_agent != nil {
  2736. edges = append(edges, agent.EdgeTokenAgent)
  2737. }
  2738. if m.wa_agent != nil {
  2739. edges = append(edges, agent.EdgeWaAgent)
  2740. }
  2741. if m.xjs_agent != nil {
  2742. edges = append(edges, agent.EdgeXjsAgent)
  2743. }
  2744. if m.key_agent != nil {
  2745. edges = append(edges, agent.EdgeKeyAgent)
  2746. }
  2747. return edges
  2748. }
  2749. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2750. // name in this mutation.
  2751. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  2752. switch name {
  2753. case agent.EdgeWxAgent:
  2754. ids := make([]ent.Value, 0, len(m.wx_agent))
  2755. for id := range m.wx_agent {
  2756. ids = append(ids, id)
  2757. }
  2758. return ids
  2759. case agent.EdgeTokenAgent:
  2760. ids := make([]ent.Value, 0, len(m.token_agent))
  2761. for id := range m.token_agent {
  2762. ids = append(ids, id)
  2763. }
  2764. return ids
  2765. case agent.EdgeWaAgent:
  2766. ids := make([]ent.Value, 0, len(m.wa_agent))
  2767. for id := range m.wa_agent {
  2768. ids = append(ids, id)
  2769. }
  2770. return ids
  2771. case agent.EdgeXjsAgent:
  2772. ids := make([]ent.Value, 0, len(m.xjs_agent))
  2773. for id := range m.xjs_agent {
  2774. ids = append(ids, id)
  2775. }
  2776. return ids
  2777. case agent.EdgeKeyAgent:
  2778. ids := make([]ent.Value, 0, len(m.key_agent))
  2779. for id := range m.key_agent {
  2780. ids = append(ids, id)
  2781. }
  2782. return ids
  2783. }
  2784. return nil
  2785. }
  2786. // RemovedEdges returns all edge names that were removed in this mutation.
  2787. func (m *AgentMutation) RemovedEdges() []string {
  2788. edges := make([]string, 0, 5)
  2789. if m.removedwx_agent != nil {
  2790. edges = append(edges, agent.EdgeWxAgent)
  2791. }
  2792. if m.removedtoken_agent != nil {
  2793. edges = append(edges, agent.EdgeTokenAgent)
  2794. }
  2795. if m.removedwa_agent != nil {
  2796. edges = append(edges, agent.EdgeWaAgent)
  2797. }
  2798. if m.removedxjs_agent != nil {
  2799. edges = append(edges, agent.EdgeXjsAgent)
  2800. }
  2801. if m.removedkey_agent != nil {
  2802. edges = append(edges, agent.EdgeKeyAgent)
  2803. }
  2804. return edges
  2805. }
  2806. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2807. // the given name in this mutation.
  2808. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  2809. switch name {
  2810. case agent.EdgeWxAgent:
  2811. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2812. for id := range m.removedwx_agent {
  2813. ids = append(ids, id)
  2814. }
  2815. return ids
  2816. case agent.EdgeTokenAgent:
  2817. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  2818. for id := range m.removedtoken_agent {
  2819. ids = append(ids, id)
  2820. }
  2821. return ids
  2822. case agent.EdgeWaAgent:
  2823. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  2824. for id := range m.removedwa_agent {
  2825. ids = append(ids, id)
  2826. }
  2827. return ids
  2828. case agent.EdgeXjsAgent:
  2829. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  2830. for id := range m.removedxjs_agent {
  2831. ids = append(ids, id)
  2832. }
  2833. return ids
  2834. case agent.EdgeKeyAgent:
  2835. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  2836. for id := range m.removedkey_agent {
  2837. ids = append(ids, id)
  2838. }
  2839. return ids
  2840. }
  2841. return nil
  2842. }
  2843. // ClearedEdges returns all edge names that were cleared in this mutation.
  2844. func (m *AgentMutation) ClearedEdges() []string {
  2845. edges := make([]string, 0, 5)
  2846. if m.clearedwx_agent {
  2847. edges = append(edges, agent.EdgeWxAgent)
  2848. }
  2849. if m.clearedtoken_agent {
  2850. edges = append(edges, agent.EdgeTokenAgent)
  2851. }
  2852. if m.clearedwa_agent {
  2853. edges = append(edges, agent.EdgeWaAgent)
  2854. }
  2855. if m.clearedxjs_agent {
  2856. edges = append(edges, agent.EdgeXjsAgent)
  2857. }
  2858. if m.clearedkey_agent {
  2859. edges = append(edges, agent.EdgeKeyAgent)
  2860. }
  2861. return edges
  2862. }
  2863. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2864. // was cleared in this mutation.
  2865. func (m *AgentMutation) EdgeCleared(name string) bool {
  2866. switch name {
  2867. case agent.EdgeWxAgent:
  2868. return m.clearedwx_agent
  2869. case agent.EdgeTokenAgent:
  2870. return m.clearedtoken_agent
  2871. case agent.EdgeWaAgent:
  2872. return m.clearedwa_agent
  2873. case agent.EdgeXjsAgent:
  2874. return m.clearedxjs_agent
  2875. case agent.EdgeKeyAgent:
  2876. return m.clearedkey_agent
  2877. }
  2878. return false
  2879. }
  2880. // ClearEdge clears the value of the edge with the given name. It returns an error
  2881. // if that edge is not defined in the schema.
  2882. func (m *AgentMutation) ClearEdge(name string) error {
  2883. switch name {
  2884. }
  2885. return fmt.Errorf("unknown Agent unique edge %s", name)
  2886. }
  2887. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2888. // It returns an error if the edge is not defined in the schema.
  2889. func (m *AgentMutation) ResetEdge(name string) error {
  2890. switch name {
  2891. case agent.EdgeWxAgent:
  2892. m.ResetWxAgent()
  2893. return nil
  2894. case agent.EdgeTokenAgent:
  2895. m.ResetTokenAgent()
  2896. return nil
  2897. case agent.EdgeWaAgent:
  2898. m.ResetWaAgent()
  2899. return nil
  2900. case agent.EdgeXjsAgent:
  2901. m.ResetXjsAgent()
  2902. return nil
  2903. case agent.EdgeKeyAgent:
  2904. m.ResetKeyAgent()
  2905. return nil
  2906. }
  2907. return fmt.Errorf("unknown Agent edge %s", name)
  2908. }
  2909. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  2910. type AgentBaseMutation struct {
  2911. config
  2912. op Op
  2913. typ string
  2914. id *string
  2915. q *string
  2916. a *string
  2917. chunk_index *uint64
  2918. addchunk_index *int64
  2919. indexes *[]string
  2920. appendindexes []string
  2921. dataset_id *string
  2922. collection_id *string
  2923. source_name *string
  2924. can_write *[]bool
  2925. appendcan_write []bool
  2926. is_owner *[]bool
  2927. appendis_owner []bool
  2928. clearedFields map[string]struct{}
  2929. wx_agent map[uint64]struct{}
  2930. removedwx_agent map[uint64]struct{}
  2931. clearedwx_agent bool
  2932. done bool
  2933. oldValue func(context.Context) (*AgentBase, error)
  2934. predicates []predicate.AgentBase
  2935. }
  2936. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  2937. // agentbaseOption allows management of the mutation configuration using functional options.
  2938. type agentbaseOption func(*AgentBaseMutation)
  2939. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  2940. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  2941. m := &AgentBaseMutation{
  2942. config: c,
  2943. op: op,
  2944. typ: TypeAgentBase,
  2945. clearedFields: make(map[string]struct{}),
  2946. }
  2947. for _, opt := range opts {
  2948. opt(m)
  2949. }
  2950. return m
  2951. }
  2952. // withAgentBaseID sets the ID field of the mutation.
  2953. func withAgentBaseID(id string) agentbaseOption {
  2954. return func(m *AgentBaseMutation) {
  2955. var (
  2956. err error
  2957. once sync.Once
  2958. value *AgentBase
  2959. )
  2960. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  2961. once.Do(func() {
  2962. if m.done {
  2963. err = errors.New("querying old values post mutation is not allowed")
  2964. } else {
  2965. value, err = m.Client().AgentBase.Get(ctx, id)
  2966. }
  2967. })
  2968. return value, err
  2969. }
  2970. m.id = &id
  2971. }
  2972. }
  2973. // withAgentBase sets the old AgentBase of the mutation.
  2974. func withAgentBase(node *AgentBase) agentbaseOption {
  2975. return func(m *AgentBaseMutation) {
  2976. m.oldValue = func(context.Context) (*AgentBase, error) {
  2977. return node, nil
  2978. }
  2979. m.id = &node.ID
  2980. }
  2981. }
  2982. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2983. // executed in a transaction (ent.Tx), a transactional client is returned.
  2984. func (m AgentBaseMutation) Client() *Client {
  2985. client := &Client{config: m.config}
  2986. client.init()
  2987. return client
  2988. }
  2989. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2990. // it returns an error otherwise.
  2991. func (m AgentBaseMutation) Tx() (*Tx, error) {
  2992. if _, ok := m.driver.(*txDriver); !ok {
  2993. return nil, errors.New("ent: mutation is not running in a transaction")
  2994. }
  2995. tx := &Tx{config: m.config}
  2996. tx.init()
  2997. return tx, nil
  2998. }
  2999. // SetID sets the value of the id field. Note that this
  3000. // operation is only accepted on creation of AgentBase entities.
  3001. func (m *AgentBaseMutation) SetID(id string) {
  3002. m.id = &id
  3003. }
  3004. // ID returns the ID value in the mutation. Note that the ID is only available
  3005. // if it was provided to the builder or after it was returned from the database.
  3006. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  3007. if m.id == nil {
  3008. return
  3009. }
  3010. return *m.id, true
  3011. }
  3012. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3013. // That means, if the mutation is applied within a transaction with an isolation level such
  3014. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3015. // or updated by the mutation.
  3016. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  3017. switch {
  3018. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3019. id, exists := m.ID()
  3020. if exists {
  3021. return []string{id}, nil
  3022. }
  3023. fallthrough
  3024. case m.op.Is(OpUpdate | OpDelete):
  3025. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  3026. default:
  3027. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3028. }
  3029. }
  3030. // SetQ sets the "q" field.
  3031. func (m *AgentBaseMutation) SetQ(s string) {
  3032. m.q = &s
  3033. }
  3034. // Q returns the value of the "q" field in the mutation.
  3035. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  3036. v := m.q
  3037. if v == nil {
  3038. return
  3039. }
  3040. return *v, true
  3041. }
  3042. // OldQ returns the old "q" field's value of the AgentBase entity.
  3043. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3045. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  3046. if !m.op.Is(OpUpdateOne) {
  3047. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  3048. }
  3049. if m.id == nil || m.oldValue == nil {
  3050. return v, errors.New("OldQ requires an ID field in the mutation")
  3051. }
  3052. oldValue, err := m.oldValue(ctx)
  3053. if err != nil {
  3054. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  3055. }
  3056. return oldValue.Q, nil
  3057. }
  3058. // ClearQ clears the value of the "q" field.
  3059. func (m *AgentBaseMutation) ClearQ() {
  3060. m.q = nil
  3061. m.clearedFields[agentbase.FieldQ] = struct{}{}
  3062. }
  3063. // QCleared returns if the "q" field was cleared in this mutation.
  3064. func (m *AgentBaseMutation) QCleared() bool {
  3065. _, ok := m.clearedFields[agentbase.FieldQ]
  3066. return ok
  3067. }
  3068. // ResetQ resets all changes to the "q" field.
  3069. func (m *AgentBaseMutation) ResetQ() {
  3070. m.q = nil
  3071. delete(m.clearedFields, agentbase.FieldQ)
  3072. }
  3073. // SetA sets the "a" field.
  3074. func (m *AgentBaseMutation) SetA(s string) {
  3075. m.a = &s
  3076. }
  3077. // A returns the value of the "a" field in the mutation.
  3078. func (m *AgentBaseMutation) A() (r string, exists bool) {
  3079. v := m.a
  3080. if v == nil {
  3081. return
  3082. }
  3083. return *v, true
  3084. }
  3085. // OldA returns the old "a" field's value of the AgentBase entity.
  3086. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3088. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  3089. if !m.op.Is(OpUpdateOne) {
  3090. return v, errors.New("OldA is only allowed on UpdateOne operations")
  3091. }
  3092. if m.id == nil || m.oldValue == nil {
  3093. return v, errors.New("OldA requires an ID field in the mutation")
  3094. }
  3095. oldValue, err := m.oldValue(ctx)
  3096. if err != nil {
  3097. return v, fmt.Errorf("querying old value for OldA: %w", err)
  3098. }
  3099. return oldValue.A, nil
  3100. }
  3101. // ClearA clears the value of the "a" field.
  3102. func (m *AgentBaseMutation) ClearA() {
  3103. m.a = nil
  3104. m.clearedFields[agentbase.FieldA] = struct{}{}
  3105. }
  3106. // ACleared returns if the "a" field was cleared in this mutation.
  3107. func (m *AgentBaseMutation) ACleared() bool {
  3108. _, ok := m.clearedFields[agentbase.FieldA]
  3109. return ok
  3110. }
  3111. // ResetA resets all changes to the "a" field.
  3112. func (m *AgentBaseMutation) ResetA() {
  3113. m.a = nil
  3114. delete(m.clearedFields, agentbase.FieldA)
  3115. }
  3116. // SetChunkIndex sets the "chunk_index" field.
  3117. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  3118. m.chunk_index = &u
  3119. m.addchunk_index = nil
  3120. }
  3121. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  3122. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  3123. v := m.chunk_index
  3124. if v == nil {
  3125. return
  3126. }
  3127. return *v, true
  3128. }
  3129. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  3130. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3132. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  3133. if !m.op.Is(OpUpdateOne) {
  3134. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  3135. }
  3136. if m.id == nil || m.oldValue == nil {
  3137. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  3138. }
  3139. oldValue, err := m.oldValue(ctx)
  3140. if err != nil {
  3141. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  3142. }
  3143. return oldValue.ChunkIndex, nil
  3144. }
  3145. // AddChunkIndex adds u to the "chunk_index" field.
  3146. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  3147. if m.addchunk_index != nil {
  3148. *m.addchunk_index += u
  3149. } else {
  3150. m.addchunk_index = &u
  3151. }
  3152. }
  3153. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  3154. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  3155. v := m.addchunk_index
  3156. if v == nil {
  3157. return
  3158. }
  3159. return *v, true
  3160. }
  3161. // ResetChunkIndex resets all changes to the "chunk_index" field.
  3162. func (m *AgentBaseMutation) ResetChunkIndex() {
  3163. m.chunk_index = nil
  3164. m.addchunk_index = nil
  3165. }
  3166. // SetIndexes sets the "indexes" field.
  3167. func (m *AgentBaseMutation) SetIndexes(s []string) {
  3168. m.indexes = &s
  3169. m.appendindexes = nil
  3170. }
  3171. // Indexes returns the value of the "indexes" field in the mutation.
  3172. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  3173. v := m.indexes
  3174. if v == nil {
  3175. return
  3176. }
  3177. return *v, true
  3178. }
  3179. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  3180. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3182. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  3183. if !m.op.Is(OpUpdateOne) {
  3184. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  3185. }
  3186. if m.id == nil || m.oldValue == nil {
  3187. return v, errors.New("OldIndexes requires an ID field in the mutation")
  3188. }
  3189. oldValue, err := m.oldValue(ctx)
  3190. if err != nil {
  3191. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  3192. }
  3193. return oldValue.Indexes, nil
  3194. }
  3195. // AppendIndexes adds s to the "indexes" field.
  3196. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  3197. m.appendindexes = append(m.appendindexes, s...)
  3198. }
  3199. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  3200. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  3201. if len(m.appendindexes) == 0 {
  3202. return nil, false
  3203. }
  3204. return m.appendindexes, true
  3205. }
  3206. // ClearIndexes clears the value of the "indexes" field.
  3207. func (m *AgentBaseMutation) ClearIndexes() {
  3208. m.indexes = nil
  3209. m.appendindexes = nil
  3210. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  3211. }
  3212. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  3213. func (m *AgentBaseMutation) IndexesCleared() bool {
  3214. _, ok := m.clearedFields[agentbase.FieldIndexes]
  3215. return ok
  3216. }
  3217. // ResetIndexes resets all changes to the "indexes" field.
  3218. func (m *AgentBaseMutation) ResetIndexes() {
  3219. m.indexes = nil
  3220. m.appendindexes = nil
  3221. delete(m.clearedFields, agentbase.FieldIndexes)
  3222. }
  3223. // SetDatasetID sets the "dataset_id" field.
  3224. func (m *AgentBaseMutation) SetDatasetID(s string) {
  3225. m.dataset_id = &s
  3226. }
  3227. // DatasetID returns the value of the "dataset_id" field in the mutation.
  3228. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  3229. v := m.dataset_id
  3230. if v == nil {
  3231. return
  3232. }
  3233. return *v, true
  3234. }
  3235. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  3236. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3238. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  3239. if !m.op.Is(OpUpdateOne) {
  3240. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  3241. }
  3242. if m.id == nil || m.oldValue == nil {
  3243. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  3244. }
  3245. oldValue, err := m.oldValue(ctx)
  3246. if err != nil {
  3247. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  3248. }
  3249. return oldValue.DatasetID, nil
  3250. }
  3251. // ClearDatasetID clears the value of the "dataset_id" field.
  3252. func (m *AgentBaseMutation) ClearDatasetID() {
  3253. m.dataset_id = nil
  3254. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  3255. }
  3256. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  3257. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  3258. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  3259. return ok
  3260. }
  3261. // ResetDatasetID resets all changes to the "dataset_id" field.
  3262. func (m *AgentBaseMutation) ResetDatasetID() {
  3263. m.dataset_id = nil
  3264. delete(m.clearedFields, agentbase.FieldDatasetID)
  3265. }
  3266. // SetCollectionID sets the "collection_id" field.
  3267. func (m *AgentBaseMutation) SetCollectionID(s string) {
  3268. m.collection_id = &s
  3269. }
  3270. // CollectionID returns the value of the "collection_id" field in the mutation.
  3271. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  3272. v := m.collection_id
  3273. if v == nil {
  3274. return
  3275. }
  3276. return *v, true
  3277. }
  3278. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  3279. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3281. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  3282. if !m.op.Is(OpUpdateOne) {
  3283. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  3284. }
  3285. if m.id == nil || m.oldValue == nil {
  3286. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  3287. }
  3288. oldValue, err := m.oldValue(ctx)
  3289. if err != nil {
  3290. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  3291. }
  3292. return oldValue.CollectionID, nil
  3293. }
  3294. // ClearCollectionID clears the value of the "collection_id" field.
  3295. func (m *AgentBaseMutation) ClearCollectionID() {
  3296. m.collection_id = nil
  3297. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  3298. }
  3299. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  3300. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  3301. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  3302. return ok
  3303. }
  3304. // ResetCollectionID resets all changes to the "collection_id" field.
  3305. func (m *AgentBaseMutation) ResetCollectionID() {
  3306. m.collection_id = nil
  3307. delete(m.clearedFields, agentbase.FieldCollectionID)
  3308. }
  3309. // SetSourceName sets the "source_name" field.
  3310. func (m *AgentBaseMutation) SetSourceName(s string) {
  3311. m.source_name = &s
  3312. }
  3313. // SourceName returns the value of the "source_name" field in the mutation.
  3314. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  3315. v := m.source_name
  3316. if v == nil {
  3317. return
  3318. }
  3319. return *v, true
  3320. }
  3321. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  3322. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3324. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  3325. if !m.op.Is(OpUpdateOne) {
  3326. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  3327. }
  3328. if m.id == nil || m.oldValue == nil {
  3329. return v, errors.New("OldSourceName requires an ID field in the mutation")
  3330. }
  3331. oldValue, err := m.oldValue(ctx)
  3332. if err != nil {
  3333. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  3334. }
  3335. return oldValue.SourceName, nil
  3336. }
  3337. // ClearSourceName clears the value of the "source_name" field.
  3338. func (m *AgentBaseMutation) ClearSourceName() {
  3339. m.source_name = nil
  3340. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  3341. }
  3342. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  3343. func (m *AgentBaseMutation) SourceNameCleared() bool {
  3344. _, ok := m.clearedFields[agentbase.FieldSourceName]
  3345. return ok
  3346. }
  3347. // ResetSourceName resets all changes to the "source_name" field.
  3348. func (m *AgentBaseMutation) ResetSourceName() {
  3349. m.source_name = nil
  3350. delete(m.clearedFields, agentbase.FieldSourceName)
  3351. }
  3352. // SetCanWrite sets the "can_write" field.
  3353. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  3354. m.can_write = &b
  3355. m.appendcan_write = nil
  3356. }
  3357. // CanWrite returns the value of the "can_write" field in the mutation.
  3358. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  3359. v := m.can_write
  3360. if v == nil {
  3361. return
  3362. }
  3363. return *v, true
  3364. }
  3365. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  3366. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3368. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  3369. if !m.op.Is(OpUpdateOne) {
  3370. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  3371. }
  3372. if m.id == nil || m.oldValue == nil {
  3373. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  3374. }
  3375. oldValue, err := m.oldValue(ctx)
  3376. if err != nil {
  3377. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  3378. }
  3379. return oldValue.CanWrite, nil
  3380. }
  3381. // AppendCanWrite adds b to the "can_write" field.
  3382. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  3383. m.appendcan_write = append(m.appendcan_write, b...)
  3384. }
  3385. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  3386. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  3387. if len(m.appendcan_write) == 0 {
  3388. return nil, false
  3389. }
  3390. return m.appendcan_write, true
  3391. }
  3392. // ClearCanWrite clears the value of the "can_write" field.
  3393. func (m *AgentBaseMutation) ClearCanWrite() {
  3394. m.can_write = nil
  3395. m.appendcan_write = nil
  3396. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  3397. }
  3398. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  3399. func (m *AgentBaseMutation) CanWriteCleared() bool {
  3400. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  3401. return ok
  3402. }
  3403. // ResetCanWrite resets all changes to the "can_write" field.
  3404. func (m *AgentBaseMutation) ResetCanWrite() {
  3405. m.can_write = nil
  3406. m.appendcan_write = nil
  3407. delete(m.clearedFields, agentbase.FieldCanWrite)
  3408. }
  3409. // SetIsOwner sets the "is_owner" field.
  3410. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  3411. m.is_owner = &b
  3412. m.appendis_owner = nil
  3413. }
  3414. // IsOwner returns the value of the "is_owner" field in the mutation.
  3415. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  3416. v := m.is_owner
  3417. if v == nil {
  3418. return
  3419. }
  3420. return *v, true
  3421. }
  3422. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  3423. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3425. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  3426. if !m.op.Is(OpUpdateOne) {
  3427. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  3428. }
  3429. if m.id == nil || m.oldValue == nil {
  3430. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  3431. }
  3432. oldValue, err := m.oldValue(ctx)
  3433. if err != nil {
  3434. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  3435. }
  3436. return oldValue.IsOwner, nil
  3437. }
  3438. // AppendIsOwner adds b to the "is_owner" field.
  3439. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  3440. m.appendis_owner = append(m.appendis_owner, b...)
  3441. }
  3442. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  3443. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  3444. if len(m.appendis_owner) == 0 {
  3445. return nil, false
  3446. }
  3447. return m.appendis_owner, true
  3448. }
  3449. // ClearIsOwner clears the value of the "is_owner" field.
  3450. func (m *AgentBaseMutation) ClearIsOwner() {
  3451. m.is_owner = nil
  3452. m.appendis_owner = nil
  3453. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  3454. }
  3455. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  3456. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  3457. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  3458. return ok
  3459. }
  3460. // ResetIsOwner resets all changes to the "is_owner" field.
  3461. func (m *AgentBaseMutation) ResetIsOwner() {
  3462. m.is_owner = nil
  3463. m.appendis_owner = nil
  3464. delete(m.clearedFields, agentbase.FieldIsOwner)
  3465. }
  3466. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  3467. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  3468. if m.wx_agent == nil {
  3469. m.wx_agent = make(map[uint64]struct{})
  3470. }
  3471. for i := range ids {
  3472. m.wx_agent[ids[i]] = struct{}{}
  3473. }
  3474. }
  3475. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  3476. func (m *AgentBaseMutation) ClearWxAgent() {
  3477. m.clearedwx_agent = true
  3478. }
  3479. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  3480. func (m *AgentBaseMutation) WxAgentCleared() bool {
  3481. return m.clearedwx_agent
  3482. }
  3483. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  3484. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  3485. if m.removedwx_agent == nil {
  3486. m.removedwx_agent = make(map[uint64]struct{})
  3487. }
  3488. for i := range ids {
  3489. delete(m.wx_agent, ids[i])
  3490. m.removedwx_agent[ids[i]] = struct{}{}
  3491. }
  3492. }
  3493. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  3494. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  3495. for id := range m.removedwx_agent {
  3496. ids = append(ids, id)
  3497. }
  3498. return
  3499. }
  3500. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  3501. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  3502. for id := range m.wx_agent {
  3503. ids = append(ids, id)
  3504. }
  3505. return
  3506. }
  3507. // ResetWxAgent resets all changes to the "wx_agent" edge.
  3508. func (m *AgentBaseMutation) ResetWxAgent() {
  3509. m.wx_agent = nil
  3510. m.clearedwx_agent = false
  3511. m.removedwx_agent = nil
  3512. }
  3513. // Where appends a list predicates to the AgentBaseMutation builder.
  3514. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  3515. m.predicates = append(m.predicates, ps...)
  3516. }
  3517. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  3518. // users can use type-assertion to append predicates that do not depend on any generated package.
  3519. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  3520. p := make([]predicate.AgentBase, len(ps))
  3521. for i := range ps {
  3522. p[i] = ps[i]
  3523. }
  3524. m.Where(p...)
  3525. }
  3526. // Op returns the operation name.
  3527. func (m *AgentBaseMutation) Op() Op {
  3528. return m.op
  3529. }
  3530. // SetOp allows setting the mutation operation.
  3531. func (m *AgentBaseMutation) SetOp(op Op) {
  3532. m.op = op
  3533. }
  3534. // Type returns the node type of this mutation (AgentBase).
  3535. func (m *AgentBaseMutation) Type() string {
  3536. return m.typ
  3537. }
  3538. // Fields returns all fields that were changed during this mutation. Note that in
  3539. // order to get all numeric fields that were incremented/decremented, call
  3540. // AddedFields().
  3541. func (m *AgentBaseMutation) Fields() []string {
  3542. fields := make([]string, 0, 9)
  3543. if m.q != nil {
  3544. fields = append(fields, agentbase.FieldQ)
  3545. }
  3546. if m.a != nil {
  3547. fields = append(fields, agentbase.FieldA)
  3548. }
  3549. if m.chunk_index != nil {
  3550. fields = append(fields, agentbase.FieldChunkIndex)
  3551. }
  3552. if m.indexes != nil {
  3553. fields = append(fields, agentbase.FieldIndexes)
  3554. }
  3555. if m.dataset_id != nil {
  3556. fields = append(fields, agentbase.FieldDatasetID)
  3557. }
  3558. if m.collection_id != nil {
  3559. fields = append(fields, agentbase.FieldCollectionID)
  3560. }
  3561. if m.source_name != nil {
  3562. fields = append(fields, agentbase.FieldSourceName)
  3563. }
  3564. if m.can_write != nil {
  3565. fields = append(fields, agentbase.FieldCanWrite)
  3566. }
  3567. if m.is_owner != nil {
  3568. fields = append(fields, agentbase.FieldIsOwner)
  3569. }
  3570. return fields
  3571. }
  3572. // Field returns the value of a field with the given name. The second boolean
  3573. // return value indicates that this field was not set, or was not defined in the
  3574. // schema.
  3575. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  3576. switch name {
  3577. case agentbase.FieldQ:
  3578. return m.Q()
  3579. case agentbase.FieldA:
  3580. return m.A()
  3581. case agentbase.FieldChunkIndex:
  3582. return m.ChunkIndex()
  3583. case agentbase.FieldIndexes:
  3584. return m.Indexes()
  3585. case agentbase.FieldDatasetID:
  3586. return m.DatasetID()
  3587. case agentbase.FieldCollectionID:
  3588. return m.CollectionID()
  3589. case agentbase.FieldSourceName:
  3590. return m.SourceName()
  3591. case agentbase.FieldCanWrite:
  3592. return m.CanWrite()
  3593. case agentbase.FieldIsOwner:
  3594. return m.IsOwner()
  3595. }
  3596. return nil, false
  3597. }
  3598. // OldField returns the old value of the field from the database. An error is
  3599. // returned if the mutation operation is not UpdateOne, or the query to the
  3600. // database failed.
  3601. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3602. switch name {
  3603. case agentbase.FieldQ:
  3604. return m.OldQ(ctx)
  3605. case agentbase.FieldA:
  3606. return m.OldA(ctx)
  3607. case agentbase.FieldChunkIndex:
  3608. return m.OldChunkIndex(ctx)
  3609. case agentbase.FieldIndexes:
  3610. return m.OldIndexes(ctx)
  3611. case agentbase.FieldDatasetID:
  3612. return m.OldDatasetID(ctx)
  3613. case agentbase.FieldCollectionID:
  3614. return m.OldCollectionID(ctx)
  3615. case agentbase.FieldSourceName:
  3616. return m.OldSourceName(ctx)
  3617. case agentbase.FieldCanWrite:
  3618. return m.OldCanWrite(ctx)
  3619. case agentbase.FieldIsOwner:
  3620. return m.OldIsOwner(ctx)
  3621. }
  3622. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  3623. }
  3624. // SetField sets the value of a field with the given name. It returns an error if
  3625. // the field is not defined in the schema, or if the type mismatched the field
  3626. // type.
  3627. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  3628. switch name {
  3629. case agentbase.FieldQ:
  3630. v, ok := value.(string)
  3631. if !ok {
  3632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3633. }
  3634. m.SetQ(v)
  3635. return nil
  3636. case agentbase.FieldA:
  3637. v, ok := value.(string)
  3638. if !ok {
  3639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3640. }
  3641. m.SetA(v)
  3642. return nil
  3643. case agentbase.FieldChunkIndex:
  3644. v, ok := value.(uint64)
  3645. if !ok {
  3646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3647. }
  3648. m.SetChunkIndex(v)
  3649. return nil
  3650. case agentbase.FieldIndexes:
  3651. v, ok := value.([]string)
  3652. if !ok {
  3653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3654. }
  3655. m.SetIndexes(v)
  3656. return nil
  3657. case agentbase.FieldDatasetID:
  3658. v, ok := value.(string)
  3659. if !ok {
  3660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3661. }
  3662. m.SetDatasetID(v)
  3663. return nil
  3664. case agentbase.FieldCollectionID:
  3665. v, ok := value.(string)
  3666. if !ok {
  3667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3668. }
  3669. m.SetCollectionID(v)
  3670. return nil
  3671. case agentbase.FieldSourceName:
  3672. v, ok := value.(string)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetSourceName(v)
  3677. return nil
  3678. case agentbase.FieldCanWrite:
  3679. v, ok := value.([]bool)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetCanWrite(v)
  3684. return nil
  3685. case agentbase.FieldIsOwner:
  3686. v, ok := value.([]bool)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetIsOwner(v)
  3691. return nil
  3692. }
  3693. return fmt.Errorf("unknown AgentBase field %s", name)
  3694. }
  3695. // AddedFields returns all numeric fields that were incremented/decremented during
  3696. // this mutation.
  3697. func (m *AgentBaseMutation) AddedFields() []string {
  3698. var fields []string
  3699. if m.addchunk_index != nil {
  3700. fields = append(fields, agentbase.FieldChunkIndex)
  3701. }
  3702. return fields
  3703. }
  3704. // AddedField returns the numeric value that was incremented/decremented on a field
  3705. // with the given name. The second boolean return value indicates that this field
  3706. // was not set, or was not defined in the schema.
  3707. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  3708. switch name {
  3709. case agentbase.FieldChunkIndex:
  3710. return m.AddedChunkIndex()
  3711. }
  3712. return nil, false
  3713. }
  3714. // AddField adds the value to the field with the given name. It returns an error if
  3715. // the field is not defined in the schema, or if the type mismatched the field
  3716. // type.
  3717. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  3718. switch name {
  3719. case agentbase.FieldChunkIndex:
  3720. v, ok := value.(int64)
  3721. if !ok {
  3722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3723. }
  3724. m.AddChunkIndex(v)
  3725. return nil
  3726. }
  3727. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  3728. }
  3729. // ClearedFields returns all nullable fields that were cleared during this
  3730. // mutation.
  3731. func (m *AgentBaseMutation) ClearedFields() []string {
  3732. var fields []string
  3733. if m.FieldCleared(agentbase.FieldQ) {
  3734. fields = append(fields, agentbase.FieldQ)
  3735. }
  3736. if m.FieldCleared(agentbase.FieldA) {
  3737. fields = append(fields, agentbase.FieldA)
  3738. }
  3739. if m.FieldCleared(agentbase.FieldIndexes) {
  3740. fields = append(fields, agentbase.FieldIndexes)
  3741. }
  3742. if m.FieldCleared(agentbase.FieldDatasetID) {
  3743. fields = append(fields, agentbase.FieldDatasetID)
  3744. }
  3745. if m.FieldCleared(agentbase.FieldCollectionID) {
  3746. fields = append(fields, agentbase.FieldCollectionID)
  3747. }
  3748. if m.FieldCleared(agentbase.FieldSourceName) {
  3749. fields = append(fields, agentbase.FieldSourceName)
  3750. }
  3751. if m.FieldCleared(agentbase.FieldCanWrite) {
  3752. fields = append(fields, agentbase.FieldCanWrite)
  3753. }
  3754. if m.FieldCleared(agentbase.FieldIsOwner) {
  3755. fields = append(fields, agentbase.FieldIsOwner)
  3756. }
  3757. return fields
  3758. }
  3759. // FieldCleared returns a boolean indicating if a field with the given name was
  3760. // cleared in this mutation.
  3761. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  3762. _, ok := m.clearedFields[name]
  3763. return ok
  3764. }
  3765. // ClearField clears the value of the field with the given name. It returns an
  3766. // error if the field is not defined in the schema.
  3767. func (m *AgentBaseMutation) ClearField(name string) error {
  3768. switch name {
  3769. case agentbase.FieldQ:
  3770. m.ClearQ()
  3771. return nil
  3772. case agentbase.FieldA:
  3773. m.ClearA()
  3774. return nil
  3775. case agentbase.FieldIndexes:
  3776. m.ClearIndexes()
  3777. return nil
  3778. case agentbase.FieldDatasetID:
  3779. m.ClearDatasetID()
  3780. return nil
  3781. case agentbase.FieldCollectionID:
  3782. m.ClearCollectionID()
  3783. return nil
  3784. case agentbase.FieldSourceName:
  3785. m.ClearSourceName()
  3786. return nil
  3787. case agentbase.FieldCanWrite:
  3788. m.ClearCanWrite()
  3789. return nil
  3790. case agentbase.FieldIsOwner:
  3791. m.ClearIsOwner()
  3792. return nil
  3793. }
  3794. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  3795. }
  3796. // ResetField resets all changes in the mutation for the field with the given name.
  3797. // It returns an error if the field is not defined in the schema.
  3798. func (m *AgentBaseMutation) ResetField(name string) error {
  3799. switch name {
  3800. case agentbase.FieldQ:
  3801. m.ResetQ()
  3802. return nil
  3803. case agentbase.FieldA:
  3804. m.ResetA()
  3805. return nil
  3806. case agentbase.FieldChunkIndex:
  3807. m.ResetChunkIndex()
  3808. return nil
  3809. case agentbase.FieldIndexes:
  3810. m.ResetIndexes()
  3811. return nil
  3812. case agentbase.FieldDatasetID:
  3813. m.ResetDatasetID()
  3814. return nil
  3815. case agentbase.FieldCollectionID:
  3816. m.ResetCollectionID()
  3817. return nil
  3818. case agentbase.FieldSourceName:
  3819. m.ResetSourceName()
  3820. return nil
  3821. case agentbase.FieldCanWrite:
  3822. m.ResetCanWrite()
  3823. return nil
  3824. case agentbase.FieldIsOwner:
  3825. m.ResetIsOwner()
  3826. return nil
  3827. }
  3828. return fmt.Errorf("unknown AgentBase field %s", name)
  3829. }
  3830. // AddedEdges returns all edge names that were set/added in this mutation.
  3831. func (m *AgentBaseMutation) AddedEdges() []string {
  3832. edges := make([]string, 0, 1)
  3833. if m.wx_agent != nil {
  3834. edges = append(edges, agentbase.EdgeWxAgent)
  3835. }
  3836. return edges
  3837. }
  3838. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3839. // name in this mutation.
  3840. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  3841. switch name {
  3842. case agentbase.EdgeWxAgent:
  3843. ids := make([]ent.Value, 0, len(m.wx_agent))
  3844. for id := range m.wx_agent {
  3845. ids = append(ids, id)
  3846. }
  3847. return ids
  3848. }
  3849. return nil
  3850. }
  3851. // RemovedEdges returns all edge names that were removed in this mutation.
  3852. func (m *AgentBaseMutation) RemovedEdges() []string {
  3853. edges := make([]string, 0, 1)
  3854. if m.removedwx_agent != nil {
  3855. edges = append(edges, agentbase.EdgeWxAgent)
  3856. }
  3857. return edges
  3858. }
  3859. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3860. // the given name in this mutation.
  3861. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  3862. switch name {
  3863. case agentbase.EdgeWxAgent:
  3864. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  3865. for id := range m.removedwx_agent {
  3866. ids = append(ids, id)
  3867. }
  3868. return ids
  3869. }
  3870. return nil
  3871. }
  3872. // ClearedEdges returns all edge names that were cleared in this mutation.
  3873. func (m *AgentBaseMutation) ClearedEdges() []string {
  3874. edges := make([]string, 0, 1)
  3875. if m.clearedwx_agent {
  3876. edges = append(edges, agentbase.EdgeWxAgent)
  3877. }
  3878. return edges
  3879. }
  3880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3881. // was cleared in this mutation.
  3882. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  3883. switch name {
  3884. case agentbase.EdgeWxAgent:
  3885. return m.clearedwx_agent
  3886. }
  3887. return false
  3888. }
  3889. // ClearEdge clears the value of the edge with the given name. It returns an error
  3890. // if that edge is not defined in the schema.
  3891. func (m *AgentBaseMutation) ClearEdge(name string) error {
  3892. switch name {
  3893. }
  3894. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  3895. }
  3896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3897. // It returns an error if the edge is not defined in the schema.
  3898. func (m *AgentBaseMutation) ResetEdge(name string) error {
  3899. switch name {
  3900. case agentbase.EdgeWxAgent:
  3901. m.ResetWxAgent()
  3902. return nil
  3903. }
  3904. return fmt.Errorf("unknown AgentBase edge %s", name)
  3905. }
  3906. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  3907. type AliyunAvatarMutation struct {
  3908. config
  3909. op Op
  3910. typ string
  3911. id *uint64
  3912. created_at *time.Time
  3913. updated_at *time.Time
  3914. deleted_at *time.Time
  3915. user_id *uint64
  3916. adduser_id *int64
  3917. biz_id *string
  3918. access_key_id *string
  3919. access_key_secret *string
  3920. app_id *string
  3921. tenant_id *uint64
  3922. addtenant_id *int64
  3923. response *string
  3924. token *string
  3925. session_id *string
  3926. clearedFields map[string]struct{}
  3927. done bool
  3928. oldValue func(context.Context) (*AliyunAvatar, error)
  3929. predicates []predicate.AliyunAvatar
  3930. }
  3931. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  3932. // aliyunavatarOption allows management of the mutation configuration using functional options.
  3933. type aliyunavatarOption func(*AliyunAvatarMutation)
  3934. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  3935. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  3936. m := &AliyunAvatarMutation{
  3937. config: c,
  3938. op: op,
  3939. typ: TypeAliyunAvatar,
  3940. clearedFields: make(map[string]struct{}),
  3941. }
  3942. for _, opt := range opts {
  3943. opt(m)
  3944. }
  3945. return m
  3946. }
  3947. // withAliyunAvatarID sets the ID field of the mutation.
  3948. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  3949. return func(m *AliyunAvatarMutation) {
  3950. var (
  3951. err error
  3952. once sync.Once
  3953. value *AliyunAvatar
  3954. )
  3955. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  3956. once.Do(func() {
  3957. if m.done {
  3958. err = errors.New("querying old values post mutation is not allowed")
  3959. } else {
  3960. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  3961. }
  3962. })
  3963. return value, err
  3964. }
  3965. m.id = &id
  3966. }
  3967. }
  3968. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  3969. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  3970. return func(m *AliyunAvatarMutation) {
  3971. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  3972. return node, nil
  3973. }
  3974. m.id = &node.ID
  3975. }
  3976. }
  3977. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3978. // executed in a transaction (ent.Tx), a transactional client is returned.
  3979. func (m AliyunAvatarMutation) Client() *Client {
  3980. client := &Client{config: m.config}
  3981. client.init()
  3982. return client
  3983. }
  3984. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3985. // it returns an error otherwise.
  3986. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  3987. if _, ok := m.driver.(*txDriver); !ok {
  3988. return nil, errors.New("ent: mutation is not running in a transaction")
  3989. }
  3990. tx := &Tx{config: m.config}
  3991. tx.init()
  3992. return tx, nil
  3993. }
  3994. // SetID sets the value of the id field. Note that this
  3995. // operation is only accepted on creation of AliyunAvatar entities.
  3996. func (m *AliyunAvatarMutation) SetID(id uint64) {
  3997. m.id = &id
  3998. }
  3999. // ID returns the ID value in the mutation. Note that the ID is only available
  4000. // if it was provided to the builder or after it was returned from the database.
  4001. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  4002. if m.id == nil {
  4003. return
  4004. }
  4005. return *m.id, true
  4006. }
  4007. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4008. // That means, if the mutation is applied within a transaction with an isolation level such
  4009. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4010. // or updated by the mutation.
  4011. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  4012. switch {
  4013. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4014. id, exists := m.ID()
  4015. if exists {
  4016. return []uint64{id}, nil
  4017. }
  4018. fallthrough
  4019. case m.op.Is(OpUpdate | OpDelete):
  4020. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  4021. default:
  4022. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4023. }
  4024. }
  4025. // SetCreatedAt sets the "created_at" field.
  4026. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  4027. m.created_at = &t
  4028. }
  4029. // CreatedAt returns the value of the "created_at" field in the mutation.
  4030. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  4031. v := m.created_at
  4032. if v == nil {
  4033. return
  4034. }
  4035. return *v, true
  4036. }
  4037. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  4038. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4040. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4041. if !m.op.Is(OpUpdateOne) {
  4042. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4043. }
  4044. if m.id == nil || m.oldValue == nil {
  4045. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4046. }
  4047. oldValue, err := m.oldValue(ctx)
  4048. if err != nil {
  4049. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4050. }
  4051. return oldValue.CreatedAt, nil
  4052. }
  4053. // ResetCreatedAt resets all changes to the "created_at" field.
  4054. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  4055. m.created_at = nil
  4056. }
  4057. // SetUpdatedAt sets the "updated_at" field.
  4058. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  4059. m.updated_at = &t
  4060. }
  4061. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4062. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  4063. v := m.updated_at
  4064. if v == nil {
  4065. return
  4066. }
  4067. return *v, true
  4068. }
  4069. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  4070. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4072. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4073. if !m.op.Is(OpUpdateOne) {
  4074. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4075. }
  4076. if m.id == nil || m.oldValue == nil {
  4077. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4078. }
  4079. oldValue, err := m.oldValue(ctx)
  4080. if err != nil {
  4081. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4082. }
  4083. return oldValue.UpdatedAt, nil
  4084. }
  4085. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4086. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  4087. m.updated_at = nil
  4088. }
  4089. // SetDeletedAt sets the "deleted_at" field.
  4090. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  4091. m.deleted_at = &t
  4092. }
  4093. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4094. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  4095. v := m.deleted_at
  4096. if v == nil {
  4097. return
  4098. }
  4099. return *v, true
  4100. }
  4101. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  4102. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4104. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4105. if !m.op.Is(OpUpdateOne) {
  4106. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4107. }
  4108. if m.id == nil || m.oldValue == nil {
  4109. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4110. }
  4111. oldValue, err := m.oldValue(ctx)
  4112. if err != nil {
  4113. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4114. }
  4115. return oldValue.DeletedAt, nil
  4116. }
  4117. // ClearDeletedAt clears the value of the "deleted_at" field.
  4118. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  4119. m.deleted_at = nil
  4120. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  4121. }
  4122. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4123. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  4124. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  4125. return ok
  4126. }
  4127. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4128. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  4129. m.deleted_at = nil
  4130. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  4131. }
  4132. // SetUserID sets the "user_id" field.
  4133. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  4134. m.user_id = &u
  4135. m.adduser_id = nil
  4136. }
  4137. // UserID returns the value of the "user_id" field in the mutation.
  4138. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  4139. v := m.user_id
  4140. if v == nil {
  4141. return
  4142. }
  4143. return *v, true
  4144. }
  4145. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  4146. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4148. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  4149. if !m.op.Is(OpUpdateOne) {
  4150. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4151. }
  4152. if m.id == nil || m.oldValue == nil {
  4153. return v, errors.New("OldUserID requires an ID field in the mutation")
  4154. }
  4155. oldValue, err := m.oldValue(ctx)
  4156. if err != nil {
  4157. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4158. }
  4159. return oldValue.UserID, nil
  4160. }
  4161. // AddUserID adds u to the "user_id" field.
  4162. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  4163. if m.adduser_id != nil {
  4164. *m.adduser_id += u
  4165. } else {
  4166. m.adduser_id = &u
  4167. }
  4168. }
  4169. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  4170. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  4171. v := m.adduser_id
  4172. if v == nil {
  4173. return
  4174. }
  4175. return *v, true
  4176. }
  4177. // ResetUserID resets all changes to the "user_id" field.
  4178. func (m *AliyunAvatarMutation) ResetUserID() {
  4179. m.user_id = nil
  4180. m.adduser_id = nil
  4181. }
  4182. // SetBizID sets the "biz_id" field.
  4183. func (m *AliyunAvatarMutation) SetBizID(s string) {
  4184. m.biz_id = &s
  4185. }
  4186. // BizID returns the value of the "biz_id" field in the mutation.
  4187. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  4188. v := m.biz_id
  4189. if v == nil {
  4190. return
  4191. }
  4192. return *v, true
  4193. }
  4194. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  4195. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4197. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  4198. if !m.op.Is(OpUpdateOne) {
  4199. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  4200. }
  4201. if m.id == nil || m.oldValue == nil {
  4202. return v, errors.New("OldBizID requires an ID field in the mutation")
  4203. }
  4204. oldValue, err := m.oldValue(ctx)
  4205. if err != nil {
  4206. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  4207. }
  4208. return oldValue.BizID, nil
  4209. }
  4210. // ResetBizID resets all changes to the "biz_id" field.
  4211. func (m *AliyunAvatarMutation) ResetBizID() {
  4212. m.biz_id = nil
  4213. }
  4214. // SetAccessKeyID sets the "access_key_id" field.
  4215. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  4216. m.access_key_id = &s
  4217. }
  4218. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  4219. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  4220. v := m.access_key_id
  4221. if v == nil {
  4222. return
  4223. }
  4224. return *v, true
  4225. }
  4226. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  4227. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4229. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  4230. if !m.op.Is(OpUpdateOne) {
  4231. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  4232. }
  4233. if m.id == nil || m.oldValue == nil {
  4234. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  4235. }
  4236. oldValue, err := m.oldValue(ctx)
  4237. if err != nil {
  4238. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  4239. }
  4240. return oldValue.AccessKeyID, nil
  4241. }
  4242. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  4243. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  4244. m.access_key_id = nil
  4245. }
  4246. // SetAccessKeySecret sets the "access_key_secret" field.
  4247. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  4248. m.access_key_secret = &s
  4249. }
  4250. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  4251. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  4252. v := m.access_key_secret
  4253. if v == nil {
  4254. return
  4255. }
  4256. return *v, true
  4257. }
  4258. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  4259. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4261. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  4262. if !m.op.Is(OpUpdateOne) {
  4263. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  4264. }
  4265. if m.id == nil || m.oldValue == nil {
  4266. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  4267. }
  4268. oldValue, err := m.oldValue(ctx)
  4269. if err != nil {
  4270. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  4271. }
  4272. return oldValue.AccessKeySecret, nil
  4273. }
  4274. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  4275. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  4276. m.access_key_secret = nil
  4277. }
  4278. // SetAppID sets the "app_id" field.
  4279. func (m *AliyunAvatarMutation) SetAppID(s string) {
  4280. m.app_id = &s
  4281. }
  4282. // AppID returns the value of the "app_id" field in the mutation.
  4283. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  4284. v := m.app_id
  4285. if v == nil {
  4286. return
  4287. }
  4288. return *v, true
  4289. }
  4290. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  4291. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4293. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  4294. if !m.op.Is(OpUpdateOne) {
  4295. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  4296. }
  4297. if m.id == nil || m.oldValue == nil {
  4298. return v, errors.New("OldAppID requires an ID field in the mutation")
  4299. }
  4300. oldValue, err := m.oldValue(ctx)
  4301. if err != nil {
  4302. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  4303. }
  4304. return oldValue.AppID, nil
  4305. }
  4306. // ClearAppID clears the value of the "app_id" field.
  4307. func (m *AliyunAvatarMutation) ClearAppID() {
  4308. m.app_id = nil
  4309. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  4310. }
  4311. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  4312. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  4313. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  4314. return ok
  4315. }
  4316. // ResetAppID resets all changes to the "app_id" field.
  4317. func (m *AliyunAvatarMutation) ResetAppID() {
  4318. m.app_id = nil
  4319. delete(m.clearedFields, aliyunavatar.FieldAppID)
  4320. }
  4321. // SetTenantID sets the "tenant_id" field.
  4322. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  4323. m.tenant_id = &u
  4324. m.addtenant_id = nil
  4325. }
  4326. // TenantID returns the value of the "tenant_id" field in the mutation.
  4327. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  4328. v := m.tenant_id
  4329. if v == nil {
  4330. return
  4331. }
  4332. return *v, true
  4333. }
  4334. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  4335. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4337. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  4338. if !m.op.Is(OpUpdateOne) {
  4339. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  4340. }
  4341. if m.id == nil || m.oldValue == nil {
  4342. return v, errors.New("OldTenantID requires an ID field in the mutation")
  4343. }
  4344. oldValue, err := m.oldValue(ctx)
  4345. if err != nil {
  4346. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  4347. }
  4348. return oldValue.TenantID, nil
  4349. }
  4350. // AddTenantID adds u to the "tenant_id" field.
  4351. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  4352. if m.addtenant_id != nil {
  4353. *m.addtenant_id += u
  4354. } else {
  4355. m.addtenant_id = &u
  4356. }
  4357. }
  4358. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  4359. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  4360. v := m.addtenant_id
  4361. if v == nil {
  4362. return
  4363. }
  4364. return *v, true
  4365. }
  4366. // ResetTenantID resets all changes to the "tenant_id" field.
  4367. func (m *AliyunAvatarMutation) ResetTenantID() {
  4368. m.tenant_id = nil
  4369. m.addtenant_id = nil
  4370. }
  4371. // SetResponse sets the "response" field.
  4372. func (m *AliyunAvatarMutation) SetResponse(s string) {
  4373. m.response = &s
  4374. }
  4375. // Response returns the value of the "response" field in the mutation.
  4376. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  4377. v := m.response
  4378. if v == nil {
  4379. return
  4380. }
  4381. return *v, true
  4382. }
  4383. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  4384. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4386. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  4387. if !m.op.Is(OpUpdateOne) {
  4388. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  4389. }
  4390. if m.id == nil || m.oldValue == nil {
  4391. return v, errors.New("OldResponse requires an ID field in the mutation")
  4392. }
  4393. oldValue, err := m.oldValue(ctx)
  4394. if err != nil {
  4395. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  4396. }
  4397. return oldValue.Response, nil
  4398. }
  4399. // ResetResponse resets all changes to the "response" field.
  4400. func (m *AliyunAvatarMutation) ResetResponse() {
  4401. m.response = nil
  4402. }
  4403. // SetToken sets the "token" field.
  4404. func (m *AliyunAvatarMutation) SetToken(s string) {
  4405. m.token = &s
  4406. }
  4407. // Token returns the value of the "token" field in the mutation.
  4408. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  4409. v := m.token
  4410. if v == nil {
  4411. return
  4412. }
  4413. return *v, true
  4414. }
  4415. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  4416. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4418. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  4419. if !m.op.Is(OpUpdateOne) {
  4420. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  4421. }
  4422. if m.id == nil || m.oldValue == nil {
  4423. return v, errors.New("OldToken requires an ID field in the mutation")
  4424. }
  4425. oldValue, err := m.oldValue(ctx)
  4426. if err != nil {
  4427. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  4428. }
  4429. return oldValue.Token, nil
  4430. }
  4431. // ResetToken resets all changes to the "token" field.
  4432. func (m *AliyunAvatarMutation) ResetToken() {
  4433. m.token = nil
  4434. }
  4435. // SetSessionID sets the "session_id" field.
  4436. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  4437. m.session_id = &s
  4438. }
  4439. // SessionID returns the value of the "session_id" field in the mutation.
  4440. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  4441. v := m.session_id
  4442. if v == nil {
  4443. return
  4444. }
  4445. return *v, true
  4446. }
  4447. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  4448. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4450. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  4451. if !m.op.Is(OpUpdateOne) {
  4452. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  4453. }
  4454. if m.id == nil || m.oldValue == nil {
  4455. return v, errors.New("OldSessionID requires an ID field in the mutation")
  4456. }
  4457. oldValue, err := m.oldValue(ctx)
  4458. if err != nil {
  4459. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  4460. }
  4461. return oldValue.SessionID, nil
  4462. }
  4463. // ResetSessionID resets all changes to the "session_id" field.
  4464. func (m *AliyunAvatarMutation) ResetSessionID() {
  4465. m.session_id = nil
  4466. }
  4467. // Where appends a list predicates to the AliyunAvatarMutation builder.
  4468. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  4469. m.predicates = append(m.predicates, ps...)
  4470. }
  4471. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  4472. // users can use type-assertion to append predicates that do not depend on any generated package.
  4473. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  4474. p := make([]predicate.AliyunAvatar, len(ps))
  4475. for i := range ps {
  4476. p[i] = ps[i]
  4477. }
  4478. m.Where(p...)
  4479. }
  4480. // Op returns the operation name.
  4481. func (m *AliyunAvatarMutation) Op() Op {
  4482. return m.op
  4483. }
  4484. // SetOp allows setting the mutation operation.
  4485. func (m *AliyunAvatarMutation) SetOp(op Op) {
  4486. m.op = op
  4487. }
  4488. // Type returns the node type of this mutation (AliyunAvatar).
  4489. func (m *AliyunAvatarMutation) Type() string {
  4490. return m.typ
  4491. }
  4492. // Fields returns all fields that were changed during this mutation. Note that in
  4493. // order to get all numeric fields that were incremented/decremented, call
  4494. // AddedFields().
  4495. func (m *AliyunAvatarMutation) Fields() []string {
  4496. fields := make([]string, 0, 12)
  4497. if m.created_at != nil {
  4498. fields = append(fields, aliyunavatar.FieldCreatedAt)
  4499. }
  4500. if m.updated_at != nil {
  4501. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  4502. }
  4503. if m.deleted_at != nil {
  4504. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4505. }
  4506. if m.user_id != nil {
  4507. fields = append(fields, aliyunavatar.FieldUserID)
  4508. }
  4509. if m.biz_id != nil {
  4510. fields = append(fields, aliyunavatar.FieldBizID)
  4511. }
  4512. if m.access_key_id != nil {
  4513. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  4514. }
  4515. if m.access_key_secret != nil {
  4516. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  4517. }
  4518. if m.app_id != nil {
  4519. fields = append(fields, aliyunavatar.FieldAppID)
  4520. }
  4521. if m.tenant_id != nil {
  4522. fields = append(fields, aliyunavatar.FieldTenantID)
  4523. }
  4524. if m.response != nil {
  4525. fields = append(fields, aliyunavatar.FieldResponse)
  4526. }
  4527. if m.token != nil {
  4528. fields = append(fields, aliyunavatar.FieldToken)
  4529. }
  4530. if m.session_id != nil {
  4531. fields = append(fields, aliyunavatar.FieldSessionID)
  4532. }
  4533. return fields
  4534. }
  4535. // Field returns the value of a field with the given name. The second boolean
  4536. // return value indicates that this field was not set, or was not defined in the
  4537. // schema.
  4538. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  4539. switch name {
  4540. case aliyunavatar.FieldCreatedAt:
  4541. return m.CreatedAt()
  4542. case aliyunavatar.FieldUpdatedAt:
  4543. return m.UpdatedAt()
  4544. case aliyunavatar.FieldDeletedAt:
  4545. return m.DeletedAt()
  4546. case aliyunavatar.FieldUserID:
  4547. return m.UserID()
  4548. case aliyunavatar.FieldBizID:
  4549. return m.BizID()
  4550. case aliyunavatar.FieldAccessKeyID:
  4551. return m.AccessKeyID()
  4552. case aliyunavatar.FieldAccessKeySecret:
  4553. return m.AccessKeySecret()
  4554. case aliyunavatar.FieldAppID:
  4555. return m.AppID()
  4556. case aliyunavatar.FieldTenantID:
  4557. return m.TenantID()
  4558. case aliyunavatar.FieldResponse:
  4559. return m.Response()
  4560. case aliyunavatar.FieldToken:
  4561. return m.Token()
  4562. case aliyunavatar.FieldSessionID:
  4563. return m.SessionID()
  4564. }
  4565. return nil, false
  4566. }
  4567. // OldField returns the old value of the field from the database. An error is
  4568. // returned if the mutation operation is not UpdateOne, or the query to the
  4569. // database failed.
  4570. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4571. switch name {
  4572. case aliyunavatar.FieldCreatedAt:
  4573. return m.OldCreatedAt(ctx)
  4574. case aliyunavatar.FieldUpdatedAt:
  4575. return m.OldUpdatedAt(ctx)
  4576. case aliyunavatar.FieldDeletedAt:
  4577. return m.OldDeletedAt(ctx)
  4578. case aliyunavatar.FieldUserID:
  4579. return m.OldUserID(ctx)
  4580. case aliyunavatar.FieldBizID:
  4581. return m.OldBizID(ctx)
  4582. case aliyunavatar.FieldAccessKeyID:
  4583. return m.OldAccessKeyID(ctx)
  4584. case aliyunavatar.FieldAccessKeySecret:
  4585. return m.OldAccessKeySecret(ctx)
  4586. case aliyunavatar.FieldAppID:
  4587. return m.OldAppID(ctx)
  4588. case aliyunavatar.FieldTenantID:
  4589. return m.OldTenantID(ctx)
  4590. case aliyunavatar.FieldResponse:
  4591. return m.OldResponse(ctx)
  4592. case aliyunavatar.FieldToken:
  4593. return m.OldToken(ctx)
  4594. case aliyunavatar.FieldSessionID:
  4595. return m.OldSessionID(ctx)
  4596. }
  4597. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  4598. }
  4599. // SetField sets the value of a field with the given name. It returns an error if
  4600. // the field is not defined in the schema, or if the type mismatched the field
  4601. // type.
  4602. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  4603. switch name {
  4604. case aliyunavatar.FieldCreatedAt:
  4605. v, ok := value.(time.Time)
  4606. if !ok {
  4607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4608. }
  4609. m.SetCreatedAt(v)
  4610. return nil
  4611. case aliyunavatar.FieldUpdatedAt:
  4612. v, ok := value.(time.Time)
  4613. if !ok {
  4614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4615. }
  4616. m.SetUpdatedAt(v)
  4617. return nil
  4618. case aliyunavatar.FieldDeletedAt:
  4619. v, ok := value.(time.Time)
  4620. if !ok {
  4621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4622. }
  4623. m.SetDeletedAt(v)
  4624. return nil
  4625. case aliyunavatar.FieldUserID:
  4626. v, ok := value.(uint64)
  4627. if !ok {
  4628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4629. }
  4630. m.SetUserID(v)
  4631. return nil
  4632. case aliyunavatar.FieldBizID:
  4633. v, ok := value.(string)
  4634. if !ok {
  4635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4636. }
  4637. m.SetBizID(v)
  4638. return nil
  4639. case aliyunavatar.FieldAccessKeyID:
  4640. v, ok := value.(string)
  4641. if !ok {
  4642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4643. }
  4644. m.SetAccessKeyID(v)
  4645. return nil
  4646. case aliyunavatar.FieldAccessKeySecret:
  4647. v, ok := value.(string)
  4648. if !ok {
  4649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4650. }
  4651. m.SetAccessKeySecret(v)
  4652. return nil
  4653. case aliyunavatar.FieldAppID:
  4654. v, ok := value.(string)
  4655. if !ok {
  4656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4657. }
  4658. m.SetAppID(v)
  4659. return nil
  4660. case aliyunavatar.FieldTenantID:
  4661. v, ok := value.(uint64)
  4662. if !ok {
  4663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4664. }
  4665. m.SetTenantID(v)
  4666. return nil
  4667. case aliyunavatar.FieldResponse:
  4668. v, ok := value.(string)
  4669. if !ok {
  4670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4671. }
  4672. m.SetResponse(v)
  4673. return nil
  4674. case aliyunavatar.FieldToken:
  4675. v, ok := value.(string)
  4676. if !ok {
  4677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4678. }
  4679. m.SetToken(v)
  4680. return nil
  4681. case aliyunavatar.FieldSessionID:
  4682. v, ok := value.(string)
  4683. if !ok {
  4684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4685. }
  4686. m.SetSessionID(v)
  4687. return nil
  4688. }
  4689. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4690. }
  4691. // AddedFields returns all numeric fields that were incremented/decremented during
  4692. // this mutation.
  4693. func (m *AliyunAvatarMutation) AddedFields() []string {
  4694. var fields []string
  4695. if m.adduser_id != nil {
  4696. fields = append(fields, aliyunavatar.FieldUserID)
  4697. }
  4698. if m.addtenant_id != nil {
  4699. fields = append(fields, aliyunavatar.FieldTenantID)
  4700. }
  4701. return fields
  4702. }
  4703. // AddedField returns the numeric value that was incremented/decremented on a field
  4704. // with the given name. The second boolean return value indicates that this field
  4705. // was not set, or was not defined in the schema.
  4706. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  4707. switch name {
  4708. case aliyunavatar.FieldUserID:
  4709. return m.AddedUserID()
  4710. case aliyunavatar.FieldTenantID:
  4711. return m.AddedTenantID()
  4712. }
  4713. return nil, false
  4714. }
  4715. // AddField adds the value to the field with the given name. It returns an error if
  4716. // the field is not defined in the schema, or if the type mismatched the field
  4717. // type.
  4718. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  4719. switch name {
  4720. case aliyunavatar.FieldUserID:
  4721. v, ok := value.(int64)
  4722. if !ok {
  4723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4724. }
  4725. m.AddUserID(v)
  4726. return nil
  4727. case aliyunavatar.FieldTenantID:
  4728. v, ok := value.(int64)
  4729. if !ok {
  4730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4731. }
  4732. m.AddTenantID(v)
  4733. return nil
  4734. }
  4735. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  4736. }
  4737. // ClearedFields returns all nullable fields that were cleared during this
  4738. // mutation.
  4739. func (m *AliyunAvatarMutation) ClearedFields() []string {
  4740. var fields []string
  4741. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  4742. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4743. }
  4744. if m.FieldCleared(aliyunavatar.FieldAppID) {
  4745. fields = append(fields, aliyunavatar.FieldAppID)
  4746. }
  4747. return fields
  4748. }
  4749. // FieldCleared returns a boolean indicating if a field with the given name was
  4750. // cleared in this mutation.
  4751. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  4752. _, ok := m.clearedFields[name]
  4753. return ok
  4754. }
  4755. // ClearField clears the value of the field with the given name. It returns an
  4756. // error if the field is not defined in the schema.
  4757. func (m *AliyunAvatarMutation) ClearField(name string) error {
  4758. switch name {
  4759. case aliyunavatar.FieldDeletedAt:
  4760. m.ClearDeletedAt()
  4761. return nil
  4762. case aliyunavatar.FieldAppID:
  4763. m.ClearAppID()
  4764. return nil
  4765. }
  4766. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  4767. }
  4768. // ResetField resets all changes in the mutation for the field with the given name.
  4769. // It returns an error if the field is not defined in the schema.
  4770. func (m *AliyunAvatarMutation) ResetField(name string) error {
  4771. switch name {
  4772. case aliyunavatar.FieldCreatedAt:
  4773. m.ResetCreatedAt()
  4774. return nil
  4775. case aliyunavatar.FieldUpdatedAt:
  4776. m.ResetUpdatedAt()
  4777. return nil
  4778. case aliyunavatar.FieldDeletedAt:
  4779. m.ResetDeletedAt()
  4780. return nil
  4781. case aliyunavatar.FieldUserID:
  4782. m.ResetUserID()
  4783. return nil
  4784. case aliyunavatar.FieldBizID:
  4785. m.ResetBizID()
  4786. return nil
  4787. case aliyunavatar.FieldAccessKeyID:
  4788. m.ResetAccessKeyID()
  4789. return nil
  4790. case aliyunavatar.FieldAccessKeySecret:
  4791. m.ResetAccessKeySecret()
  4792. return nil
  4793. case aliyunavatar.FieldAppID:
  4794. m.ResetAppID()
  4795. return nil
  4796. case aliyunavatar.FieldTenantID:
  4797. m.ResetTenantID()
  4798. return nil
  4799. case aliyunavatar.FieldResponse:
  4800. m.ResetResponse()
  4801. return nil
  4802. case aliyunavatar.FieldToken:
  4803. m.ResetToken()
  4804. return nil
  4805. case aliyunavatar.FieldSessionID:
  4806. m.ResetSessionID()
  4807. return nil
  4808. }
  4809. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4810. }
  4811. // AddedEdges returns all edge names that were set/added in this mutation.
  4812. func (m *AliyunAvatarMutation) AddedEdges() []string {
  4813. edges := make([]string, 0, 0)
  4814. return edges
  4815. }
  4816. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4817. // name in this mutation.
  4818. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  4819. return nil
  4820. }
  4821. // RemovedEdges returns all edge names that were removed in this mutation.
  4822. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  4823. edges := make([]string, 0, 0)
  4824. return edges
  4825. }
  4826. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4827. // the given name in this mutation.
  4828. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  4829. return nil
  4830. }
  4831. // ClearedEdges returns all edge names that were cleared in this mutation.
  4832. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  4833. edges := make([]string, 0, 0)
  4834. return edges
  4835. }
  4836. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4837. // was cleared in this mutation.
  4838. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  4839. return false
  4840. }
  4841. // ClearEdge clears the value of the edge with the given name. It returns an error
  4842. // if that edge is not defined in the schema.
  4843. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  4844. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  4845. }
  4846. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4847. // It returns an error if the edge is not defined in the schema.
  4848. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  4849. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  4850. }
  4851. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  4852. type AllocAgentMutation struct {
  4853. config
  4854. op Op
  4855. typ string
  4856. id *uint64
  4857. created_at *time.Time
  4858. updated_at *time.Time
  4859. deleted_at *time.Time
  4860. user_id *string
  4861. organization_id *uint64
  4862. addorganization_id *int64
  4863. agents *[]uint64
  4864. appendagents []uint64
  4865. status *int
  4866. addstatus *int
  4867. clearedFields map[string]struct{}
  4868. done bool
  4869. oldValue func(context.Context) (*AllocAgent, error)
  4870. predicates []predicate.AllocAgent
  4871. }
  4872. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  4873. // allocagentOption allows management of the mutation configuration using functional options.
  4874. type allocagentOption func(*AllocAgentMutation)
  4875. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  4876. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  4877. m := &AllocAgentMutation{
  4878. config: c,
  4879. op: op,
  4880. typ: TypeAllocAgent,
  4881. clearedFields: make(map[string]struct{}),
  4882. }
  4883. for _, opt := range opts {
  4884. opt(m)
  4885. }
  4886. return m
  4887. }
  4888. // withAllocAgentID sets the ID field of the mutation.
  4889. func withAllocAgentID(id uint64) allocagentOption {
  4890. return func(m *AllocAgentMutation) {
  4891. var (
  4892. err error
  4893. once sync.Once
  4894. value *AllocAgent
  4895. )
  4896. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  4897. once.Do(func() {
  4898. if m.done {
  4899. err = errors.New("querying old values post mutation is not allowed")
  4900. } else {
  4901. value, err = m.Client().AllocAgent.Get(ctx, id)
  4902. }
  4903. })
  4904. return value, err
  4905. }
  4906. m.id = &id
  4907. }
  4908. }
  4909. // withAllocAgent sets the old AllocAgent of the mutation.
  4910. func withAllocAgent(node *AllocAgent) allocagentOption {
  4911. return func(m *AllocAgentMutation) {
  4912. m.oldValue = func(context.Context) (*AllocAgent, error) {
  4913. return node, nil
  4914. }
  4915. m.id = &node.ID
  4916. }
  4917. }
  4918. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4919. // executed in a transaction (ent.Tx), a transactional client is returned.
  4920. func (m AllocAgentMutation) Client() *Client {
  4921. client := &Client{config: m.config}
  4922. client.init()
  4923. return client
  4924. }
  4925. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4926. // it returns an error otherwise.
  4927. func (m AllocAgentMutation) Tx() (*Tx, error) {
  4928. if _, ok := m.driver.(*txDriver); !ok {
  4929. return nil, errors.New("ent: mutation is not running in a transaction")
  4930. }
  4931. tx := &Tx{config: m.config}
  4932. tx.init()
  4933. return tx, nil
  4934. }
  4935. // SetID sets the value of the id field. Note that this
  4936. // operation is only accepted on creation of AllocAgent entities.
  4937. func (m *AllocAgentMutation) SetID(id uint64) {
  4938. m.id = &id
  4939. }
  4940. // ID returns the ID value in the mutation. Note that the ID is only available
  4941. // if it was provided to the builder or after it was returned from the database.
  4942. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  4943. if m.id == nil {
  4944. return
  4945. }
  4946. return *m.id, true
  4947. }
  4948. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4949. // That means, if the mutation is applied within a transaction with an isolation level such
  4950. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4951. // or updated by the mutation.
  4952. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  4953. switch {
  4954. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4955. id, exists := m.ID()
  4956. if exists {
  4957. return []uint64{id}, nil
  4958. }
  4959. fallthrough
  4960. case m.op.Is(OpUpdate | OpDelete):
  4961. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  4962. default:
  4963. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4964. }
  4965. }
  4966. // SetCreatedAt sets the "created_at" field.
  4967. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  4968. m.created_at = &t
  4969. }
  4970. // CreatedAt returns the value of the "created_at" field in the mutation.
  4971. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  4972. v := m.created_at
  4973. if v == nil {
  4974. return
  4975. }
  4976. return *v, true
  4977. }
  4978. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  4979. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4981. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4982. if !m.op.Is(OpUpdateOne) {
  4983. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4984. }
  4985. if m.id == nil || m.oldValue == nil {
  4986. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4987. }
  4988. oldValue, err := m.oldValue(ctx)
  4989. if err != nil {
  4990. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4991. }
  4992. return oldValue.CreatedAt, nil
  4993. }
  4994. // ResetCreatedAt resets all changes to the "created_at" field.
  4995. func (m *AllocAgentMutation) ResetCreatedAt() {
  4996. m.created_at = nil
  4997. }
  4998. // SetUpdatedAt sets the "updated_at" field.
  4999. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  5000. m.updated_at = &t
  5001. }
  5002. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5003. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  5004. v := m.updated_at
  5005. if v == nil {
  5006. return
  5007. }
  5008. return *v, true
  5009. }
  5010. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  5011. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5013. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5014. if !m.op.Is(OpUpdateOne) {
  5015. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5016. }
  5017. if m.id == nil || m.oldValue == nil {
  5018. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5019. }
  5020. oldValue, err := m.oldValue(ctx)
  5021. if err != nil {
  5022. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5023. }
  5024. return oldValue.UpdatedAt, nil
  5025. }
  5026. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5027. func (m *AllocAgentMutation) ResetUpdatedAt() {
  5028. m.updated_at = nil
  5029. }
  5030. // SetDeletedAt sets the "deleted_at" field.
  5031. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  5032. m.deleted_at = &t
  5033. }
  5034. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5035. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  5036. v := m.deleted_at
  5037. if v == nil {
  5038. return
  5039. }
  5040. return *v, true
  5041. }
  5042. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  5043. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5045. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5046. if !m.op.Is(OpUpdateOne) {
  5047. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5048. }
  5049. if m.id == nil || m.oldValue == nil {
  5050. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5051. }
  5052. oldValue, err := m.oldValue(ctx)
  5053. if err != nil {
  5054. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5055. }
  5056. return oldValue.DeletedAt, nil
  5057. }
  5058. // ClearDeletedAt clears the value of the "deleted_at" field.
  5059. func (m *AllocAgentMutation) ClearDeletedAt() {
  5060. m.deleted_at = nil
  5061. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  5062. }
  5063. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5064. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  5065. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  5066. return ok
  5067. }
  5068. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5069. func (m *AllocAgentMutation) ResetDeletedAt() {
  5070. m.deleted_at = nil
  5071. delete(m.clearedFields, allocagent.FieldDeletedAt)
  5072. }
  5073. // SetUserID sets the "user_id" field.
  5074. func (m *AllocAgentMutation) SetUserID(s string) {
  5075. m.user_id = &s
  5076. }
  5077. // UserID returns the value of the "user_id" field in the mutation.
  5078. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  5079. v := m.user_id
  5080. if v == nil {
  5081. return
  5082. }
  5083. return *v, true
  5084. }
  5085. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  5086. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5088. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  5089. if !m.op.Is(OpUpdateOne) {
  5090. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5091. }
  5092. if m.id == nil || m.oldValue == nil {
  5093. return v, errors.New("OldUserID requires an ID field in the mutation")
  5094. }
  5095. oldValue, err := m.oldValue(ctx)
  5096. if err != nil {
  5097. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5098. }
  5099. return oldValue.UserID, nil
  5100. }
  5101. // ClearUserID clears the value of the "user_id" field.
  5102. func (m *AllocAgentMutation) ClearUserID() {
  5103. m.user_id = nil
  5104. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  5105. }
  5106. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  5107. func (m *AllocAgentMutation) UserIDCleared() bool {
  5108. _, ok := m.clearedFields[allocagent.FieldUserID]
  5109. return ok
  5110. }
  5111. // ResetUserID resets all changes to the "user_id" field.
  5112. func (m *AllocAgentMutation) ResetUserID() {
  5113. m.user_id = nil
  5114. delete(m.clearedFields, allocagent.FieldUserID)
  5115. }
  5116. // SetOrganizationID sets the "organization_id" field.
  5117. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  5118. m.organization_id = &u
  5119. m.addorganization_id = nil
  5120. }
  5121. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5122. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  5123. v := m.organization_id
  5124. if v == nil {
  5125. return
  5126. }
  5127. return *v, true
  5128. }
  5129. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  5130. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5132. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5133. if !m.op.Is(OpUpdateOne) {
  5134. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5135. }
  5136. if m.id == nil || m.oldValue == nil {
  5137. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5138. }
  5139. oldValue, err := m.oldValue(ctx)
  5140. if err != nil {
  5141. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5142. }
  5143. return oldValue.OrganizationID, nil
  5144. }
  5145. // AddOrganizationID adds u to the "organization_id" field.
  5146. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  5147. if m.addorganization_id != nil {
  5148. *m.addorganization_id += u
  5149. } else {
  5150. m.addorganization_id = &u
  5151. }
  5152. }
  5153. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5154. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  5155. v := m.addorganization_id
  5156. if v == nil {
  5157. return
  5158. }
  5159. return *v, true
  5160. }
  5161. // ClearOrganizationID clears the value of the "organization_id" field.
  5162. func (m *AllocAgentMutation) ClearOrganizationID() {
  5163. m.organization_id = nil
  5164. m.addorganization_id = nil
  5165. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  5166. }
  5167. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5168. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  5169. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  5170. return ok
  5171. }
  5172. // ResetOrganizationID resets all changes to the "organization_id" field.
  5173. func (m *AllocAgentMutation) ResetOrganizationID() {
  5174. m.organization_id = nil
  5175. m.addorganization_id = nil
  5176. delete(m.clearedFields, allocagent.FieldOrganizationID)
  5177. }
  5178. // SetAgents sets the "agents" field.
  5179. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  5180. m.agents = &u
  5181. m.appendagents = nil
  5182. }
  5183. // Agents returns the value of the "agents" field in the mutation.
  5184. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  5185. v := m.agents
  5186. if v == nil {
  5187. return
  5188. }
  5189. return *v, true
  5190. }
  5191. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  5192. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5194. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  5195. if !m.op.Is(OpUpdateOne) {
  5196. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  5197. }
  5198. if m.id == nil || m.oldValue == nil {
  5199. return v, errors.New("OldAgents requires an ID field in the mutation")
  5200. }
  5201. oldValue, err := m.oldValue(ctx)
  5202. if err != nil {
  5203. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  5204. }
  5205. return oldValue.Agents, nil
  5206. }
  5207. // AppendAgents adds u to the "agents" field.
  5208. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  5209. m.appendagents = append(m.appendagents, u...)
  5210. }
  5211. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  5212. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  5213. if len(m.appendagents) == 0 {
  5214. return nil, false
  5215. }
  5216. return m.appendagents, true
  5217. }
  5218. // ResetAgents resets all changes to the "agents" field.
  5219. func (m *AllocAgentMutation) ResetAgents() {
  5220. m.agents = nil
  5221. m.appendagents = nil
  5222. }
  5223. // SetStatus sets the "status" field.
  5224. func (m *AllocAgentMutation) SetStatus(i int) {
  5225. m.status = &i
  5226. m.addstatus = nil
  5227. }
  5228. // Status returns the value of the "status" field in the mutation.
  5229. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  5230. v := m.status
  5231. if v == nil {
  5232. return
  5233. }
  5234. return *v, true
  5235. }
  5236. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  5237. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5239. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  5240. if !m.op.Is(OpUpdateOne) {
  5241. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5242. }
  5243. if m.id == nil || m.oldValue == nil {
  5244. return v, errors.New("OldStatus requires an ID field in the mutation")
  5245. }
  5246. oldValue, err := m.oldValue(ctx)
  5247. if err != nil {
  5248. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5249. }
  5250. return oldValue.Status, nil
  5251. }
  5252. // AddStatus adds i to the "status" field.
  5253. func (m *AllocAgentMutation) AddStatus(i int) {
  5254. if m.addstatus != nil {
  5255. *m.addstatus += i
  5256. } else {
  5257. m.addstatus = &i
  5258. }
  5259. }
  5260. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5261. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  5262. v := m.addstatus
  5263. if v == nil {
  5264. return
  5265. }
  5266. return *v, true
  5267. }
  5268. // ClearStatus clears the value of the "status" field.
  5269. func (m *AllocAgentMutation) ClearStatus() {
  5270. m.status = nil
  5271. m.addstatus = nil
  5272. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  5273. }
  5274. // StatusCleared returns if the "status" field was cleared in this mutation.
  5275. func (m *AllocAgentMutation) StatusCleared() bool {
  5276. _, ok := m.clearedFields[allocagent.FieldStatus]
  5277. return ok
  5278. }
  5279. // ResetStatus resets all changes to the "status" field.
  5280. func (m *AllocAgentMutation) ResetStatus() {
  5281. m.status = nil
  5282. m.addstatus = nil
  5283. delete(m.clearedFields, allocagent.FieldStatus)
  5284. }
  5285. // Where appends a list predicates to the AllocAgentMutation builder.
  5286. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  5287. m.predicates = append(m.predicates, ps...)
  5288. }
  5289. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  5290. // users can use type-assertion to append predicates that do not depend on any generated package.
  5291. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  5292. p := make([]predicate.AllocAgent, len(ps))
  5293. for i := range ps {
  5294. p[i] = ps[i]
  5295. }
  5296. m.Where(p...)
  5297. }
  5298. // Op returns the operation name.
  5299. func (m *AllocAgentMutation) Op() Op {
  5300. return m.op
  5301. }
  5302. // SetOp allows setting the mutation operation.
  5303. func (m *AllocAgentMutation) SetOp(op Op) {
  5304. m.op = op
  5305. }
  5306. // Type returns the node type of this mutation (AllocAgent).
  5307. func (m *AllocAgentMutation) Type() string {
  5308. return m.typ
  5309. }
  5310. // Fields returns all fields that were changed during this mutation. Note that in
  5311. // order to get all numeric fields that were incremented/decremented, call
  5312. // AddedFields().
  5313. func (m *AllocAgentMutation) Fields() []string {
  5314. fields := make([]string, 0, 7)
  5315. if m.created_at != nil {
  5316. fields = append(fields, allocagent.FieldCreatedAt)
  5317. }
  5318. if m.updated_at != nil {
  5319. fields = append(fields, allocagent.FieldUpdatedAt)
  5320. }
  5321. if m.deleted_at != nil {
  5322. fields = append(fields, allocagent.FieldDeletedAt)
  5323. }
  5324. if m.user_id != nil {
  5325. fields = append(fields, allocagent.FieldUserID)
  5326. }
  5327. if m.organization_id != nil {
  5328. fields = append(fields, allocagent.FieldOrganizationID)
  5329. }
  5330. if m.agents != nil {
  5331. fields = append(fields, allocagent.FieldAgents)
  5332. }
  5333. if m.status != nil {
  5334. fields = append(fields, allocagent.FieldStatus)
  5335. }
  5336. return fields
  5337. }
  5338. // Field returns the value of a field with the given name. The second boolean
  5339. // return value indicates that this field was not set, or was not defined in the
  5340. // schema.
  5341. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  5342. switch name {
  5343. case allocagent.FieldCreatedAt:
  5344. return m.CreatedAt()
  5345. case allocagent.FieldUpdatedAt:
  5346. return m.UpdatedAt()
  5347. case allocagent.FieldDeletedAt:
  5348. return m.DeletedAt()
  5349. case allocagent.FieldUserID:
  5350. return m.UserID()
  5351. case allocagent.FieldOrganizationID:
  5352. return m.OrganizationID()
  5353. case allocagent.FieldAgents:
  5354. return m.Agents()
  5355. case allocagent.FieldStatus:
  5356. return m.Status()
  5357. }
  5358. return nil, false
  5359. }
  5360. // OldField returns the old value of the field from the database. An error is
  5361. // returned if the mutation operation is not UpdateOne, or the query to the
  5362. // database failed.
  5363. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5364. switch name {
  5365. case allocagent.FieldCreatedAt:
  5366. return m.OldCreatedAt(ctx)
  5367. case allocagent.FieldUpdatedAt:
  5368. return m.OldUpdatedAt(ctx)
  5369. case allocagent.FieldDeletedAt:
  5370. return m.OldDeletedAt(ctx)
  5371. case allocagent.FieldUserID:
  5372. return m.OldUserID(ctx)
  5373. case allocagent.FieldOrganizationID:
  5374. return m.OldOrganizationID(ctx)
  5375. case allocagent.FieldAgents:
  5376. return m.OldAgents(ctx)
  5377. case allocagent.FieldStatus:
  5378. return m.OldStatus(ctx)
  5379. }
  5380. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  5381. }
  5382. // SetField sets the value of a field with the given name. It returns an error if
  5383. // the field is not defined in the schema, or if the type mismatched the field
  5384. // type.
  5385. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  5386. switch name {
  5387. case allocagent.FieldCreatedAt:
  5388. v, ok := value.(time.Time)
  5389. if !ok {
  5390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5391. }
  5392. m.SetCreatedAt(v)
  5393. return nil
  5394. case allocagent.FieldUpdatedAt:
  5395. v, ok := value.(time.Time)
  5396. if !ok {
  5397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5398. }
  5399. m.SetUpdatedAt(v)
  5400. return nil
  5401. case allocagent.FieldDeletedAt:
  5402. v, ok := value.(time.Time)
  5403. if !ok {
  5404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5405. }
  5406. m.SetDeletedAt(v)
  5407. return nil
  5408. case allocagent.FieldUserID:
  5409. v, ok := value.(string)
  5410. if !ok {
  5411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5412. }
  5413. m.SetUserID(v)
  5414. return nil
  5415. case allocagent.FieldOrganizationID:
  5416. v, ok := value.(uint64)
  5417. if !ok {
  5418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5419. }
  5420. m.SetOrganizationID(v)
  5421. return nil
  5422. case allocagent.FieldAgents:
  5423. v, ok := value.([]uint64)
  5424. if !ok {
  5425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5426. }
  5427. m.SetAgents(v)
  5428. return nil
  5429. case allocagent.FieldStatus:
  5430. v, ok := value.(int)
  5431. if !ok {
  5432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5433. }
  5434. m.SetStatus(v)
  5435. return nil
  5436. }
  5437. return fmt.Errorf("unknown AllocAgent field %s", name)
  5438. }
  5439. // AddedFields returns all numeric fields that were incremented/decremented during
  5440. // this mutation.
  5441. func (m *AllocAgentMutation) AddedFields() []string {
  5442. var fields []string
  5443. if m.addorganization_id != nil {
  5444. fields = append(fields, allocagent.FieldOrganizationID)
  5445. }
  5446. if m.addstatus != nil {
  5447. fields = append(fields, allocagent.FieldStatus)
  5448. }
  5449. return fields
  5450. }
  5451. // AddedField returns the numeric value that was incremented/decremented on a field
  5452. // with the given name. The second boolean return value indicates that this field
  5453. // was not set, or was not defined in the schema.
  5454. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  5455. switch name {
  5456. case allocagent.FieldOrganizationID:
  5457. return m.AddedOrganizationID()
  5458. case allocagent.FieldStatus:
  5459. return m.AddedStatus()
  5460. }
  5461. return nil, false
  5462. }
  5463. // AddField adds the value to the field with the given name. It returns an error if
  5464. // the field is not defined in the schema, or if the type mismatched the field
  5465. // type.
  5466. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  5467. switch name {
  5468. case allocagent.FieldOrganizationID:
  5469. v, ok := value.(int64)
  5470. if !ok {
  5471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5472. }
  5473. m.AddOrganizationID(v)
  5474. return nil
  5475. case allocagent.FieldStatus:
  5476. v, ok := value.(int)
  5477. if !ok {
  5478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5479. }
  5480. m.AddStatus(v)
  5481. return nil
  5482. }
  5483. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  5484. }
  5485. // ClearedFields returns all nullable fields that were cleared during this
  5486. // mutation.
  5487. func (m *AllocAgentMutation) ClearedFields() []string {
  5488. var fields []string
  5489. if m.FieldCleared(allocagent.FieldDeletedAt) {
  5490. fields = append(fields, allocagent.FieldDeletedAt)
  5491. }
  5492. if m.FieldCleared(allocagent.FieldUserID) {
  5493. fields = append(fields, allocagent.FieldUserID)
  5494. }
  5495. if m.FieldCleared(allocagent.FieldOrganizationID) {
  5496. fields = append(fields, allocagent.FieldOrganizationID)
  5497. }
  5498. if m.FieldCleared(allocagent.FieldStatus) {
  5499. fields = append(fields, allocagent.FieldStatus)
  5500. }
  5501. return fields
  5502. }
  5503. // FieldCleared returns a boolean indicating if a field with the given name was
  5504. // cleared in this mutation.
  5505. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  5506. _, ok := m.clearedFields[name]
  5507. return ok
  5508. }
  5509. // ClearField clears the value of the field with the given name. It returns an
  5510. // error if the field is not defined in the schema.
  5511. func (m *AllocAgentMutation) ClearField(name string) error {
  5512. switch name {
  5513. case allocagent.FieldDeletedAt:
  5514. m.ClearDeletedAt()
  5515. return nil
  5516. case allocagent.FieldUserID:
  5517. m.ClearUserID()
  5518. return nil
  5519. case allocagent.FieldOrganizationID:
  5520. m.ClearOrganizationID()
  5521. return nil
  5522. case allocagent.FieldStatus:
  5523. m.ClearStatus()
  5524. return nil
  5525. }
  5526. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  5527. }
  5528. // ResetField resets all changes in the mutation for the field with the given name.
  5529. // It returns an error if the field is not defined in the schema.
  5530. func (m *AllocAgentMutation) ResetField(name string) error {
  5531. switch name {
  5532. case allocagent.FieldCreatedAt:
  5533. m.ResetCreatedAt()
  5534. return nil
  5535. case allocagent.FieldUpdatedAt:
  5536. m.ResetUpdatedAt()
  5537. return nil
  5538. case allocagent.FieldDeletedAt:
  5539. m.ResetDeletedAt()
  5540. return nil
  5541. case allocagent.FieldUserID:
  5542. m.ResetUserID()
  5543. return nil
  5544. case allocagent.FieldOrganizationID:
  5545. m.ResetOrganizationID()
  5546. return nil
  5547. case allocagent.FieldAgents:
  5548. m.ResetAgents()
  5549. return nil
  5550. case allocagent.FieldStatus:
  5551. m.ResetStatus()
  5552. return nil
  5553. }
  5554. return fmt.Errorf("unknown AllocAgent field %s", name)
  5555. }
  5556. // AddedEdges returns all edge names that were set/added in this mutation.
  5557. func (m *AllocAgentMutation) AddedEdges() []string {
  5558. edges := make([]string, 0, 0)
  5559. return edges
  5560. }
  5561. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5562. // name in this mutation.
  5563. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  5564. return nil
  5565. }
  5566. // RemovedEdges returns all edge names that were removed in this mutation.
  5567. func (m *AllocAgentMutation) RemovedEdges() []string {
  5568. edges := make([]string, 0, 0)
  5569. return edges
  5570. }
  5571. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5572. // the given name in this mutation.
  5573. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  5574. return nil
  5575. }
  5576. // ClearedEdges returns all edge names that were cleared in this mutation.
  5577. func (m *AllocAgentMutation) ClearedEdges() []string {
  5578. edges := make([]string, 0, 0)
  5579. return edges
  5580. }
  5581. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5582. // was cleared in this mutation.
  5583. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  5584. return false
  5585. }
  5586. // ClearEdge clears the value of the edge with the given name. It returns an error
  5587. // if that edge is not defined in the schema.
  5588. func (m *AllocAgentMutation) ClearEdge(name string) error {
  5589. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  5590. }
  5591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5592. // It returns an error if the edge is not defined in the schema.
  5593. func (m *AllocAgentMutation) ResetEdge(name string) error {
  5594. return fmt.Errorf("unknown AllocAgent edge %s", name)
  5595. }
  5596. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  5597. type ApiKeyMutation struct {
  5598. config
  5599. op Op
  5600. typ string
  5601. id *uint64
  5602. created_at *time.Time
  5603. updated_at *time.Time
  5604. deleted_at *time.Time
  5605. title *string
  5606. key *string
  5607. organization_id *uint64
  5608. addorganization_id *int64
  5609. custom_agent_base *string
  5610. custom_agent_key *string
  5611. openai_base *string
  5612. openai_key *string
  5613. clearedFields map[string]struct{}
  5614. agent *uint64
  5615. clearedagent bool
  5616. done bool
  5617. oldValue func(context.Context) (*ApiKey, error)
  5618. predicates []predicate.ApiKey
  5619. }
  5620. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  5621. // apikeyOption allows management of the mutation configuration using functional options.
  5622. type apikeyOption func(*ApiKeyMutation)
  5623. // newApiKeyMutation creates new mutation for the ApiKey entity.
  5624. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  5625. m := &ApiKeyMutation{
  5626. config: c,
  5627. op: op,
  5628. typ: TypeApiKey,
  5629. clearedFields: make(map[string]struct{}),
  5630. }
  5631. for _, opt := range opts {
  5632. opt(m)
  5633. }
  5634. return m
  5635. }
  5636. // withApiKeyID sets the ID field of the mutation.
  5637. func withApiKeyID(id uint64) apikeyOption {
  5638. return func(m *ApiKeyMutation) {
  5639. var (
  5640. err error
  5641. once sync.Once
  5642. value *ApiKey
  5643. )
  5644. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  5645. once.Do(func() {
  5646. if m.done {
  5647. err = errors.New("querying old values post mutation is not allowed")
  5648. } else {
  5649. value, err = m.Client().ApiKey.Get(ctx, id)
  5650. }
  5651. })
  5652. return value, err
  5653. }
  5654. m.id = &id
  5655. }
  5656. }
  5657. // withApiKey sets the old ApiKey of the mutation.
  5658. func withApiKey(node *ApiKey) apikeyOption {
  5659. return func(m *ApiKeyMutation) {
  5660. m.oldValue = func(context.Context) (*ApiKey, error) {
  5661. return node, nil
  5662. }
  5663. m.id = &node.ID
  5664. }
  5665. }
  5666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5667. // executed in a transaction (ent.Tx), a transactional client is returned.
  5668. func (m ApiKeyMutation) Client() *Client {
  5669. client := &Client{config: m.config}
  5670. client.init()
  5671. return client
  5672. }
  5673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5674. // it returns an error otherwise.
  5675. func (m ApiKeyMutation) Tx() (*Tx, error) {
  5676. if _, ok := m.driver.(*txDriver); !ok {
  5677. return nil, errors.New("ent: mutation is not running in a transaction")
  5678. }
  5679. tx := &Tx{config: m.config}
  5680. tx.init()
  5681. return tx, nil
  5682. }
  5683. // SetID sets the value of the id field. Note that this
  5684. // operation is only accepted on creation of ApiKey entities.
  5685. func (m *ApiKeyMutation) SetID(id uint64) {
  5686. m.id = &id
  5687. }
  5688. // ID returns the ID value in the mutation. Note that the ID is only available
  5689. // if it was provided to the builder or after it was returned from the database.
  5690. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  5691. if m.id == nil {
  5692. return
  5693. }
  5694. return *m.id, true
  5695. }
  5696. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5697. // That means, if the mutation is applied within a transaction with an isolation level such
  5698. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5699. // or updated by the mutation.
  5700. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  5701. switch {
  5702. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5703. id, exists := m.ID()
  5704. if exists {
  5705. return []uint64{id}, nil
  5706. }
  5707. fallthrough
  5708. case m.op.Is(OpUpdate | OpDelete):
  5709. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  5710. default:
  5711. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5712. }
  5713. }
  5714. // SetCreatedAt sets the "created_at" field.
  5715. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  5716. m.created_at = &t
  5717. }
  5718. // CreatedAt returns the value of the "created_at" field in the mutation.
  5719. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  5720. v := m.created_at
  5721. if v == nil {
  5722. return
  5723. }
  5724. return *v, true
  5725. }
  5726. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  5727. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5729. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5730. if !m.op.Is(OpUpdateOne) {
  5731. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5732. }
  5733. if m.id == nil || m.oldValue == nil {
  5734. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5735. }
  5736. oldValue, err := m.oldValue(ctx)
  5737. if err != nil {
  5738. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5739. }
  5740. return oldValue.CreatedAt, nil
  5741. }
  5742. // ResetCreatedAt resets all changes to the "created_at" field.
  5743. func (m *ApiKeyMutation) ResetCreatedAt() {
  5744. m.created_at = nil
  5745. }
  5746. // SetUpdatedAt sets the "updated_at" field.
  5747. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  5748. m.updated_at = &t
  5749. }
  5750. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5751. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  5752. v := m.updated_at
  5753. if v == nil {
  5754. return
  5755. }
  5756. return *v, true
  5757. }
  5758. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  5759. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5761. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5762. if !m.op.Is(OpUpdateOne) {
  5763. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5764. }
  5765. if m.id == nil || m.oldValue == nil {
  5766. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5767. }
  5768. oldValue, err := m.oldValue(ctx)
  5769. if err != nil {
  5770. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5771. }
  5772. return oldValue.UpdatedAt, nil
  5773. }
  5774. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5775. func (m *ApiKeyMutation) ResetUpdatedAt() {
  5776. m.updated_at = nil
  5777. }
  5778. // SetDeletedAt sets the "deleted_at" field.
  5779. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  5780. m.deleted_at = &t
  5781. }
  5782. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5783. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  5784. v := m.deleted_at
  5785. if v == nil {
  5786. return
  5787. }
  5788. return *v, true
  5789. }
  5790. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  5791. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5793. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5794. if !m.op.Is(OpUpdateOne) {
  5795. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5796. }
  5797. if m.id == nil || m.oldValue == nil {
  5798. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5799. }
  5800. oldValue, err := m.oldValue(ctx)
  5801. if err != nil {
  5802. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5803. }
  5804. return oldValue.DeletedAt, nil
  5805. }
  5806. // ClearDeletedAt clears the value of the "deleted_at" field.
  5807. func (m *ApiKeyMutation) ClearDeletedAt() {
  5808. m.deleted_at = nil
  5809. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  5810. }
  5811. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5812. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  5813. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  5814. return ok
  5815. }
  5816. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5817. func (m *ApiKeyMutation) ResetDeletedAt() {
  5818. m.deleted_at = nil
  5819. delete(m.clearedFields, apikey.FieldDeletedAt)
  5820. }
  5821. // SetTitle sets the "title" field.
  5822. func (m *ApiKeyMutation) SetTitle(s string) {
  5823. m.title = &s
  5824. }
  5825. // Title returns the value of the "title" field in the mutation.
  5826. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  5827. v := m.title
  5828. if v == nil {
  5829. return
  5830. }
  5831. return *v, true
  5832. }
  5833. // OldTitle returns the old "title" field's value of the ApiKey entity.
  5834. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5836. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  5837. if !m.op.Is(OpUpdateOne) {
  5838. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5839. }
  5840. if m.id == nil || m.oldValue == nil {
  5841. return v, errors.New("OldTitle requires an ID field in the mutation")
  5842. }
  5843. oldValue, err := m.oldValue(ctx)
  5844. if err != nil {
  5845. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5846. }
  5847. return oldValue.Title, nil
  5848. }
  5849. // ClearTitle clears the value of the "title" field.
  5850. func (m *ApiKeyMutation) ClearTitle() {
  5851. m.title = nil
  5852. m.clearedFields[apikey.FieldTitle] = struct{}{}
  5853. }
  5854. // TitleCleared returns if the "title" field was cleared in this mutation.
  5855. func (m *ApiKeyMutation) TitleCleared() bool {
  5856. _, ok := m.clearedFields[apikey.FieldTitle]
  5857. return ok
  5858. }
  5859. // ResetTitle resets all changes to the "title" field.
  5860. func (m *ApiKeyMutation) ResetTitle() {
  5861. m.title = nil
  5862. delete(m.clearedFields, apikey.FieldTitle)
  5863. }
  5864. // SetKey sets the "key" field.
  5865. func (m *ApiKeyMutation) SetKey(s string) {
  5866. m.key = &s
  5867. }
  5868. // Key returns the value of the "key" field in the mutation.
  5869. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  5870. v := m.key
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // OldKey returns the old "key" field's value of the ApiKey entity.
  5877. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5879. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  5880. if !m.op.Is(OpUpdateOne) {
  5881. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  5882. }
  5883. if m.id == nil || m.oldValue == nil {
  5884. return v, errors.New("OldKey requires an ID field in the mutation")
  5885. }
  5886. oldValue, err := m.oldValue(ctx)
  5887. if err != nil {
  5888. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  5889. }
  5890. return oldValue.Key, nil
  5891. }
  5892. // ClearKey clears the value of the "key" field.
  5893. func (m *ApiKeyMutation) ClearKey() {
  5894. m.key = nil
  5895. m.clearedFields[apikey.FieldKey] = struct{}{}
  5896. }
  5897. // KeyCleared returns if the "key" field was cleared in this mutation.
  5898. func (m *ApiKeyMutation) KeyCleared() bool {
  5899. _, ok := m.clearedFields[apikey.FieldKey]
  5900. return ok
  5901. }
  5902. // ResetKey resets all changes to the "key" field.
  5903. func (m *ApiKeyMutation) ResetKey() {
  5904. m.key = nil
  5905. delete(m.clearedFields, apikey.FieldKey)
  5906. }
  5907. // SetOrganizationID sets the "organization_id" field.
  5908. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  5909. m.organization_id = &u
  5910. m.addorganization_id = nil
  5911. }
  5912. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5913. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  5914. v := m.organization_id
  5915. if v == nil {
  5916. return
  5917. }
  5918. return *v, true
  5919. }
  5920. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  5921. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5923. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5924. if !m.op.Is(OpUpdateOne) {
  5925. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5926. }
  5927. if m.id == nil || m.oldValue == nil {
  5928. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5929. }
  5930. oldValue, err := m.oldValue(ctx)
  5931. if err != nil {
  5932. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5933. }
  5934. return oldValue.OrganizationID, nil
  5935. }
  5936. // AddOrganizationID adds u to the "organization_id" field.
  5937. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  5938. if m.addorganization_id != nil {
  5939. *m.addorganization_id += u
  5940. } else {
  5941. m.addorganization_id = &u
  5942. }
  5943. }
  5944. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5945. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  5946. v := m.addorganization_id
  5947. if v == nil {
  5948. return
  5949. }
  5950. return *v, true
  5951. }
  5952. // ResetOrganizationID resets all changes to the "organization_id" field.
  5953. func (m *ApiKeyMutation) ResetOrganizationID() {
  5954. m.organization_id = nil
  5955. m.addorganization_id = nil
  5956. }
  5957. // SetAgentID sets the "agent_id" field.
  5958. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  5959. m.agent = &u
  5960. }
  5961. // AgentID returns the value of the "agent_id" field in the mutation.
  5962. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  5963. v := m.agent
  5964. if v == nil {
  5965. return
  5966. }
  5967. return *v, true
  5968. }
  5969. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  5970. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5972. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  5973. if !m.op.Is(OpUpdateOne) {
  5974. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  5975. }
  5976. if m.id == nil || m.oldValue == nil {
  5977. return v, errors.New("OldAgentID requires an ID field in the mutation")
  5978. }
  5979. oldValue, err := m.oldValue(ctx)
  5980. if err != nil {
  5981. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  5982. }
  5983. return oldValue.AgentID, nil
  5984. }
  5985. // ResetAgentID resets all changes to the "agent_id" field.
  5986. func (m *ApiKeyMutation) ResetAgentID() {
  5987. m.agent = nil
  5988. }
  5989. // SetCustomAgentBase sets the "custom_agent_base" field.
  5990. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  5991. m.custom_agent_base = &s
  5992. }
  5993. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  5994. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  5995. v := m.custom_agent_base
  5996. if v == nil {
  5997. return
  5998. }
  5999. return *v, true
  6000. }
  6001. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  6002. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6004. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  6005. if !m.op.Is(OpUpdateOne) {
  6006. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  6007. }
  6008. if m.id == nil || m.oldValue == nil {
  6009. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  6010. }
  6011. oldValue, err := m.oldValue(ctx)
  6012. if err != nil {
  6013. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  6014. }
  6015. return oldValue.CustomAgentBase, nil
  6016. }
  6017. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  6018. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  6019. m.custom_agent_base = nil
  6020. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  6021. }
  6022. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  6023. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  6024. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  6025. return ok
  6026. }
  6027. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  6028. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  6029. m.custom_agent_base = nil
  6030. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  6031. }
  6032. // SetCustomAgentKey sets the "custom_agent_key" field.
  6033. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  6034. m.custom_agent_key = &s
  6035. }
  6036. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  6037. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  6038. v := m.custom_agent_key
  6039. if v == nil {
  6040. return
  6041. }
  6042. return *v, true
  6043. }
  6044. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  6045. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6047. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  6048. if !m.op.Is(OpUpdateOne) {
  6049. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  6050. }
  6051. if m.id == nil || m.oldValue == nil {
  6052. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  6053. }
  6054. oldValue, err := m.oldValue(ctx)
  6055. if err != nil {
  6056. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  6057. }
  6058. return oldValue.CustomAgentKey, nil
  6059. }
  6060. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  6061. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  6062. m.custom_agent_key = nil
  6063. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  6064. }
  6065. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  6066. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  6067. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  6068. return ok
  6069. }
  6070. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  6071. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  6072. m.custom_agent_key = nil
  6073. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  6074. }
  6075. // SetOpenaiBase sets the "openai_base" field.
  6076. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  6077. m.openai_base = &s
  6078. }
  6079. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  6080. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  6081. v := m.openai_base
  6082. if v == nil {
  6083. return
  6084. }
  6085. return *v, true
  6086. }
  6087. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  6088. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6090. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  6091. if !m.op.Is(OpUpdateOne) {
  6092. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  6093. }
  6094. if m.id == nil || m.oldValue == nil {
  6095. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  6096. }
  6097. oldValue, err := m.oldValue(ctx)
  6098. if err != nil {
  6099. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  6100. }
  6101. return oldValue.OpenaiBase, nil
  6102. }
  6103. // ClearOpenaiBase clears the value of the "openai_base" field.
  6104. func (m *ApiKeyMutation) ClearOpenaiBase() {
  6105. m.openai_base = nil
  6106. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  6107. }
  6108. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  6109. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  6110. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  6111. return ok
  6112. }
  6113. // ResetOpenaiBase resets all changes to the "openai_base" field.
  6114. func (m *ApiKeyMutation) ResetOpenaiBase() {
  6115. m.openai_base = nil
  6116. delete(m.clearedFields, apikey.FieldOpenaiBase)
  6117. }
  6118. // SetOpenaiKey sets the "openai_key" field.
  6119. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  6120. m.openai_key = &s
  6121. }
  6122. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  6123. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  6124. v := m.openai_key
  6125. if v == nil {
  6126. return
  6127. }
  6128. return *v, true
  6129. }
  6130. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  6131. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6133. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  6134. if !m.op.Is(OpUpdateOne) {
  6135. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  6136. }
  6137. if m.id == nil || m.oldValue == nil {
  6138. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  6139. }
  6140. oldValue, err := m.oldValue(ctx)
  6141. if err != nil {
  6142. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  6143. }
  6144. return oldValue.OpenaiKey, nil
  6145. }
  6146. // ClearOpenaiKey clears the value of the "openai_key" field.
  6147. func (m *ApiKeyMutation) ClearOpenaiKey() {
  6148. m.openai_key = nil
  6149. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  6150. }
  6151. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  6152. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  6153. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  6154. return ok
  6155. }
  6156. // ResetOpenaiKey resets all changes to the "openai_key" field.
  6157. func (m *ApiKeyMutation) ResetOpenaiKey() {
  6158. m.openai_key = nil
  6159. delete(m.clearedFields, apikey.FieldOpenaiKey)
  6160. }
  6161. // ClearAgent clears the "agent" edge to the Agent entity.
  6162. func (m *ApiKeyMutation) ClearAgent() {
  6163. m.clearedagent = true
  6164. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  6165. }
  6166. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  6167. func (m *ApiKeyMutation) AgentCleared() bool {
  6168. return m.clearedagent
  6169. }
  6170. // AgentIDs returns the "agent" edge IDs in the mutation.
  6171. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6172. // AgentID instead. It exists only for internal usage by the builders.
  6173. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  6174. if id := m.agent; id != nil {
  6175. ids = append(ids, *id)
  6176. }
  6177. return
  6178. }
  6179. // ResetAgent resets all changes to the "agent" edge.
  6180. func (m *ApiKeyMutation) ResetAgent() {
  6181. m.agent = nil
  6182. m.clearedagent = false
  6183. }
  6184. // Where appends a list predicates to the ApiKeyMutation builder.
  6185. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  6186. m.predicates = append(m.predicates, ps...)
  6187. }
  6188. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  6189. // users can use type-assertion to append predicates that do not depend on any generated package.
  6190. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  6191. p := make([]predicate.ApiKey, len(ps))
  6192. for i := range ps {
  6193. p[i] = ps[i]
  6194. }
  6195. m.Where(p...)
  6196. }
  6197. // Op returns the operation name.
  6198. func (m *ApiKeyMutation) Op() Op {
  6199. return m.op
  6200. }
  6201. // SetOp allows setting the mutation operation.
  6202. func (m *ApiKeyMutation) SetOp(op Op) {
  6203. m.op = op
  6204. }
  6205. // Type returns the node type of this mutation (ApiKey).
  6206. func (m *ApiKeyMutation) Type() string {
  6207. return m.typ
  6208. }
  6209. // Fields returns all fields that were changed during this mutation. Note that in
  6210. // order to get all numeric fields that were incremented/decremented, call
  6211. // AddedFields().
  6212. func (m *ApiKeyMutation) Fields() []string {
  6213. fields := make([]string, 0, 11)
  6214. if m.created_at != nil {
  6215. fields = append(fields, apikey.FieldCreatedAt)
  6216. }
  6217. if m.updated_at != nil {
  6218. fields = append(fields, apikey.FieldUpdatedAt)
  6219. }
  6220. if m.deleted_at != nil {
  6221. fields = append(fields, apikey.FieldDeletedAt)
  6222. }
  6223. if m.title != nil {
  6224. fields = append(fields, apikey.FieldTitle)
  6225. }
  6226. if m.key != nil {
  6227. fields = append(fields, apikey.FieldKey)
  6228. }
  6229. if m.organization_id != nil {
  6230. fields = append(fields, apikey.FieldOrganizationID)
  6231. }
  6232. if m.agent != nil {
  6233. fields = append(fields, apikey.FieldAgentID)
  6234. }
  6235. if m.custom_agent_base != nil {
  6236. fields = append(fields, apikey.FieldCustomAgentBase)
  6237. }
  6238. if m.custom_agent_key != nil {
  6239. fields = append(fields, apikey.FieldCustomAgentKey)
  6240. }
  6241. if m.openai_base != nil {
  6242. fields = append(fields, apikey.FieldOpenaiBase)
  6243. }
  6244. if m.openai_key != nil {
  6245. fields = append(fields, apikey.FieldOpenaiKey)
  6246. }
  6247. return fields
  6248. }
  6249. // Field returns the value of a field with the given name. The second boolean
  6250. // return value indicates that this field was not set, or was not defined in the
  6251. // schema.
  6252. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  6253. switch name {
  6254. case apikey.FieldCreatedAt:
  6255. return m.CreatedAt()
  6256. case apikey.FieldUpdatedAt:
  6257. return m.UpdatedAt()
  6258. case apikey.FieldDeletedAt:
  6259. return m.DeletedAt()
  6260. case apikey.FieldTitle:
  6261. return m.Title()
  6262. case apikey.FieldKey:
  6263. return m.Key()
  6264. case apikey.FieldOrganizationID:
  6265. return m.OrganizationID()
  6266. case apikey.FieldAgentID:
  6267. return m.AgentID()
  6268. case apikey.FieldCustomAgentBase:
  6269. return m.CustomAgentBase()
  6270. case apikey.FieldCustomAgentKey:
  6271. return m.CustomAgentKey()
  6272. case apikey.FieldOpenaiBase:
  6273. return m.OpenaiBase()
  6274. case apikey.FieldOpenaiKey:
  6275. return m.OpenaiKey()
  6276. }
  6277. return nil, false
  6278. }
  6279. // OldField returns the old value of the field from the database. An error is
  6280. // returned if the mutation operation is not UpdateOne, or the query to the
  6281. // database failed.
  6282. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6283. switch name {
  6284. case apikey.FieldCreatedAt:
  6285. return m.OldCreatedAt(ctx)
  6286. case apikey.FieldUpdatedAt:
  6287. return m.OldUpdatedAt(ctx)
  6288. case apikey.FieldDeletedAt:
  6289. return m.OldDeletedAt(ctx)
  6290. case apikey.FieldTitle:
  6291. return m.OldTitle(ctx)
  6292. case apikey.FieldKey:
  6293. return m.OldKey(ctx)
  6294. case apikey.FieldOrganizationID:
  6295. return m.OldOrganizationID(ctx)
  6296. case apikey.FieldAgentID:
  6297. return m.OldAgentID(ctx)
  6298. case apikey.FieldCustomAgentBase:
  6299. return m.OldCustomAgentBase(ctx)
  6300. case apikey.FieldCustomAgentKey:
  6301. return m.OldCustomAgentKey(ctx)
  6302. case apikey.FieldOpenaiBase:
  6303. return m.OldOpenaiBase(ctx)
  6304. case apikey.FieldOpenaiKey:
  6305. return m.OldOpenaiKey(ctx)
  6306. }
  6307. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  6308. }
  6309. // SetField sets the value of a field with the given name. It returns an error if
  6310. // the field is not defined in the schema, or if the type mismatched the field
  6311. // type.
  6312. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  6313. switch name {
  6314. case apikey.FieldCreatedAt:
  6315. v, ok := value.(time.Time)
  6316. if !ok {
  6317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6318. }
  6319. m.SetCreatedAt(v)
  6320. return nil
  6321. case apikey.FieldUpdatedAt:
  6322. v, ok := value.(time.Time)
  6323. if !ok {
  6324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6325. }
  6326. m.SetUpdatedAt(v)
  6327. return nil
  6328. case apikey.FieldDeletedAt:
  6329. v, ok := value.(time.Time)
  6330. if !ok {
  6331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6332. }
  6333. m.SetDeletedAt(v)
  6334. return nil
  6335. case apikey.FieldTitle:
  6336. v, ok := value.(string)
  6337. if !ok {
  6338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6339. }
  6340. m.SetTitle(v)
  6341. return nil
  6342. case apikey.FieldKey:
  6343. v, ok := value.(string)
  6344. if !ok {
  6345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6346. }
  6347. m.SetKey(v)
  6348. return nil
  6349. case apikey.FieldOrganizationID:
  6350. v, ok := value.(uint64)
  6351. if !ok {
  6352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6353. }
  6354. m.SetOrganizationID(v)
  6355. return nil
  6356. case apikey.FieldAgentID:
  6357. v, ok := value.(uint64)
  6358. if !ok {
  6359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6360. }
  6361. m.SetAgentID(v)
  6362. return nil
  6363. case apikey.FieldCustomAgentBase:
  6364. v, ok := value.(string)
  6365. if !ok {
  6366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6367. }
  6368. m.SetCustomAgentBase(v)
  6369. return nil
  6370. case apikey.FieldCustomAgentKey:
  6371. v, ok := value.(string)
  6372. if !ok {
  6373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6374. }
  6375. m.SetCustomAgentKey(v)
  6376. return nil
  6377. case apikey.FieldOpenaiBase:
  6378. v, ok := value.(string)
  6379. if !ok {
  6380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6381. }
  6382. m.SetOpenaiBase(v)
  6383. return nil
  6384. case apikey.FieldOpenaiKey:
  6385. v, ok := value.(string)
  6386. if !ok {
  6387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6388. }
  6389. m.SetOpenaiKey(v)
  6390. return nil
  6391. }
  6392. return fmt.Errorf("unknown ApiKey field %s", name)
  6393. }
  6394. // AddedFields returns all numeric fields that were incremented/decremented during
  6395. // this mutation.
  6396. func (m *ApiKeyMutation) AddedFields() []string {
  6397. var fields []string
  6398. if m.addorganization_id != nil {
  6399. fields = append(fields, apikey.FieldOrganizationID)
  6400. }
  6401. return fields
  6402. }
  6403. // AddedField returns the numeric value that was incremented/decremented on a field
  6404. // with the given name. The second boolean return value indicates that this field
  6405. // was not set, or was not defined in the schema.
  6406. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  6407. switch name {
  6408. case apikey.FieldOrganizationID:
  6409. return m.AddedOrganizationID()
  6410. }
  6411. return nil, false
  6412. }
  6413. // AddField adds the value to the field with the given name. It returns an error if
  6414. // the field is not defined in the schema, or if the type mismatched the field
  6415. // type.
  6416. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  6417. switch name {
  6418. case apikey.FieldOrganizationID:
  6419. v, ok := value.(int64)
  6420. if !ok {
  6421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6422. }
  6423. m.AddOrganizationID(v)
  6424. return nil
  6425. }
  6426. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  6427. }
  6428. // ClearedFields returns all nullable fields that were cleared during this
  6429. // mutation.
  6430. func (m *ApiKeyMutation) ClearedFields() []string {
  6431. var fields []string
  6432. if m.FieldCleared(apikey.FieldDeletedAt) {
  6433. fields = append(fields, apikey.FieldDeletedAt)
  6434. }
  6435. if m.FieldCleared(apikey.FieldTitle) {
  6436. fields = append(fields, apikey.FieldTitle)
  6437. }
  6438. if m.FieldCleared(apikey.FieldKey) {
  6439. fields = append(fields, apikey.FieldKey)
  6440. }
  6441. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  6442. fields = append(fields, apikey.FieldCustomAgentBase)
  6443. }
  6444. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  6445. fields = append(fields, apikey.FieldCustomAgentKey)
  6446. }
  6447. if m.FieldCleared(apikey.FieldOpenaiBase) {
  6448. fields = append(fields, apikey.FieldOpenaiBase)
  6449. }
  6450. if m.FieldCleared(apikey.FieldOpenaiKey) {
  6451. fields = append(fields, apikey.FieldOpenaiKey)
  6452. }
  6453. return fields
  6454. }
  6455. // FieldCleared returns a boolean indicating if a field with the given name was
  6456. // cleared in this mutation.
  6457. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  6458. _, ok := m.clearedFields[name]
  6459. return ok
  6460. }
  6461. // ClearField clears the value of the field with the given name. It returns an
  6462. // error if the field is not defined in the schema.
  6463. func (m *ApiKeyMutation) ClearField(name string) error {
  6464. switch name {
  6465. case apikey.FieldDeletedAt:
  6466. m.ClearDeletedAt()
  6467. return nil
  6468. case apikey.FieldTitle:
  6469. m.ClearTitle()
  6470. return nil
  6471. case apikey.FieldKey:
  6472. m.ClearKey()
  6473. return nil
  6474. case apikey.FieldCustomAgentBase:
  6475. m.ClearCustomAgentBase()
  6476. return nil
  6477. case apikey.FieldCustomAgentKey:
  6478. m.ClearCustomAgentKey()
  6479. return nil
  6480. case apikey.FieldOpenaiBase:
  6481. m.ClearOpenaiBase()
  6482. return nil
  6483. case apikey.FieldOpenaiKey:
  6484. m.ClearOpenaiKey()
  6485. return nil
  6486. }
  6487. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  6488. }
  6489. // ResetField resets all changes in the mutation for the field with the given name.
  6490. // It returns an error if the field is not defined in the schema.
  6491. func (m *ApiKeyMutation) ResetField(name string) error {
  6492. switch name {
  6493. case apikey.FieldCreatedAt:
  6494. m.ResetCreatedAt()
  6495. return nil
  6496. case apikey.FieldUpdatedAt:
  6497. m.ResetUpdatedAt()
  6498. return nil
  6499. case apikey.FieldDeletedAt:
  6500. m.ResetDeletedAt()
  6501. return nil
  6502. case apikey.FieldTitle:
  6503. m.ResetTitle()
  6504. return nil
  6505. case apikey.FieldKey:
  6506. m.ResetKey()
  6507. return nil
  6508. case apikey.FieldOrganizationID:
  6509. m.ResetOrganizationID()
  6510. return nil
  6511. case apikey.FieldAgentID:
  6512. m.ResetAgentID()
  6513. return nil
  6514. case apikey.FieldCustomAgentBase:
  6515. m.ResetCustomAgentBase()
  6516. return nil
  6517. case apikey.FieldCustomAgentKey:
  6518. m.ResetCustomAgentKey()
  6519. return nil
  6520. case apikey.FieldOpenaiBase:
  6521. m.ResetOpenaiBase()
  6522. return nil
  6523. case apikey.FieldOpenaiKey:
  6524. m.ResetOpenaiKey()
  6525. return nil
  6526. }
  6527. return fmt.Errorf("unknown ApiKey field %s", name)
  6528. }
  6529. // AddedEdges returns all edge names that were set/added in this mutation.
  6530. func (m *ApiKeyMutation) AddedEdges() []string {
  6531. edges := make([]string, 0, 1)
  6532. if m.agent != nil {
  6533. edges = append(edges, apikey.EdgeAgent)
  6534. }
  6535. return edges
  6536. }
  6537. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6538. // name in this mutation.
  6539. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  6540. switch name {
  6541. case apikey.EdgeAgent:
  6542. if id := m.agent; id != nil {
  6543. return []ent.Value{*id}
  6544. }
  6545. }
  6546. return nil
  6547. }
  6548. // RemovedEdges returns all edge names that were removed in this mutation.
  6549. func (m *ApiKeyMutation) RemovedEdges() []string {
  6550. edges := make([]string, 0, 1)
  6551. return edges
  6552. }
  6553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6554. // the given name in this mutation.
  6555. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  6556. return nil
  6557. }
  6558. // ClearedEdges returns all edge names that were cleared in this mutation.
  6559. func (m *ApiKeyMutation) ClearedEdges() []string {
  6560. edges := make([]string, 0, 1)
  6561. if m.clearedagent {
  6562. edges = append(edges, apikey.EdgeAgent)
  6563. }
  6564. return edges
  6565. }
  6566. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6567. // was cleared in this mutation.
  6568. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  6569. switch name {
  6570. case apikey.EdgeAgent:
  6571. return m.clearedagent
  6572. }
  6573. return false
  6574. }
  6575. // ClearEdge clears the value of the edge with the given name. It returns an error
  6576. // if that edge is not defined in the schema.
  6577. func (m *ApiKeyMutation) ClearEdge(name string) error {
  6578. switch name {
  6579. case apikey.EdgeAgent:
  6580. m.ClearAgent()
  6581. return nil
  6582. }
  6583. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  6584. }
  6585. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6586. // It returns an error if the edge is not defined in the schema.
  6587. func (m *ApiKeyMutation) ResetEdge(name string) error {
  6588. switch name {
  6589. case apikey.EdgeAgent:
  6590. m.ResetAgent()
  6591. return nil
  6592. }
  6593. return fmt.Errorf("unknown ApiKey edge %s", name)
  6594. }
  6595. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  6596. type BatchMsgMutation struct {
  6597. config
  6598. op Op
  6599. typ string
  6600. id *uint64
  6601. created_at *time.Time
  6602. updated_at *time.Time
  6603. deleted_at *time.Time
  6604. status *uint8
  6605. addstatus *int8
  6606. batch_no *string
  6607. task_name *string
  6608. fromwxid *string
  6609. msg *string
  6610. tag *string
  6611. tagids *string
  6612. total *int32
  6613. addtotal *int32
  6614. success *int32
  6615. addsuccess *int32
  6616. fail *int32
  6617. addfail *int32
  6618. start_time *time.Time
  6619. stop_time *time.Time
  6620. send_time *time.Time
  6621. _type *int32
  6622. add_type *int32
  6623. organization_id *uint64
  6624. addorganization_id *int64
  6625. ctype *uint64
  6626. addctype *int64
  6627. cc *string
  6628. phone *string
  6629. template_name *string
  6630. template_code *string
  6631. lang *string
  6632. clearedFields map[string]struct{}
  6633. done bool
  6634. oldValue func(context.Context) (*BatchMsg, error)
  6635. predicates []predicate.BatchMsg
  6636. }
  6637. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  6638. // batchmsgOption allows management of the mutation configuration using functional options.
  6639. type batchmsgOption func(*BatchMsgMutation)
  6640. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  6641. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  6642. m := &BatchMsgMutation{
  6643. config: c,
  6644. op: op,
  6645. typ: TypeBatchMsg,
  6646. clearedFields: make(map[string]struct{}),
  6647. }
  6648. for _, opt := range opts {
  6649. opt(m)
  6650. }
  6651. return m
  6652. }
  6653. // withBatchMsgID sets the ID field of the mutation.
  6654. func withBatchMsgID(id uint64) batchmsgOption {
  6655. return func(m *BatchMsgMutation) {
  6656. var (
  6657. err error
  6658. once sync.Once
  6659. value *BatchMsg
  6660. )
  6661. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  6662. once.Do(func() {
  6663. if m.done {
  6664. err = errors.New("querying old values post mutation is not allowed")
  6665. } else {
  6666. value, err = m.Client().BatchMsg.Get(ctx, id)
  6667. }
  6668. })
  6669. return value, err
  6670. }
  6671. m.id = &id
  6672. }
  6673. }
  6674. // withBatchMsg sets the old BatchMsg of the mutation.
  6675. func withBatchMsg(node *BatchMsg) batchmsgOption {
  6676. return func(m *BatchMsgMutation) {
  6677. m.oldValue = func(context.Context) (*BatchMsg, error) {
  6678. return node, nil
  6679. }
  6680. m.id = &node.ID
  6681. }
  6682. }
  6683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6684. // executed in a transaction (ent.Tx), a transactional client is returned.
  6685. func (m BatchMsgMutation) Client() *Client {
  6686. client := &Client{config: m.config}
  6687. client.init()
  6688. return client
  6689. }
  6690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6691. // it returns an error otherwise.
  6692. func (m BatchMsgMutation) Tx() (*Tx, error) {
  6693. if _, ok := m.driver.(*txDriver); !ok {
  6694. return nil, errors.New("ent: mutation is not running in a transaction")
  6695. }
  6696. tx := &Tx{config: m.config}
  6697. tx.init()
  6698. return tx, nil
  6699. }
  6700. // SetID sets the value of the id field. Note that this
  6701. // operation is only accepted on creation of BatchMsg entities.
  6702. func (m *BatchMsgMutation) SetID(id uint64) {
  6703. m.id = &id
  6704. }
  6705. // ID returns the ID value in the mutation. Note that the ID is only available
  6706. // if it was provided to the builder or after it was returned from the database.
  6707. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  6708. if m.id == nil {
  6709. return
  6710. }
  6711. return *m.id, true
  6712. }
  6713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6714. // That means, if the mutation is applied within a transaction with an isolation level such
  6715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6716. // or updated by the mutation.
  6717. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  6718. switch {
  6719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6720. id, exists := m.ID()
  6721. if exists {
  6722. return []uint64{id}, nil
  6723. }
  6724. fallthrough
  6725. case m.op.Is(OpUpdate | OpDelete):
  6726. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  6727. default:
  6728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6729. }
  6730. }
  6731. // SetCreatedAt sets the "created_at" field.
  6732. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  6733. m.created_at = &t
  6734. }
  6735. // CreatedAt returns the value of the "created_at" field in the mutation.
  6736. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  6737. v := m.created_at
  6738. if v == nil {
  6739. return
  6740. }
  6741. return *v, true
  6742. }
  6743. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  6744. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6746. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6747. if !m.op.Is(OpUpdateOne) {
  6748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6749. }
  6750. if m.id == nil || m.oldValue == nil {
  6751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6752. }
  6753. oldValue, err := m.oldValue(ctx)
  6754. if err != nil {
  6755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6756. }
  6757. return oldValue.CreatedAt, nil
  6758. }
  6759. // ResetCreatedAt resets all changes to the "created_at" field.
  6760. func (m *BatchMsgMutation) ResetCreatedAt() {
  6761. m.created_at = nil
  6762. }
  6763. // SetUpdatedAt sets the "updated_at" field.
  6764. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  6765. m.updated_at = &t
  6766. }
  6767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6768. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  6769. v := m.updated_at
  6770. if v == nil {
  6771. return
  6772. }
  6773. return *v, true
  6774. }
  6775. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  6776. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6778. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6779. if !m.op.Is(OpUpdateOne) {
  6780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6781. }
  6782. if m.id == nil || m.oldValue == nil {
  6783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6784. }
  6785. oldValue, err := m.oldValue(ctx)
  6786. if err != nil {
  6787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6788. }
  6789. return oldValue.UpdatedAt, nil
  6790. }
  6791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6792. func (m *BatchMsgMutation) ResetUpdatedAt() {
  6793. m.updated_at = nil
  6794. }
  6795. // SetDeletedAt sets the "deleted_at" field.
  6796. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  6797. m.deleted_at = &t
  6798. }
  6799. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6800. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  6801. v := m.deleted_at
  6802. if v == nil {
  6803. return
  6804. }
  6805. return *v, true
  6806. }
  6807. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  6808. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6810. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6811. if !m.op.Is(OpUpdateOne) {
  6812. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6813. }
  6814. if m.id == nil || m.oldValue == nil {
  6815. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6816. }
  6817. oldValue, err := m.oldValue(ctx)
  6818. if err != nil {
  6819. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6820. }
  6821. return oldValue.DeletedAt, nil
  6822. }
  6823. // ClearDeletedAt clears the value of the "deleted_at" field.
  6824. func (m *BatchMsgMutation) ClearDeletedAt() {
  6825. m.deleted_at = nil
  6826. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  6827. }
  6828. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6829. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  6830. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  6831. return ok
  6832. }
  6833. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6834. func (m *BatchMsgMutation) ResetDeletedAt() {
  6835. m.deleted_at = nil
  6836. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  6837. }
  6838. // SetStatus sets the "status" field.
  6839. func (m *BatchMsgMutation) SetStatus(u uint8) {
  6840. m.status = &u
  6841. m.addstatus = nil
  6842. }
  6843. // Status returns the value of the "status" field in the mutation.
  6844. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  6845. v := m.status
  6846. if v == nil {
  6847. return
  6848. }
  6849. return *v, true
  6850. }
  6851. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  6852. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6854. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6855. if !m.op.Is(OpUpdateOne) {
  6856. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6857. }
  6858. if m.id == nil || m.oldValue == nil {
  6859. return v, errors.New("OldStatus requires an ID field in the mutation")
  6860. }
  6861. oldValue, err := m.oldValue(ctx)
  6862. if err != nil {
  6863. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6864. }
  6865. return oldValue.Status, nil
  6866. }
  6867. // AddStatus adds u to the "status" field.
  6868. func (m *BatchMsgMutation) AddStatus(u int8) {
  6869. if m.addstatus != nil {
  6870. *m.addstatus += u
  6871. } else {
  6872. m.addstatus = &u
  6873. }
  6874. }
  6875. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6876. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  6877. v := m.addstatus
  6878. if v == nil {
  6879. return
  6880. }
  6881. return *v, true
  6882. }
  6883. // ClearStatus clears the value of the "status" field.
  6884. func (m *BatchMsgMutation) ClearStatus() {
  6885. m.status = nil
  6886. m.addstatus = nil
  6887. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  6888. }
  6889. // StatusCleared returns if the "status" field was cleared in this mutation.
  6890. func (m *BatchMsgMutation) StatusCleared() bool {
  6891. _, ok := m.clearedFields[batchmsg.FieldStatus]
  6892. return ok
  6893. }
  6894. // ResetStatus resets all changes to the "status" field.
  6895. func (m *BatchMsgMutation) ResetStatus() {
  6896. m.status = nil
  6897. m.addstatus = nil
  6898. delete(m.clearedFields, batchmsg.FieldStatus)
  6899. }
  6900. // SetBatchNo sets the "batch_no" field.
  6901. func (m *BatchMsgMutation) SetBatchNo(s string) {
  6902. m.batch_no = &s
  6903. }
  6904. // BatchNo returns the value of the "batch_no" field in the mutation.
  6905. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  6906. v := m.batch_no
  6907. if v == nil {
  6908. return
  6909. }
  6910. return *v, true
  6911. }
  6912. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  6913. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6915. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  6916. if !m.op.Is(OpUpdateOne) {
  6917. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  6918. }
  6919. if m.id == nil || m.oldValue == nil {
  6920. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  6921. }
  6922. oldValue, err := m.oldValue(ctx)
  6923. if err != nil {
  6924. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  6925. }
  6926. return oldValue.BatchNo, nil
  6927. }
  6928. // ClearBatchNo clears the value of the "batch_no" field.
  6929. func (m *BatchMsgMutation) ClearBatchNo() {
  6930. m.batch_no = nil
  6931. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  6932. }
  6933. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  6934. func (m *BatchMsgMutation) BatchNoCleared() bool {
  6935. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  6936. return ok
  6937. }
  6938. // ResetBatchNo resets all changes to the "batch_no" field.
  6939. func (m *BatchMsgMutation) ResetBatchNo() {
  6940. m.batch_no = nil
  6941. delete(m.clearedFields, batchmsg.FieldBatchNo)
  6942. }
  6943. // SetTaskName sets the "task_name" field.
  6944. func (m *BatchMsgMutation) SetTaskName(s string) {
  6945. m.task_name = &s
  6946. }
  6947. // TaskName returns the value of the "task_name" field in the mutation.
  6948. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  6949. v := m.task_name
  6950. if v == nil {
  6951. return
  6952. }
  6953. return *v, true
  6954. }
  6955. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  6956. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6958. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  6959. if !m.op.Is(OpUpdateOne) {
  6960. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  6961. }
  6962. if m.id == nil || m.oldValue == nil {
  6963. return v, errors.New("OldTaskName requires an ID field in the mutation")
  6964. }
  6965. oldValue, err := m.oldValue(ctx)
  6966. if err != nil {
  6967. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  6968. }
  6969. return oldValue.TaskName, nil
  6970. }
  6971. // ClearTaskName clears the value of the "task_name" field.
  6972. func (m *BatchMsgMutation) ClearTaskName() {
  6973. m.task_name = nil
  6974. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  6975. }
  6976. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  6977. func (m *BatchMsgMutation) TaskNameCleared() bool {
  6978. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  6979. return ok
  6980. }
  6981. // ResetTaskName resets all changes to the "task_name" field.
  6982. func (m *BatchMsgMutation) ResetTaskName() {
  6983. m.task_name = nil
  6984. delete(m.clearedFields, batchmsg.FieldTaskName)
  6985. }
  6986. // SetFromwxid sets the "fromwxid" field.
  6987. func (m *BatchMsgMutation) SetFromwxid(s string) {
  6988. m.fromwxid = &s
  6989. }
  6990. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  6991. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  6992. v := m.fromwxid
  6993. if v == nil {
  6994. return
  6995. }
  6996. return *v, true
  6997. }
  6998. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  6999. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7001. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  7002. if !m.op.Is(OpUpdateOne) {
  7003. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  7004. }
  7005. if m.id == nil || m.oldValue == nil {
  7006. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  7007. }
  7008. oldValue, err := m.oldValue(ctx)
  7009. if err != nil {
  7010. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  7011. }
  7012. return oldValue.Fromwxid, nil
  7013. }
  7014. // ClearFromwxid clears the value of the "fromwxid" field.
  7015. func (m *BatchMsgMutation) ClearFromwxid() {
  7016. m.fromwxid = nil
  7017. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  7018. }
  7019. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  7020. func (m *BatchMsgMutation) FromwxidCleared() bool {
  7021. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  7022. return ok
  7023. }
  7024. // ResetFromwxid resets all changes to the "fromwxid" field.
  7025. func (m *BatchMsgMutation) ResetFromwxid() {
  7026. m.fromwxid = nil
  7027. delete(m.clearedFields, batchmsg.FieldFromwxid)
  7028. }
  7029. // SetMsg sets the "msg" field.
  7030. func (m *BatchMsgMutation) SetMsg(s string) {
  7031. m.msg = &s
  7032. }
  7033. // Msg returns the value of the "msg" field in the mutation.
  7034. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  7035. v := m.msg
  7036. if v == nil {
  7037. return
  7038. }
  7039. return *v, true
  7040. }
  7041. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  7042. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7044. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  7045. if !m.op.Is(OpUpdateOne) {
  7046. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  7047. }
  7048. if m.id == nil || m.oldValue == nil {
  7049. return v, errors.New("OldMsg requires an ID field in the mutation")
  7050. }
  7051. oldValue, err := m.oldValue(ctx)
  7052. if err != nil {
  7053. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  7054. }
  7055. return oldValue.Msg, nil
  7056. }
  7057. // ClearMsg clears the value of the "msg" field.
  7058. func (m *BatchMsgMutation) ClearMsg() {
  7059. m.msg = nil
  7060. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  7061. }
  7062. // MsgCleared returns if the "msg" field was cleared in this mutation.
  7063. func (m *BatchMsgMutation) MsgCleared() bool {
  7064. _, ok := m.clearedFields[batchmsg.FieldMsg]
  7065. return ok
  7066. }
  7067. // ResetMsg resets all changes to the "msg" field.
  7068. func (m *BatchMsgMutation) ResetMsg() {
  7069. m.msg = nil
  7070. delete(m.clearedFields, batchmsg.FieldMsg)
  7071. }
  7072. // SetTag sets the "tag" field.
  7073. func (m *BatchMsgMutation) SetTag(s string) {
  7074. m.tag = &s
  7075. }
  7076. // Tag returns the value of the "tag" field in the mutation.
  7077. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  7078. v := m.tag
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  7085. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldTag requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  7097. }
  7098. return oldValue.Tag, nil
  7099. }
  7100. // ClearTag clears the value of the "tag" field.
  7101. func (m *BatchMsgMutation) ClearTag() {
  7102. m.tag = nil
  7103. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  7104. }
  7105. // TagCleared returns if the "tag" field was cleared in this mutation.
  7106. func (m *BatchMsgMutation) TagCleared() bool {
  7107. _, ok := m.clearedFields[batchmsg.FieldTag]
  7108. return ok
  7109. }
  7110. // ResetTag resets all changes to the "tag" field.
  7111. func (m *BatchMsgMutation) ResetTag() {
  7112. m.tag = nil
  7113. delete(m.clearedFields, batchmsg.FieldTag)
  7114. }
  7115. // SetTagids sets the "tagids" field.
  7116. func (m *BatchMsgMutation) SetTagids(s string) {
  7117. m.tagids = &s
  7118. }
  7119. // Tagids returns the value of the "tagids" field in the mutation.
  7120. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  7121. v := m.tagids
  7122. if v == nil {
  7123. return
  7124. }
  7125. return *v, true
  7126. }
  7127. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  7128. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7130. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  7131. if !m.op.Is(OpUpdateOne) {
  7132. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  7133. }
  7134. if m.id == nil || m.oldValue == nil {
  7135. return v, errors.New("OldTagids requires an ID field in the mutation")
  7136. }
  7137. oldValue, err := m.oldValue(ctx)
  7138. if err != nil {
  7139. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  7140. }
  7141. return oldValue.Tagids, nil
  7142. }
  7143. // ClearTagids clears the value of the "tagids" field.
  7144. func (m *BatchMsgMutation) ClearTagids() {
  7145. m.tagids = nil
  7146. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  7147. }
  7148. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  7149. func (m *BatchMsgMutation) TagidsCleared() bool {
  7150. _, ok := m.clearedFields[batchmsg.FieldTagids]
  7151. return ok
  7152. }
  7153. // ResetTagids resets all changes to the "tagids" field.
  7154. func (m *BatchMsgMutation) ResetTagids() {
  7155. m.tagids = nil
  7156. delete(m.clearedFields, batchmsg.FieldTagids)
  7157. }
  7158. // SetTotal sets the "total" field.
  7159. func (m *BatchMsgMutation) SetTotal(i int32) {
  7160. m.total = &i
  7161. m.addtotal = nil
  7162. }
  7163. // Total returns the value of the "total" field in the mutation.
  7164. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  7165. v := m.total
  7166. if v == nil {
  7167. return
  7168. }
  7169. return *v, true
  7170. }
  7171. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  7172. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7174. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  7175. if !m.op.Is(OpUpdateOne) {
  7176. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  7177. }
  7178. if m.id == nil || m.oldValue == nil {
  7179. return v, errors.New("OldTotal requires an ID field in the mutation")
  7180. }
  7181. oldValue, err := m.oldValue(ctx)
  7182. if err != nil {
  7183. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  7184. }
  7185. return oldValue.Total, nil
  7186. }
  7187. // AddTotal adds i to the "total" field.
  7188. func (m *BatchMsgMutation) AddTotal(i int32) {
  7189. if m.addtotal != nil {
  7190. *m.addtotal += i
  7191. } else {
  7192. m.addtotal = &i
  7193. }
  7194. }
  7195. // AddedTotal returns the value that was added to the "total" field in this mutation.
  7196. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  7197. v := m.addtotal
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // ClearTotal clears the value of the "total" field.
  7204. func (m *BatchMsgMutation) ClearTotal() {
  7205. m.total = nil
  7206. m.addtotal = nil
  7207. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  7208. }
  7209. // TotalCleared returns if the "total" field was cleared in this mutation.
  7210. func (m *BatchMsgMutation) TotalCleared() bool {
  7211. _, ok := m.clearedFields[batchmsg.FieldTotal]
  7212. return ok
  7213. }
  7214. // ResetTotal resets all changes to the "total" field.
  7215. func (m *BatchMsgMutation) ResetTotal() {
  7216. m.total = nil
  7217. m.addtotal = nil
  7218. delete(m.clearedFields, batchmsg.FieldTotal)
  7219. }
  7220. // SetSuccess sets the "success" field.
  7221. func (m *BatchMsgMutation) SetSuccess(i int32) {
  7222. m.success = &i
  7223. m.addsuccess = nil
  7224. }
  7225. // Success returns the value of the "success" field in the mutation.
  7226. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  7227. v := m.success
  7228. if v == nil {
  7229. return
  7230. }
  7231. return *v, true
  7232. }
  7233. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  7234. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7236. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  7237. if !m.op.Is(OpUpdateOne) {
  7238. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  7239. }
  7240. if m.id == nil || m.oldValue == nil {
  7241. return v, errors.New("OldSuccess requires an ID field in the mutation")
  7242. }
  7243. oldValue, err := m.oldValue(ctx)
  7244. if err != nil {
  7245. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  7246. }
  7247. return oldValue.Success, nil
  7248. }
  7249. // AddSuccess adds i to the "success" field.
  7250. func (m *BatchMsgMutation) AddSuccess(i int32) {
  7251. if m.addsuccess != nil {
  7252. *m.addsuccess += i
  7253. } else {
  7254. m.addsuccess = &i
  7255. }
  7256. }
  7257. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  7258. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  7259. v := m.addsuccess
  7260. if v == nil {
  7261. return
  7262. }
  7263. return *v, true
  7264. }
  7265. // ClearSuccess clears the value of the "success" field.
  7266. func (m *BatchMsgMutation) ClearSuccess() {
  7267. m.success = nil
  7268. m.addsuccess = nil
  7269. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  7270. }
  7271. // SuccessCleared returns if the "success" field was cleared in this mutation.
  7272. func (m *BatchMsgMutation) SuccessCleared() bool {
  7273. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  7274. return ok
  7275. }
  7276. // ResetSuccess resets all changes to the "success" field.
  7277. func (m *BatchMsgMutation) ResetSuccess() {
  7278. m.success = nil
  7279. m.addsuccess = nil
  7280. delete(m.clearedFields, batchmsg.FieldSuccess)
  7281. }
  7282. // SetFail sets the "fail" field.
  7283. func (m *BatchMsgMutation) SetFail(i int32) {
  7284. m.fail = &i
  7285. m.addfail = nil
  7286. }
  7287. // Fail returns the value of the "fail" field in the mutation.
  7288. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  7289. v := m.fail
  7290. if v == nil {
  7291. return
  7292. }
  7293. return *v, true
  7294. }
  7295. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  7296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7298. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  7299. if !m.op.Is(OpUpdateOne) {
  7300. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  7301. }
  7302. if m.id == nil || m.oldValue == nil {
  7303. return v, errors.New("OldFail requires an ID field in the mutation")
  7304. }
  7305. oldValue, err := m.oldValue(ctx)
  7306. if err != nil {
  7307. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  7308. }
  7309. return oldValue.Fail, nil
  7310. }
  7311. // AddFail adds i to the "fail" field.
  7312. func (m *BatchMsgMutation) AddFail(i int32) {
  7313. if m.addfail != nil {
  7314. *m.addfail += i
  7315. } else {
  7316. m.addfail = &i
  7317. }
  7318. }
  7319. // AddedFail returns the value that was added to the "fail" field in this mutation.
  7320. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  7321. v := m.addfail
  7322. if v == nil {
  7323. return
  7324. }
  7325. return *v, true
  7326. }
  7327. // ClearFail clears the value of the "fail" field.
  7328. func (m *BatchMsgMutation) ClearFail() {
  7329. m.fail = nil
  7330. m.addfail = nil
  7331. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  7332. }
  7333. // FailCleared returns if the "fail" field was cleared in this mutation.
  7334. func (m *BatchMsgMutation) FailCleared() bool {
  7335. _, ok := m.clearedFields[batchmsg.FieldFail]
  7336. return ok
  7337. }
  7338. // ResetFail resets all changes to the "fail" field.
  7339. func (m *BatchMsgMutation) ResetFail() {
  7340. m.fail = nil
  7341. m.addfail = nil
  7342. delete(m.clearedFields, batchmsg.FieldFail)
  7343. }
  7344. // SetStartTime sets the "start_time" field.
  7345. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  7346. m.start_time = &t
  7347. }
  7348. // StartTime returns the value of the "start_time" field in the mutation.
  7349. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  7350. v := m.start_time
  7351. if v == nil {
  7352. return
  7353. }
  7354. return *v, true
  7355. }
  7356. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  7357. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7359. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  7360. if !m.op.Is(OpUpdateOne) {
  7361. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  7362. }
  7363. if m.id == nil || m.oldValue == nil {
  7364. return v, errors.New("OldStartTime requires an ID field in the mutation")
  7365. }
  7366. oldValue, err := m.oldValue(ctx)
  7367. if err != nil {
  7368. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  7369. }
  7370. return oldValue.StartTime, nil
  7371. }
  7372. // ClearStartTime clears the value of the "start_time" field.
  7373. func (m *BatchMsgMutation) ClearStartTime() {
  7374. m.start_time = nil
  7375. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  7376. }
  7377. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  7378. func (m *BatchMsgMutation) StartTimeCleared() bool {
  7379. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  7380. return ok
  7381. }
  7382. // ResetStartTime resets all changes to the "start_time" field.
  7383. func (m *BatchMsgMutation) ResetStartTime() {
  7384. m.start_time = nil
  7385. delete(m.clearedFields, batchmsg.FieldStartTime)
  7386. }
  7387. // SetStopTime sets the "stop_time" field.
  7388. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  7389. m.stop_time = &t
  7390. }
  7391. // StopTime returns the value of the "stop_time" field in the mutation.
  7392. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  7393. v := m.stop_time
  7394. if v == nil {
  7395. return
  7396. }
  7397. return *v, true
  7398. }
  7399. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  7400. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7402. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  7403. if !m.op.Is(OpUpdateOne) {
  7404. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  7405. }
  7406. if m.id == nil || m.oldValue == nil {
  7407. return v, errors.New("OldStopTime requires an ID field in the mutation")
  7408. }
  7409. oldValue, err := m.oldValue(ctx)
  7410. if err != nil {
  7411. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  7412. }
  7413. return oldValue.StopTime, nil
  7414. }
  7415. // ClearStopTime clears the value of the "stop_time" field.
  7416. func (m *BatchMsgMutation) ClearStopTime() {
  7417. m.stop_time = nil
  7418. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  7419. }
  7420. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  7421. func (m *BatchMsgMutation) StopTimeCleared() bool {
  7422. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  7423. return ok
  7424. }
  7425. // ResetStopTime resets all changes to the "stop_time" field.
  7426. func (m *BatchMsgMutation) ResetStopTime() {
  7427. m.stop_time = nil
  7428. delete(m.clearedFields, batchmsg.FieldStopTime)
  7429. }
  7430. // SetSendTime sets the "send_time" field.
  7431. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  7432. m.send_time = &t
  7433. }
  7434. // SendTime returns the value of the "send_time" field in the mutation.
  7435. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  7436. v := m.send_time
  7437. if v == nil {
  7438. return
  7439. }
  7440. return *v, true
  7441. }
  7442. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  7443. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7445. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  7446. if !m.op.Is(OpUpdateOne) {
  7447. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  7448. }
  7449. if m.id == nil || m.oldValue == nil {
  7450. return v, errors.New("OldSendTime requires an ID field in the mutation")
  7451. }
  7452. oldValue, err := m.oldValue(ctx)
  7453. if err != nil {
  7454. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  7455. }
  7456. return oldValue.SendTime, nil
  7457. }
  7458. // ClearSendTime clears the value of the "send_time" field.
  7459. func (m *BatchMsgMutation) ClearSendTime() {
  7460. m.send_time = nil
  7461. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  7462. }
  7463. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  7464. func (m *BatchMsgMutation) SendTimeCleared() bool {
  7465. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  7466. return ok
  7467. }
  7468. // ResetSendTime resets all changes to the "send_time" field.
  7469. func (m *BatchMsgMutation) ResetSendTime() {
  7470. m.send_time = nil
  7471. delete(m.clearedFields, batchmsg.FieldSendTime)
  7472. }
  7473. // SetType sets the "type" field.
  7474. func (m *BatchMsgMutation) SetType(i int32) {
  7475. m._type = &i
  7476. m.add_type = nil
  7477. }
  7478. // GetType returns the value of the "type" field in the mutation.
  7479. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  7480. v := m._type
  7481. if v == nil {
  7482. return
  7483. }
  7484. return *v, true
  7485. }
  7486. // OldType returns the old "type" field's value of the BatchMsg entity.
  7487. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7489. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  7490. if !m.op.Is(OpUpdateOne) {
  7491. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7492. }
  7493. if m.id == nil || m.oldValue == nil {
  7494. return v, errors.New("OldType requires an ID field in the mutation")
  7495. }
  7496. oldValue, err := m.oldValue(ctx)
  7497. if err != nil {
  7498. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7499. }
  7500. return oldValue.Type, nil
  7501. }
  7502. // AddType adds i to the "type" field.
  7503. func (m *BatchMsgMutation) AddType(i int32) {
  7504. if m.add_type != nil {
  7505. *m.add_type += i
  7506. } else {
  7507. m.add_type = &i
  7508. }
  7509. }
  7510. // AddedType returns the value that was added to the "type" field in this mutation.
  7511. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  7512. v := m.add_type
  7513. if v == nil {
  7514. return
  7515. }
  7516. return *v, true
  7517. }
  7518. // ClearType clears the value of the "type" field.
  7519. func (m *BatchMsgMutation) ClearType() {
  7520. m._type = nil
  7521. m.add_type = nil
  7522. m.clearedFields[batchmsg.FieldType] = struct{}{}
  7523. }
  7524. // TypeCleared returns if the "type" field was cleared in this mutation.
  7525. func (m *BatchMsgMutation) TypeCleared() bool {
  7526. _, ok := m.clearedFields[batchmsg.FieldType]
  7527. return ok
  7528. }
  7529. // ResetType resets all changes to the "type" field.
  7530. func (m *BatchMsgMutation) ResetType() {
  7531. m._type = nil
  7532. m.add_type = nil
  7533. delete(m.clearedFields, batchmsg.FieldType)
  7534. }
  7535. // SetOrganizationID sets the "organization_id" field.
  7536. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  7537. m.organization_id = &u
  7538. m.addorganization_id = nil
  7539. }
  7540. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7541. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  7542. v := m.organization_id
  7543. if v == nil {
  7544. return
  7545. }
  7546. return *v, true
  7547. }
  7548. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  7549. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7551. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7552. if !m.op.Is(OpUpdateOne) {
  7553. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7554. }
  7555. if m.id == nil || m.oldValue == nil {
  7556. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7557. }
  7558. oldValue, err := m.oldValue(ctx)
  7559. if err != nil {
  7560. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7561. }
  7562. return oldValue.OrganizationID, nil
  7563. }
  7564. // AddOrganizationID adds u to the "organization_id" field.
  7565. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  7566. if m.addorganization_id != nil {
  7567. *m.addorganization_id += u
  7568. } else {
  7569. m.addorganization_id = &u
  7570. }
  7571. }
  7572. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7573. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  7574. v := m.addorganization_id
  7575. if v == nil {
  7576. return
  7577. }
  7578. return *v, true
  7579. }
  7580. // ResetOrganizationID resets all changes to the "organization_id" field.
  7581. func (m *BatchMsgMutation) ResetOrganizationID() {
  7582. m.organization_id = nil
  7583. m.addorganization_id = nil
  7584. }
  7585. // SetCtype sets the "ctype" field.
  7586. func (m *BatchMsgMutation) SetCtype(u uint64) {
  7587. m.ctype = &u
  7588. m.addctype = nil
  7589. }
  7590. // Ctype returns the value of the "ctype" field in the mutation.
  7591. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  7592. v := m.ctype
  7593. if v == nil {
  7594. return
  7595. }
  7596. return *v, true
  7597. }
  7598. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  7599. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7601. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  7602. if !m.op.Is(OpUpdateOne) {
  7603. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  7604. }
  7605. if m.id == nil || m.oldValue == nil {
  7606. return v, errors.New("OldCtype requires an ID field in the mutation")
  7607. }
  7608. oldValue, err := m.oldValue(ctx)
  7609. if err != nil {
  7610. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  7611. }
  7612. return oldValue.Ctype, nil
  7613. }
  7614. // AddCtype adds u to the "ctype" field.
  7615. func (m *BatchMsgMutation) AddCtype(u int64) {
  7616. if m.addctype != nil {
  7617. *m.addctype += u
  7618. } else {
  7619. m.addctype = &u
  7620. }
  7621. }
  7622. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  7623. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  7624. v := m.addctype
  7625. if v == nil {
  7626. return
  7627. }
  7628. return *v, true
  7629. }
  7630. // ResetCtype resets all changes to the "ctype" field.
  7631. func (m *BatchMsgMutation) ResetCtype() {
  7632. m.ctype = nil
  7633. m.addctype = nil
  7634. }
  7635. // SetCc sets the "cc" field.
  7636. func (m *BatchMsgMutation) SetCc(s string) {
  7637. m.cc = &s
  7638. }
  7639. // Cc returns the value of the "cc" field in the mutation.
  7640. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  7641. v := m.cc
  7642. if v == nil {
  7643. return
  7644. }
  7645. return *v, true
  7646. }
  7647. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  7648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7650. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  7651. if !m.op.Is(OpUpdateOne) {
  7652. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  7653. }
  7654. if m.id == nil || m.oldValue == nil {
  7655. return v, errors.New("OldCc requires an ID field in the mutation")
  7656. }
  7657. oldValue, err := m.oldValue(ctx)
  7658. if err != nil {
  7659. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  7660. }
  7661. return oldValue.Cc, nil
  7662. }
  7663. // ClearCc clears the value of the "cc" field.
  7664. func (m *BatchMsgMutation) ClearCc() {
  7665. m.cc = nil
  7666. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  7667. }
  7668. // CcCleared returns if the "cc" field was cleared in this mutation.
  7669. func (m *BatchMsgMutation) CcCleared() bool {
  7670. _, ok := m.clearedFields[batchmsg.FieldCc]
  7671. return ok
  7672. }
  7673. // ResetCc resets all changes to the "cc" field.
  7674. func (m *BatchMsgMutation) ResetCc() {
  7675. m.cc = nil
  7676. delete(m.clearedFields, batchmsg.FieldCc)
  7677. }
  7678. // SetPhone sets the "phone" field.
  7679. func (m *BatchMsgMutation) SetPhone(s string) {
  7680. m.phone = &s
  7681. }
  7682. // Phone returns the value of the "phone" field in the mutation.
  7683. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  7684. v := m.phone
  7685. if v == nil {
  7686. return
  7687. }
  7688. return *v, true
  7689. }
  7690. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  7691. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7693. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  7694. if !m.op.Is(OpUpdateOne) {
  7695. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  7696. }
  7697. if m.id == nil || m.oldValue == nil {
  7698. return v, errors.New("OldPhone requires an ID field in the mutation")
  7699. }
  7700. oldValue, err := m.oldValue(ctx)
  7701. if err != nil {
  7702. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  7703. }
  7704. return oldValue.Phone, nil
  7705. }
  7706. // ClearPhone clears the value of the "phone" field.
  7707. func (m *BatchMsgMutation) ClearPhone() {
  7708. m.phone = nil
  7709. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  7710. }
  7711. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  7712. func (m *BatchMsgMutation) PhoneCleared() bool {
  7713. _, ok := m.clearedFields[batchmsg.FieldPhone]
  7714. return ok
  7715. }
  7716. // ResetPhone resets all changes to the "phone" field.
  7717. func (m *BatchMsgMutation) ResetPhone() {
  7718. m.phone = nil
  7719. delete(m.clearedFields, batchmsg.FieldPhone)
  7720. }
  7721. // SetTemplateName sets the "template_name" field.
  7722. func (m *BatchMsgMutation) SetTemplateName(s string) {
  7723. m.template_name = &s
  7724. }
  7725. // TemplateName returns the value of the "template_name" field in the mutation.
  7726. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  7727. v := m.template_name
  7728. if v == nil {
  7729. return
  7730. }
  7731. return *v, true
  7732. }
  7733. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  7734. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7736. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  7737. if !m.op.Is(OpUpdateOne) {
  7738. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  7739. }
  7740. if m.id == nil || m.oldValue == nil {
  7741. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  7742. }
  7743. oldValue, err := m.oldValue(ctx)
  7744. if err != nil {
  7745. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  7746. }
  7747. return oldValue.TemplateName, nil
  7748. }
  7749. // ClearTemplateName clears the value of the "template_name" field.
  7750. func (m *BatchMsgMutation) ClearTemplateName() {
  7751. m.template_name = nil
  7752. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  7753. }
  7754. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  7755. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  7756. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  7757. return ok
  7758. }
  7759. // ResetTemplateName resets all changes to the "template_name" field.
  7760. func (m *BatchMsgMutation) ResetTemplateName() {
  7761. m.template_name = nil
  7762. delete(m.clearedFields, batchmsg.FieldTemplateName)
  7763. }
  7764. // SetTemplateCode sets the "template_code" field.
  7765. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  7766. m.template_code = &s
  7767. }
  7768. // TemplateCode returns the value of the "template_code" field in the mutation.
  7769. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  7770. v := m.template_code
  7771. if v == nil {
  7772. return
  7773. }
  7774. return *v, true
  7775. }
  7776. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  7777. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7779. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  7780. if !m.op.Is(OpUpdateOne) {
  7781. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  7782. }
  7783. if m.id == nil || m.oldValue == nil {
  7784. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  7785. }
  7786. oldValue, err := m.oldValue(ctx)
  7787. if err != nil {
  7788. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  7789. }
  7790. return oldValue.TemplateCode, nil
  7791. }
  7792. // ClearTemplateCode clears the value of the "template_code" field.
  7793. func (m *BatchMsgMutation) ClearTemplateCode() {
  7794. m.template_code = nil
  7795. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  7796. }
  7797. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  7798. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  7799. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  7800. return ok
  7801. }
  7802. // ResetTemplateCode resets all changes to the "template_code" field.
  7803. func (m *BatchMsgMutation) ResetTemplateCode() {
  7804. m.template_code = nil
  7805. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  7806. }
  7807. // SetLang sets the "lang" field.
  7808. func (m *BatchMsgMutation) SetLang(s string) {
  7809. m.lang = &s
  7810. }
  7811. // Lang returns the value of the "lang" field in the mutation.
  7812. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  7813. v := m.lang
  7814. if v == nil {
  7815. return
  7816. }
  7817. return *v, true
  7818. }
  7819. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  7820. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7822. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  7823. if !m.op.Is(OpUpdateOne) {
  7824. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  7825. }
  7826. if m.id == nil || m.oldValue == nil {
  7827. return v, errors.New("OldLang requires an ID field in the mutation")
  7828. }
  7829. oldValue, err := m.oldValue(ctx)
  7830. if err != nil {
  7831. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  7832. }
  7833. return oldValue.Lang, nil
  7834. }
  7835. // ClearLang clears the value of the "lang" field.
  7836. func (m *BatchMsgMutation) ClearLang() {
  7837. m.lang = nil
  7838. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  7839. }
  7840. // LangCleared returns if the "lang" field was cleared in this mutation.
  7841. func (m *BatchMsgMutation) LangCleared() bool {
  7842. _, ok := m.clearedFields[batchmsg.FieldLang]
  7843. return ok
  7844. }
  7845. // ResetLang resets all changes to the "lang" field.
  7846. func (m *BatchMsgMutation) ResetLang() {
  7847. m.lang = nil
  7848. delete(m.clearedFields, batchmsg.FieldLang)
  7849. }
  7850. // Where appends a list predicates to the BatchMsgMutation builder.
  7851. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  7852. m.predicates = append(m.predicates, ps...)
  7853. }
  7854. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  7855. // users can use type-assertion to append predicates that do not depend on any generated package.
  7856. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  7857. p := make([]predicate.BatchMsg, len(ps))
  7858. for i := range ps {
  7859. p[i] = ps[i]
  7860. }
  7861. m.Where(p...)
  7862. }
  7863. // Op returns the operation name.
  7864. func (m *BatchMsgMutation) Op() Op {
  7865. return m.op
  7866. }
  7867. // SetOp allows setting the mutation operation.
  7868. func (m *BatchMsgMutation) SetOp(op Op) {
  7869. m.op = op
  7870. }
  7871. // Type returns the node type of this mutation (BatchMsg).
  7872. func (m *BatchMsgMutation) Type() string {
  7873. return m.typ
  7874. }
  7875. // Fields returns all fields that were changed during this mutation. Note that in
  7876. // order to get all numeric fields that were incremented/decremented, call
  7877. // AddedFields().
  7878. func (m *BatchMsgMutation) Fields() []string {
  7879. fields := make([]string, 0, 24)
  7880. if m.created_at != nil {
  7881. fields = append(fields, batchmsg.FieldCreatedAt)
  7882. }
  7883. if m.updated_at != nil {
  7884. fields = append(fields, batchmsg.FieldUpdatedAt)
  7885. }
  7886. if m.deleted_at != nil {
  7887. fields = append(fields, batchmsg.FieldDeletedAt)
  7888. }
  7889. if m.status != nil {
  7890. fields = append(fields, batchmsg.FieldStatus)
  7891. }
  7892. if m.batch_no != nil {
  7893. fields = append(fields, batchmsg.FieldBatchNo)
  7894. }
  7895. if m.task_name != nil {
  7896. fields = append(fields, batchmsg.FieldTaskName)
  7897. }
  7898. if m.fromwxid != nil {
  7899. fields = append(fields, batchmsg.FieldFromwxid)
  7900. }
  7901. if m.msg != nil {
  7902. fields = append(fields, batchmsg.FieldMsg)
  7903. }
  7904. if m.tag != nil {
  7905. fields = append(fields, batchmsg.FieldTag)
  7906. }
  7907. if m.tagids != nil {
  7908. fields = append(fields, batchmsg.FieldTagids)
  7909. }
  7910. if m.total != nil {
  7911. fields = append(fields, batchmsg.FieldTotal)
  7912. }
  7913. if m.success != nil {
  7914. fields = append(fields, batchmsg.FieldSuccess)
  7915. }
  7916. if m.fail != nil {
  7917. fields = append(fields, batchmsg.FieldFail)
  7918. }
  7919. if m.start_time != nil {
  7920. fields = append(fields, batchmsg.FieldStartTime)
  7921. }
  7922. if m.stop_time != nil {
  7923. fields = append(fields, batchmsg.FieldStopTime)
  7924. }
  7925. if m.send_time != nil {
  7926. fields = append(fields, batchmsg.FieldSendTime)
  7927. }
  7928. if m._type != nil {
  7929. fields = append(fields, batchmsg.FieldType)
  7930. }
  7931. if m.organization_id != nil {
  7932. fields = append(fields, batchmsg.FieldOrganizationID)
  7933. }
  7934. if m.ctype != nil {
  7935. fields = append(fields, batchmsg.FieldCtype)
  7936. }
  7937. if m.cc != nil {
  7938. fields = append(fields, batchmsg.FieldCc)
  7939. }
  7940. if m.phone != nil {
  7941. fields = append(fields, batchmsg.FieldPhone)
  7942. }
  7943. if m.template_name != nil {
  7944. fields = append(fields, batchmsg.FieldTemplateName)
  7945. }
  7946. if m.template_code != nil {
  7947. fields = append(fields, batchmsg.FieldTemplateCode)
  7948. }
  7949. if m.lang != nil {
  7950. fields = append(fields, batchmsg.FieldLang)
  7951. }
  7952. return fields
  7953. }
  7954. // Field returns the value of a field with the given name. The second boolean
  7955. // return value indicates that this field was not set, or was not defined in the
  7956. // schema.
  7957. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  7958. switch name {
  7959. case batchmsg.FieldCreatedAt:
  7960. return m.CreatedAt()
  7961. case batchmsg.FieldUpdatedAt:
  7962. return m.UpdatedAt()
  7963. case batchmsg.FieldDeletedAt:
  7964. return m.DeletedAt()
  7965. case batchmsg.FieldStatus:
  7966. return m.Status()
  7967. case batchmsg.FieldBatchNo:
  7968. return m.BatchNo()
  7969. case batchmsg.FieldTaskName:
  7970. return m.TaskName()
  7971. case batchmsg.FieldFromwxid:
  7972. return m.Fromwxid()
  7973. case batchmsg.FieldMsg:
  7974. return m.Msg()
  7975. case batchmsg.FieldTag:
  7976. return m.Tag()
  7977. case batchmsg.FieldTagids:
  7978. return m.Tagids()
  7979. case batchmsg.FieldTotal:
  7980. return m.Total()
  7981. case batchmsg.FieldSuccess:
  7982. return m.Success()
  7983. case batchmsg.FieldFail:
  7984. return m.Fail()
  7985. case batchmsg.FieldStartTime:
  7986. return m.StartTime()
  7987. case batchmsg.FieldStopTime:
  7988. return m.StopTime()
  7989. case batchmsg.FieldSendTime:
  7990. return m.SendTime()
  7991. case batchmsg.FieldType:
  7992. return m.GetType()
  7993. case batchmsg.FieldOrganizationID:
  7994. return m.OrganizationID()
  7995. case batchmsg.FieldCtype:
  7996. return m.Ctype()
  7997. case batchmsg.FieldCc:
  7998. return m.Cc()
  7999. case batchmsg.FieldPhone:
  8000. return m.Phone()
  8001. case batchmsg.FieldTemplateName:
  8002. return m.TemplateName()
  8003. case batchmsg.FieldTemplateCode:
  8004. return m.TemplateCode()
  8005. case batchmsg.FieldLang:
  8006. return m.Lang()
  8007. }
  8008. return nil, false
  8009. }
  8010. // OldField returns the old value of the field from the database. An error is
  8011. // returned if the mutation operation is not UpdateOne, or the query to the
  8012. // database failed.
  8013. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8014. switch name {
  8015. case batchmsg.FieldCreatedAt:
  8016. return m.OldCreatedAt(ctx)
  8017. case batchmsg.FieldUpdatedAt:
  8018. return m.OldUpdatedAt(ctx)
  8019. case batchmsg.FieldDeletedAt:
  8020. return m.OldDeletedAt(ctx)
  8021. case batchmsg.FieldStatus:
  8022. return m.OldStatus(ctx)
  8023. case batchmsg.FieldBatchNo:
  8024. return m.OldBatchNo(ctx)
  8025. case batchmsg.FieldTaskName:
  8026. return m.OldTaskName(ctx)
  8027. case batchmsg.FieldFromwxid:
  8028. return m.OldFromwxid(ctx)
  8029. case batchmsg.FieldMsg:
  8030. return m.OldMsg(ctx)
  8031. case batchmsg.FieldTag:
  8032. return m.OldTag(ctx)
  8033. case batchmsg.FieldTagids:
  8034. return m.OldTagids(ctx)
  8035. case batchmsg.FieldTotal:
  8036. return m.OldTotal(ctx)
  8037. case batchmsg.FieldSuccess:
  8038. return m.OldSuccess(ctx)
  8039. case batchmsg.FieldFail:
  8040. return m.OldFail(ctx)
  8041. case batchmsg.FieldStartTime:
  8042. return m.OldStartTime(ctx)
  8043. case batchmsg.FieldStopTime:
  8044. return m.OldStopTime(ctx)
  8045. case batchmsg.FieldSendTime:
  8046. return m.OldSendTime(ctx)
  8047. case batchmsg.FieldType:
  8048. return m.OldType(ctx)
  8049. case batchmsg.FieldOrganizationID:
  8050. return m.OldOrganizationID(ctx)
  8051. case batchmsg.FieldCtype:
  8052. return m.OldCtype(ctx)
  8053. case batchmsg.FieldCc:
  8054. return m.OldCc(ctx)
  8055. case batchmsg.FieldPhone:
  8056. return m.OldPhone(ctx)
  8057. case batchmsg.FieldTemplateName:
  8058. return m.OldTemplateName(ctx)
  8059. case batchmsg.FieldTemplateCode:
  8060. return m.OldTemplateCode(ctx)
  8061. case batchmsg.FieldLang:
  8062. return m.OldLang(ctx)
  8063. }
  8064. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  8065. }
  8066. // SetField sets the value of a field with the given name. It returns an error if
  8067. // the field is not defined in the schema, or if the type mismatched the field
  8068. // type.
  8069. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  8070. switch name {
  8071. case batchmsg.FieldCreatedAt:
  8072. v, ok := value.(time.Time)
  8073. if !ok {
  8074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8075. }
  8076. m.SetCreatedAt(v)
  8077. return nil
  8078. case batchmsg.FieldUpdatedAt:
  8079. v, ok := value.(time.Time)
  8080. if !ok {
  8081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8082. }
  8083. m.SetUpdatedAt(v)
  8084. return nil
  8085. case batchmsg.FieldDeletedAt:
  8086. v, ok := value.(time.Time)
  8087. if !ok {
  8088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8089. }
  8090. m.SetDeletedAt(v)
  8091. return nil
  8092. case batchmsg.FieldStatus:
  8093. v, ok := value.(uint8)
  8094. if !ok {
  8095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8096. }
  8097. m.SetStatus(v)
  8098. return nil
  8099. case batchmsg.FieldBatchNo:
  8100. v, ok := value.(string)
  8101. if !ok {
  8102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8103. }
  8104. m.SetBatchNo(v)
  8105. return nil
  8106. case batchmsg.FieldTaskName:
  8107. v, ok := value.(string)
  8108. if !ok {
  8109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8110. }
  8111. m.SetTaskName(v)
  8112. return nil
  8113. case batchmsg.FieldFromwxid:
  8114. v, ok := value.(string)
  8115. if !ok {
  8116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8117. }
  8118. m.SetFromwxid(v)
  8119. return nil
  8120. case batchmsg.FieldMsg:
  8121. v, ok := value.(string)
  8122. if !ok {
  8123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8124. }
  8125. m.SetMsg(v)
  8126. return nil
  8127. case batchmsg.FieldTag:
  8128. v, ok := value.(string)
  8129. if !ok {
  8130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8131. }
  8132. m.SetTag(v)
  8133. return nil
  8134. case batchmsg.FieldTagids:
  8135. v, ok := value.(string)
  8136. if !ok {
  8137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8138. }
  8139. m.SetTagids(v)
  8140. return nil
  8141. case batchmsg.FieldTotal:
  8142. v, ok := value.(int32)
  8143. if !ok {
  8144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8145. }
  8146. m.SetTotal(v)
  8147. return nil
  8148. case batchmsg.FieldSuccess:
  8149. v, ok := value.(int32)
  8150. if !ok {
  8151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8152. }
  8153. m.SetSuccess(v)
  8154. return nil
  8155. case batchmsg.FieldFail:
  8156. v, ok := value.(int32)
  8157. if !ok {
  8158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8159. }
  8160. m.SetFail(v)
  8161. return nil
  8162. case batchmsg.FieldStartTime:
  8163. v, ok := value.(time.Time)
  8164. if !ok {
  8165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8166. }
  8167. m.SetStartTime(v)
  8168. return nil
  8169. case batchmsg.FieldStopTime:
  8170. v, ok := value.(time.Time)
  8171. if !ok {
  8172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8173. }
  8174. m.SetStopTime(v)
  8175. return nil
  8176. case batchmsg.FieldSendTime:
  8177. v, ok := value.(time.Time)
  8178. if !ok {
  8179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8180. }
  8181. m.SetSendTime(v)
  8182. return nil
  8183. case batchmsg.FieldType:
  8184. v, ok := value.(int32)
  8185. if !ok {
  8186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8187. }
  8188. m.SetType(v)
  8189. return nil
  8190. case batchmsg.FieldOrganizationID:
  8191. v, ok := value.(uint64)
  8192. if !ok {
  8193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8194. }
  8195. m.SetOrganizationID(v)
  8196. return nil
  8197. case batchmsg.FieldCtype:
  8198. v, ok := value.(uint64)
  8199. if !ok {
  8200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8201. }
  8202. m.SetCtype(v)
  8203. return nil
  8204. case batchmsg.FieldCc:
  8205. v, ok := value.(string)
  8206. if !ok {
  8207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8208. }
  8209. m.SetCc(v)
  8210. return nil
  8211. case batchmsg.FieldPhone:
  8212. v, ok := value.(string)
  8213. if !ok {
  8214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8215. }
  8216. m.SetPhone(v)
  8217. return nil
  8218. case batchmsg.FieldTemplateName:
  8219. v, ok := value.(string)
  8220. if !ok {
  8221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8222. }
  8223. m.SetTemplateName(v)
  8224. return nil
  8225. case batchmsg.FieldTemplateCode:
  8226. v, ok := value.(string)
  8227. if !ok {
  8228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8229. }
  8230. m.SetTemplateCode(v)
  8231. return nil
  8232. case batchmsg.FieldLang:
  8233. v, ok := value.(string)
  8234. if !ok {
  8235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8236. }
  8237. m.SetLang(v)
  8238. return nil
  8239. }
  8240. return fmt.Errorf("unknown BatchMsg field %s", name)
  8241. }
  8242. // AddedFields returns all numeric fields that were incremented/decremented during
  8243. // this mutation.
  8244. func (m *BatchMsgMutation) AddedFields() []string {
  8245. var fields []string
  8246. if m.addstatus != nil {
  8247. fields = append(fields, batchmsg.FieldStatus)
  8248. }
  8249. if m.addtotal != nil {
  8250. fields = append(fields, batchmsg.FieldTotal)
  8251. }
  8252. if m.addsuccess != nil {
  8253. fields = append(fields, batchmsg.FieldSuccess)
  8254. }
  8255. if m.addfail != nil {
  8256. fields = append(fields, batchmsg.FieldFail)
  8257. }
  8258. if m.add_type != nil {
  8259. fields = append(fields, batchmsg.FieldType)
  8260. }
  8261. if m.addorganization_id != nil {
  8262. fields = append(fields, batchmsg.FieldOrganizationID)
  8263. }
  8264. if m.addctype != nil {
  8265. fields = append(fields, batchmsg.FieldCtype)
  8266. }
  8267. return fields
  8268. }
  8269. // AddedField returns the numeric value that was incremented/decremented on a field
  8270. // with the given name. The second boolean return value indicates that this field
  8271. // was not set, or was not defined in the schema.
  8272. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  8273. switch name {
  8274. case batchmsg.FieldStatus:
  8275. return m.AddedStatus()
  8276. case batchmsg.FieldTotal:
  8277. return m.AddedTotal()
  8278. case batchmsg.FieldSuccess:
  8279. return m.AddedSuccess()
  8280. case batchmsg.FieldFail:
  8281. return m.AddedFail()
  8282. case batchmsg.FieldType:
  8283. return m.AddedType()
  8284. case batchmsg.FieldOrganizationID:
  8285. return m.AddedOrganizationID()
  8286. case batchmsg.FieldCtype:
  8287. return m.AddedCtype()
  8288. }
  8289. return nil, false
  8290. }
  8291. // AddField adds the value to the field with the given name. It returns an error if
  8292. // the field is not defined in the schema, or if the type mismatched the field
  8293. // type.
  8294. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  8295. switch name {
  8296. case batchmsg.FieldStatus:
  8297. v, ok := value.(int8)
  8298. if !ok {
  8299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8300. }
  8301. m.AddStatus(v)
  8302. return nil
  8303. case batchmsg.FieldTotal:
  8304. v, ok := value.(int32)
  8305. if !ok {
  8306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8307. }
  8308. m.AddTotal(v)
  8309. return nil
  8310. case batchmsg.FieldSuccess:
  8311. v, ok := value.(int32)
  8312. if !ok {
  8313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8314. }
  8315. m.AddSuccess(v)
  8316. return nil
  8317. case batchmsg.FieldFail:
  8318. v, ok := value.(int32)
  8319. if !ok {
  8320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8321. }
  8322. m.AddFail(v)
  8323. return nil
  8324. case batchmsg.FieldType:
  8325. v, ok := value.(int32)
  8326. if !ok {
  8327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8328. }
  8329. m.AddType(v)
  8330. return nil
  8331. case batchmsg.FieldOrganizationID:
  8332. v, ok := value.(int64)
  8333. if !ok {
  8334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8335. }
  8336. m.AddOrganizationID(v)
  8337. return nil
  8338. case batchmsg.FieldCtype:
  8339. v, ok := value.(int64)
  8340. if !ok {
  8341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8342. }
  8343. m.AddCtype(v)
  8344. return nil
  8345. }
  8346. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  8347. }
  8348. // ClearedFields returns all nullable fields that were cleared during this
  8349. // mutation.
  8350. func (m *BatchMsgMutation) ClearedFields() []string {
  8351. var fields []string
  8352. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  8353. fields = append(fields, batchmsg.FieldDeletedAt)
  8354. }
  8355. if m.FieldCleared(batchmsg.FieldStatus) {
  8356. fields = append(fields, batchmsg.FieldStatus)
  8357. }
  8358. if m.FieldCleared(batchmsg.FieldBatchNo) {
  8359. fields = append(fields, batchmsg.FieldBatchNo)
  8360. }
  8361. if m.FieldCleared(batchmsg.FieldTaskName) {
  8362. fields = append(fields, batchmsg.FieldTaskName)
  8363. }
  8364. if m.FieldCleared(batchmsg.FieldFromwxid) {
  8365. fields = append(fields, batchmsg.FieldFromwxid)
  8366. }
  8367. if m.FieldCleared(batchmsg.FieldMsg) {
  8368. fields = append(fields, batchmsg.FieldMsg)
  8369. }
  8370. if m.FieldCleared(batchmsg.FieldTag) {
  8371. fields = append(fields, batchmsg.FieldTag)
  8372. }
  8373. if m.FieldCleared(batchmsg.FieldTagids) {
  8374. fields = append(fields, batchmsg.FieldTagids)
  8375. }
  8376. if m.FieldCleared(batchmsg.FieldTotal) {
  8377. fields = append(fields, batchmsg.FieldTotal)
  8378. }
  8379. if m.FieldCleared(batchmsg.FieldSuccess) {
  8380. fields = append(fields, batchmsg.FieldSuccess)
  8381. }
  8382. if m.FieldCleared(batchmsg.FieldFail) {
  8383. fields = append(fields, batchmsg.FieldFail)
  8384. }
  8385. if m.FieldCleared(batchmsg.FieldStartTime) {
  8386. fields = append(fields, batchmsg.FieldStartTime)
  8387. }
  8388. if m.FieldCleared(batchmsg.FieldStopTime) {
  8389. fields = append(fields, batchmsg.FieldStopTime)
  8390. }
  8391. if m.FieldCleared(batchmsg.FieldSendTime) {
  8392. fields = append(fields, batchmsg.FieldSendTime)
  8393. }
  8394. if m.FieldCleared(batchmsg.FieldType) {
  8395. fields = append(fields, batchmsg.FieldType)
  8396. }
  8397. if m.FieldCleared(batchmsg.FieldCc) {
  8398. fields = append(fields, batchmsg.FieldCc)
  8399. }
  8400. if m.FieldCleared(batchmsg.FieldPhone) {
  8401. fields = append(fields, batchmsg.FieldPhone)
  8402. }
  8403. if m.FieldCleared(batchmsg.FieldTemplateName) {
  8404. fields = append(fields, batchmsg.FieldTemplateName)
  8405. }
  8406. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  8407. fields = append(fields, batchmsg.FieldTemplateCode)
  8408. }
  8409. if m.FieldCleared(batchmsg.FieldLang) {
  8410. fields = append(fields, batchmsg.FieldLang)
  8411. }
  8412. return fields
  8413. }
  8414. // FieldCleared returns a boolean indicating if a field with the given name was
  8415. // cleared in this mutation.
  8416. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  8417. _, ok := m.clearedFields[name]
  8418. return ok
  8419. }
  8420. // ClearField clears the value of the field with the given name. It returns an
  8421. // error if the field is not defined in the schema.
  8422. func (m *BatchMsgMutation) ClearField(name string) error {
  8423. switch name {
  8424. case batchmsg.FieldDeletedAt:
  8425. m.ClearDeletedAt()
  8426. return nil
  8427. case batchmsg.FieldStatus:
  8428. m.ClearStatus()
  8429. return nil
  8430. case batchmsg.FieldBatchNo:
  8431. m.ClearBatchNo()
  8432. return nil
  8433. case batchmsg.FieldTaskName:
  8434. m.ClearTaskName()
  8435. return nil
  8436. case batchmsg.FieldFromwxid:
  8437. m.ClearFromwxid()
  8438. return nil
  8439. case batchmsg.FieldMsg:
  8440. m.ClearMsg()
  8441. return nil
  8442. case batchmsg.FieldTag:
  8443. m.ClearTag()
  8444. return nil
  8445. case batchmsg.FieldTagids:
  8446. m.ClearTagids()
  8447. return nil
  8448. case batchmsg.FieldTotal:
  8449. m.ClearTotal()
  8450. return nil
  8451. case batchmsg.FieldSuccess:
  8452. m.ClearSuccess()
  8453. return nil
  8454. case batchmsg.FieldFail:
  8455. m.ClearFail()
  8456. return nil
  8457. case batchmsg.FieldStartTime:
  8458. m.ClearStartTime()
  8459. return nil
  8460. case batchmsg.FieldStopTime:
  8461. m.ClearStopTime()
  8462. return nil
  8463. case batchmsg.FieldSendTime:
  8464. m.ClearSendTime()
  8465. return nil
  8466. case batchmsg.FieldType:
  8467. m.ClearType()
  8468. return nil
  8469. case batchmsg.FieldCc:
  8470. m.ClearCc()
  8471. return nil
  8472. case batchmsg.FieldPhone:
  8473. m.ClearPhone()
  8474. return nil
  8475. case batchmsg.FieldTemplateName:
  8476. m.ClearTemplateName()
  8477. return nil
  8478. case batchmsg.FieldTemplateCode:
  8479. m.ClearTemplateCode()
  8480. return nil
  8481. case batchmsg.FieldLang:
  8482. m.ClearLang()
  8483. return nil
  8484. }
  8485. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  8486. }
  8487. // ResetField resets all changes in the mutation for the field with the given name.
  8488. // It returns an error if the field is not defined in the schema.
  8489. func (m *BatchMsgMutation) ResetField(name string) error {
  8490. switch name {
  8491. case batchmsg.FieldCreatedAt:
  8492. m.ResetCreatedAt()
  8493. return nil
  8494. case batchmsg.FieldUpdatedAt:
  8495. m.ResetUpdatedAt()
  8496. return nil
  8497. case batchmsg.FieldDeletedAt:
  8498. m.ResetDeletedAt()
  8499. return nil
  8500. case batchmsg.FieldStatus:
  8501. m.ResetStatus()
  8502. return nil
  8503. case batchmsg.FieldBatchNo:
  8504. m.ResetBatchNo()
  8505. return nil
  8506. case batchmsg.FieldTaskName:
  8507. m.ResetTaskName()
  8508. return nil
  8509. case batchmsg.FieldFromwxid:
  8510. m.ResetFromwxid()
  8511. return nil
  8512. case batchmsg.FieldMsg:
  8513. m.ResetMsg()
  8514. return nil
  8515. case batchmsg.FieldTag:
  8516. m.ResetTag()
  8517. return nil
  8518. case batchmsg.FieldTagids:
  8519. m.ResetTagids()
  8520. return nil
  8521. case batchmsg.FieldTotal:
  8522. m.ResetTotal()
  8523. return nil
  8524. case batchmsg.FieldSuccess:
  8525. m.ResetSuccess()
  8526. return nil
  8527. case batchmsg.FieldFail:
  8528. m.ResetFail()
  8529. return nil
  8530. case batchmsg.FieldStartTime:
  8531. m.ResetStartTime()
  8532. return nil
  8533. case batchmsg.FieldStopTime:
  8534. m.ResetStopTime()
  8535. return nil
  8536. case batchmsg.FieldSendTime:
  8537. m.ResetSendTime()
  8538. return nil
  8539. case batchmsg.FieldType:
  8540. m.ResetType()
  8541. return nil
  8542. case batchmsg.FieldOrganizationID:
  8543. m.ResetOrganizationID()
  8544. return nil
  8545. case batchmsg.FieldCtype:
  8546. m.ResetCtype()
  8547. return nil
  8548. case batchmsg.FieldCc:
  8549. m.ResetCc()
  8550. return nil
  8551. case batchmsg.FieldPhone:
  8552. m.ResetPhone()
  8553. return nil
  8554. case batchmsg.FieldTemplateName:
  8555. m.ResetTemplateName()
  8556. return nil
  8557. case batchmsg.FieldTemplateCode:
  8558. m.ResetTemplateCode()
  8559. return nil
  8560. case batchmsg.FieldLang:
  8561. m.ResetLang()
  8562. return nil
  8563. }
  8564. return fmt.Errorf("unknown BatchMsg field %s", name)
  8565. }
  8566. // AddedEdges returns all edge names that were set/added in this mutation.
  8567. func (m *BatchMsgMutation) AddedEdges() []string {
  8568. edges := make([]string, 0, 0)
  8569. return edges
  8570. }
  8571. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8572. // name in this mutation.
  8573. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  8574. return nil
  8575. }
  8576. // RemovedEdges returns all edge names that were removed in this mutation.
  8577. func (m *BatchMsgMutation) RemovedEdges() []string {
  8578. edges := make([]string, 0, 0)
  8579. return edges
  8580. }
  8581. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8582. // the given name in this mutation.
  8583. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  8584. return nil
  8585. }
  8586. // ClearedEdges returns all edge names that were cleared in this mutation.
  8587. func (m *BatchMsgMutation) ClearedEdges() []string {
  8588. edges := make([]string, 0, 0)
  8589. return edges
  8590. }
  8591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8592. // was cleared in this mutation.
  8593. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  8594. return false
  8595. }
  8596. // ClearEdge clears the value of the edge with the given name. It returns an error
  8597. // if that edge is not defined in the schema.
  8598. func (m *BatchMsgMutation) ClearEdge(name string) error {
  8599. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  8600. }
  8601. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8602. // It returns an error if the edge is not defined in the schema.
  8603. func (m *BatchMsgMutation) ResetEdge(name string) error {
  8604. return fmt.Errorf("unknown BatchMsg edge %s", name)
  8605. }
  8606. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  8607. type CategoryMutation struct {
  8608. config
  8609. op Op
  8610. typ string
  8611. id *uint64
  8612. created_at *time.Time
  8613. updated_at *time.Time
  8614. deleted_at *time.Time
  8615. name *string
  8616. organization_id *uint64
  8617. addorganization_id *int64
  8618. clearedFields map[string]struct{}
  8619. done bool
  8620. oldValue func(context.Context) (*Category, error)
  8621. predicates []predicate.Category
  8622. }
  8623. var _ ent.Mutation = (*CategoryMutation)(nil)
  8624. // categoryOption allows management of the mutation configuration using functional options.
  8625. type categoryOption func(*CategoryMutation)
  8626. // newCategoryMutation creates new mutation for the Category entity.
  8627. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  8628. m := &CategoryMutation{
  8629. config: c,
  8630. op: op,
  8631. typ: TypeCategory,
  8632. clearedFields: make(map[string]struct{}),
  8633. }
  8634. for _, opt := range opts {
  8635. opt(m)
  8636. }
  8637. return m
  8638. }
  8639. // withCategoryID sets the ID field of the mutation.
  8640. func withCategoryID(id uint64) categoryOption {
  8641. return func(m *CategoryMutation) {
  8642. var (
  8643. err error
  8644. once sync.Once
  8645. value *Category
  8646. )
  8647. m.oldValue = func(ctx context.Context) (*Category, error) {
  8648. once.Do(func() {
  8649. if m.done {
  8650. err = errors.New("querying old values post mutation is not allowed")
  8651. } else {
  8652. value, err = m.Client().Category.Get(ctx, id)
  8653. }
  8654. })
  8655. return value, err
  8656. }
  8657. m.id = &id
  8658. }
  8659. }
  8660. // withCategory sets the old Category of the mutation.
  8661. func withCategory(node *Category) categoryOption {
  8662. return func(m *CategoryMutation) {
  8663. m.oldValue = func(context.Context) (*Category, error) {
  8664. return node, nil
  8665. }
  8666. m.id = &node.ID
  8667. }
  8668. }
  8669. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8670. // executed in a transaction (ent.Tx), a transactional client is returned.
  8671. func (m CategoryMutation) Client() *Client {
  8672. client := &Client{config: m.config}
  8673. client.init()
  8674. return client
  8675. }
  8676. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8677. // it returns an error otherwise.
  8678. func (m CategoryMutation) Tx() (*Tx, error) {
  8679. if _, ok := m.driver.(*txDriver); !ok {
  8680. return nil, errors.New("ent: mutation is not running in a transaction")
  8681. }
  8682. tx := &Tx{config: m.config}
  8683. tx.init()
  8684. return tx, nil
  8685. }
  8686. // SetID sets the value of the id field. Note that this
  8687. // operation is only accepted on creation of Category entities.
  8688. func (m *CategoryMutation) SetID(id uint64) {
  8689. m.id = &id
  8690. }
  8691. // ID returns the ID value in the mutation. Note that the ID is only available
  8692. // if it was provided to the builder or after it was returned from the database.
  8693. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  8694. if m.id == nil {
  8695. return
  8696. }
  8697. return *m.id, true
  8698. }
  8699. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8700. // That means, if the mutation is applied within a transaction with an isolation level such
  8701. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8702. // or updated by the mutation.
  8703. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  8704. switch {
  8705. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8706. id, exists := m.ID()
  8707. if exists {
  8708. return []uint64{id}, nil
  8709. }
  8710. fallthrough
  8711. case m.op.Is(OpUpdate | OpDelete):
  8712. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  8713. default:
  8714. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8715. }
  8716. }
  8717. // SetCreatedAt sets the "created_at" field.
  8718. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  8719. m.created_at = &t
  8720. }
  8721. // CreatedAt returns the value of the "created_at" field in the mutation.
  8722. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  8723. v := m.created_at
  8724. if v == nil {
  8725. return
  8726. }
  8727. return *v, true
  8728. }
  8729. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  8730. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8732. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8733. if !m.op.Is(OpUpdateOne) {
  8734. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8735. }
  8736. if m.id == nil || m.oldValue == nil {
  8737. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8738. }
  8739. oldValue, err := m.oldValue(ctx)
  8740. if err != nil {
  8741. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8742. }
  8743. return oldValue.CreatedAt, nil
  8744. }
  8745. // ResetCreatedAt resets all changes to the "created_at" field.
  8746. func (m *CategoryMutation) ResetCreatedAt() {
  8747. m.created_at = nil
  8748. }
  8749. // SetUpdatedAt sets the "updated_at" field.
  8750. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  8751. m.updated_at = &t
  8752. }
  8753. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8754. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  8755. v := m.updated_at
  8756. if v == nil {
  8757. return
  8758. }
  8759. return *v, true
  8760. }
  8761. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  8762. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8764. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8765. if !m.op.Is(OpUpdateOne) {
  8766. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8767. }
  8768. if m.id == nil || m.oldValue == nil {
  8769. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8770. }
  8771. oldValue, err := m.oldValue(ctx)
  8772. if err != nil {
  8773. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8774. }
  8775. return oldValue.UpdatedAt, nil
  8776. }
  8777. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8778. func (m *CategoryMutation) ResetUpdatedAt() {
  8779. m.updated_at = nil
  8780. }
  8781. // SetDeletedAt sets the "deleted_at" field.
  8782. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  8783. m.deleted_at = &t
  8784. }
  8785. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8786. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  8787. v := m.deleted_at
  8788. if v == nil {
  8789. return
  8790. }
  8791. return *v, true
  8792. }
  8793. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  8794. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8796. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8797. if !m.op.Is(OpUpdateOne) {
  8798. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8799. }
  8800. if m.id == nil || m.oldValue == nil {
  8801. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8802. }
  8803. oldValue, err := m.oldValue(ctx)
  8804. if err != nil {
  8805. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8806. }
  8807. return oldValue.DeletedAt, nil
  8808. }
  8809. // ClearDeletedAt clears the value of the "deleted_at" field.
  8810. func (m *CategoryMutation) ClearDeletedAt() {
  8811. m.deleted_at = nil
  8812. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  8813. }
  8814. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8815. func (m *CategoryMutation) DeletedAtCleared() bool {
  8816. _, ok := m.clearedFields[category.FieldDeletedAt]
  8817. return ok
  8818. }
  8819. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8820. func (m *CategoryMutation) ResetDeletedAt() {
  8821. m.deleted_at = nil
  8822. delete(m.clearedFields, category.FieldDeletedAt)
  8823. }
  8824. // SetName sets the "name" field.
  8825. func (m *CategoryMutation) SetName(s string) {
  8826. m.name = &s
  8827. }
  8828. // Name returns the value of the "name" field in the mutation.
  8829. func (m *CategoryMutation) Name() (r string, exists bool) {
  8830. v := m.name
  8831. if v == nil {
  8832. return
  8833. }
  8834. return *v, true
  8835. }
  8836. // OldName returns the old "name" field's value of the Category entity.
  8837. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8839. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  8840. if !m.op.Is(OpUpdateOne) {
  8841. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8842. }
  8843. if m.id == nil || m.oldValue == nil {
  8844. return v, errors.New("OldName requires an ID field in the mutation")
  8845. }
  8846. oldValue, err := m.oldValue(ctx)
  8847. if err != nil {
  8848. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8849. }
  8850. return oldValue.Name, nil
  8851. }
  8852. // ResetName resets all changes to the "name" field.
  8853. func (m *CategoryMutation) ResetName() {
  8854. m.name = nil
  8855. }
  8856. // SetOrganizationID sets the "organization_id" field.
  8857. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  8858. m.organization_id = &u
  8859. m.addorganization_id = nil
  8860. }
  8861. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8862. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  8863. v := m.organization_id
  8864. if v == nil {
  8865. return
  8866. }
  8867. return *v, true
  8868. }
  8869. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  8870. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8872. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8873. if !m.op.Is(OpUpdateOne) {
  8874. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8875. }
  8876. if m.id == nil || m.oldValue == nil {
  8877. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8878. }
  8879. oldValue, err := m.oldValue(ctx)
  8880. if err != nil {
  8881. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8882. }
  8883. return oldValue.OrganizationID, nil
  8884. }
  8885. // AddOrganizationID adds u to the "organization_id" field.
  8886. func (m *CategoryMutation) AddOrganizationID(u int64) {
  8887. if m.addorganization_id != nil {
  8888. *m.addorganization_id += u
  8889. } else {
  8890. m.addorganization_id = &u
  8891. }
  8892. }
  8893. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8894. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  8895. v := m.addorganization_id
  8896. if v == nil {
  8897. return
  8898. }
  8899. return *v, true
  8900. }
  8901. // ResetOrganizationID resets all changes to the "organization_id" field.
  8902. func (m *CategoryMutation) ResetOrganizationID() {
  8903. m.organization_id = nil
  8904. m.addorganization_id = nil
  8905. }
  8906. // Where appends a list predicates to the CategoryMutation builder.
  8907. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  8908. m.predicates = append(m.predicates, ps...)
  8909. }
  8910. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  8911. // users can use type-assertion to append predicates that do not depend on any generated package.
  8912. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  8913. p := make([]predicate.Category, len(ps))
  8914. for i := range ps {
  8915. p[i] = ps[i]
  8916. }
  8917. m.Where(p...)
  8918. }
  8919. // Op returns the operation name.
  8920. func (m *CategoryMutation) Op() Op {
  8921. return m.op
  8922. }
  8923. // SetOp allows setting the mutation operation.
  8924. func (m *CategoryMutation) SetOp(op Op) {
  8925. m.op = op
  8926. }
  8927. // Type returns the node type of this mutation (Category).
  8928. func (m *CategoryMutation) Type() string {
  8929. return m.typ
  8930. }
  8931. // Fields returns all fields that were changed during this mutation. Note that in
  8932. // order to get all numeric fields that were incremented/decremented, call
  8933. // AddedFields().
  8934. func (m *CategoryMutation) Fields() []string {
  8935. fields := make([]string, 0, 5)
  8936. if m.created_at != nil {
  8937. fields = append(fields, category.FieldCreatedAt)
  8938. }
  8939. if m.updated_at != nil {
  8940. fields = append(fields, category.FieldUpdatedAt)
  8941. }
  8942. if m.deleted_at != nil {
  8943. fields = append(fields, category.FieldDeletedAt)
  8944. }
  8945. if m.name != nil {
  8946. fields = append(fields, category.FieldName)
  8947. }
  8948. if m.organization_id != nil {
  8949. fields = append(fields, category.FieldOrganizationID)
  8950. }
  8951. return fields
  8952. }
  8953. // Field returns the value of a field with the given name. The second boolean
  8954. // return value indicates that this field was not set, or was not defined in the
  8955. // schema.
  8956. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  8957. switch name {
  8958. case category.FieldCreatedAt:
  8959. return m.CreatedAt()
  8960. case category.FieldUpdatedAt:
  8961. return m.UpdatedAt()
  8962. case category.FieldDeletedAt:
  8963. return m.DeletedAt()
  8964. case category.FieldName:
  8965. return m.Name()
  8966. case category.FieldOrganizationID:
  8967. return m.OrganizationID()
  8968. }
  8969. return nil, false
  8970. }
  8971. // OldField returns the old value of the field from the database. An error is
  8972. // returned if the mutation operation is not UpdateOne, or the query to the
  8973. // database failed.
  8974. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8975. switch name {
  8976. case category.FieldCreatedAt:
  8977. return m.OldCreatedAt(ctx)
  8978. case category.FieldUpdatedAt:
  8979. return m.OldUpdatedAt(ctx)
  8980. case category.FieldDeletedAt:
  8981. return m.OldDeletedAt(ctx)
  8982. case category.FieldName:
  8983. return m.OldName(ctx)
  8984. case category.FieldOrganizationID:
  8985. return m.OldOrganizationID(ctx)
  8986. }
  8987. return nil, fmt.Errorf("unknown Category field %s", name)
  8988. }
  8989. // SetField sets the value of a field with the given name. It returns an error if
  8990. // the field is not defined in the schema, or if the type mismatched the field
  8991. // type.
  8992. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  8993. switch name {
  8994. case category.FieldCreatedAt:
  8995. v, ok := value.(time.Time)
  8996. if !ok {
  8997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8998. }
  8999. m.SetCreatedAt(v)
  9000. return nil
  9001. case category.FieldUpdatedAt:
  9002. v, ok := value.(time.Time)
  9003. if !ok {
  9004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9005. }
  9006. m.SetUpdatedAt(v)
  9007. return nil
  9008. case category.FieldDeletedAt:
  9009. v, ok := value.(time.Time)
  9010. if !ok {
  9011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9012. }
  9013. m.SetDeletedAt(v)
  9014. return nil
  9015. case category.FieldName:
  9016. v, ok := value.(string)
  9017. if !ok {
  9018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9019. }
  9020. m.SetName(v)
  9021. return nil
  9022. case category.FieldOrganizationID:
  9023. v, ok := value.(uint64)
  9024. if !ok {
  9025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9026. }
  9027. m.SetOrganizationID(v)
  9028. return nil
  9029. }
  9030. return fmt.Errorf("unknown Category field %s", name)
  9031. }
  9032. // AddedFields returns all numeric fields that were incremented/decremented during
  9033. // this mutation.
  9034. func (m *CategoryMutation) AddedFields() []string {
  9035. var fields []string
  9036. if m.addorganization_id != nil {
  9037. fields = append(fields, category.FieldOrganizationID)
  9038. }
  9039. return fields
  9040. }
  9041. // AddedField returns the numeric value that was incremented/decremented on a field
  9042. // with the given name. The second boolean return value indicates that this field
  9043. // was not set, or was not defined in the schema.
  9044. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  9045. switch name {
  9046. case category.FieldOrganizationID:
  9047. return m.AddedOrganizationID()
  9048. }
  9049. return nil, false
  9050. }
  9051. // AddField adds the value to the field with the given name. It returns an error if
  9052. // the field is not defined in the schema, or if the type mismatched the field
  9053. // type.
  9054. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  9055. switch name {
  9056. case category.FieldOrganizationID:
  9057. v, ok := value.(int64)
  9058. if !ok {
  9059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9060. }
  9061. m.AddOrganizationID(v)
  9062. return nil
  9063. }
  9064. return fmt.Errorf("unknown Category numeric field %s", name)
  9065. }
  9066. // ClearedFields returns all nullable fields that were cleared during this
  9067. // mutation.
  9068. func (m *CategoryMutation) ClearedFields() []string {
  9069. var fields []string
  9070. if m.FieldCleared(category.FieldDeletedAt) {
  9071. fields = append(fields, category.FieldDeletedAt)
  9072. }
  9073. return fields
  9074. }
  9075. // FieldCleared returns a boolean indicating if a field with the given name was
  9076. // cleared in this mutation.
  9077. func (m *CategoryMutation) FieldCleared(name string) bool {
  9078. _, ok := m.clearedFields[name]
  9079. return ok
  9080. }
  9081. // ClearField clears the value of the field with the given name. It returns an
  9082. // error if the field is not defined in the schema.
  9083. func (m *CategoryMutation) ClearField(name string) error {
  9084. switch name {
  9085. case category.FieldDeletedAt:
  9086. m.ClearDeletedAt()
  9087. return nil
  9088. }
  9089. return fmt.Errorf("unknown Category nullable field %s", name)
  9090. }
  9091. // ResetField resets all changes in the mutation for the field with the given name.
  9092. // It returns an error if the field is not defined in the schema.
  9093. func (m *CategoryMutation) ResetField(name string) error {
  9094. switch name {
  9095. case category.FieldCreatedAt:
  9096. m.ResetCreatedAt()
  9097. return nil
  9098. case category.FieldUpdatedAt:
  9099. m.ResetUpdatedAt()
  9100. return nil
  9101. case category.FieldDeletedAt:
  9102. m.ResetDeletedAt()
  9103. return nil
  9104. case category.FieldName:
  9105. m.ResetName()
  9106. return nil
  9107. case category.FieldOrganizationID:
  9108. m.ResetOrganizationID()
  9109. return nil
  9110. }
  9111. return fmt.Errorf("unknown Category field %s", name)
  9112. }
  9113. // AddedEdges returns all edge names that were set/added in this mutation.
  9114. func (m *CategoryMutation) AddedEdges() []string {
  9115. edges := make([]string, 0, 0)
  9116. return edges
  9117. }
  9118. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9119. // name in this mutation.
  9120. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  9121. return nil
  9122. }
  9123. // RemovedEdges returns all edge names that were removed in this mutation.
  9124. func (m *CategoryMutation) RemovedEdges() []string {
  9125. edges := make([]string, 0, 0)
  9126. return edges
  9127. }
  9128. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9129. // the given name in this mutation.
  9130. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  9131. return nil
  9132. }
  9133. // ClearedEdges returns all edge names that were cleared in this mutation.
  9134. func (m *CategoryMutation) ClearedEdges() []string {
  9135. edges := make([]string, 0, 0)
  9136. return edges
  9137. }
  9138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9139. // was cleared in this mutation.
  9140. func (m *CategoryMutation) EdgeCleared(name string) bool {
  9141. return false
  9142. }
  9143. // ClearEdge clears the value of the edge with the given name. It returns an error
  9144. // if that edge is not defined in the schema.
  9145. func (m *CategoryMutation) ClearEdge(name string) error {
  9146. return fmt.Errorf("unknown Category unique edge %s", name)
  9147. }
  9148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9149. // It returns an error if the edge is not defined in the schema.
  9150. func (m *CategoryMutation) ResetEdge(name string) error {
  9151. return fmt.Errorf("unknown Category edge %s", name)
  9152. }
  9153. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  9154. type ChatRecordsMutation struct {
  9155. config
  9156. op Op
  9157. typ string
  9158. id *uint64
  9159. created_at *time.Time
  9160. updated_at *time.Time
  9161. deleted_at *time.Time
  9162. content *string
  9163. content_type *uint8
  9164. addcontent_type *int8
  9165. session_id *uint64
  9166. addsession_id *int64
  9167. user_id *uint64
  9168. adduser_id *int64
  9169. bot_id *uint64
  9170. addbot_id *int64
  9171. bot_type *uint8
  9172. addbot_type *int8
  9173. clearedFields map[string]struct{}
  9174. done bool
  9175. oldValue func(context.Context) (*ChatRecords, error)
  9176. predicates []predicate.ChatRecords
  9177. }
  9178. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  9179. // chatrecordsOption allows management of the mutation configuration using functional options.
  9180. type chatrecordsOption func(*ChatRecordsMutation)
  9181. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  9182. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  9183. m := &ChatRecordsMutation{
  9184. config: c,
  9185. op: op,
  9186. typ: TypeChatRecords,
  9187. clearedFields: make(map[string]struct{}),
  9188. }
  9189. for _, opt := range opts {
  9190. opt(m)
  9191. }
  9192. return m
  9193. }
  9194. // withChatRecordsID sets the ID field of the mutation.
  9195. func withChatRecordsID(id uint64) chatrecordsOption {
  9196. return func(m *ChatRecordsMutation) {
  9197. var (
  9198. err error
  9199. once sync.Once
  9200. value *ChatRecords
  9201. )
  9202. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  9203. once.Do(func() {
  9204. if m.done {
  9205. err = errors.New("querying old values post mutation is not allowed")
  9206. } else {
  9207. value, err = m.Client().ChatRecords.Get(ctx, id)
  9208. }
  9209. })
  9210. return value, err
  9211. }
  9212. m.id = &id
  9213. }
  9214. }
  9215. // withChatRecords sets the old ChatRecords of the mutation.
  9216. func withChatRecords(node *ChatRecords) chatrecordsOption {
  9217. return func(m *ChatRecordsMutation) {
  9218. m.oldValue = func(context.Context) (*ChatRecords, error) {
  9219. return node, nil
  9220. }
  9221. m.id = &node.ID
  9222. }
  9223. }
  9224. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9225. // executed in a transaction (ent.Tx), a transactional client is returned.
  9226. func (m ChatRecordsMutation) Client() *Client {
  9227. client := &Client{config: m.config}
  9228. client.init()
  9229. return client
  9230. }
  9231. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9232. // it returns an error otherwise.
  9233. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  9234. if _, ok := m.driver.(*txDriver); !ok {
  9235. return nil, errors.New("ent: mutation is not running in a transaction")
  9236. }
  9237. tx := &Tx{config: m.config}
  9238. tx.init()
  9239. return tx, nil
  9240. }
  9241. // SetID sets the value of the id field. Note that this
  9242. // operation is only accepted on creation of ChatRecords entities.
  9243. func (m *ChatRecordsMutation) SetID(id uint64) {
  9244. m.id = &id
  9245. }
  9246. // ID returns the ID value in the mutation. Note that the ID is only available
  9247. // if it was provided to the builder or after it was returned from the database.
  9248. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  9249. if m.id == nil {
  9250. return
  9251. }
  9252. return *m.id, true
  9253. }
  9254. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9255. // That means, if the mutation is applied within a transaction with an isolation level such
  9256. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9257. // or updated by the mutation.
  9258. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9259. switch {
  9260. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9261. id, exists := m.ID()
  9262. if exists {
  9263. return []uint64{id}, nil
  9264. }
  9265. fallthrough
  9266. case m.op.Is(OpUpdate | OpDelete):
  9267. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  9268. default:
  9269. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9270. }
  9271. }
  9272. // SetCreatedAt sets the "created_at" field.
  9273. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  9274. m.created_at = &t
  9275. }
  9276. // CreatedAt returns the value of the "created_at" field in the mutation.
  9277. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9278. v := m.created_at
  9279. if v == nil {
  9280. return
  9281. }
  9282. return *v, true
  9283. }
  9284. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  9285. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9287. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9288. if !m.op.Is(OpUpdateOne) {
  9289. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9290. }
  9291. if m.id == nil || m.oldValue == nil {
  9292. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9293. }
  9294. oldValue, err := m.oldValue(ctx)
  9295. if err != nil {
  9296. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9297. }
  9298. return oldValue.CreatedAt, nil
  9299. }
  9300. // ResetCreatedAt resets all changes to the "created_at" field.
  9301. func (m *ChatRecordsMutation) ResetCreatedAt() {
  9302. m.created_at = nil
  9303. }
  9304. // SetUpdatedAt sets the "updated_at" field.
  9305. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  9306. m.updated_at = &t
  9307. }
  9308. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9309. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9310. v := m.updated_at
  9311. if v == nil {
  9312. return
  9313. }
  9314. return *v, true
  9315. }
  9316. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  9317. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9319. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9320. if !m.op.Is(OpUpdateOne) {
  9321. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9322. }
  9323. if m.id == nil || m.oldValue == nil {
  9324. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9325. }
  9326. oldValue, err := m.oldValue(ctx)
  9327. if err != nil {
  9328. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9329. }
  9330. return oldValue.UpdatedAt, nil
  9331. }
  9332. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9333. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  9334. m.updated_at = nil
  9335. }
  9336. // SetDeletedAt sets the "deleted_at" field.
  9337. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  9338. m.deleted_at = &t
  9339. }
  9340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9341. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9342. v := m.deleted_at
  9343. if v == nil {
  9344. return
  9345. }
  9346. return *v, true
  9347. }
  9348. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  9349. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9351. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9352. if !m.op.Is(OpUpdateOne) {
  9353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9354. }
  9355. if m.id == nil || m.oldValue == nil {
  9356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9357. }
  9358. oldValue, err := m.oldValue(ctx)
  9359. if err != nil {
  9360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9361. }
  9362. return oldValue.DeletedAt, nil
  9363. }
  9364. // ClearDeletedAt clears the value of the "deleted_at" field.
  9365. func (m *ChatRecordsMutation) ClearDeletedAt() {
  9366. m.deleted_at = nil
  9367. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  9368. }
  9369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9370. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  9371. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  9372. return ok
  9373. }
  9374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9375. func (m *ChatRecordsMutation) ResetDeletedAt() {
  9376. m.deleted_at = nil
  9377. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  9378. }
  9379. // SetContent sets the "content" field.
  9380. func (m *ChatRecordsMutation) SetContent(s string) {
  9381. m.content = &s
  9382. }
  9383. // Content returns the value of the "content" field in the mutation.
  9384. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  9385. v := m.content
  9386. if v == nil {
  9387. return
  9388. }
  9389. return *v, true
  9390. }
  9391. // OldContent returns the old "content" field's value of the ChatRecords entity.
  9392. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9394. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9395. if !m.op.Is(OpUpdateOne) {
  9396. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9397. }
  9398. if m.id == nil || m.oldValue == nil {
  9399. return v, errors.New("OldContent requires an ID field in the mutation")
  9400. }
  9401. oldValue, err := m.oldValue(ctx)
  9402. if err != nil {
  9403. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9404. }
  9405. return oldValue.Content, nil
  9406. }
  9407. // ResetContent resets all changes to the "content" field.
  9408. func (m *ChatRecordsMutation) ResetContent() {
  9409. m.content = nil
  9410. }
  9411. // SetContentType sets the "content_type" field.
  9412. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  9413. m.content_type = &u
  9414. m.addcontent_type = nil
  9415. }
  9416. // ContentType returns the value of the "content_type" field in the mutation.
  9417. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  9418. v := m.content_type
  9419. if v == nil {
  9420. return
  9421. }
  9422. return *v, true
  9423. }
  9424. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  9425. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9427. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  9428. if !m.op.Is(OpUpdateOne) {
  9429. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9430. }
  9431. if m.id == nil || m.oldValue == nil {
  9432. return v, errors.New("OldContentType requires an ID field in the mutation")
  9433. }
  9434. oldValue, err := m.oldValue(ctx)
  9435. if err != nil {
  9436. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9437. }
  9438. return oldValue.ContentType, nil
  9439. }
  9440. // AddContentType adds u to the "content_type" field.
  9441. func (m *ChatRecordsMutation) AddContentType(u int8) {
  9442. if m.addcontent_type != nil {
  9443. *m.addcontent_type += u
  9444. } else {
  9445. m.addcontent_type = &u
  9446. }
  9447. }
  9448. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9449. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  9450. v := m.addcontent_type
  9451. if v == nil {
  9452. return
  9453. }
  9454. return *v, true
  9455. }
  9456. // ResetContentType resets all changes to the "content_type" field.
  9457. func (m *ChatRecordsMutation) ResetContentType() {
  9458. m.content_type = nil
  9459. m.addcontent_type = nil
  9460. }
  9461. // SetSessionID sets the "session_id" field.
  9462. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  9463. m.session_id = &u
  9464. m.addsession_id = nil
  9465. }
  9466. // SessionID returns the value of the "session_id" field in the mutation.
  9467. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  9468. v := m.session_id
  9469. if v == nil {
  9470. return
  9471. }
  9472. return *v, true
  9473. }
  9474. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  9475. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9477. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  9478. if !m.op.Is(OpUpdateOne) {
  9479. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  9480. }
  9481. if m.id == nil || m.oldValue == nil {
  9482. return v, errors.New("OldSessionID requires an ID field in the mutation")
  9483. }
  9484. oldValue, err := m.oldValue(ctx)
  9485. if err != nil {
  9486. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  9487. }
  9488. return oldValue.SessionID, nil
  9489. }
  9490. // AddSessionID adds u to the "session_id" field.
  9491. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  9492. if m.addsession_id != nil {
  9493. *m.addsession_id += u
  9494. } else {
  9495. m.addsession_id = &u
  9496. }
  9497. }
  9498. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  9499. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  9500. v := m.addsession_id
  9501. if v == nil {
  9502. return
  9503. }
  9504. return *v, true
  9505. }
  9506. // ResetSessionID resets all changes to the "session_id" field.
  9507. func (m *ChatRecordsMutation) ResetSessionID() {
  9508. m.session_id = nil
  9509. m.addsession_id = nil
  9510. }
  9511. // SetUserID sets the "user_id" field.
  9512. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  9513. m.user_id = &u
  9514. m.adduser_id = nil
  9515. }
  9516. // UserID returns the value of the "user_id" field in the mutation.
  9517. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  9518. v := m.user_id
  9519. if v == nil {
  9520. return
  9521. }
  9522. return *v, true
  9523. }
  9524. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  9525. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9527. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9528. if !m.op.Is(OpUpdateOne) {
  9529. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9530. }
  9531. if m.id == nil || m.oldValue == nil {
  9532. return v, errors.New("OldUserID requires an ID field in the mutation")
  9533. }
  9534. oldValue, err := m.oldValue(ctx)
  9535. if err != nil {
  9536. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9537. }
  9538. return oldValue.UserID, nil
  9539. }
  9540. // AddUserID adds u to the "user_id" field.
  9541. func (m *ChatRecordsMutation) AddUserID(u int64) {
  9542. if m.adduser_id != nil {
  9543. *m.adduser_id += u
  9544. } else {
  9545. m.adduser_id = &u
  9546. }
  9547. }
  9548. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9549. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  9550. v := m.adduser_id
  9551. if v == nil {
  9552. return
  9553. }
  9554. return *v, true
  9555. }
  9556. // ResetUserID resets all changes to the "user_id" field.
  9557. func (m *ChatRecordsMutation) ResetUserID() {
  9558. m.user_id = nil
  9559. m.adduser_id = nil
  9560. }
  9561. // SetBotID sets the "bot_id" field.
  9562. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  9563. m.bot_id = &u
  9564. m.addbot_id = nil
  9565. }
  9566. // BotID returns the value of the "bot_id" field in the mutation.
  9567. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  9568. v := m.bot_id
  9569. if v == nil {
  9570. return
  9571. }
  9572. return *v, true
  9573. }
  9574. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  9575. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9577. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9578. if !m.op.Is(OpUpdateOne) {
  9579. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9580. }
  9581. if m.id == nil || m.oldValue == nil {
  9582. return v, errors.New("OldBotID requires an ID field in the mutation")
  9583. }
  9584. oldValue, err := m.oldValue(ctx)
  9585. if err != nil {
  9586. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9587. }
  9588. return oldValue.BotID, nil
  9589. }
  9590. // AddBotID adds u to the "bot_id" field.
  9591. func (m *ChatRecordsMutation) AddBotID(u int64) {
  9592. if m.addbot_id != nil {
  9593. *m.addbot_id += u
  9594. } else {
  9595. m.addbot_id = &u
  9596. }
  9597. }
  9598. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9599. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  9600. v := m.addbot_id
  9601. if v == nil {
  9602. return
  9603. }
  9604. return *v, true
  9605. }
  9606. // ResetBotID resets all changes to the "bot_id" field.
  9607. func (m *ChatRecordsMutation) ResetBotID() {
  9608. m.bot_id = nil
  9609. m.addbot_id = nil
  9610. }
  9611. // SetBotType sets the "bot_type" field.
  9612. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  9613. m.bot_type = &u
  9614. m.addbot_type = nil
  9615. }
  9616. // BotType returns the value of the "bot_type" field in the mutation.
  9617. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  9618. v := m.bot_type
  9619. if v == nil {
  9620. return
  9621. }
  9622. return *v, true
  9623. }
  9624. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  9625. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9627. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9628. if !m.op.Is(OpUpdateOne) {
  9629. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9630. }
  9631. if m.id == nil || m.oldValue == nil {
  9632. return v, errors.New("OldBotType requires an ID field in the mutation")
  9633. }
  9634. oldValue, err := m.oldValue(ctx)
  9635. if err != nil {
  9636. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9637. }
  9638. return oldValue.BotType, nil
  9639. }
  9640. // AddBotType adds u to the "bot_type" field.
  9641. func (m *ChatRecordsMutation) AddBotType(u int8) {
  9642. if m.addbot_type != nil {
  9643. *m.addbot_type += u
  9644. } else {
  9645. m.addbot_type = &u
  9646. }
  9647. }
  9648. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9649. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  9650. v := m.addbot_type
  9651. if v == nil {
  9652. return
  9653. }
  9654. return *v, true
  9655. }
  9656. // ResetBotType resets all changes to the "bot_type" field.
  9657. func (m *ChatRecordsMutation) ResetBotType() {
  9658. m.bot_type = nil
  9659. m.addbot_type = nil
  9660. }
  9661. // Where appends a list predicates to the ChatRecordsMutation builder.
  9662. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  9663. m.predicates = append(m.predicates, ps...)
  9664. }
  9665. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  9666. // users can use type-assertion to append predicates that do not depend on any generated package.
  9667. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  9668. p := make([]predicate.ChatRecords, len(ps))
  9669. for i := range ps {
  9670. p[i] = ps[i]
  9671. }
  9672. m.Where(p...)
  9673. }
  9674. // Op returns the operation name.
  9675. func (m *ChatRecordsMutation) Op() Op {
  9676. return m.op
  9677. }
  9678. // SetOp allows setting the mutation operation.
  9679. func (m *ChatRecordsMutation) SetOp(op Op) {
  9680. m.op = op
  9681. }
  9682. // Type returns the node type of this mutation (ChatRecords).
  9683. func (m *ChatRecordsMutation) Type() string {
  9684. return m.typ
  9685. }
  9686. // Fields returns all fields that were changed during this mutation. Note that in
  9687. // order to get all numeric fields that were incremented/decremented, call
  9688. // AddedFields().
  9689. func (m *ChatRecordsMutation) Fields() []string {
  9690. fields := make([]string, 0, 9)
  9691. if m.created_at != nil {
  9692. fields = append(fields, chatrecords.FieldCreatedAt)
  9693. }
  9694. if m.updated_at != nil {
  9695. fields = append(fields, chatrecords.FieldUpdatedAt)
  9696. }
  9697. if m.deleted_at != nil {
  9698. fields = append(fields, chatrecords.FieldDeletedAt)
  9699. }
  9700. if m.content != nil {
  9701. fields = append(fields, chatrecords.FieldContent)
  9702. }
  9703. if m.content_type != nil {
  9704. fields = append(fields, chatrecords.FieldContentType)
  9705. }
  9706. if m.session_id != nil {
  9707. fields = append(fields, chatrecords.FieldSessionID)
  9708. }
  9709. if m.user_id != nil {
  9710. fields = append(fields, chatrecords.FieldUserID)
  9711. }
  9712. if m.bot_id != nil {
  9713. fields = append(fields, chatrecords.FieldBotID)
  9714. }
  9715. if m.bot_type != nil {
  9716. fields = append(fields, chatrecords.FieldBotType)
  9717. }
  9718. return fields
  9719. }
  9720. // Field returns the value of a field with the given name. The second boolean
  9721. // return value indicates that this field was not set, or was not defined in the
  9722. // schema.
  9723. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  9724. switch name {
  9725. case chatrecords.FieldCreatedAt:
  9726. return m.CreatedAt()
  9727. case chatrecords.FieldUpdatedAt:
  9728. return m.UpdatedAt()
  9729. case chatrecords.FieldDeletedAt:
  9730. return m.DeletedAt()
  9731. case chatrecords.FieldContent:
  9732. return m.Content()
  9733. case chatrecords.FieldContentType:
  9734. return m.ContentType()
  9735. case chatrecords.FieldSessionID:
  9736. return m.SessionID()
  9737. case chatrecords.FieldUserID:
  9738. return m.UserID()
  9739. case chatrecords.FieldBotID:
  9740. return m.BotID()
  9741. case chatrecords.FieldBotType:
  9742. return m.BotType()
  9743. }
  9744. return nil, false
  9745. }
  9746. // OldField returns the old value of the field from the database. An error is
  9747. // returned if the mutation operation is not UpdateOne, or the query to the
  9748. // database failed.
  9749. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9750. switch name {
  9751. case chatrecords.FieldCreatedAt:
  9752. return m.OldCreatedAt(ctx)
  9753. case chatrecords.FieldUpdatedAt:
  9754. return m.OldUpdatedAt(ctx)
  9755. case chatrecords.FieldDeletedAt:
  9756. return m.OldDeletedAt(ctx)
  9757. case chatrecords.FieldContent:
  9758. return m.OldContent(ctx)
  9759. case chatrecords.FieldContentType:
  9760. return m.OldContentType(ctx)
  9761. case chatrecords.FieldSessionID:
  9762. return m.OldSessionID(ctx)
  9763. case chatrecords.FieldUserID:
  9764. return m.OldUserID(ctx)
  9765. case chatrecords.FieldBotID:
  9766. return m.OldBotID(ctx)
  9767. case chatrecords.FieldBotType:
  9768. return m.OldBotType(ctx)
  9769. }
  9770. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  9771. }
  9772. // SetField sets the value of a field with the given name. It returns an error if
  9773. // the field is not defined in the schema, or if the type mismatched the field
  9774. // type.
  9775. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  9776. switch name {
  9777. case chatrecords.FieldCreatedAt:
  9778. v, ok := value.(time.Time)
  9779. if !ok {
  9780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9781. }
  9782. m.SetCreatedAt(v)
  9783. return nil
  9784. case chatrecords.FieldUpdatedAt:
  9785. v, ok := value.(time.Time)
  9786. if !ok {
  9787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9788. }
  9789. m.SetUpdatedAt(v)
  9790. return nil
  9791. case chatrecords.FieldDeletedAt:
  9792. v, ok := value.(time.Time)
  9793. if !ok {
  9794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9795. }
  9796. m.SetDeletedAt(v)
  9797. return nil
  9798. case chatrecords.FieldContent:
  9799. v, ok := value.(string)
  9800. if !ok {
  9801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9802. }
  9803. m.SetContent(v)
  9804. return nil
  9805. case chatrecords.FieldContentType:
  9806. v, ok := value.(uint8)
  9807. if !ok {
  9808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9809. }
  9810. m.SetContentType(v)
  9811. return nil
  9812. case chatrecords.FieldSessionID:
  9813. v, ok := value.(uint64)
  9814. if !ok {
  9815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9816. }
  9817. m.SetSessionID(v)
  9818. return nil
  9819. case chatrecords.FieldUserID:
  9820. v, ok := value.(uint64)
  9821. if !ok {
  9822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9823. }
  9824. m.SetUserID(v)
  9825. return nil
  9826. case chatrecords.FieldBotID:
  9827. v, ok := value.(uint64)
  9828. if !ok {
  9829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9830. }
  9831. m.SetBotID(v)
  9832. return nil
  9833. case chatrecords.FieldBotType:
  9834. v, ok := value.(uint8)
  9835. if !ok {
  9836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9837. }
  9838. m.SetBotType(v)
  9839. return nil
  9840. }
  9841. return fmt.Errorf("unknown ChatRecords field %s", name)
  9842. }
  9843. // AddedFields returns all numeric fields that were incremented/decremented during
  9844. // this mutation.
  9845. func (m *ChatRecordsMutation) AddedFields() []string {
  9846. var fields []string
  9847. if m.addcontent_type != nil {
  9848. fields = append(fields, chatrecords.FieldContentType)
  9849. }
  9850. if m.addsession_id != nil {
  9851. fields = append(fields, chatrecords.FieldSessionID)
  9852. }
  9853. if m.adduser_id != nil {
  9854. fields = append(fields, chatrecords.FieldUserID)
  9855. }
  9856. if m.addbot_id != nil {
  9857. fields = append(fields, chatrecords.FieldBotID)
  9858. }
  9859. if m.addbot_type != nil {
  9860. fields = append(fields, chatrecords.FieldBotType)
  9861. }
  9862. return fields
  9863. }
  9864. // AddedField returns the numeric value that was incremented/decremented on a field
  9865. // with the given name. The second boolean return value indicates that this field
  9866. // was not set, or was not defined in the schema.
  9867. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9868. switch name {
  9869. case chatrecords.FieldContentType:
  9870. return m.AddedContentType()
  9871. case chatrecords.FieldSessionID:
  9872. return m.AddedSessionID()
  9873. case chatrecords.FieldUserID:
  9874. return m.AddedUserID()
  9875. case chatrecords.FieldBotID:
  9876. return m.AddedBotID()
  9877. case chatrecords.FieldBotType:
  9878. return m.AddedBotType()
  9879. }
  9880. return nil, false
  9881. }
  9882. // AddField adds the value to the field with the given name. It returns an error if
  9883. // the field is not defined in the schema, or if the type mismatched the field
  9884. // type.
  9885. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  9886. switch name {
  9887. case chatrecords.FieldContentType:
  9888. v, ok := value.(int8)
  9889. if !ok {
  9890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9891. }
  9892. m.AddContentType(v)
  9893. return nil
  9894. case chatrecords.FieldSessionID:
  9895. v, ok := value.(int64)
  9896. if !ok {
  9897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9898. }
  9899. m.AddSessionID(v)
  9900. return nil
  9901. case chatrecords.FieldUserID:
  9902. v, ok := value.(int64)
  9903. if !ok {
  9904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9905. }
  9906. m.AddUserID(v)
  9907. return nil
  9908. case chatrecords.FieldBotID:
  9909. v, ok := value.(int64)
  9910. if !ok {
  9911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9912. }
  9913. m.AddBotID(v)
  9914. return nil
  9915. case chatrecords.FieldBotType:
  9916. v, ok := value.(int8)
  9917. if !ok {
  9918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9919. }
  9920. m.AddBotType(v)
  9921. return nil
  9922. }
  9923. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  9924. }
  9925. // ClearedFields returns all nullable fields that were cleared during this
  9926. // mutation.
  9927. func (m *ChatRecordsMutation) ClearedFields() []string {
  9928. var fields []string
  9929. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  9930. fields = append(fields, chatrecords.FieldDeletedAt)
  9931. }
  9932. return fields
  9933. }
  9934. // FieldCleared returns a boolean indicating if a field with the given name was
  9935. // cleared in this mutation.
  9936. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  9937. _, ok := m.clearedFields[name]
  9938. return ok
  9939. }
  9940. // ClearField clears the value of the field with the given name. It returns an
  9941. // error if the field is not defined in the schema.
  9942. func (m *ChatRecordsMutation) ClearField(name string) error {
  9943. switch name {
  9944. case chatrecords.FieldDeletedAt:
  9945. m.ClearDeletedAt()
  9946. return nil
  9947. }
  9948. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  9949. }
  9950. // ResetField resets all changes in the mutation for the field with the given name.
  9951. // It returns an error if the field is not defined in the schema.
  9952. func (m *ChatRecordsMutation) ResetField(name string) error {
  9953. switch name {
  9954. case chatrecords.FieldCreatedAt:
  9955. m.ResetCreatedAt()
  9956. return nil
  9957. case chatrecords.FieldUpdatedAt:
  9958. m.ResetUpdatedAt()
  9959. return nil
  9960. case chatrecords.FieldDeletedAt:
  9961. m.ResetDeletedAt()
  9962. return nil
  9963. case chatrecords.FieldContent:
  9964. m.ResetContent()
  9965. return nil
  9966. case chatrecords.FieldContentType:
  9967. m.ResetContentType()
  9968. return nil
  9969. case chatrecords.FieldSessionID:
  9970. m.ResetSessionID()
  9971. return nil
  9972. case chatrecords.FieldUserID:
  9973. m.ResetUserID()
  9974. return nil
  9975. case chatrecords.FieldBotID:
  9976. m.ResetBotID()
  9977. return nil
  9978. case chatrecords.FieldBotType:
  9979. m.ResetBotType()
  9980. return nil
  9981. }
  9982. return fmt.Errorf("unknown ChatRecords field %s", name)
  9983. }
  9984. // AddedEdges returns all edge names that were set/added in this mutation.
  9985. func (m *ChatRecordsMutation) AddedEdges() []string {
  9986. edges := make([]string, 0, 0)
  9987. return edges
  9988. }
  9989. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9990. // name in this mutation.
  9991. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  9992. return nil
  9993. }
  9994. // RemovedEdges returns all edge names that were removed in this mutation.
  9995. func (m *ChatRecordsMutation) RemovedEdges() []string {
  9996. edges := make([]string, 0, 0)
  9997. return edges
  9998. }
  9999. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10000. // the given name in this mutation.
  10001. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  10002. return nil
  10003. }
  10004. // ClearedEdges returns all edge names that were cleared in this mutation.
  10005. func (m *ChatRecordsMutation) ClearedEdges() []string {
  10006. edges := make([]string, 0, 0)
  10007. return edges
  10008. }
  10009. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10010. // was cleared in this mutation.
  10011. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  10012. return false
  10013. }
  10014. // ClearEdge clears the value of the edge with the given name. It returns an error
  10015. // if that edge is not defined in the schema.
  10016. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  10017. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  10018. }
  10019. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10020. // It returns an error if the edge is not defined in the schema.
  10021. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  10022. return fmt.Errorf("unknown ChatRecords edge %s", name)
  10023. }
  10024. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  10025. type ChatSessionMutation struct {
  10026. config
  10027. op Op
  10028. typ string
  10029. id *uint64
  10030. created_at *time.Time
  10031. updated_at *time.Time
  10032. deleted_at *time.Time
  10033. name *string
  10034. user_id *uint64
  10035. adduser_id *int64
  10036. bot_id *uint64
  10037. addbot_id *int64
  10038. bot_type *uint8
  10039. addbot_type *int8
  10040. clearedFields map[string]struct{}
  10041. done bool
  10042. oldValue func(context.Context) (*ChatSession, error)
  10043. predicates []predicate.ChatSession
  10044. }
  10045. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  10046. // chatsessionOption allows management of the mutation configuration using functional options.
  10047. type chatsessionOption func(*ChatSessionMutation)
  10048. // newChatSessionMutation creates new mutation for the ChatSession entity.
  10049. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  10050. m := &ChatSessionMutation{
  10051. config: c,
  10052. op: op,
  10053. typ: TypeChatSession,
  10054. clearedFields: make(map[string]struct{}),
  10055. }
  10056. for _, opt := range opts {
  10057. opt(m)
  10058. }
  10059. return m
  10060. }
  10061. // withChatSessionID sets the ID field of the mutation.
  10062. func withChatSessionID(id uint64) chatsessionOption {
  10063. return func(m *ChatSessionMutation) {
  10064. var (
  10065. err error
  10066. once sync.Once
  10067. value *ChatSession
  10068. )
  10069. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  10070. once.Do(func() {
  10071. if m.done {
  10072. err = errors.New("querying old values post mutation is not allowed")
  10073. } else {
  10074. value, err = m.Client().ChatSession.Get(ctx, id)
  10075. }
  10076. })
  10077. return value, err
  10078. }
  10079. m.id = &id
  10080. }
  10081. }
  10082. // withChatSession sets the old ChatSession of the mutation.
  10083. func withChatSession(node *ChatSession) chatsessionOption {
  10084. return func(m *ChatSessionMutation) {
  10085. m.oldValue = func(context.Context) (*ChatSession, error) {
  10086. return node, nil
  10087. }
  10088. m.id = &node.ID
  10089. }
  10090. }
  10091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10092. // executed in a transaction (ent.Tx), a transactional client is returned.
  10093. func (m ChatSessionMutation) Client() *Client {
  10094. client := &Client{config: m.config}
  10095. client.init()
  10096. return client
  10097. }
  10098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10099. // it returns an error otherwise.
  10100. func (m ChatSessionMutation) Tx() (*Tx, error) {
  10101. if _, ok := m.driver.(*txDriver); !ok {
  10102. return nil, errors.New("ent: mutation is not running in a transaction")
  10103. }
  10104. tx := &Tx{config: m.config}
  10105. tx.init()
  10106. return tx, nil
  10107. }
  10108. // SetID sets the value of the id field. Note that this
  10109. // operation is only accepted on creation of ChatSession entities.
  10110. func (m *ChatSessionMutation) SetID(id uint64) {
  10111. m.id = &id
  10112. }
  10113. // ID returns the ID value in the mutation. Note that the ID is only available
  10114. // if it was provided to the builder or after it was returned from the database.
  10115. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  10116. if m.id == nil {
  10117. return
  10118. }
  10119. return *m.id, true
  10120. }
  10121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10122. // That means, if the mutation is applied within a transaction with an isolation level such
  10123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10124. // or updated by the mutation.
  10125. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  10126. switch {
  10127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10128. id, exists := m.ID()
  10129. if exists {
  10130. return []uint64{id}, nil
  10131. }
  10132. fallthrough
  10133. case m.op.Is(OpUpdate | OpDelete):
  10134. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  10135. default:
  10136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10137. }
  10138. }
  10139. // SetCreatedAt sets the "created_at" field.
  10140. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  10141. m.created_at = &t
  10142. }
  10143. // CreatedAt returns the value of the "created_at" field in the mutation.
  10144. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  10145. v := m.created_at
  10146. if v == nil {
  10147. return
  10148. }
  10149. return *v, true
  10150. }
  10151. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  10152. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10154. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10155. if !m.op.Is(OpUpdateOne) {
  10156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10157. }
  10158. if m.id == nil || m.oldValue == nil {
  10159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10160. }
  10161. oldValue, err := m.oldValue(ctx)
  10162. if err != nil {
  10163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10164. }
  10165. return oldValue.CreatedAt, nil
  10166. }
  10167. // ResetCreatedAt resets all changes to the "created_at" field.
  10168. func (m *ChatSessionMutation) ResetCreatedAt() {
  10169. m.created_at = nil
  10170. }
  10171. // SetUpdatedAt sets the "updated_at" field.
  10172. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  10173. m.updated_at = &t
  10174. }
  10175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10176. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  10177. v := m.updated_at
  10178. if v == nil {
  10179. return
  10180. }
  10181. return *v, true
  10182. }
  10183. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  10184. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10186. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10187. if !m.op.Is(OpUpdateOne) {
  10188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10189. }
  10190. if m.id == nil || m.oldValue == nil {
  10191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10192. }
  10193. oldValue, err := m.oldValue(ctx)
  10194. if err != nil {
  10195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10196. }
  10197. return oldValue.UpdatedAt, nil
  10198. }
  10199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10200. func (m *ChatSessionMutation) ResetUpdatedAt() {
  10201. m.updated_at = nil
  10202. }
  10203. // SetDeletedAt sets the "deleted_at" field.
  10204. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  10205. m.deleted_at = &t
  10206. }
  10207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10208. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  10209. v := m.deleted_at
  10210. if v == nil {
  10211. return
  10212. }
  10213. return *v, true
  10214. }
  10215. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  10216. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10218. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10219. if !m.op.Is(OpUpdateOne) {
  10220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10221. }
  10222. if m.id == nil || m.oldValue == nil {
  10223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10224. }
  10225. oldValue, err := m.oldValue(ctx)
  10226. if err != nil {
  10227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10228. }
  10229. return oldValue.DeletedAt, nil
  10230. }
  10231. // ClearDeletedAt clears the value of the "deleted_at" field.
  10232. func (m *ChatSessionMutation) ClearDeletedAt() {
  10233. m.deleted_at = nil
  10234. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  10235. }
  10236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10237. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  10238. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  10239. return ok
  10240. }
  10241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10242. func (m *ChatSessionMutation) ResetDeletedAt() {
  10243. m.deleted_at = nil
  10244. delete(m.clearedFields, chatsession.FieldDeletedAt)
  10245. }
  10246. // SetName sets the "name" field.
  10247. func (m *ChatSessionMutation) SetName(s string) {
  10248. m.name = &s
  10249. }
  10250. // Name returns the value of the "name" field in the mutation.
  10251. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  10252. v := m.name
  10253. if v == nil {
  10254. return
  10255. }
  10256. return *v, true
  10257. }
  10258. // OldName returns the old "name" field's value of the ChatSession entity.
  10259. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10261. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  10262. if !m.op.Is(OpUpdateOne) {
  10263. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10264. }
  10265. if m.id == nil || m.oldValue == nil {
  10266. return v, errors.New("OldName requires an ID field in the mutation")
  10267. }
  10268. oldValue, err := m.oldValue(ctx)
  10269. if err != nil {
  10270. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10271. }
  10272. return oldValue.Name, nil
  10273. }
  10274. // ResetName resets all changes to the "name" field.
  10275. func (m *ChatSessionMutation) ResetName() {
  10276. m.name = nil
  10277. }
  10278. // SetUserID sets the "user_id" field.
  10279. func (m *ChatSessionMutation) SetUserID(u uint64) {
  10280. m.user_id = &u
  10281. m.adduser_id = nil
  10282. }
  10283. // UserID returns the value of the "user_id" field in the mutation.
  10284. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  10285. v := m.user_id
  10286. if v == nil {
  10287. return
  10288. }
  10289. return *v, true
  10290. }
  10291. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  10292. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10294. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  10295. if !m.op.Is(OpUpdateOne) {
  10296. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10297. }
  10298. if m.id == nil || m.oldValue == nil {
  10299. return v, errors.New("OldUserID requires an ID field in the mutation")
  10300. }
  10301. oldValue, err := m.oldValue(ctx)
  10302. if err != nil {
  10303. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10304. }
  10305. return oldValue.UserID, nil
  10306. }
  10307. // AddUserID adds u to the "user_id" field.
  10308. func (m *ChatSessionMutation) AddUserID(u int64) {
  10309. if m.adduser_id != nil {
  10310. *m.adduser_id += u
  10311. } else {
  10312. m.adduser_id = &u
  10313. }
  10314. }
  10315. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  10316. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  10317. v := m.adduser_id
  10318. if v == nil {
  10319. return
  10320. }
  10321. return *v, true
  10322. }
  10323. // ResetUserID resets all changes to the "user_id" field.
  10324. func (m *ChatSessionMutation) ResetUserID() {
  10325. m.user_id = nil
  10326. m.adduser_id = nil
  10327. }
  10328. // SetBotID sets the "bot_id" field.
  10329. func (m *ChatSessionMutation) SetBotID(u uint64) {
  10330. m.bot_id = &u
  10331. m.addbot_id = nil
  10332. }
  10333. // BotID returns the value of the "bot_id" field in the mutation.
  10334. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  10335. v := m.bot_id
  10336. if v == nil {
  10337. return
  10338. }
  10339. return *v, true
  10340. }
  10341. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  10342. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10344. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  10345. if !m.op.Is(OpUpdateOne) {
  10346. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  10347. }
  10348. if m.id == nil || m.oldValue == nil {
  10349. return v, errors.New("OldBotID requires an ID field in the mutation")
  10350. }
  10351. oldValue, err := m.oldValue(ctx)
  10352. if err != nil {
  10353. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  10354. }
  10355. return oldValue.BotID, nil
  10356. }
  10357. // AddBotID adds u to the "bot_id" field.
  10358. func (m *ChatSessionMutation) AddBotID(u int64) {
  10359. if m.addbot_id != nil {
  10360. *m.addbot_id += u
  10361. } else {
  10362. m.addbot_id = &u
  10363. }
  10364. }
  10365. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  10366. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  10367. v := m.addbot_id
  10368. if v == nil {
  10369. return
  10370. }
  10371. return *v, true
  10372. }
  10373. // ResetBotID resets all changes to the "bot_id" field.
  10374. func (m *ChatSessionMutation) ResetBotID() {
  10375. m.bot_id = nil
  10376. m.addbot_id = nil
  10377. }
  10378. // SetBotType sets the "bot_type" field.
  10379. func (m *ChatSessionMutation) SetBotType(u uint8) {
  10380. m.bot_type = &u
  10381. m.addbot_type = nil
  10382. }
  10383. // BotType returns the value of the "bot_type" field in the mutation.
  10384. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  10385. v := m.bot_type
  10386. if v == nil {
  10387. return
  10388. }
  10389. return *v, true
  10390. }
  10391. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  10392. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10394. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  10395. if !m.op.Is(OpUpdateOne) {
  10396. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  10397. }
  10398. if m.id == nil || m.oldValue == nil {
  10399. return v, errors.New("OldBotType requires an ID field in the mutation")
  10400. }
  10401. oldValue, err := m.oldValue(ctx)
  10402. if err != nil {
  10403. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  10404. }
  10405. return oldValue.BotType, nil
  10406. }
  10407. // AddBotType adds u to the "bot_type" field.
  10408. func (m *ChatSessionMutation) AddBotType(u int8) {
  10409. if m.addbot_type != nil {
  10410. *m.addbot_type += u
  10411. } else {
  10412. m.addbot_type = &u
  10413. }
  10414. }
  10415. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  10416. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  10417. v := m.addbot_type
  10418. if v == nil {
  10419. return
  10420. }
  10421. return *v, true
  10422. }
  10423. // ResetBotType resets all changes to the "bot_type" field.
  10424. func (m *ChatSessionMutation) ResetBotType() {
  10425. m.bot_type = nil
  10426. m.addbot_type = nil
  10427. }
  10428. // Where appends a list predicates to the ChatSessionMutation builder.
  10429. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  10430. m.predicates = append(m.predicates, ps...)
  10431. }
  10432. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  10433. // users can use type-assertion to append predicates that do not depend on any generated package.
  10434. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  10435. p := make([]predicate.ChatSession, len(ps))
  10436. for i := range ps {
  10437. p[i] = ps[i]
  10438. }
  10439. m.Where(p...)
  10440. }
  10441. // Op returns the operation name.
  10442. func (m *ChatSessionMutation) Op() Op {
  10443. return m.op
  10444. }
  10445. // SetOp allows setting the mutation operation.
  10446. func (m *ChatSessionMutation) SetOp(op Op) {
  10447. m.op = op
  10448. }
  10449. // Type returns the node type of this mutation (ChatSession).
  10450. func (m *ChatSessionMutation) Type() string {
  10451. return m.typ
  10452. }
  10453. // Fields returns all fields that were changed during this mutation. Note that in
  10454. // order to get all numeric fields that were incremented/decremented, call
  10455. // AddedFields().
  10456. func (m *ChatSessionMutation) Fields() []string {
  10457. fields := make([]string, 0, 7)
  10458. if m.created_at != nil {
  10459. fields = append(fields, chatsession.FieldCreatedAt)
  10460. }
  10461. if m.updated_at != nil {
  10462. fields = append(fields, chatsession.FieldUpdatedAt)
  10463. }
  10464. if m.deleted_at != nil {
  10465. fields = append(fields, chatsession.FieldDeletedAt)
  10466. }
  10467. if m.name != nil {
  10468. fields = append(fields, chatsession.FieldName)
  10469. }
  10470. if m.user_id != nil {
  10471. fields = append(fields, chatsession.FieldUserID)
  10472. }
  10473. if m.bot_id != nil {
  10474. fields = append(fields, chatsession.FieldBotID)
  10475. }
  10476. if m.bot_type != nil {
  10477. fields = append(fields, chatsession.FieldBotType)
  10478. }
  10479. return fields
  10480. }
  10481. // Field returns the value of a field with the given name. The second boolean
  10482. // return value indicates that this field was not set, or was not defined in the
  10483. // schema.
  10484. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  10485. switch name {
  10486. case chatsession.FieldCreatedAt:
  10487. return m.CreatedAt()
  10488. case chatsession.FieldUpdatedAt:
  10489. return m.UpdatedAt()
  10490. case chatsession.FieldDeletedAt:
  10491. return m.DeletedAt()
  10492. case chatsession.FieldName:
  10493. return m.Name()
  10494. case chatsession.FieldUserID:
  10495. return m.UserID()
  10496. case chatsession.FieldBotID:
  10497. return m.BotID()
  10498. case chatsession.FieldBotType:
  10499. return m.BotType()
  10500. }
  10501. return nil, false
  10502. }
  10503. // OldField returns the old value of the field from the database. An error is
  10504. // returned if the mutation operation is not UpdateOne, or the query to the
  10505. // database failed.
  10506. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10507. switch name {
  10508. case chatsession.FieldCreatedAt:
  10509. return m.OldCreatedAt(ctx)
  10510. case chatsession.FieldUpdatedAt:
  10511. return m.OldUpdatedAt(ctx)
  10512. case chatsession.FieldDeletedAt:
  10513. return m.OldDeletedAt(ctx)
  10514. case chatsession.FieldName:
  10515. return m.OldName(ctx)
  10516. case chatsession.FieldUserID:
  10517. return m.OldUserID(ctx)
  10518. case chatsession.FieldBotID:
  10519. return m.OldBotID(ctx)
  10520. case chatsession.FieldBotType:
  10521. return m.OldBotType(ctx)
  10522. }
  10523. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  10524. }
  10525. // SetField sets the value of a field with the given name. It returns an error if
  10526. // the field is not defined in the schema, or if the type mismatched the field
  10527. // type.
  10528. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  10529. switch name {
  10530. case chatsession.FieldCreatedAt:
  10531. v, ok := value.(time.Time)
  10532. if !ok {
  10533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10534. }
  10535. m.SetCreatedAt(v)
  10536. return nil
  10537. case chatsession.FieldUpdatedAt:
  10538. v, ok := value.(time.Time)
  10539. if !ok {
  10540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10541. }
  10542. m.SetUpdatedAt(v)
  10543. return nil
  10544. case chatsession.FieldDeletedAt:
  10545. v, ok := value.(time.Time)
  10546. if !ok {
  10547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10548. }
  10549. m.SetDeletedAt(v)
  10550. return nil
  10551. case chatsession.FieldName:
  10552. v, ok := value.(string)
  10553. if !ok {
  10554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10555. }
  10556. m.SetName(v)
  10557. return nil
  10558. case chatsession.FieldUserID:
  10559. v, ok := value.(uint64)
  10560. if !ok {
  10561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10562. }
  10563. m.SetUserID(v)
  10564. return nil
  10565. case chatsession.FieldBotID:
  10566. v, ok := value.(uint64)
  10567. if !ok {
  10568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10569. }
  10570. m.SetBotID(v)
  10571. return nil
  10572. case chatsession.FieldBotType:
  10573. v, ok := value.(uint8)
  10574. if !ok {
  10575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10576. }
  10577. m.SetBotType(v)
  10578. return nil
  10579. }
  10580. return fmt.Errorf("unknown ChatSession field %s", name)
  10581. }
  10582. // AddedFields returns all numeric fields that were incremented/decremented during
  10583. // this mutation.
  10584. func (m *ChatSessionMutation) AddedFields() []string {
  10585. var fields []string
  10586. if m.adduser_id != nil {
  10587. fields = append(fields, chatsession.FieldUserID)
  10588. }
  10589. if m.addbot_id != nil {
  10590. fields = append(fields, chatsession.FieldBotID)
  10591. }
  10592. if m.addbot_type != nil {
  10593. fields = append(fields, chatsession.FieldBotType)
  10594. }
  10595. return fields
  10596. }
  10597. // AddedField returns the numeric value that was incremented/decremented on a field
  10598. // with the given name. The second boolean return value indicates that this field
  10599. // was not set, or was not defined in the schema.
  10600. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  10601. switch name {
  10602. case chatsession.FieldUserID:
  10603. return m.AddedUserID()
  10604. case chatsession.FieldBotID:
  10605. return m.AddedBotID()
  10606. case chatsession.FieldBotType:
  10607. return m.AddedBotType()
  10608. }
  10609. return nil, false
  10610. }
  10611. // AddField adds the value to the field with the given name. It returns an error if
  10612. // the field is not defined in the schema, or if the type mismatched the field
  10613. // type.
  10614. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  10615. switch name {
  10616. case chatsession.FieldUserID:
  10617. v, ok := value.(int64)
  10618. if !ok {
  10619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10620. }
  10621. m.AddUserID(v)
  10622. return nil
  10623. case chatsession.FieldBotID:
  10624. v, ok := value.(int64)
  10625. if !ok {
  10626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10627. }
  10628. m.AddBotID(v)
  10629. return nil
  10630. case chatsession.FieldBotType:
  10631. v, ok := value.(int8)
  10632. if !ok {
  10633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10634. }
  10635. m.AddBotType(v)
  10636. return nil
  10637. }
  10638. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  10639. }
  10640. // ClearedFields returns all nullable fields that were cleared during this
  10641. // mutation.
  10642. func (m *ChatSessionMutation) ClearedFields() []string {
  10643. var fields []string
  10644. if m.FieldCleared(chatsession.FieldDeletedAt) {
  10645. fields = append(fields, chatsession.FieldDeletedAt)
  10646. }
  10647. return fields
  10648. }
  10649. // FieldCleared returns a boolean indicating if a field with the given name was
  10650. // cleared in this mutation.
  10651. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  10652. _, ok := m.clearedFields[name]
  10653. return ok
  10654. }
  10655. // ClearField clears the value of the field with the given name. It returns an
  10656. // error if the field is not defined in the schema.
  10657. func (m *ChatSessionMutation) ClearField(name string) error {
  10658. switch name {
  10659. case chatsession.FieldDeletedAt:
  10660. m.ClearDeletedAt()
  10661. return nil
  10662. }
  10663. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  10664. }
  10665. // ResetField resets all changes in the mutation for the field with the given name.
  10666. // It returns an error if the field is not defined in the schema.
  10667. func (m *ChatSessionMutation) ResetField(name string) error {
  10668. switch name {
  10669. case chatsession.FieldCreatedAt:
  10670. m.ResetCreatedAt()
  10671. return nil
  10672. case chatsession.FieldUpdatedAt:
  10673. m.ResetUpdatedAt()
  10674. return nil
  10675. case chatsession.FieldDeletedAt:
  10676. m.ResetDeletedAt()
  10677. return nil
  10678. case chatsession.FieldName:
  10679. m.ResetName()
  10680. return nil
  10681. case chatsession.FieldUserID:
  10682. m.ResetUserID()
  10683. return nil
  10684. case chatsession.FieldBotID:
  10685. m.ResetBotID()
  10686. return nil
  10687. case chatsession.FieldBotType:
  10688. m.ResetBotType()
  10689. return nil
  10690. }
  10691. return fmt.Errorf("unknown ChatSession field %s", name)
  10692. }
  10693. // AddedEdges returns all edge names that were set/added in this mutation.
  10694. func (m *ChatSessionMutation) AddedEdges() []string {
  10695. edges := make([]string, 0, 0)
  10696. return edges
  10697. }
  10698. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10699. // name in this mutation.
  10700. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  10701. return nil
  10702. }
  10703. // RemovedEdges returns all edge names that were removed in this mutation.
  10704. func (m *ChatSessionMutation) RemovedEdges() []string {
  10705. edges := make([]string, 0, 0)
  10706. return edges
  10707. }
  10708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10709. // the given name in this mutation.
  10710. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  10711. return nil
  10712. }
  10713. // ClearedEdges returns all edge names that were cleared in this mutation.
  10714. func (m *ChatSessionMutation) ClearedEdges() []string {
  10715. edges := make([]string, 0, 0)
  10716. return edges
  10717. }
  10718. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10719. // was cleared in this mutation.
  10720. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  10721. return false
  10722. }
  10723. // ClearEdge clears the value of the edge with the given name. It returns an error
  10724. // if that edge is not defined in the schema.
  10725. func (m *ChatSessionMutation) ClearEdge(name string) error {
  10726. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  10727. }
  10728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10729. // It returns an error if the edge is not defined in the schema.
  10730. func (m *ChatSessionMutation) ResetEdge(name string) error {
  10731. return fmt.Errorf("unknown ChatSession edge %s", name)
  10732. }
  10733. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  10734. type CompapiAsynctaskMutation struct {
  10735. config
  10736. op Op
  10737. typ string
  10738. id *uint64
  10739. created_at *time.Time
  10740. updated_at *time.Time
  10741. auth_token *string
  10742. event_type *string
  10743. chat_id *string
  10744. response_chat_item_id *string
  10745. organization_id *uint64
  10746. addorganization_id *int64
  10747. openai_base *string
  10748. openai_key *string
  10749. request_raw *string
  10750. response_raw *string
  10751. callback_url *string
  10752. callback_response_raw *string
  10753. model *string
  10754. task_status *int8
  10755. addtask_status *int8
  10756. retry_count *int8
  10757. addretry_count *int8
  10758. last_error *string
  10759. clearedFields map[string]struct{}
  10760. done bool
  10761. oldValue func(context.Context) (*CompapiAsynctask, error)
  10762. predicates []predicate.CompapiAsynctask
  10763. }
  10764. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  10765. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  10766. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  10767. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  10768. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  10769. m := &CompapiAsynctaskMutation{
  10770. config: c,
  10771. op: op,
  10772. typ: TypeCompapiAsynctask,
  10773. clearedFields: make(map[string]struct{}),
  10774. }
  10775. for _, opt := range opts {
  10776. opt(m)
  10777. }
  10778. return m
  10779. }
  10780. // withCompapiAsynctaskID sets the ID field of the mutation.
  10781. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  10782. return func(m *CompapiAsynctaskMutation) {
  10783. var (
  10784. err error
  10785. once sync.Once
  10786. value *CompapiAsynctask
  10787. )
  10788. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  10789. once.Do(func() {
  10790. if m.done {
  10791. err = errors.New("querying old values post mutation is not allowed")
  10792. } else {
  10793. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  10794. }
  10795. })
  10796. return value, err
  10797. }
  10798. m.id = &id
  10799. }
  10800. }
  10801. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  10802. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  10803. return func(m *CompapiAsynctaskMutation) {
  10804. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  10805. return node, nil
  10806. }
  10807. m.id = &node.ID
  10808. }
  10809. }
  10810. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10811. // executed in a transaction (ent.Tx), a transactional client is returned.
  10812. func (m CompapiAsynctaskMutation) Client() *Client {
  10813. client := &Client{config: m.config}
  10814. client.init()
  10815. return client
  10816. }
  10817. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10818. // it returns an error otherwise.
  10819. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  10820. if _, ok := m.driver.(*txDriver); !ok {
  10821. return nil, errors.New("ent: mutation is not running in a transaction")
  10822. }
  10823. tx := &Tx{config: m.config}
  10824. tx.init()
  10825. return tx, nil
  10826. }
  10827. // SetID sets the value of the id field. Note that this
  10828. // operation is only accepted on creation of CompapiAsynctask entities.
  10829. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  10830. m.id = &id
  10831. }
  10832. // ID returns the ID value in the mutation. Note that the ID is only available
  10833. // if it was provided to the builder or after it was returned from the database.
  10834. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  10835. if m.id == nil {
  10836. return
  10837. }
  10838. return *m.id, true
  10839. }
  10840. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10841. // That means, if the mutation is applied within a transaction with an isolation level such
  10842. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10843. // or updated by the mutation.
  10844. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  10845. switch {
  10846. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10847. id, exists := m.ID()
  10848. if exists {
  10849. return []uint64{id}, nil
  10850. }
  10851. fallthrough
  10852. case m.op.Is(OpUpdate | OpDelete):
  10853. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  10854. default:
  10855. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10856. }
  10857. }
  10858. // SetCreatedAt sets the "created_at" field.
  10859. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  10860. m.created_at = &t
  10861. }
  10862. // CreatedAt returns the value of the "created_at" field in the mutation.
  10863. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  10864. v := m.created_at
  10865. if v == nil {
  10866. return
  10867. }
  10868. return *v, true
  10869. }
  10870. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  10871. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10873. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10874. if !m.op.Is(OpUpdateOne) {
  10875. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10876. }
  10877. if m.id == nil || m.oldValue == nil {
  10878. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10879. }
  10880. oldValue, err := m.oldValue(ctx)
  10881. if err != nil {
  10882. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10883. }
  10884. return oldValue.CreatedAt, nil
  10885. }
  10886. // ResetCreatedAt resets all changes to the "created_at" field.
  10887. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  10888. m.created_at = nil
  10889. }
  10890. // SetUpdatedAt sets the "updated_at" field.
  10891. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  10892. m.updated_at = &t
  10893. }
  10894. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10895. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  10896. v := m.updated_at
  10897. if v == nil {
  10898. return
  10899. }
  10900. return *v, true
  10901. }
  10902. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  10903. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10905. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10906. if !m.op.Is(OpUpdateOne) {
  10907. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10908. }
  10909. if m.id == nil || m.oldValue == nil {
  10910. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10911. }
  10912. oldValue, err := m.oldValue(ctx)
  10913. if err != nil {
  10914. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10915. }
  10916. return oldValue.UpdatedAt, nil
  10917. }
  10918. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10919. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  10920. m.updated_at = nil
  10921. }
  10922. // SetAuthToken sets the "auth_token" field.
  10923. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  10924. m.auth_token = &s
  10925. }
  10926. // AuthToken returns the value of the "auth_token" field in the mutation.
  10927. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  10928. v := m.auth_token
  10929. if v == nil {
  10930. return
  10931. }
  10932. return *v, true
  10933. }
  10934. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  10935. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10937. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  10938. if !m.op.Is(OpUpdateOne) {
  10939. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  10940. }
  10941. if m.id == nil || m.oldValue == nil {
  10942. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  10943. }
  10944. oldValue, err := m.oldValue(ctx)
  10945. if err != nil {
  10946. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  10947. }
  10948. return oldValue.AuthToken, nil
  10949. }
  10950. // ResetAuthToken resets all changes to the "auth_token" field.
  10951. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  10952. m.auth_token = nil
  10953. }
  10954. // SetEventType sets the "event_type" field.
  10955. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  10956. m.event_type = &s
  10957. }
  10958. // EventType returns the value of the "event_type" field in the mutation.
  10959. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  10960. v := m.event_type
  10961. if v == nil {
  10962. return
  10963. }
  10964. return *v, true
  10965. }
  10966. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  10967. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10969. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  10970. if !m.op.Is(OpUpdateOne) {
  10971. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  10972. }
  10973. if m.id == nil || m.oldValue == nil {
  10974. return v, errors.New("OldEventType requires an ID field in the mutation")
  10975. }
  10976. oldValue, err := m.oldValue(ctx)
  10977. if err != nil {
  10978. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  10979. }
  10980. return oldValue.EventType, nil
  10981. }
  10982. // ResetEventType resets all changes to the "event_type" field.
  10983. func (m *CompapiAsynctaskMutation) ResetEventType() {
  10984. m.event_type = nil
  10985. }
  10986. // SetChatID sets the "chat_id" field.
  10987. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  10988. m.chat_id = &s
  10989. }
  10990. // ChatID returns the value of the "chat_id" field in the mutation.
  10991. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  10992. v := m.chat_id
  10993. if v == nil {
  10994. return
  10995. }
  10996. return *v, true
  10997. }
  10998. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  10999. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11001. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  11002. if !m.op.Is(OpUpdateOne) {
  11003. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  11004. }
  11005. if m.id == nil || m.oldValue == nil {
  11006. return v, errors.New("OldChatID requires an ID field in the mutation")
  11007. }
  11008. oldValue, err := m.oldValue(ctx)
  11009. if err != nil {
  11010. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  11011. }
  11012. return oldValue.ChatID, nil
  11013. }
  11014. // ClearChatID clears the value of the "chat_id" field.
  11015. func (m *CompapiAsynctaskMutation) ClearChatID() {
  11016. m.chat_id = nil
  11017. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  11018. }
  11019. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  11020. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  11021. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  11022. return ok
  11023. }
  11024. // ResetChatID resets all changes to the "chat_id" field.
  11025. func (m *CompapiAsynctaskMutation) ResetChatID() {
  11026. m.chat_id = nil
  11027. delete(m.clearedFields, compapiasynctask.FieldChatID)
  11028. }
  11029. // SetResponseChatItemID sets the "response_chat_item_id" field.
  11030. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  11031. m.response_chat_item_id = &s
  11032. }
  11033. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  11034. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  11035. v := m.response_chat_item_id
  11036. if v == nil {
  11037. return
  11038. }
  11039. return *v, true
  11040. }
  11041. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  11042. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11044. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  11045. if !m.op.Is(OpUpdateOne) {
  11046. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  11047. }
  11048. if m.id == nil || m.oldValue == nil {
  11049. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  11050. }
  11051. oldValue, err := m.oldValue(ctx)
  11052. if err != nil {
  11053. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  11054. }
  11055. return oldValue.ResponseChatItemID, nil
  11056. }
  11057. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  11058. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  11059. m.response_chat_item_id = nil
  11060. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  11061. }
  11062. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  11063. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  11064. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  11065. return ok
  11066. }
  11067. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  11068. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  11069. m.response_chat_item_id = nil
  11070. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  11071. }
  11072. // SetOrganizationID sets the "organization_id" field.
  11073. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  11074. m.organization_id = &u
  11075. m.addorganization_id = nil
  11076. }
  11077. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11078. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  11079. v := m.organization_id
  11080. if v == nil {
  11081. return
  11082. }
  11083. return *v, true
  11084. }
  11085. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  11086. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11088. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11089. if !m.op.Is(OpUpdateOne) {
  11090. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11091. }
  11092. if m.id == nil || m.oldValue == nil {
  11093. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11094. }
  11095. oldValue, err := m.oldValue(ctx)
  11096. if err != nil {
  11097. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11098. }
  11099. return oldValue.OrganizationID, nil
  11100. }
  11101. // AddOrganizationID adds u to the "organization_id" field.
  11102. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  11103. if m.addorganization_id != nil {
  11104. *m.addorganization_id += u
  11105. } else {
  11106. m.addorganization_id = &u
  11107. }
  11108. }
  11109. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11110. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  11111. v := m.addorganization_id
  11112. if v == nil {
  11113. return
  11114. }
  11115. return *v, true
  11116. }
  11117. // ResetOrganizationID resets all changes to the "organization_id" field.
  11118. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  11119. m.organization_id = nil
  11120. m.addorganization_id = nil
  11121. }
  11122. // SetOpenaiBase sets the "openai_base" field.
  11123. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  11124. m.openai_base = &s
  11125. }
  11126. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  11127. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  11128. v := m.openai_base
  11129. if v == nil {
  11130. return
  11131. }
  11132. return *v, true
  11133. }
  11134. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  11135. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11137. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  11138. if !m.op.Is(OpUpdateOne) {
  11139. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  11140. }
  11141. if m.id == nil || m.oldValue == nil {
  11142. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  11143. }
  11144. oldValue, err := m.oldValue(ctx)
  11145. if err != nil {
  11146. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  11147. }
  11148. return oldValue.OpenaiBase, nil
  11149. }
  11150. // ResetOpenaiBase resets all changes to the "openai_base" field.
  11151. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  11152. m.openai_base = nil
  11153. }
  11154. // SetOpenaiKey sets the "openai_key" field.
  11155. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  11156. m.openai_key = &s
  11157. }
  11158. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  11159. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  11160. v := m.openai_key
  11161. if v == nil {
  11162. return
  11163. }
  11164. return *v, true
  11165. }
  11166. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  11167. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11169. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  11170. if !m.op.Is(OpUpdateOne) {
  11171. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  11172. }
  11173. if m.id == nil || m.oldValue == nil {
  11174. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  11175. }
  11176. oldValue, err := m.oldValue(ctx)
  11177. if err != nil {
  11178. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  11179. }
  11180. return oldValue.OpenaiKey, nil
  11181. }
  11182. // ResetOpenaiKey resets all changes to the "openai_key" field.
  11183. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  11184. m.openai_key = nil
  11185. }
  11186. // SetRequestRaw sets the "request_raw" field.
  11187. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  11188. m.request_raw = &s
  11189. }
  11190. // RequestRaw returns the value of the "request_raw" field in the mutation.
  11191. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  11192. v := m.request_raw
  11193. if v == nil {
  11194. return
  11195. }
  11196. return *v, true
  11197. }
  11198. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  11199. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11201. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  11202. if !m.op.Is(OpUpdateOne) {
  11203. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  11204. }
  11205. if m.id == nil || m.oldValue == nil {
  11206. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  11207. }
  11208. oldValue, err := m.oldValue(ctx)
  11209. if err != nil {
  11210. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  11211. }
  11212. return oldValue.RequestRaw, nil
  11213. }
  11214. // ResetRequestRaw resets all changes to the "request_raw" field.
  11215. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  11216. m.request_raw = nil
  11217. }
  11218. // SetResponseRaw sets the "response_raw" field.
  11219. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  11220. m.response_raw = &s
  11221. }
  11222. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  11223. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  11224. v := m.response_raw
  11225. if v == nil {
  11226. return
  11227. }
  11228. return *v, true
  11229. }
  11230. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  11231. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11233. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  11234. if !m.op.Is(OpUpdateOne) {
  11235. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  11236. }
  11237. if m.id == nil || m.oldValue == nil {
  11238. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  11239. }
  11240. oldValue, err := m.oldValue(ctx)
  11241. if err != nil {
  11242. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  11243. }
  11244. return oldValue.ResponseRaw, nil
  11245. }
  11246. // ClearResponseRaw clears the value of the "response_raw" field.
  11247. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  11248. m.response_raw = nil
  11249. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  11250. }
  11251. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  11252. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  11253. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  11254. return ok
  11255. }
  11256. // ResetResponseRaw resets all changes to the "response_raw" field.
  11257. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  11258. m.response_raw = nil
  11259. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  11260. }
  11261. // SetCallbackURL sets the "callback_url" field.
  11262. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  11263. m.callback_url = &s
  11264. }
  11265. // CallbackURL returns the value of the "callback_url" field in the mutation.
  11266. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  11267. v := m.callback_url
  11268. if v == nil {
  11269. return
  11270. }
  11271. return *v, true
  11272. }
  11273. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  11274. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11276. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  11277. if !m.op.Is(OpUpdateOne) {
  11278. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  11279. }
  11280. if m.id == nil || m.oldValue == nil {
  11281. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  11282. }
  11283. oldValue, err := m.oldValue(ctx)
  11284. if err != nil {
  11285. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  11286. }
  11287. return oldValue.CallbackURL, nil
  11288. }
  11289. // ResetCallbackURL resets all changes to the "callback_url" field.
  11290. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  11291. m.callback_url = nil
  11292. }
  11293. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  11294. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  11295. m.callback_response_raw = &s
  11296. }
  11297. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  11298. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  11299. v := m.callback_response_raw
  11300. if v == nil {
  11301. return
  11302. }
  11303. return *v, true
  11304. }
  11305. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  11306. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11308. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  11309. if !m.op.Is(OpUpdateOne) {
  11310. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  11311. }
  11312. if m.id == nil || m.oldValue == nil {
  11313. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  11314. }
  11315. oldValue, err := m.oldValue(ctx)
  11316. if err != nil {
  11317. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  11318. }
  11319. return oldValue.CallbackResponseRaw, nil
  11320. }
  11321. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  11322. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  11323. m.callback_response_raw = nil
  11324. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  11325. }
  11326. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  11327. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  11328. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  11329. return ok
  11330. }
  11331. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  11332. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  11333. m.callback_response_raw = nil
  11334. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  11335. }
  11336. // SetModel sets the "model" field.
  11337. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  11338. m.model = &s
  11339. }
  11340. // Model returns the value of the "model" field in the mutation.
  11341. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  11342. v := m.model
  11343. if v == nil {
  11344. return
  11345. }
  11346. return *v, true
  11347. }
  11348. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  11349. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11351. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  11352. if !m.op.Is(OpUpdateOne) {
  11353. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  11354. }
  11355. if m.id == nil || m.oldValue == nil {
  11356. return v, errors.New("OldModel requires an ID field in the mutation")
  11357. }
  11358. oldValue, err := m.oldValue(ctx)
  11359. if err != nil {
  11360. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  11361. }
  11362. return oldValue.Model, nil
  11363. }
  11364. // ClearModel clears the value of the "model" field.
  11365. func (m *CompapiAsynctaskMutation) ClearModel() {
  11366. m.model = nil
  11367. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  11368. }
  11369. // ModelCleared returns if the "model" field was cleared in this mutation.
  11370. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  11371. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  11372. return ok
  11373. }
  11374. // ResetModel resets all changes to the "model" field.
  11375. func (m *CompapiAsynctaskMutation) ResetModel() {
  11376. m.model = nil
  11377. delete(m.clearedFields, compapiasynctask.FieldModel)
  11378. }
  11379. // SetTaskStatus sets the "task_status" field.
  11380. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  11381. m.task_status = &i
  11382. m.addtask_status = nil
  11383. }
  11384. // TaskStatus returns the value of the "task_status" field in the mutation.
  11385. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  11386. v := m.task_status
  11387. if v == nil {
  11388. return
  11389. }
  11390. return *v, true
  11391. }
  11392. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  11393. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11395. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  11396. if !m.op.Is(OpUpdateOne) {
  11397. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  11398. }
  11399. if m.id == nil || m.oldValue == nil {
  11400. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  11401. }
  11402. oldValue, err := m.oldValue(ctx)
  11403. if err != nil {
  11404. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  11405. }
  11406. return oldValue.TaskStatus, nil
  11407. }
  11408. // AddTaskStatus adds i to the "task_status" field.
  11409. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  11410. if m.addtask_status != nil {
  11411. *m.addtask_status += i
  11412. } else {
  11413. m.addtask_status = &i
  11414. }
  11415. }
  11416. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  11417. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  11418. v := m.addtask_status
  11419. if v == nil {
  11420. return
  11421. }
  11422. return *v, true
  11423. }
  11424. // ClearTaskStatus clears the value of the "task_status" field.
  11425. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  11426. m.task_status = nil
  11427. m.addtask_status = nil
  11428. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  11429. }
  11430. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  11431. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  11432. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  11433. return ok
  11434. }
  11435. // ResetTaskStatus resets all changes to the "task_status" field.
  11436. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  11437. m.task_status = nil
  11438. m.addtask_status = nil
  11439. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  11440. }
  11441. // SetRetryCount sets the "retry_count" field.
  11442. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  11443. m.retry_count = &i
  11444. m.addretry_count = nil
  11445. }
  11446. // RetryCount returns the value of the "retry_count" field in the mutation.
  11447. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  11448. v := m.retry_count
  11449. if v == nil {
  11450. return
  11451. }
  11452. return *v, true
  11453. }
  11454. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  11455. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11457. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  11458. if !m.op.Is(OpUpdateOne) {
  11459. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  11460. }
  11461. if m.id == nil || m.oldValue == nil {
  11462. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  11463. }
  11464. oldValue, err := m.oldValue(ctx)
  11465. if err != nil {
  11466. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  11467. }
  11468. return oldValue.RetryCount, nil
  11469. }
  11470. // AddRetryCount adds i to the "retry_count" field.
  11471. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  11472. if m.addretry_count != nil {
  11473. *m.addretry_count += i
  11474. } else {
  11475. m.addretry_count = &i
  11476. }
  11477. }
  11478. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  11479. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  11480. v := m.addretry_count
  11481. if v == nil {
  11482. return
  11483. }
  11484. return *v, true
  11485. }
  11486. // ClearRetryCount clears the value of the "retry_count" field.
  11487. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  11488. m.retry_count = nil
  11489. m.addretry_count = nil
  11490. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  11491. }
  11492. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  11493. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  11494. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  11495. return ok
  11496. }
  11497. // ResetRetryCount resets all changes to the "retry_count" field.
  11498. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  11499. m.retry_count = nil
  11500. m.addretry_count = nil
  11501. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  11502. }
  11503. // SetLastError sets the "last_error" field.
  11504. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  11505. m.last_error = &s
  11506. }
  11507. // LastError returns the value of the "last_error" field in the mutation.
  11508. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  11509. v := m.last_error
  11510. if v == nil {
  11511. return
  11512. }
  11513. return *v, true
  11514. }
  11515. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  11516. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11518. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  11519. if !m.op.Is(OpUpdateOne) {
  11520. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  11521. }
  11522. if m.id == nil || m.oldValue == nil {
  11523. return v, errors.New("OldLastError requires an ID field in the mutation")
  11524. }
  11525. oldValue, err := m.oldValue(ctx)
  11526. if err != nil {
  11527. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  11528. }
  11529. return oldValue.LastError, nil
  11530. }
  11531. // ClearLastError clears the value of the "last_error" field.
  11532. func (m *CompapiAsynctaskMutation) ClearLastError() {
  11533. m.last_error = nil
  11534. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  11535. }
  11536. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  11537. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  11538. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  11539. return ok
  11540. }
  11541. // ResetLastError resets all changes to the "last_error" field.
  11542. func (m *CompapiAsynctaskMutation) ResetLastError() {
  11543. m.last_error = nil
  11544. delete(m.clearedFields, compapiasynctask.FieldLastError)
  11545. }
  11546. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  11547. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  11548. m.predicates = append(m.predicates, ps...)
  11549. }
  11550. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  11551. // users can use type-assertion to append predicates that do not depend on any generated package.
  11552. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  11553. p := make([]predicate.CompapiAsynctask, len(ps))
  11554. for i := range ps {
  11555. p[i] = ps[i]
  11556. }
  11557. m.Where(p...)
  11558. }
  11559. // Op returns the operation name.
  11560. func (m *CompapiAsynctaskMutation) Op() Op {
  11561. return m.op
  11562. }
  11563. // SetOp allows setting the mutation operation.
  11564. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  11565. m.op = op
  11566. }
  11567. // Type returns the node type of this mutation (CompapiAsynctask).
  11568. func (m *CompapiAsynctaskMutation) Type() string {
  11569. return m.typ
  11570. }
  11571. // Fields returns all fields that were changed during this mutation. Note that in
  11572. // order to get all numeric fields that were incremented/decremented, call
  11573. // AddedFields().
  11574. func (m *CompapiAsynctaskMutation) Fields() []string {
  11575. fields := make([]string, 0, 17)
  11576. if m.created_at != nil {
  11577. fields = append(fields, compapiasynctask.FieldCreatedAt)
  11578. }
  11579. if m.updated_at != nil {
  11580. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  11581. }
  11582. if m.auth_token != nil {
  11583. fields = append(fields, compapiasynctask.FieldAuthToken)
  11584. }
  11585. if m.event_type != nil {
  11586. fields = append(fields, compapiasynctask.FieldEventType)
  11587. }
  11588. if m.chat_id != nil {
  11589. fields = append(fields, compapiasynctask.FieldChatID)
  11590. }
  11591. if m.response_chat_item_id != nil {
  11592. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11593. }
  11594. if m.organization_id != nil {
  11595. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11596. }
  11597. if m.openai_base != nil {
  11598. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  11599. }
  11600. if m.openai_key != nil {
  11601. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  11602. }
  11603. if m.request_raw != nil {
  11604. fields = append(fields, compapiasynctask.FieldRequestRaw)
  11605. }
  11606. if m.response_raw != nil {
  11607. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11608. }
  11609. if m.callback_url != nil {
  11610. fields = append(fields, compapiasynctask.FieldCallbackURL)
  11611. }
  11612. if m.callback_response_raw != nil {
  11613. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11614. }
  11615. if m.model != nil {
  11616. fields = append(fields, compapiasynctask.FieldModel)
  11617. }
  11618. if m.task_status != nil {
  11619. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11620. }
  11621. if m.retry_count != nil {
  11622. fields = append(fields, compapiasynctask.FieldRetryCount)
  11623. }
  11624. if m.last_error != nil {
  11625. fields = append(fields, compapiasynctask.FieldLastError)
  11626. }
  11627. return fields
  11628. }
  11629. // Field returns the value of a field with the given name. The second boolean
  11630. // return value indicates that this field was not set, or was not defined in the
  11631. // schema.
  11632. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  11633. switch name {
  11634. case compapiasynctask.FieldCreatedAt:
  11635. return m.CreatedAt()
  11636. case compapiasynctask.FieldUpdatedAt:
  11637. return m.UpdatedAt()
  11638. case compapiasynctask.FieldAuthToken:
  11639. return m.AuthToken()
  11640. case compapiasynctask.FieldEventType:
  11641. return m.EventType()
  11642. case compapiasynctask.FieldChatID:
  11643. return m.ChatID()
  11644. case compapiasynctask.FieldResponseChatItemID:
  11645. return m.ResponseChatItemID()
  11646. case compapiasynctask.FieldOrganizationID:
  11647. return m.OrganizationID()
  11648. case compapiasynctask.FieldOpenaiBase:
  11649. return m.OpenaiBase()
  11650. case compapiasynctask.FieldOpenaiKey:
  11651. return m.OpenaiKey()
  11652. case compapiasynctask.FieldRequestRaw:
  11653. return m.RequestRaw()
  11654. case compapiasynctask.FieldResponseRaw:
  11655. return m.ResponseRaw()
  11656. case compapiasynctask.FieldCallbackURL:
  11657. return m.CallbackURL()
  11658. case compapiasynctask.FieldCallbackResponseRaw:
  11659. return m.CallbackResponseRaw()
  11660. case compapiasynctask.FieldModel:
  11661. return m.Model()
  11662. case compapiasynctask.FieldTaskStatus:
  11663. return m.TaskStatus()
  11664. case compapiasynctask.FieldRetryCount:
  11665. return m.RetryCount()
  11666. case compapiasynctask.FieldLastError:
  11667. return m.LastError()
  11668. }
  11669. return nil, false
  11670. }
  11671. // OldField returns the old value of the field from the database. An error is
  11672. // returned if the mutation operation is not UpdateOne, or the query to the
  11673. // database failed.
  11674. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11675. switch name {
  11676. case compapiasynctask.FieldCreatedAt:
  11677. return m.OldCreatedAt(ctx)
  11678. case compapiasynctask.FieldUpdatedAt:
  11679. return m.OldUpdatedAt(ctx)
  11680. case compapiasynctask.FieldAuthToken:
  11681. return m.OldAuthToken(ctx)
  11682. case compapiasynctask.FieldEventType:
  11683. return m.OldEventType(ctx)
  11684. case compapiasynctask.FieldChatID:
  11685. return m.OldChatID(ctx)
  11686. case compapiasynctask.FieldResponseChatItemID:
  11687. return m.OldResponseChatItemID(ctx)
  11688. case compapiasynctask.FieldOrganizationID:
  11689. return m.OldOrganizationID(ctx)
  11690. case compapiasynctask.FieldOpenaiBase:
  11691. return m.OldOpenaiBase(ctx)
  11692. case compapiasynctask.FieldOpenaiKey:
  11693. return m.OldOpenaiKey(ctx)
  11694. case compapiasynctask.FieldRequestRaw:
  11695. return m.OldRequestRaw(ctx)
  11696. case compapiasynctask.FieldResponseRaw:
  11697. return m.OldResponseRaw(ctx)
  11698. case compapiasynctask.FieldCallbackURL:
  11699. return m.OldCallbackURL(ctx)
  11700. case compapiasynctask.FieldCallbackResponseRaw:
  11701. return m.OldCallbackResponseRaw(ctx)
  11702. case compapiasynctask.FieldModel:
  11703. return m.OldModel(ctx)
  11704. case compapiasynctask.FieldTaskStatus:
  11705. return m.OldTaskStatus(ctx)
  11706. case compapiasynctask.FieldRetryCount:
  11707. return m.OldRetryCount(ctx)
  11708. case compapiasynctask.FieldLastError:
  11709. return m.OldLastError(ctx)
  11710. }
  11711. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11712. }
  11713. // SetField sets the value of a field with the given name. It returns an error if
  11714. // the field is not defined in the schema, or if the type mismatched the field
  11715. // type.
  11716. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  11717. switch name {
  11718. case compapiasynctask.FieldCreatedAt:
  11719. v, ok := value.(time.Time)
  11720. if !ok {
  11721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11722. }
  11723. m.SetCreatedAt(v)
  11724. return nil
  11725. case compapiasynctask.FieldUpdatedAt:
  11726. v, ok := value.(time.Time)
  11727. if !ok {
  11728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11729. }
  11730. m.SetUpdatedAt(v)
  11731. return nil
  11732. case compapiasynctask.FieldAuthToken:
  11733. v, ok := value.(string)
  11734. if !ok {
  11735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11736. }
  11737. m.SetAuthToken(v)
  11738. return nil
  11739. case compapiasynctask.FieldEventType:
  11740. v, ok := value.(string)
  11741. if !ok {
  11742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11743. }
  11744. m.SetEventType(v)
  11745. return nil
  11746. case compapiasynctask.FieldChatID:
  11747. v, ok := value.(string)
  11748. if !ok {
  11749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11750. }
  11751. m.SetChatID(v)
  11752. return nil
  11753. case compapiasynctask.FieldResponseChatItemID:
  11754. v, ok := value.(string)
  11755. if !ok {
  11756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11757. }
  11758. m.SetResponseChatItemID(v)
  11759. return nil
  11760. case compapiasynctask.FieldOrganizationID:
  11761. v, ok := value.(uint64)
  11762. if !ok {
  11763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11764. }
  11765. m.SetOrganizationID(v)
  11766. return nil
  11767. case compapiasynctask.FieldOpenaiBase:
  11768. v, ok := value.(string)
  11769. if !ok {
  11770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11771. }
  11772. m.SetOpenaiBase(v)
  11773. return nil
  11774. case compapiasynctask.FieldOpenaiKey:
  11775. v, ok := value.(string)
  11776. if !ok {
  11777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11778. }
  11779. m.SetOpenaiKey(v)
  11780. return nil
  11781. case compapiasynctask.FieldRequestRaw:
  11782. v, ok := value.(string)
  11783. if !ok {
  11784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11785. }
  11786. m.SetRequestRaw(v)
  11787. return nil
  11788. case compapiasynctask.FieldResponseRaw:
  11789. v, ok := value.(string)
  11790. if !ok {
  11791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11792. }
  11793. m.SetResponseRaw(v)
  11794. return nil
  11795. case compapiasynctask.FieldCallbackURL:
  11796. v, ok := value.(string)
  11797. if !ok {
  11798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11799. }
  11800. m.SetCallbackURL(v)
  11801. return nil
  11802. case compapiasynctask.FieldCallbackResponseRaw:
  11803. v, ok := value.(string)
  11804. if !ok {
  11805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11806. }
  11807. m.SetCallbackResponseRaw(v)
  11808. return nil
  11809. case compapiasynctask.FieldModel:
  11810. v, ok := value.(string)
  11811. if !ok {
  11812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11813. }
  11814. m.SetModel(v)
  11815. return nil
  11816. case compapiasynctask.FieldTaskStatus:
  11817. v, ok := value.(int8)
  11818. if !ok {
  11819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11820. }
  11821. m.SetTaskStatus(v)
  11822. return nil
  11823. case compapiasynctask.FieldRetryCount:
  11824. v, ok := value.(int8)
  11825. if !ok {
  11826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11827. }
  11828. m.SetRetryCount(v)
  11829. return nil
  11830. case compapiasynctask.FieldLastError:
  11831. v, ok := value.(string)
  11832. if !ok {
  11833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11834. }
  11835. m.SetLastError(v)
  11836. return nil
  11837. }
  11838. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11839. }
  11840. // AddedFields returns all numeric fields that were incremented/decremented during
  11841. // this mutation.
  11842. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  11843. var fields []string
  11844. if m.addorganization_id != nil {
  11845. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11846. }
  11847. if m.addtask_status != nil {
  11848. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11849. }
  11850. if m.addretry_count != nil {
  11851. fields = append(fields, compapiasynctask.FieldRetryCount)
  11852. }
  11853. return fields
  11854. }
  11855. // AddedField returns the numeric value that was incremented/decremented on a field
  11856. // with the given name. The second boolean return value indicates that this field
  11857. // was not set, or was not defined in the schema.
  11858. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  11859. switch name {
  11860. case compapiasynctask.FieldOrganizationID:
  11861. return m.AddedOrganizationID()
  11862. case compapiasynctask.FieldTaskStatus:
  11863. return m.AddedTaskStatus()
  11864. case compapiasynctask.FieldRetryCount:
  11865. return m.AddedRetryCount()
  11866. }
  11867. return nil, false
  11868. }
  11869. // AddField adds the value to the field with the given name. It returns an error if
  11870. // the field is not defined in the schema, or if the type mismatched the field
  11871. // type.
  11872. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  11873. switch name {
  11874. case compapiasynctask.FieldOrganizationID:
  11875. v, ok := value.(int64)
  11876. if !ok {
  11877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11878. }
  11879. m.AddOrganizationID(v)
  11880. return nil
  11881. case compapiasynctask.FieldTaskStatus:
  11882. v, ok := value.(int8)
  11883. if !ok {
  11884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11885. }
  11886. m.AddTaskStatus(v)
  11887. return nil
  11888. case compapiasynctask.FieldRetryCount:
  11889. v, ok := value.(int8)
  11890. if !ok {
  11891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11892. }
  11893. m.AddRetryCount(v)
  11894. return nil
  11895. }
  11896. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  11897. }
  11898. // ClearedFields returns all nullable fields that were cleared during this
  11899. // mutation.
  11900. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  11901. var fields []string
  11902. if m.FieldCleared(compapiasynctask.FieldChatID) {
  11903. fields = append(fields, compapiasynctask.FieldChatID)
  11904. }
  11905. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  11906. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11907. }
  11908. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  11909. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11910. }
  11911. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  11912. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11913. }
  11914. if m.FieldCleared(compapiasynctask.FieldModel) {
  11915. fields = append(fields, compapiasynctask.FieldModel)
  11916. }
  11917. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  11918. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11919. }
  11920. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  11921. fields = append(fields, compapiasynctask.FieldRetryCount)
  11922. }
  11923. if m.FieldCleared(compapiasynctask.FieldLastError) {
  11924. fields = append(fields, compapiasynctask.FieldLastError)
  11925. }
  11926. return fields
  11927. }
  11928. // FieldCleared returns a boolean indicating if a field with the given name was
  11929. // cleared in this mutation.
  11930. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  11931. _, ok := m.clearedFields[name]
  11932. return ok
  11933. }
  11934. // ClearField clears the value of the field with the given name. It returns an
  11935. // error if the field is not defined in the schema.
  11936. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  11937. switch name {
  11938. case compapiasynctask.FieldChatID:
  11939. m.ClearChatID()
  11940. return nil
  11941. case compapiasynctask.FieldResponseChatItemID:
  11942. m.ClearResponseChatItemID()
  11943. return nil
  11944. case compapiasynctask.FieldResponseRaw:
  11945. m.ClearResponseRaw()
  11946. return nil
  11947. case compapiasynctask.FieldCallbackResponseRaw:
  11948. m.ClearCallbackResponseRaw()
  11949. return nil
  11950. case compapiasynctask.FieldModel:
  11951. m.ClearModel()
  11952. return nil
  11953. case compapiasynctask.FieldTaskStatus:
  11954. m.ClearTaskStatus()
  11955. return nil
  11956. case compapiasynctask.FieldRetryCount:
  11957. m.ClearRetryCount()
  11958. return nil
  11959. case compapiasynctask.FieldLastError:
  11960. m.ClearLastError()
  11961. return nil
  11962. }
  11963. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  11964. }
  11965. // ResetField resets all changes in the mutation for the field with the given name.
  11966. // It returns an error if the field is not defined in the schema.
  11967. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  11968. switch name {
  11969. case compapiasynctask.FieldCreatedAt:
  11970. m.ResetCreatedAt()
  11971. return nil
  11972. case compapiasynctask.FieldUpdatedAt:
  11973. m.ResetUpdatedAt()
  11974. return nil
  11975. case compapiasynctask.FieldAuthToken:
  11976. m.ResetAuthToken()
  11977. return nil
  11978. case compapiasynctask.FieldEventType:
  11979. m.ResetEventType()
  11980. return nil
  11981. case compapiasynctask.FieldChatID:
  11982. m.ResetChatID()
  11983. return nil
  11984. case compapiasynctask.FieldResponseChatItemID:
  11985. m.ResetResponseChatItemID()
  11986. return nil
  11987. case compapiasynctask.FieldOrganizationID:
  11988. m.ResetOrganizationID()
  11989. return nil
  11990. case compapiasynctask.FieldOpenaiBase:
  11991. m.ResetOpenaiBase()
  11992. return nil
  11993. case compapiasynctask.FieldOpenaiKey:
  11994. m.ResetOpenaiKey()
  11995. return nil
  11996. case compapiasynctask.FieldRequestRaw:
  11997. m.ResetRequestRaw()
  11998. return nil
  11999. case compapiasynctask.FieldResponseRaw:
  12000. m.ResetResponseRaw()
  12001. return nil
  12002. case compapiasynctask.FieldCallbackURL:
  12003. m.ResetCallbackURL()
  12004. return nil
  12005. case compapiasynctask.FieldCallbackResponseRaw:
  12006. m.ResetCallbackResponseRaw()
  12007. return nil
  12008. case compapiasynctask.FieldModel:
  12009. m.ResetModel()
  12010. return nil
  12011. case compapiasynctask.FieldTaskStatus:
  12012. m.ResetTaskStatus()
  12013. return nil
  12014. case compapiasynctask.FieldRetryCount:
  12015. m.ResetRetryCount()
  12016. return nil
  12017. case compapiasynctask.FieldLastError:
  12018. m.ResetLastError()
  12019. return nil
  12020. }
  12021. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  12022. }
  12023. // AddedEdges returns all edge names that were set/added in this mutation.
  12024. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  12025. edges := make([]string, 0, 0)
  12026. return edges
  12027. }
  12028. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12029. // name in this mutation.
  12030. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  12031. return nil
  12032. }
  12033. // RemovedEdges returns all edge names that were removed in this mutation.
  12034. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  12035. edges := make([]string, 0, 0)
  12036. return edges
  12037. }
  12038. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12039. // the given name in this mutation.
  12040. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  12041. return nil
  12042. }
  12043. // ClearedEdges returns all edge names that were cleared in this mutation.
  12044. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  12045. edges := make([]string, 0, 0)
  12046. return edges
  12047. }
  12048. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12049. // was cleared in this mutation.
  12050. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  12051. return false
  12052. }
  12053. // ClearEdge clears the value of the edge with the given name. It returns an error
  12054. // if that edge is not defined in the schema.
  12055. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  12056. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  12057. }
  12058. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12059. // It returns an error if the edge is not defined in the schema.
  12060. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  12061. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  12062. }
  12063. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  12064. type ContactMutation struct {
  12065. config
  12066. op Op
  12067. typ string
  12068. id *uint64
  12069. created_at *time.Time
  12070. updated_at *time.Time
  12071. status *uint8
  12072. addstatus *int8
  12073. deleted_at *time.Time
  12074. wx_wxid *string
  12075. _type *int
  12076. add_type *int
  12077. wxid *string
  12078. account *string
  12079. nickname *string
  12080. markname *string
  12081. headimg *string
  12082. sex *int
  12083. addsex *int
  12084. starrole *string
  12085. dontseeit *int
  12086. adddontseeit *int
  12087. dontseeme *int
  12088. adddontseeme *int
  12089. lag *string
  12090. gid *string
  12091. gname *string
  12092. v3 *string
  12093. organization_id *uint64
  12094. addorganization_id *int64
  12095. ctype *uint64
  12096. addctype *int64
  12097. cage *int
  12098. addcage *int
  12099. cname *string
  12100. carea *string
  12101. cbirthday *string
  12102. cbirtharea *string
  12103. cidcard_no *string
  12104. ctitle *string
  12105. cc *string
  12106. phone *string
  12107. clearedFields map[string]struct{}
  12108. contact_relationships map[uint64]struct{}
  12109. removedcontact_relationships map[uint64]struct{}
  12110. clearedcontact_relationships bool
  12111. contact_fields map[uint64]struct{}
  12112. removedcontact_fields map[uint64]struct{}
  12113. clearedcontact_fields bool
  12114. contact_messages map[uint64]struct{}
  12115. removedcontact_messages map[uint64]struct{}
  12116. clearedcontact_messages bool
  12117. done bool
  12118. oldValue func(context.Context) (*Contact, error)
  12119. predicates []predicate.Contact
  12120. }
  12121. var _ ent.Mutation = (*ContactMutation)(nil)
  12122. // contactOption allows management of the mutation configuration using functional options.
  12123. type contactOption func(*ContactMutation)
  12124. // newContactMutation creates new mutation for the Contact entity.
  12125. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  12126. m := &ContactMutation{
  12127. config: c,
  12128. op: op,
  12129. typ: TypeContact,
  12130. clearedFields: make(map[string]struct{}),
  12131. }
  12132. for _, opt := range opts {
  12133. opt(m)
  12134. }
  12135. return m
  12136. }
  12137. // withContactID sets the ID field of the mutation.
  12138. func withContactID(id uint64) contactOption {
  12139. return func(m *ContactMutation) {
  12140. var (
  12141. err error
  12142. once sync.Once
  12143. value *Contact
  12144. )
  12145. m.oldValue = func(ctx context.Context) (*Contact, error) {
  12146. once.Do(func() {
  12147. if m.done {
  12148. err = errors.New("querying old values post mutation is not allowed")
  12149. } else {
  12150. value, err = m.Client().Contact.Get(ctx, id)
  12151. }
  12152. })
  12153. return value, err
  12154. }
  12155. m.id = &id
  12156. }
  12157. }
  12158. // withContact sets the old Contact of the mutation.
  12159. func withContact(node *Contact) contactOption {
  12160. return func(m *ContactMutation) {
  12161. m.oldValue = func(context.Context) (*Contact, error) {
  12162. return node, nil
  12163. }
  12164. m.id = &node.ID
  12165. }
  12166. }
  12167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12168. // executed in a transaction (ent.Tx), a transactional client is returned.
  12169. func (m ContactMutation) Client() *Client {
  12170. client := &Client{config: m.config}
  12171. client.init()
  12172. return client
  12173. }
  12174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12175. // it returns an error otherwise.
  12176. func (m ContactMutation) Tx() (*Tx, error) {
  12177. if _, ok := m.driver.(*txDriver); !ok {
  12178. return nil, errors.New("ent: mutation is not running in a transaction")
  12179. }
  12180. tx := &Tx{config: m.config}
  12181. tx.init()
  12182. return tx, nil
  12183. }
  12184. // SetID sets the value of the id field. Note that this
  12185. // operation is only accepted on creation of Contact entities.
  12186. func (m *ContactMutation) SetID(id uint64) {
  12187. m.id = &id
  12188. }
  12189. // ID returns the ID value in the mutation. Note that the ID is only available
  12190. // if it was provided to the builder or after it was returned from the database.
  12191. func (m *ContactMutation) ID() (id uint64, exists bool) {
  12192. if m.id == nil {
  12193. return
  12194. }
  12195. return *m.id, true
  12196. }
  12197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12198. // That means, if the mutation is applied within a transaction with an isolation level such
  12199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12200. // or updated by the mutation.
  12201. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  12202. switch {
  12203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12204. id, exists := m.ID()
  12205. if exists {
  12206. return []uint64{id}, nil
  12207. }
  12208. fallthrough
  12209. case m.op.Is(OpUpdate | OpDelete):
  12210. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  12211. default:
  12212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12213. }
  12214. }
  12215. // SetCreatedAt sets the "created_at" field.
  12216. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  12217. m.created_at = &t
  12218. }
  12219. // CreatedAt returns the value of the "created_at" field in the mutation.
  12220. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  12221. v := m.created_at
  12222. if v == nil {
  12223. return
  12224. }
  12225. return *v, true
  12226. }
  12227. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  12228. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12230. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12231. if !m.op.Is(OpUpdateOne) {
  12232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12233. }
  12234. if m.id == nil || m.oldValue == nil {
  12235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12236. }
  12237. oldValue, err := m.oldValue(ctx)
  12238. if err != nil {
  12239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12240. }
  12241. return oldValue.CreatedAt, nil
  12242. }
  12243. // ResetCreatedAt resets all changes to the "created_at" field.
  12244. func (m *ContactMutation) ResetCreatedAt() {
  12245. m.created_at = nil
  12246. }
  12247. // SetUpdatedAt sets the "updated_at" field.
  12248. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  12249. m.updated_at = &t
  12250. }
  12251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12252. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  12253. v := m.updated_at
  12254. if v == nil {
  12255. return
  12256. }
  12257. return *v, true
  12258. }
  12259. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  12260. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12262. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12263. if !m.op.Is(OpUpdateOne) {
  12264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12265. }
  12266. if m.id == nil || m.oldValue == nil {
  12267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12268. }
  12269. oldValue, err := m.oldValue(ctx)
  12270. if err != nil {
  12271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12272. }
  12273. return oldValue.UpdatedAt, nil
  12274. }
  12275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12276. func (m *ContactMutation) ResetUpdatedAt() {
  12277. m.updated_at = nil
  12278. }
  12279. // SetStatus sets the "status" field.
  12280. func (m *ContactMutation) SetStatus(u uint8) {
  12281. m.status = &u
  12282. m.addstatus = nil
  12283. }
  12284. // Status returns the value of the "status" field in the mutation.
  12285. func (m *ContactMutation) Status() (r uint8, exists bool) {
  12286. v := m.status
  12287. if v == nil {
  12288. return
  12289. }
  12290. return *v, true
  12291. }
  12292. // OldStatus returns the old "status" field's value of the Contact entity.
  12293. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12295. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12296. if !m.op.Is(OpUpdateOne) {
  12297. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12298. }
  12299. if m.id == nil || m.oldValue == nil {
  12300. return v, errors.New("OldStatus requires an ID field in the mutation")
  12301. }
  12302. oldValue, err := m.oldValue(ctx)
  12303. if err != nil {
  12304. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12305. }
  12306. return oldValue.Status, nil
  12307. }
  12308. // AddStatus adds u to the "status" field.
  12309. func (m *ContactMutation) AddStatus(u int8) {
  12310. if m.addstatus != nil {
  12311. *m.addstatus += u
  12312. } else {
  12313. m.addstatus = &u
  12314. }
  12315. }
  12316. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12317. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  12318. v := m.addstatus
  12319. if v == nil {
  12320. return
  12321. }
  12322. return *v, true
  12323. }
  12324. // ClearStatus clears the value of the "status" field.
  12325. func (m *ContactMutation) ClearStatus() {
  12326. m.status = nil
  12327. m.addstatus = nil
  12328. m.clearedFields[contact.FieldStatus] = struct{}{}
  12329. }
  12330. // StatusCleared returns if the "status" field was cleared in this mutation.
  12331. func (m *ContactMutation) StatusCleared() bool {
  12332. _, ok := m.clearedFields[contact.FieldStatus]
  12333. return ok
  12334. }
  12335. // ResetStatus resets all changes to the "status" field.
  12336. func (m *ContactMutation) ResetStatus() {
  12337. m.status = nil
  12338. m.addstatus = nil
  12339. delete(m.clearedFields, contact.FieldStatus)
  12340. }
  12341. // SetDeletedAt sets the "deleted_at" field.
  12342. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  12343. m.deleted_at = &t
  12344. }
  12345. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12346. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  12347. v := m.deleted_at
  12348. if v == nil {
  12349. return
  12350. }
  12351. return *v, true
  12352. }
  12353. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  12354. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12356. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12357. if !m.op.Is(OpUpdateOne) {
  12358. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12359. }
  12360. if m.id == nil || m.oldValue == nil {
  12361. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12362. }
  12363. oldValue, err := m.oldValue(ctx)
  12364. if err != nil {
  12365. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12366. }
  12367. return oldValue.DeletedAt, nil
  12368. }
  12369. // ClearDeletedAt clears the value of the "deleted_at" field.
  12370. func (m *ContactMutation) ClearDeletedAt() {
  12371. m.deleted_at = nil
  12372. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  12373. }
  12374. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12375. func (m *ContactMutation) DeletedAtCleared() bool {
  12376. _, ok := m.clearedFields[contact.FieldDeletedAt]
  12377. return ok
  12378. }
  12379. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12380. func (m *ContactMutation) ResetDeletedAt() {
  12381. m.deleted_at = nil
  12382. delete(m.clearedFields, contact.FieldDeletedAt)
  12383. }
  12384. // SetWxWxid sets the "wx_wxid" field.
  12385. func (m *ContactMutation) SetWxWxid(s string) {
  12386. m.wx_wxid = &s
  12387. }
  12388. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12389. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  12390. v := m.wx_wxid
  12391. if v == nil {
  12392. return
  12393. }
  12394. return *v, true
  12395. }
  12396. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  12397. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12399. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12400. if !m.op.Is(OpUpdateOne) {
  12401. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12402. }
  12403. if m.id == nil || m.oldValue == nil {
  12404. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12405. }
  12406. oldValue, err := m.oldValue(ctx)
  12407. if err != nil {
  12408. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12409. }
  12410. return oldValue.WxWxid, nil
  12411. }
  12412. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12413. func (m *ContactMutation) ResetWxWxid() {
  12414. m.wx_wxid = nil
  12415. }
  12416. // SetType sets the "type" field.
  12417. func (m *ContactMutation) SetType(i int) {
  12418. m._type = &i
  12419. m.add_type = nil
  12420. }
  12421. // GetType returns the value of the "type" field in the mutation.
  12422. func (m *ContactMutation) GetType() (r int, exists bool) {
  12423. v := m._type
  12424. if v == nil {
  12425. return
  12426. }
  12427. return *v, true
  12428. }
  12429. // OldType returns the old "type" field's value of the Contact entity.
  12430. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12432. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  12433. if !m.op.Is(OpUpdateOne) {
  12434. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12435. }
  12436. if m.id == nil || m.oldValue == nil {
  12437. return v, errors.New("OldType requires an ID field in the mutation")
  12438. }
  12439. oldValue, err := m.oldValue(ctx)
  12440. if err != nil {
  12441. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12442. }
  12443. return oldValue.Type, nil
  12444. }
  12445. // AddType adds i to the "type" field.
  12446. func (m *ContactMutation) AddType(i int) {
  12447. if m.add_type != nil {
  12448. *m.add_type += i
  12449. } else {
  12450. m.add_type = &i
  12451. }
  12452. }
  12453. // AddedType returns the value that was added to the "type" field in this mutation.
  12454. func (m *ContactMutation) AddedType() (r int, exists bool) {
  12455. v := m.add_type
  12456. if v == nil {
  12457. return
  12458. }
  12459. return *v, true
  12460. }
  12461. // ClearType clears the value of the "type" field.
  12462. func (m *ContactMutation) ClearType() {
  12463. m._type = nil
  12464. m.add_type = nil
  12465. m.clearedFields[contact.FieldType] = struct{}{}
  12466. }
  12467. // TypeCleared returns if the "type" field was cleared in this mutation.
  12468. func (m *ContactMutation) TypeCleared() bool {
  12469. _, ok := m.clearedFields[contact.FieldType]
  12470. return ok
  12471. }
  12472. // ResetType resets all changes to the "type" field.
  12473. func (m *ContactMutation) ResetType() {
  12474. m._type = nil
  12475. m.add_type = nil
  12476. delete(m.clearedFields, contact.FieldType)
  12477. }
  12478. // SetWxid sets the "wxid" field.
  12479. func (m *ContactMutation) SetWxid(s string) {
  12480. m.wxid = &s
  12481. }
  12482. // Wxid returns the value of the "wxid" field in the mutation.
  12483. func (m *ContactMutation) Wxid() (r string, exists bool) {
  12484. v := m.wxid
  12485. if v == nil {
  12486. return
  12487. }
  12488. return *v, true
  12489. }
  12490. // OldWxid returns the old "wxid" field's value of the Contact entity.
  12491. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12493. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  12494. if !m.op.Is(OpUpdateOne) {
  12495. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12496. }
  12497. if m.id == nil || m.oldValue == nil {
  12498. return v, errors.New("OldWxid requires an ID field in the mutation")
  12499. }
  12500. oldValue, err := m.oldValue(ctx)
  12501. if err != nil {
  12502. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12503. }
  12504. return oldValue.Wxid, nil
  12505. }
  12506. // ResetWxid resets all changes to the "wxid" field.
  12507. func (m *ContactMutation) ResetWxid() {
  12508. m.wxid = nil
  12509. }
  12510. // SetAccount sets the "account" field.
  12511. func (m *ContactMutation) SetAccount(s string) {
  12512. m.account = &s
  12513. }
  12514. // Account returns the value of the "account" field in the mutation.
  12515. func (m *ContactMutation) Account() (r string, exists bool) {
  12516. v := m.account
  12517. if v == nil {
  12518. return
  12519. }
  12520. return *v, true
  12521. }
  12522. // OldAccount returns the old "account" field's value of the Contact entity.
  12523. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12525. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  12526. if !m.op.Is(OpUpdateOne) {
  12527. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  12528. }
  12529. if m.id == nil || m.oldValue == nil {
  12530. return v, errors.New("OldAccount requires an ID field in the mutation")
  12531. }
  12532. oldValue, err := m.oldValue(ctx)
  12533. if err != nil {
  12534. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  12535. }
  12536. return oldValue.Account, nil
  12537. }
  12538. // ResetAccount resets all changes to the "account" field.
  12539. func (m *ContactMutation) ResetAccount() {
  12540. m.account = nil
  12541. }
  12542. // SetNickname sets the "nickname" field.
  12543. func (m *ContactMutation) SetNickname(s string) {
  12544. m.nickname = &s
  12545. }
  12546. // Nickname returns the value of the "nickname" field in the mutation.
  12547. func (m *ContactMutation) Nickname() (r string, exists bool) {
  12548. v := m.nickname
  12549. if v == nil {
  12550. return
  12551. }
  12552. return *v, true
  12553. }
  12554. // OldNickname returns the old "nickname" field's value of the Contact entity.
  12555. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12557. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  12558. if !m.op.Is(OpUpdateOne) {
  12559. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  12560. }
  12561. if m.id == nil || m.oldValue == nil {
  12562. return v, errors.New("OldNickname requires an ID field in the mutation")
  12563. }
  12564. oldValue, err := m.oldValue(ctx)
  12565. if err != nil {
  12566. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  12567. }
  12568. return oldValue.Nickname, nil
  12569. }
  12570. // ResetNickname resets all changes to the "nickname" field.
  12571. func (m *ContactMutation) ResetNickname() {
  12572. m.nickname = nil
  12573. }
  12574. // SetMarkname sets the "markname" field.
  12575. func (m *ContactMutation) SetMarkname(s string) {
  12576. m.markname = &s
  12577. }
  12578. // Markname returns the value of the "markname" field in the mutation.
  12579. func (m *ContactMutation) Markname() (r string, exists bool) {
  12580. v := m.markname
  12581. if v == nil {
  12582. return
  12583. }
  12584. return *v, true
  12585. }
  12586. // OldMarkname returns the old "markname" field's value of the Contact entity.
  12587. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12589. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  12590. if !m.op.Is(OpUpdateOne) {
  12591. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  12592. }
  12593. if m.id == nil || m.oldValue == nil {
  12594. return v, errors.New("OldMarkname requires an ID field in the mutation")
  12595. }
  12596. oldValue, err := m.oldValue(ctx)
  12597. if err != nil {
  12598. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  12599. }
  12600. return oldValue.Markname, nil
  12601. }
  12602. // ResetMarkname resets all changes to the "markname" field.
  12603. func (m *ContactMutation) ResetMarkname() {
  12604. m.markname = nil
  12605. }
  12606. // SetHeadimg sets the "headimg" field.
  12607. func (m *ContactMutation) SetHeadimg(s string) {
  12608. m.headimg = &s
  12609. }
  12610. // Headimg returns the value of the "headimg" field in the mutation.
  12611. func (m *ContactMutation) Headimg() (r string, exists bool) {
  12612. v := m.headimg
  12613. if v == nil {
  12614. return
  12615. }
  12616. return *v, true
  12617. }
  12618. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  12619. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12621. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  12622. if !m.op.Is(OpUpdateOne) {
  12623. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  12624. }
  12625. if m.id == nil || m.oldValue == nil {
  12626. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  12627. }
  12628. oldValue, err := m.oldValue(ctx)
  12629. if err != nil {
  12630. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  12631. }
  12632. return oldValue.Headimg, nil
  12633. }
  12634. // ResetHeadimg resets all changes to the "headimg" field.
  12635. func (m *ContactMutation) ResetHeadimg() {
  12636. m.headimg = nil
  12637. }
  12638. // SetSex sets the "sex" field.
  12639. func (m *ContactMutation) SetSex(i int) {
  12640. m.sex = &i
  12641. m.addsex = nil
  12642. }
  12643. // Sex returns the value of the "sex" field in the mutation.
  12644. func (m *ContactMutation) Sex() (r int, exists bool) {
  12645. v := m.sex
  12646. if v == nil {
  12647. return
  12648. }
  12649. return *v, true
  12650. }
  12651. // OldSex returns the old "sex" field's value of the Contact entity.
  12652. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12654. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  12655. if !m.op.Is(OpUpdateOne) {
  12656. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  12657. }
  12658. if m.id == nil || m.oldValue == nil {
  12659. return v, errors.New("OldSex requires an ID field in the mutation")
  12660. }
  12661. oldValue, err := m.oldValue(ctx)
  12662. if err != nil {
  12663. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  12664. }
  12665. return oldValue.Sex, nil
  12666. }
  12667. // AddSex adds i to the "sex" field.
  12668. func (m *ContactMutation) AddSex(i int) {
  12669. if m.addsex != nil {
  12670. *m.addsex += i
  12671. } else {
  12672. m.addsex = &i
  12673. }
  12674. }
  12675. // AddedSex returns the value that was added to the "sex" field in this mutation.
  12676. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  12677. v := m.addsex
  12678. if v == nil {
  12679. return
  12680. }
  12681. return *v, true
  12682. }
  12683. // ResetSex resets all changes to the "sex" field.
  12684. func (m *ContactMutation) ResetSex() {
  12685. m.sex = nil
  12686. m.addsex = nil
  12687. }
  12688. // SetStarrole sets the "starrole" field.
  12689. func (m *ContactMutation) SetStarrole(s string) {
  12690. m.starrole = &s
  12691. }
  12692. // Starrole returns the value of the "starrole" field in the mutation.
  12693. func (m *ContactMutation) Starrole() (r string, exists bool) {
  12694. v := m.starrole
  12695. if v == nil {
  12696. return
  12697. }
  12698. return *v, true
  12699. }
  12700. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  12701. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12703. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  12704. if !m.op.Is(OpUpdateOne) {
  12705. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  12706. }
  12707. if m.id == nil || m.oldValue == nil {
  12708. return v, errors.New("OldStarrole requires an ID field in the mutation")
  12709. }
  12710. oldValue, err := m.oldValue(ctx)
  12711. if err != nil {
  12712. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  12713. }
  12714. return oldValue.Starrole, nil
  12715. }
  12716. // ResetStarrole resets all changes to the "starrole" field.
  12717. func (m *ContactMutation) ResetStarrole() {
  12718. m.starrole = nil
  12719. }
  12720. // SetDontseeit sets the "dontseeit" field.
  12721. func (m *ContactMutation) SetDontseeit(i int) {
  12722. m.dontseeit = &i
  12723. m.adddontseeit = nil
  12724. }
  12725. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  12726. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  12727. v := m.dontseeit
  12728. if v == nil {
  12729. return
  12730. }
  12731. return *v, true
  12732. }
  12733. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  12734. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12736. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  12737. if !m.op.Is(OpUpdateOne) {
  12738. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  12739. }
  12740. if m.id == nil || m.oldValue == nil {
  12741. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  12742. }
  12743. oldValue, err := m.oldValue(ctx)
  12744. if err != nil {
  12745. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  12746. }
  12747. return oldValue.Dontseeit, nil
  12748. }
  12749. // AddDontseeit adds i to the "dontseeit" field.
  12750. func (m *ContactMutation) AddDontseeit(i int) {
  12751. if m.adddontseeit != nil {
  12752. *m.adddontseeit += i
  12753. } else {
  12754. m.adddontseeit = &i
  12755. }
  12756. }
  12757. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  12758. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  12759. v := m.adddontseeit
  12760. if v == nil {
  12761. return
  12762. }
  12763. return *v, true
  12764. }
  12765. // ResetDontseeit resets all changes to the "dontseeit" field.
  12766. func (m *ContactMutation) ResetDontseeit() {
  12767. m.dontseeit = nil
  12768. m.adddontseeit = nil
  12769. }
  12770. // SetDontseeme sets the "dontseeme" field.
  12771. func (m *ContactMutation) SetDontseeme(i int) {
  12772. m.dontseeme = &i
  12773. m.adddontseeme = nil
  12774. }
  12775. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  12776. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  12777. v := m.dontseeme
  12778. if v == nil {
  12779. return
  12780. }
  12781. return *v, true
  12782. }
  12783. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  12784. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12786. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  12787. if !m.op.Is(OpUpdateOne) {
  12788. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  12789. }
  12790. if m.id == nil || m.oldValue == nil {
  12791. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  12792. }
  12793. oldValue, err := m.oldValue(ctx)
  12794. if err != nil {
  12795. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  12796. }
  12797. return oldValue.Dontseeme, nil
  12798. }
  12799. // AddDontseeme adds i to the "dontseeme" field.
  12800. func (m *ContactMutation) AddDontseeme(i int) {
  12801. if m.adddontseeme != nil {
  12802. *m.adddontseeme += i
  12803. } else {
  12804. m.adddontseeme = &i
  12805. }
  12806. }
  12807. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  12808. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  12809. v := m.adddontseeme
  12810. if v == nil {
  12811. return
  12812. }
  12813. return *v, true
  12814. }
  12815. // ResetDontseeme resets all changes to the "dontseeme" field.
  12816. func (m *ContactMutation) ResetDontseeme() {
  12817. m.dontseeme = nil
  12818. m.adddontseeme = nil
  12819. }
  12820. // SetLag sets the "lag" field.
  12821. func (m *ContactMutation) SetLag(s string) {
  12822. m.lag = &s
  12823. }
  12824. // Lag returns the value of the "lag" field in the mutation.
  12825. func (m *ContactMutation) Lag() (r string, exists bool) {
  12826. v := m.lag
  12827. if v == nil {
  12828. return
  12829. }
  12830. return *v, true
  12831. }
  12832. // OldLag returns the old "lag" field's value of the Contact entity.
  12833. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12835. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  12836. if !m.op.Is(OpUpdateOne) {
  12837. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  12838. }
  12839. if m.id == nil || m.oldValue == nil {
  12840. return v, errors.New("OldLag requires an ID field in the mutation")
  12841. }
  12842. oldValue, err := m.oldValue(ctx)
  12843. if err != nil {
  12844. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  12845. }
  12846. return oldValue.Lag, nil
  12847. }
  12848. // ResetLag resets all changes to the "lag" field.
  12849. func (m *ContactMutation) ResetLag() {
  12850. m.lag = nil
  12851. }
  12852. // SetGid sets the "gid" field.
  12853. func (m *ContactMutation) SetGid(s string) {
  12854. m.gid = &s
  12855. }
  12856. // Gid returns the value of the "gid" field in the mutation.
  12857. func (m *ContactMutation) Gid() (r string, exists bool) {
  12858. v := m.gid
  12859. if v == nil {
  12860. return
  12861. }
  12862. return *v, true
  12863. }
  12864. // OldGid returns the old "gid" field's value of the Contact entity.
  12865. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12867. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  12868. if !m.op.Is(OpUpdateOne) {
  12869. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  12870. }
  12871. if m.id == nil || m.oldValue == nil {
  12872. return v, errors.New("OldGid requires an ID field in the mutation")
  12873. }
  12874. oldValue, err := m.oldValue(ctx)
  12875. if err != nil {
  12876. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  12877. }
  12878. return oldValue.Gid, nil
  12879. }
  12880. // ResetGid resets all changes to the "gid" field.
  12881. func (m *ContactMutation) ResetGid() {
  12882. m.gid = nil
  12883. }
  12884. // SetGname sets the "gname" field.
  12885. func (m *ContactMutation) SetGname(s string) {
  12886. m.gname = &s
  12887. }
  12888. // Gname returns the value of the "gname" field in the mutation.
  12889. func (m *ContactMutation) Gname() (r string, exists bool) {
  12890. v := m.gname
  12891. if v == nil {
  12892. return
  12893. }
  12894. return *v, true
  12895. }
  12896. // OldGname returns the old "gname" field's value of the Contact entity.
  12897. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12899. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  12900. if !m.op.Is(OpUpdateOne) {
  12901. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  12902. }
  12903. if m.id == nil || m.oldValue == nil {
  12904. return v, errors.New("OldGname requires an ID field in the mutation")
  12905. }
  12906. oldValue, err := m.oldValue(ctx)
  12907. if err != nil {
  12908. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  12909. }
  12910. return oldValue.Gname, nil
  12911. }
  12912. // ResetGname resets all changes to the "gname" field.
  12913. func (m *ContactMutation) ResetGname() {
  12914. m.gname = nil
  12915. }
  12916. // SetV3 sets the "v3" field.
  12917. func (m *ContactMutation) SetV3(s string) {
  12918. m.v3 = &s
  12919. }
  12920. // V3 returns the value of the "v3" field in the mutation.
  12921. func (m *ContactMutation) V3() (r string, exists bool) {
  12922. v := m.v3
  12923. if v == nil {
  12924. return
  12925. }
  12926. return *v, true
  12927. }
  12928. // OldV3 returns the old "v3" field's value of the Contact entity.
  12929. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12931. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  12932. if !m.op.Is(OpUpdateOne) {
  12933. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  12934. }
  12935. if m.id == nil || m.oldValue == nil {
  12936. return v, errors.New("OldV3 requires an ID field in the mutation")
  12937. }
  12938. oldValue, err := m.oldValue(ctx)
  12939. if err != nil {
  12940. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  12941. }
  12942. return oldValue.V3, nil
  12943. }
  12944. // ResetV3 resets all changes to the "v3" field.
  12945. func (m *ContactMutation) ResetV3() {
  12946. m.v3 = nil
  12947. }
  12948. // SetOrganizationID sets the "organization_id" field.
  12949. func (m *ContactMutation) SetOrganizationID(u uint64) {
  12950. m.organization_id = &u
  12951. m.addorganization_id = nil
  12952. }
  12953. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12954. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  12955. v := m.organization_id
  12956. if v == nil {
  12957. return
  12958. }
  12959. return *v, true
  12960. }
  12961. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  12962. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12964. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12965. if !m.op.Is(OpUpdateOne) {
  12966. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12967. }
  12968. if m.id == nil || m.oldValue == nil {
  12969. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12970. }
  12971. oldValue, err := m.oldValue(ctx)
  12972. if err != nil {
  12973. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12974. }
  12975. return oldValue.OrganizationID, nil
  12976. }
  12977. // AddOrganizationID adds u to the "organization_id" field.
  12978. func (m *ContactMutation) AddOrganizationID(u int64) {
  12979. if m.addorganization_id != nil {
  12980. *m.addorganization_id += u
  12981. } else {
  12982. m.addorganization_id = &u
  12983. }
  12984. }
  12985. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12986. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  12987. v := m.addorganization_id
  12988. if v == nil {
  12989. return
  12990. }
  12991. return *v, true
  12992. }
  12993. // ClearOrganizationID clears the value of the "organization_id" field.
  12994. func (m *ContactMutation) ClearOrganizationID() {
  12995. m.organization_id = nil
  12996. m.addorganization_id = nil
  12997. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  12998. }
  12999. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13000. func (m *ContactMutation) OrganizationIDCleared() bool {
  13001. _, ok := m.clearedFields[contact.FieldOrganizationID]
  13002. return ok
  13003. }
  13004. // ResetOrganizationID resets all changes to the "organization_id" field.
  13005. func (m *ContactMutation) ResetOrganizationID() {
  13006. m.organization_id = nil
  13007. m.addorganization_id = nil
  13008. delete(m.clearedFields, contact.FieldOrganizationID)
  13009. }
  13010. // SetCtype sets the "ctype" field.
  13011. func (m *ContactMutation) SetCtype(u uint64) {
  13012. m.ctype = &u
  13013. m.addctype = nil
  13014. }
  13015. // Ctype returns the value of the "ctype" field in the mutation.
  13016. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  13017. v := m.ctype
  13018. if v == nil {
  13019. return
  13020. }
  13021. return *v, true
  13022. }
  13023. // OldCtype returns the old "ctype" field's value of the Contact entity.
  13024. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13026. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  13027. if !m.op.Is(OpUpdateOne) {
  13028. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  13029. }
  13030. if m.id == nil || m.oldValue == nil {
  13031. return v, errors.New("OldCtype requires an ID field in the mutation")
  13032. }
  13033. oldValue, err := m.oldValue(ctx)
  13034. if err != nil {
  13035. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  13036. }
  13037. return oldValue.Ctype, nil
  13038. }
  13039. // AddCtype adds u to the "ctype" field.
  13040. func (m *ContactMutation) AddCtype(u int64) {
  13041. if m.addctype != nil {
  13042. *m.addctype += u
  13043. } else {
  13044. m.addctype = &u
  13045. }
  13046. }
  13047. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  13048. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  13049. v := m.addctype
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // ResetCtype resets all changes to the "ctype" field.
  13056. func (m *ContactMutation) ResetCtype() {
  13057. m.ctype = nil
  13058. m.addctype = nil
  13059. }
  13060. // SetCage sets the "cage" field.
  13061. func (m *ContactMutation) SetCage(i int) {
  13062. m.cage = &i
  13063. m.addcage = nil
  13064. }
  13065. // Cage returns the value of the "cage" field in the mutation.
  13066. func (m *ContactMutation) Cage() (r int, exists bool) {
  13067. v := m.cage
  13068. if v == nil {
  13069. return
  13070. }
  13071. return *v, true
  13072. }
  13073. // OldCage returns the old "cage" field's value of the Contact entity.
  13074. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13076. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  13077. if !m.op.Is(OpUpdateOne) {
  13078. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  13079. }
  13080. if m.id == nil || m.oldValue == nil {
  13081. return v, errors.New("OldCage requires an ID field in the mutation")
  13082. }
  13083. oldValue, err := m.oldValue(ctx)
  13084. if err != nil {
  13085. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  13086. }
  13087. return oldValue.Cage, nil
  13088. }
  13089. // AddCage adds i to the "cage" field.
  13090. func (m *ContactMutation) AddCage(i int) {
  13091. if m.addcage != nil {
  13092. *m.addcage += i
  13093. } else {
  13094. m.addcage = &i
  13095. }
  13096. }
  13097. // AddedCage returns the value that was added to the "cage" field in this mutation.
  13098. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  13099. v := m.addcage
  13100. if v == nil {
  13101. return
  13102. }
  13103. return *v, true
  13104. }
  13105. // ResetCage resets all changes to the "cage" field.
  13106. func (m *ContactMutation) ResetCage() {
  13107. m.cage = nil
  13108. m.addcage = nil
  13109. }
  13110. // SetCname sets the "cname" field.
  13111. func (m *ContactMutation) SetCname(s string) {
  13112. m.cname = &s
  13113. }
  13114. // Cname returns the value of the "cname" field in the mutation.
  13115. func (m *ContactMutation) Cname() (r string, exists bool) {
  13116. v := m.cname
  13117. if v == nil {
  13118. return
  13119. }
  13120. return *v, true
  13121. }
  13122. // OldCname returns the old "cname" field's value of the Contact entity.
  13123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13125. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  13126. if !m.op.Is(OpUpdateOne) {
  13127. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  13128. }
  13129. if m.id == nil || m.oldValue == nil {
  13130. return v, errors.New("OldCname requires an ID field in the mutation")
  13131. }
  13132. oldValue, err := m.oldValue(ctx)
  13133. if err != nil {
  13134. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  13135. }
  13136. return oldValue.Cname, nil
  13137. }
  13138. // ResetCname resets all changes to the "cname" field.
  13139. func (m *ContactMutation) ResetCname() {
  13140. m.cname = nil
  13141. }
  13142. // SetCarea sets the "carea" field.
  13143. func (m *ContactMutation) SetCarea(s string) {
  13144. m.carea = &s
  13145. }
  13146. // Carea returns the value of the "carea" field in the mutation.
  13147. func (m *ContactMutation) Carea() (r string, exists bool) {
  13148. v := m.carea
  13149. if v == nil {
  13150. return
  13151. }
  13152. return *v, true
  13153. }
  13154. // OldCarea returns the old "carea" field's value of the Contact entity.
  13155. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13157. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  13158. if !m.op.Is(OpUpdateOne) {
  13159. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  13160. }
  13161. if m.id == nil || m.oldValue == nil {
  13162. return v, errors.New("OldCarea requires an ID field in the mutation")
  13163. }
  13164. oldValue, err := m.oldValue(ctx)
  13165. if err != nil {
  13166. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  13167. }
  13168. return oldValue.Carea, nil
  13169. }
  13170. // ResetCarea resets all changes to the "carea" field.
  13171. func (m *ContactMutation) ResetCarea() {
  13172. m.carea = nil
  13173. }
  13174. // SetCbirthday sets the "cbirthday" field.
  13175. func (m *ContactMutation) SetCbirthday(s string) {
  13176. m.cbirthday = &s
  13177. }
  13178. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  13179. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  13180. v := m.cbirthday
  13181. if v == nil {
  13182. return
  13183. }
  13184. return *v, true
  13185. }
  13186. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  13187. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13189. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  13190. if !m.op.Is(OpUpdateOne) {
  13191. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  13192. }
  13193. if m.id == nil || m.oldValue == nil {
  13194. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  13195. }
  13196. oldValue, err := m.oldValue(ctx)
  13197. if err != nil {
  13198. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  13199. }
  13200. return oldValue.Cbirthday, nil
  13201. }
  13202. // ResetCbirthday resets all changes to the "cbirthday" field.
  13203. func (m *ContactMutation) ResetCbirthday() {
  13204. m.cbirthday = nil
  13205. }
  13206. // SetCbirtharea sets the "cbirtharea" field.
  13207. func (m *ContactMutation) SetCbirtharea(s string) {
  13208. m.cbirtharea = &s
  13209. }
  13210. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  13211. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  13212. v := m.cbirtharea
  13213. if v == nil {
  13214. return
  13215. }
  13216. return *v, true
  13217. }
  13218. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  13219. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13221. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  13222. if !m.op.Is(OpUpdateOne) {
  13223. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  13224. }
  13225. if m.id == nil || m.oldValue == nil {
  13226. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  13227. }
  13228. oldValue, err := m.oldValue(ctx)
  13229. if err != nil {
  13230. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  13231. }
  13232. return oldValue.Cbirtharea, nil
  13233. }
  13234. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  13235. func (m *ContactMutation) ResetCbirtharea() {
  13236. m.cbirtharea = nil
  13237. }
  13238. // SetCidcardNo sets the "cidcard_no" field.
  13239. func (m *ContactMutation) SetCidcardNo(s string) {
  13240. m.cidcard_no = &s
  13241. }
  13242. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  13243. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  13244. v := m.cidcard_no
  13245. if v == nil {
  13246. return
  13247. }
  13248. return *v, true
  13249. }
  13250. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  13251. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13253. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  13254. if !m.op.Is(OpUpdateOne) {
  13255. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  13256. }
  13257. if m.id == nil || m.oldValue == nil {
  13258. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  13259. }
  13260. oldValue, err := m.oldValue(ctx)
  13261. if err != nil {
  13262. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  13263. }
  13264. return oldValue.CidcardNo, nil
  13265. }
  13266. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  13267. func (m *ContactMutation) ResetCidcardNo() {
  13268. m.cidcard_no = nil
  13269. }
  13270. // SetCtitle sets the "ctitle" field.
  13271. func (m *ContactMutation) SetCtitle(s string) {
  13272. m.ctitle = &s
  13273. }
  13274. // Ctitle returns the value of the "ctitle" field in the mutation.
  13275. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  13276. v := m.ctitle
  13277. if v == nil {
  13278. return
  13279. }
  13280. return *v, true
  13281. }
  13282. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  13283. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13285. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  13286. if !m.op.Is(OpUpdateOne) {
  13287. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  13288. }
  13289. if m.id == nil || m.oldValue == nil {
  13290. return v, errors.New("OldCtitle requires an ID field in the mutation")
  13291. }
  13292. oldValue, err := m.oldValue(ctx)
  13293. if err != nil {
  13294. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  13295. }
  13296. return oldValue.Ctitle, nil
  13297. }
  13298. // ResetCtitle resets all changes to the "ctitle" field.
  13299. func (m *ContactMutation) ResetCtitle() {
  13300. m.ctitle = nil
  13301. }
  13302. // SetCc sets the "cc" field.
  13303. func (m *ContactMutation) SetCc(s string) {
  13304. m.cc = &s
  13305. }
  13306. // Cc returns the value of the "cc" field in the mutation.
  13307. func (m *ContactMutation) Cc() (r string, exists bool) {
  13308. v := m.cc
  13309. if v == nil {
  13310. return
  13311. }
  13312. return *v, true
  13313. }
  13314. // OldCc returns the old "cc" field's value of the Contact entity.
  13315. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13317. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  13318. if !m.op.Is(OpUpdateOne) {
  13319. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  13320. }
  13321. if m.id == nil || m.oldValue == nil {
  13322. return v, errors.New("OldCc requires an ID field in the mutation")
  13323. }
  13324. oldValue, err := m.oldValue(ctx)
  13325. if err != nil {
  13326. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  13327. }
  13328. return oldValue.Cc, nil
  13329. }
  13330. // ResetCc resets all changes to the "cc" field.
  13331. func (m *ContactMutation) ResetCc() {
  13332. m.cc = nil
  13333. }
  13334. // SetPhone sets the "phone" field.
  13335. func (m *ContactMutation) SetPhone(s string) {
  13336. m.phone = &s
  13337. }
  13338. // Phone returns the value of the "phone" field in the mutation.
  13339. func (m *ContactMutation) Phone() (r string, exists bool) {
  13340. v := m.phone
  13341. if v == nil {
  13342. return
  13343. }
  13344. return *v, true
  13345. }
  13346. // OldPhone returns the old "phone" field's value of the Contact entity.
  13347. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13349. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  13350. if !m.op.Is(OpUpdateOne) {
  13351. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  13352. }
  13353. if m.id == nil || m.oldValue == nil {
  13354. return v, errors.New("OldPhone requires an ID field in the mutation")
  13355. }
  13356. oldValue, err := m.oldValue(ctx)
  13357. if err != nil {
  13358. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  13359. }
  13360. return oldValue.Phone, nil
  13361. }
  13362. // ResetPhone resets all changes to the "phone" field.
  13363. func (m *ContactMutation) ResetPhone() {
  13364. m.phone = nil
  13365. }
  13366. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  13367. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  13368. if m.contact_relationships == nil {
  13369. m.contact_relationships = make(map[uint64]struct{})
  13370. }
  13371. for i := range ids {
  13372. m.contact_relationships[ids[i]] = struct{}{}
  13373. }
  13374. }
  13375. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  13376. func (m *ContactMutation) ClearContactRelationships() {
  13377. m.clearedcontact_relationships = true
  13378. }
  13379. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  13380. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  13381. return m.clearedcontact_relationships
  13382. }
  13383. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  13384. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  13385. if m.removedcontact_relationships == nil {
  13386. m.removedcontact_relationships = make(map[uint64]struct{})
  13387. }
  13388. for i := range ids {
  13389. delete(m.contact_relationships, ids[i])
  13390. m.removedcontact_relationships[ids[i]] = struct{}{}
  13391. }
  13392. }
  13393. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  13394. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  13395. for id := range m.removedcontact_relationships {
  13396. ids = append(ids, id)
  13397. }
  13398. return
  13399. }
  13400. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  13401. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  13402. for id := range m.contact_relationships {
  13403. ids = append(ids, id)
  13404. }
  13405. return
  13406. }
  13407. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  13408. func (m *ContactMutation) ResetContactRelationships() {
  13409. m.contact_relationships = nil
  13410. m.clearedcontact_relationships = false
  13411. m.removedcontact_relationships = nil
  13412. }
  13413. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  13414. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  13415. if m.contact_fields == nil {
  13416. m.contact_fields = make(map[uint64]struct{})
  13417. }
  13418. for i := range ids {
  13419. m.contact_fields[ids[i]] = struct{}{}
  13420. }
  13421. }
  13422. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  13423. func (m *ContactMutation) ClearContactFields() {
  13424. m.clearedcontact_fields = true
  13425. }
  13426. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  13427. func (m *ContactMutation) ContactFieldsCleared() bool {
  13428. return m.clearedcontact_fields
  13429. }
  13430. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  13431. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  13432. if m.removedcontact_fields == nil {
  13433. m.removedcontact_fields = make(map[uint64]struct{})
  13434. }
  13435. for i := range ids {
  13436. delete(m.contact_fields, ids[i])
  13437. m.removedcontact_fields[ids[i]] = struct{}{}
  13438. }
  13439. }
  13440. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  13441. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  13442. for id := range m.removedcontact_fields {
  13443. ids = append(ids, id)
  13444. }
  13445. return
  13446. }
  13447. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  13448. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  13449. for id := range m.contact_fields {
  13450. ids = append(ids, id)
  13451. }
  13452. return
  13453. }
  13454. // ResetContactFields resets all changes to the "contact_fields" edge.
  13455. func (m *ContactMutation) ResetContactFields() {
  13456. m.contact_fields = nil
  13457. m.clearedcontact_fields = false
  13458. m.removedcontact_fields = nil
  13459. }
  13460. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  13461. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  13462. if m.contact_messages == nil {
  13463. m.contact_messages = make(map[uint64]struct{})
  13464. }
  13465. for i := range ids {
  13466. m.contact_messages[ids[i]] = struct{}{}
  13467. }
  13468. }
  13469. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  13470. func (m *ContactMutation) ClearContactMessages() {
  13471. m.clearedcontact_messages = true
  13472. }
  13473. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  13474. func (m *ContactMutation) ContactMessagesCleared() bool {
  13475. return m.clearedcontact_messages
  13476. }
  13477. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  13478. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  13479. if m.removedcontact_messages == nil {
  13480. m.removedcontact_messages = make(map[uint64]struct{})
  13481. }
  13482. for i := range ids {
  13483. delete(m.contact_messages, ids[i])
  13484. m.removedcontact_messages[ids[i]] = struct{}{}
  13485. }
  13486. }
  13487. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  13488. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  13489. for id := range m.removedcontact_messages {
  13490. ids = append(ids, id)
  13491. }
  13492. return
  13493. }
  13494. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  13495. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  13496. for id := range m.contact_messages {
  13497. ids = append(ids, id)
  13498. }
  13499. return
  13500. }
  13501. // ResetContactMessages resets all changes to the "contact_messages" edge.
  13502. func (m *ContactMutation) ResetContactMessages() {
  13503. m.contact_messages = nil
  13504. m.clearedcontact_messages = false
  13505. m.removedcontact_messages = nil
  13506. }
  13507. // Where appends a list predicates to the ContactMutation builder.
  13508. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  13509. m.predicates = append(m.predicates, ps...)
  13510. }
  13511. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  13512. // users can use type-assertion to append predicates that do not depend on any generated package.
  13513. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  13514. p := make([]predicate.Contact, len(ps))
  13515. for i := range ps {
  13516. p[i] = ps[i]
  13517. }
  13518. m.Where(p...)
  13519. }
  13520. // Op returns the operation name.
  13521. func (m *ContactMutation) Op() Op {
  13522. return m.op
  13523. }
  13524. // SetOp allows setting the mutation operation.
  13525. func (m *ContactMutation) SetOp(op Op) {
  13526. m.op = op
  13527. }
  13528. // Type returns the node type of this mutation (Contact).
  13529. func (m *ContactMutation) Type() string {
  13530. return m.typ
  13531. }
  13532. // Fields returns all fields that were changed during this mutation. Note that in
  13533. // order to get all numeric fields that were incremented/decremented, call
  13534. // AddedFields().
  13535. func (m *ContactMutation) Fields() []string {
  13536. fields := make([]string, 0, 30)
  13537. if m.created_at != nil {
  13538. fields = append(fields, contact.FieldCreatedAt)
  13539. }
  13540. if m.updated_at != nil {
  13541. fields = append(fields, contact.FieldUpdatedAt)
  13542. }
  13543. if m.status != nil {
  13544. fields = append(fields, contact.FieldStatus)
  13545. }
  13546. if m.deleted_at != nil {
  13547. fields = append(fields, contact.FieldDeletedAt)
  13548. }
  13549. if m.wx_wxid != nil {
  13550. fields = append(fields, contact.FieldWxWxid)
  13551. }
  13552. if m._type != nil {
  13553. fields = append(fields, contact.FieldType)
  13554. }
  13555. if m.wxid != nil {
  13556. fields = append(fields, contact.FieldWxid)
  13557. }
  13558. if m.account != nil {
  13559. fields = append(fields, contact.FieldAccount)
  13560. }
  13561. if m.nickname != nil {
  13562. fields = append(fields, contact.FieldNickname)
  13563. }
  13564. if m.markname != nil {
  13565. fields = append(fields, contact.FieldMarkname)
  13566. }
  13567. if m.headimg != nil {
  13568. fields = append(fields, contact.FieldHeadimg)
  13569. }
  13570. if m.sex != nil {
  13571. fields = append(fields, contact.FieldSex)
  13572. }
  13573. if m.starrole != nil {
  13574. fields = append(fields, contact.FieldStarrole)
  13575. }
  13576. if m.dontseeit != nil {
  13577. fields = append(fields, contact.FieldDontseeit)
  13578. }
  13579. if m.dontseeme != nil {
  13580. fields = append(fields, contact.FieldDontseeme)
  13581. }
  13582. if m.lag != nil {
  13583. fields = append(fields, contact.FieldLag)
  13584. }
  13585. if m.gid != nil {
  13586. fields = append(fields, contact.FieldGid)
  13587. }
  13588. if m.gname != nil {
  13589. fields = append(fields, contact.FieldGname)
  13590. }
  13591. if m.v3 != nil {
  13592. fields = append(fields, contact.FieldV3)
  13593. }
  13594. if m.organization_id != nil {
  13595. fields = append(fields, contact.FieldOrganizationID)
  13596. }
  13597. if m.ctype != nil {
  13598. fields = append(fields, contact.FieldCtype)
  13599. }
  13600. if m.cage != nil {
  13601. fields = append(fields, contact.FieldCage)
  13602. }
  13603. if m.cname != nil {
  13604. fields = append(fields, contact.FieldCname)
  13605. }
  13606. if m.carea != nil {
  13607. fields = append(fields, contact.FieldCarea)
  13608. }
  13609. if m.cbirthday != nil {
  13610. fields = append(fields, contact.FieldCbirthday)
  13611. }
  13612. if m.cbirtharea != nil {
  13613. fields = append(fields, contact.FieldCbirtharea)
  13614. }
  13615. if m.cidcard_no != nil {
  13616. fields = append(fields, contact.FieldCidcardNo)
  13617. }
  13618. if m.ctitle != nil {
  13619. fields = append(fields, contact.FieldCtitle)
  13620. }
  13621. if m.cc != nil {
  13622. fields = append(fields, contact.FieldCc)
  13623. }
  13624. if m.phone != nil {
  13625. fields = append(fields, contact.FieldPhone)
  13626. }
  13627. return fields
  13628. }
  13629. // Field returns the value of a field with the given name. The second boolean
  13630. // return value indicates that this field was not set, or was not defined in the
  13631. // schema.
  13632. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  13633. switch name {
  13634. case contact.FieldCreatedAt:
  13635. return m.CreatedAt()
  13636. case contact.FieldUpdatedAt:
  13637. return m.UpdatedAt()
  13638. case contact.FieldStatus:
  13639. return m.Status()
  13640. case contact.FieldDeletedAt:
  13641. return m.DeletedAt()
  13642. case contact.FieldWxWxid:
  13643. return m.WxWxid()
  13644. case contact.FieldType:
  13645. return m.GetType()
  13646. case contact.FieldWxid:
  13647. return m.Wxid()
  13648. case contact.FieldAccount:
  13649. return m.Account()
  13650. case contact.FieldNickname:
  13651. return m.Nickname()
  13652. case contact.FieldMarkname:
  13653. return m.Markname()
  13654. case contact.FieldHeadimg:
  13655. return m.Headimg()
  13656. case contact.FieldSex:
  13657. return m.Sex()
  13658. case contact.FieldStarrole:
  13659. return m.Starrole()
  13660. case contact.FieldDontseeit:
  13661. return m.Dontseeit()
  13662. case contact.FieldDontseeme:
  13663. return m.Dontseeme()
  13664. case contact.FieldLag:
  13665. return m.Lag()
  13666. case contact.FieldGid:
  13667. return m.Gid()
  13668. case contact.FieldGname:
  13669. return m.Gname()
  13670. case contact.FieldV3:
  13671. return m.V3()
  13672. case contact.FieldOrganizationID:
  13673. return m.OrganizationID()
  13674. case contact.FieldCtype:
  13675. return m.Ctype()
  13676. case contact.FieldCage:
  13677. return m.Cage()
  13678. case contact.FieldCname:
  13679. return m.Cname()
  13680. case contact.FieldCarea:
  13681. return m.Carea()
  13682. case contact.FieldCbirthday:
  13683. return m.Cbirthday()
  13684. case contact.FieldCbirtharea:
  13685. return m.Cbirtharea()
  13686. case contact.FieldCidcardNo:
  13687. return m.CidcardNo()
  13688. case contact.FieldCtitle:
  13689. return m.Ctitle()
  13690. case contact.FieldCc:
  13691. return m.Cc()
  13692. case contact.FieldPhone:
  13693. return m.Phone()
  13694. }
  13695. return nil, false
  13696. }
  13697. // OldField returns the old value of the field from the database. An error is
  13698. // returned if the mutation operation is not UpdateOne, or the query to the
  13699. // database failed.
  13700. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13701. switch name {
  13702. case contact.FieldCreatedAt:
  13703. return m.OldCreatedAt(ctx)
  13704. case contact.FieldUpdatedAt:
  13705. return m.OldUpdatedAt(ctx)
  13706. case contact.FieldStatus:
  13707. return m.OldStatus(ctx)
  13708. case contact.FieldDeletedAt:
  13709. return m.OldDeletedAt(ctx)
  13710. case contact.FieldWxWxid:
  13711. return m.OldWxWxid(ctx)
  13712. case contact.FieldType:
  13713. return m.OldType(ctx)
  13714. case contact.FieldWxid:
  13715. return m.OldWxid(ctx)
  13716. case contact.FieldAccount:
  13717. return m.OldAccount(ctx)
  13718. case contact.FieldNickname:
  13719. return m.OldNickname(ctx)
  13720. case contact.FieldMarkname:
  13721. return m.OldMarkname(ctx)
  13722. case contact.FieldHeadimg:
  13723. return m.OldHeadimg(ctx)
  13724. case contact.FieldSex:
  13725. return m.OldSex(ctx)
  13726. case contact.FieldStarrole:
  13727. return m.OldStarrole(ctx)
  13728. case contact.FieldDontseeit:
  13729. return m.OldDontseeit(ctx)
  13730. case contact.FieldDontseeme:
  13731. return m.OldDontseeme(ctx)
  13732. case contact.FieldLag:
  13733. return m.OldLag(ctx)
  13734. case contact.FieldGid:
  13735. return m.OldGid(ctx)
  13736. case contact.FieldGname:
  13737. return m.OldGname(ctx)
  13738. case contact.FieldV3:
  13739. return m.OldV3(ctx)
  13740. case contact.FieldOrganizationID:
  13741. return m.OldOrganizationID(ctx)
  13742. case contact.FieldCtype:
  13743. return m.OldCtype(ctx)
  13744. case contact.FieldCage:
  13745. return m.OldCage(ctx)
  13746. case contact.FieldCname:
  13747. return m.OldCname(ctx)
  13748. case contact.FieldCarea:
  13749. return m.OldCarea(ctx)
  13750. case contact.FieldCbirthday:
  13751. return m.OldCbirthday(ctx)
  13752. case contact.FieldCbirtharea:
  13753. return m.OldCbirtharea(ctx)
  13754. case contact.FieldCidcardNo:
  13755. return m.OldCidcardNo(ctx)
  13756. case contact.FieldCtitle:
  13757. return m.OldCtitle(ctx)
  13758. case contact.FieldCc:
  13759. return m.OldCc(ctx)
  13760. case contact.FieldPhone:
  13761. return m.OldPhone(ctx)
  13762. }
  13763. return nil, fmt.Errorf("unknown Contact field %s", name)
  13764. }
  13765. // SetField sets the value of a field with the given name. It returns an error if
  13766. // the field is not defined in the schema, or if the type mismatched the field
  13767. // type.
  13768. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  13769. switch name {
  13770. case contact.FieldCreatedAt:
  13771. v, ok := value.(time.Time)
  13772. if !ok {
  13773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13774. }
  13775. m.SetCreatedAt(v)
  13776. return nil
  13777. case contact.FieldUpdatedAt:
  13778. v, ok := value.(time.Time)
  13779. if !ok {
  13780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13781. }
  13782. m.SetUpdatedAt(v)
  13783. return nil
  13784. case contact.FieldStatus:
  13785. v, ok := value.(uint8)
  13786. if !ok {
  13787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13788. }
  13789. m.SetStatus(v)
  13790. return nil
  13791. case contact.FieldDeletedAt:
  13792. v, ok := value.(time.Time)
  13793. if !ok {
  13794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13795. }
  13796. m.SetDeletedAt(v)
  13797. return nil
  13798. case contact.FieldWxWxid:
  13799. v, ok := value.(string)
  13800. if !ok {
  13801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13802. }
  13803. m.SetWxWxid(v)
  13804. return nil
  13805. case contact.FieldType:
  13806. v, ok := value.(int)
  13807. if !ok {
  13808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13809. }
  13810. m.SetType(v)
  13811. return nil
  13812. case contact.FieldWxid:
  13813. v, ok := value.(string)
  13814. if !ok {
  13815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13816. }
  13817. m.SetWxid(v)
  13818. return nil
  13819. case contact.FieldAccount:
  13820. v, ok := value.(string)
  13821. if !ok {
  13822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13823. }
  13824. m.SetAccount(v)
  13825. return nil
  13826. case contact.FieldNickname:
  13827. v, ok := value.(string)
  13828. if !ok {
  13829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13830. }
  13831. m.SetNickname(v)
  13832. return nil
  13833. case contact.FieldMarkname:
  13834. v, ok := value.(string)
  13835. if !ok {
  13836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13837. }
  13838. m.SetMarkname(v)
  13839. return nil
  13840. case contact.FieldHeadimg:
  13841. v, ok := value.(string)
  13842. if !ok {
  13843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13844. }
  13845. m.SetHeadimg(v)
  13846. return nil
  13847. case contact.FieldSex:
  13848. v, ok := value.(int)
  13849. if !ok {
  13850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13851. }
  13852. m.SetSex(v)
  13853. return nil
  13854. case contact.FieldStarrole:
  13855. v, ok := value.(string)
  13856. if !ok {
  13857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13858. }
  13859. m.SetStarrole(v)
  13860. return nil
  13861. case contact.FieldDontseeit:
  13862. v, ok := value.(int)
  13863. if !ok {
  13864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13865. }
  13866. m.SetDontseeit(v)
  13867. return nil
  13868. case contact.FieldDontseeme:
  13869. v, ok := value.(int)
  13870. if !ok {
  13871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13872. }
  13873. m.SetDontseeme(v)
  13874. return nil
  13875. case contact.FieldLag:
  13876. v, ok := value.(string)
  13877. if !ok {
  13878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13879. }
  13880. m.SetLag(v)
  13881. return nil
  13882. case contact.FieldGid:
  13883. v, ok := value.(string)
  13884. if !ok {
  13885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13886. }
  13887. m.SetGid(v)
  13888. return nil
  13889. case contact.FieldGname:
  13890. v, ok := value.(string)
  13891. if !ok {
  13892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13893. }
  13894. m.SetGname(v)
  13895. return nil
  13896. case contact.FieldV3:
  13897. v, ok := value.(string)
  13898. if !ok {
  13899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13900. }
  13901. m.SetV3(v)
  13902. return nil
  13903. case contact.FieldOrganizationID:
  13904. v, ok := value.(uint64)
  13905. if !ok {
  13906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13907. }
  13908. m.SetOrganizationID(v)
  13909. return nil
  13910. case contact.FieldCtype:
  13911. v, ok := value.(uint64)
  13912. if !ok {
  13913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13914. }
  13915. m.SetCtype(v)
  13916. return nil
  13917. case contact.FieldCage:
  13918. v, ok := value.(int)
  13919. if !ok {
  13920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13921. }
  13922. m.SetCage(v)
  13923. return nil
  13924. case contact.FieldCname:
  13925. v, ok := value.(string)
  13926. if !ok {
  13927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13928. }
  13929. m.SetCname(v)
  13930. return nil
  13931. case contact.FieldCarea:
  13932. v, ok := value.(string)
  13933. if !ok {
  13934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13935. }
  13936. m.SetCarea(v)
  13937. return nil
  13938. case contact.FieldCbirthday:
  13939. v, ok := value.(string)
  13940. if !ok {
  13941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13942. }
  13943. m.SetCbirthday(v)
  13944. return nil
  13945. case contact.FieldCbirtharea:
  13946. v, ok := value.(string)
  13947. if !ok {
  13948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13949. }
  13950. m.SetCbirtharea(v)
  13951. return nil
  13952. case contact.FieldCidcardNo:
  13953. v, ok := value.(string)
  13954. if !ok {
  13955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13956. }
  13957. m.SetCidcardNo(v)
  13958. return nil
  13959. case contact.FieldCtitle:
  13960. v, ok := value.(string)
  13961. if !ok {
  13962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13963. }
  13964. m.SetCtitle(v)
  13965. return nil
  13966. case contact.FieldCc:
  13967. v, ok := value.(string)
  13968. if !ok {
  13969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13970. }
  13971. m.SetCc(v)
  13972. return nil
  13973. case contact.FieldPhone:
  13974. v, ok := value.(string)
  13975. if !ok {
  13976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13977. }
  13978. m.SetPhone(v)
  13979. return nil
  13980. }
  13981. return fmt.Errorf("unknown Contact field %s", name)
  13982. }
  13983. // AddedFields returns all numeric fields that were incremented/decremented during
  13984. // this mutation.
  13985. func (m *ContactMutation) AddedFields() []string {
  13986. var fields []string
  13987. if m.addstatus != nil {
  13988. fields = append(fields, contact.FieldStatus)
  13989. }
  13990. if m.add_type != nil {
  13991. fields = append(fields, contact.FieldType)
  13992. }
  13993. if m.addsex != nil {
  13994. fields = append(fields, contact.FieldSex)
  13995. }
  13996. if m.adddontseeit != nil {
  13997. fields = append(fields, contact.FieldDontseeit)
  13998. }
  13999. if m.adddontseeme != nil {
  14000. fields = append(fields, contact.FieldDontseeme)
  14001. }
  14002. if m.addorganization_id != nil {
  14003. fields = append(fields, contact.FieldOrganizationID)
  14004. }
  14005. if m.addctype != nil {
  14006. fields = append(fields, contact.FieldCtype)
  14007. }
  14008. if m.addcage != nil {
  14009. fields = append(fields, contact.FieldCage)
  14010. }
  14011. return fields
  14012. }
  14013. // AddedField returns the numeric value that was incremented/decremented on a field
  14014. // with the given name. The second boolean return value indicates that this field
  14015. // was not set, or was not defined in the schema.
  14016. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  14017. switch name {
  14018. case contact.FieldStatus:
  14019. return m.AddedStatus()
  14020. case contact.FieldType:
  14021. return m.AddedType()
  14022. case contact.FieldSex:
  14023. return m.AddedSex()
  14024. case contact.FieldDontseeit:
  14025. return m.AddedDontseeit()
  14026. case contact.FieldDontseeme:
  14027. return m.AddedDontseeme()
  14028. case contact.FieldOrganizationID:
  14029. return m.AddedOrganizationID()
  14030. case contact.FieldCtype:
  14031. return m.AddedCtype()
  14032. case contact.FieldCage:
  14033. return m.AddedCage()
  14034. }
  14035. return nil, false
  14036. }
  14037. // AddField adds the value to the field with the given name. It returns an error if
  14038. // the field is not defined in the schema, or if the type mismatched the field
  14039. // type.
  14040. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  14041. switch name {
  14042. case contact.FieldStatus:
  14043. v, ok := value.(int8)
  14044. if !ok {
  14045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14046. }
  14047. m.AddStatus(v)
  14048. return nil
  14049. case contact.FieldType:
  14050. v, ok := value.(int)
  14051. if !ok {
  14052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14053. }
  14054. m.AddType(v)
  14055. return nil
  14056. case contact.FieldSex:
  14057. v, ok := value.(int)
  14058. if !ok {
  14059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14060. }
  14061. m.AddSex(v)
  14062. return nil
  14063. case contact.FieldDontseeit:
  14064. v, ok := value.(int)
  14065. if !ok {
  14066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14067. }
  14068. m.AddDontseeit(v)
  14069. return nil
  14070. case contact.FieldDontseeme:
  14071. v, ok := value.(int)
  14072. if !ok {
  14073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14074. }
  14075. m.AddDontseeme(v)
  14076. return nil
  14077. case contact.FieldOrganizationID:
  14078. v, ok := value.(int64)
  14079. if !ok {
  14080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14081. }
  14082. m.AddOrganizationID(v)
  14083. return nil
  14084. case contact.FieldCtype:
  14085. v, ok := value.(int64)
  14086. if !ok {
  14087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14088. }
  14089. m.AddCtype(v)
  14090. return nil
  14091. case contact.FieldCage:
  14092. v, ok := value.(int)
  14093. if !ok {
  14094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14095. }
  14096. m.AddCage(v)
  14097. return nil
  14098. }
  14099. return fmt.Errorf("unknown Contact numeric field %s", name)
  14100. }
  14101. // ClearedFields returns all nullable fields that were cleared during this
  14102. // mutation.
  14103. func (m *ContactMutation) ClearedFields() []string {
  14104. var fields []string
  14105. if m.FieldCleared(contact.FieldStatus) {
  14106. fields = append(fields, contact.FieldStatus)
  14107. }
  14108. if m.FieldCleared(contact.FieldDeletedAt) {
  14109. fields = append(fields, contact.FieldDeletedAt)
  14110. }
  14111. if m.FieldCleared(contact.FieldType) {
  14112. fields = append(fields, contact.FieldType)
  14113. }
  14114. if m.FieldCleared(contact.FieldOrganizationID) {
  14115. fields = append(fields, contact.FieldOrganizationID)
  14116. }
  14117. return fields
  14118. }
  14119. // FieldCleared returns a boolean indicating if a field with the given name was
  14120. // cleared in this mutation.
  14121. func (m *ContactMutation) FieldCleared(name string) bool {
  14122. _, ok := m.clearedFields[name]
  14123. return ok
  14124. }
  14125. // ClearField clears the value of the field with the given name. It returns an
  14126. // error if the field is not defined in the schema.
  14127. func (m *ContactMutation) ClearField(name string) error {
  14128. switch name {
  14129. case contact.FieldStatus:
  14130. m.ClearStatus()
  14131. return nil
  14132. case contact.FieldDeletedAt:
  14133. m.ClearDeletedAt()
  14134. return nil
  14135. case contact.FieldType:
  14136. m.ClearType()
  14137. return nil
  14138. case contact.FieldOrganizationID:
  14139. m.ClearOrganizationID()
  14140. return nil
  14141. }
  14142. return fmt.Errorf("unknown Contact nullable field %s", name)
  14143. }
  14144. // ResetField resets all changes in the mutation for the field with the given name.
  14145. // It returns an error if the field is not defined in the schema.
  14146. func (m *ContactMutation) ResetField(name string) error {
  14147. switch name {
  14148. case contact.FieldCreatedAt:
  14149. m.ResetCreatedAt()
  14150. return nil
  14151. case contact.FieldUpdatedAt:
  14152. m.ResetUpdatedAt()
  14153. return nil
  14154. case contact.FieldStatus:
  14155. m.ResetStatus()
  14156. return nil
  14157. case contact.FieldDeletedAt:
  14158. m.ResetDeletedAt()
  14159. return nil
  14160. case contact.FieldWxWxid:
  14161. m.ResetWxWxid()
  14162. return nil
  14163. case contact.FieldType:
  14164. m.ResetType()
  14165. return nil
  14166. case contact.FieldWxid:
  14167. m.ResetWxid()
  14168. return nil
  14169. case contact.FieldAccount:
  14170. m.ResetAccount()
  14171. return nil
  14172. case contact.FieldNickname:
  14173. m.ResetNickname()
  14174. return nil
  14175. case contact.FieldMarkname:
  14176. m.ResetMarkname()
  14177. return nil
  14178. case contact.FieldHeadimg:
  14179. m.ResetHeadimg()
  14180. return nil
  14181. case contact.FieldSex:
  14182. m.ResetSex()
  14183. return nil
  14184. case contact.FieldStarrole:
  14185. m.ResetStarrole()
  14186. return nil
  14187. case contact.FieldDontseeit:
  14188. m.ResetDontseeit()
  14189. return nil
  14190. case contact.FieldDontseeme:
  14191. m.ResetDontseeme()
  14192. return nil
  14193. case contact.FieldLag:
  14194. m.ResetLag()
  14195. return nil
  14196. case contact.FieldGid:
  14197. m.ResetGid()
  14198. return nil
  14199. case contact.FieldGname:
  14200. m.ResetGname()
  14201. return nil
  14202. case contact.FieldV3:
  14203. m.ResetV3()
  14204. return nil
  14205. case contact.FieldOrganizationID:
  14206. m.ResetOrganizationID()
  14207. return nil
  14208. case contact.FieldCtype:
  14209. m.ResetCtype()
  14210. return nil
  14211. case contact.FieldCage:
  14212. m.ResetCage()
  14213. return nil
  14214. case contact.FieldCname:
  14215. m.ResetCname()
  14216. return nil
  14217. case contact.FieldCarea:
  14218. m.ResetCarea()
  14219. return nil
  14220. case contact.FieldCbirthday:
  14221. m.ResetCbirthday()
  14222. return nil
  14223. case contact.FieldCbirtharea:
  14224. m.ResetCbirtharea()
  14225. return nil
  14226. case contact.FieldCidcardNo:
  14227. m.ResetCidcardNo()
  14228. return nil
  14229. case contact.FieldCtitle:
  14230. m.ResetCtitle()
  14231. return nil
  14232. case contact.FieldCc:
  14233. m.ResetCc()
  14234. return nil
  14235. case contact.FieldPhone:
  14236. m.ResetPhone()
  14237. return nil
  14238. }
  14239. return fmt.Errorf("unknown Contact field %s", name)
  14240. }
  14241. // AddedEdges returns all edge names that were set/added in this mutation.
  14242. func (m *ContactMutation) AddedEdges() []string {
  14243. edges := make([]string, 0, 3)
  14244. if m.contact_relationships != nil {
  14245. edges = append(edges, contact.EdgeContactRelationships)
  14246. }
  14247. if m.contact_fields != nil {
  14248. edges = append(edges, contact.EdgeContactFields)
  14249. }
  14250. if m.contact_messages != nil {
  14251. edges = append(edges, contact.EdgeContactMessages)
  14252. }
  14253. return edges
  14254. }
  14255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14256. // name in this mutation.
  14257. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  14258. switch name {
  14259. case contact.EdgeContactRelationships:
  14260. ids := make([]ent.Value, 0, len(m.contact_relationships))
  14261. for id := range m.contact_relationships {
  14262. ids = append(ids, id)
  14263. }
  14264. return ids
  14265. case contact.EdgeContactFields:
  14266. ids := make([]ent.Value, 0, len(m.contact_fields))
  14267. for id := range m.contact_fields {
  14268. ids = append(ids, id)
  14269. }
  14270. return ids
  14271. case contact.EdgeContactMessages:
  14272. ids := make([]ent.Value, 0, len(m.contact_messages))
  14273. for id := range m.contact_messages {
  14274. ids = append(ids, id)
  14275. }
  14276. return ids
  14277. }
  14278. return nil
  14279. }
  14280. // RemovedEdges returns all edge names that were removed in this mutation.
  14281. func (m *ContactMutation) RemovedEdges() []string {
  14282. edges := make([]string, 0, 3)
  14283. if m.removedcontact_relationships != nil {
  14284. edges = append(edges, contact.EdgeContactRelationships)
  14285. }
  14286. if m.removedcontact_fields != nil {
  14287. edges = append(edges, contact.EdgeContactFields)
  14288. }
  14289. if m.removedcontact_messages != nil {
  14290. edges = append(edges, contact.EdgeContactMessages)
  14291. }
  14292. return edges
  14293. }
  14294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14295. // the given name in this mutation.
  14296. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  14297. switch name {
  14298. case contact.EdgeContactRelationships:
  14299. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  14300. for id := range m.removedcontact_relationships {
  14301. ids = append(ids, id)
  14302. }
  14303. return ids
  14304. case contact.EdgeContactFields:
  14305. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  14306. for id := range m.removedcontact_fields {
  14307. ids = append(ids, id)
  14308. }
  14309. return ids
  14310. case contact.EdgeContactMessages:
  14311. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  14312. for id := range m.removedcontact_messages {
  14313. ids = append(ids, id)
  14314. }
  14315. return ids
  14316. }
  14317. return nil
  14318. }
  14319. // ClearedEdges returns all edge names that were cleared in this mutation.
  14320. func (m *ContactMutation) ClearedEdges() []string {
  14321. edges := make([]string, 0, 3)
  14322. if m.clearedcontact_relationships {
  14323. edges = append(edges, contact.EdgeContactRelationships)
  14324. }
  14325. if m.clearedcontact_fields {
  14326. edges = append(edges, contact.EdgeContactFields)
  14327. }
  14328. if m.clearedcontact_messages {
  14329. edges = append(edges, contact.EdgeContactMessages)
  14330. }
  14331. return edges
  14332. }
  14333. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14334. // was cleared in this mutation.
  14335. func (m *ContactMutation) EdgeCleared(name string) bool {
  14336. switch name {
  14337. case contact.EdgeContactRelationships:
  14338. return m.clearedcontact_relationships
  14339. case contact.EdgeContactFields:
  14340. return m.clearedcontact_fields
  14341. case contact.EdgeContactMessages:
  14342. return m.clearedcontact_messages
  14343. }
  14344. return false
  14345. }
  14346. // ClearEdge clears the value of the edge with the given name. It returns an error
  14347. // if that edge is not defined in the schema.
  14348. func (m *ContactMutation) ClearEdge(name string) error {
  14349. switch name {
  14350. }
  14351. return fmt.Errorf("unknown Contact unique edge %s", name)
  14352. }
  14353. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14354. // It returns an error if the edge is not defined in the schema.
  14355. func (m *ContactMutation) ResetEdge(name string) error {
  14356. switch name {
  14357. case contact.EdgeContactRelationships:
  14358. m.ResetContactRelationships()
  14359. return nil
  14360. case contact.EdgeContactFields:
  14361. m.ResetContactFields()
  14362. return nil
  14363. case contact.EdgeContactMessages:
  14364. m.ResetContactMessages()
  14365. return nil
  14366. }
  14367. return fmt.Errorf("unknown Contact edge %s", name)
  14368. }
  14369. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  14370. type ContactFieldMutation struct {
  14371. config
  14372. op Op
  14373. typ string
  14374. id *uint64
  14375. created_at *time.Time
  14376. updated_at *time.Time
  14377. status *uint8
  14378. addstatus *int8
  14379. deleted_at *time.Time
  14380. form_id *string
  14381. value *[]string
  14382. appendvalue []string
  14383. clearedFields map[string]struct{}
  14384. field_contact *uint64
  14385. clearedfield_contact bool
  14386. done bool
  14387. oldValue func(context.Context) (*ContactField, error)
  14388. predicates []predicate.ContactField
  14389. }
  14390. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  14391. // contactfieldOption allows management of the mutation configuration using functional options.
  14392. type contactfieldOption func(*ContactFieldMutation)
  14393. // newContactFieldMutation creates new mutation for the ContactField entity.
  14394. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  14395. m := &ContactFieldMutation{
  14396. config: c,
  14397. op: op,
  14398. typ: TypeContactField,
  14399. clearedFields: make(map[string]struct{}),
  14400. }
  14401. for _, opt := range opts {
  14402. opt(m)
  14403. }
  14404. return m
  14405. }
  14406. // withContactFieldID sets the ID field of the mutation.
  14407. func withContactFieldID(id uint64) contactfieldOption {
  14408. return func(m *ContactFieldMutation) {
  14409. var (
  14410. err error
  14411. once sync.Once
  14412. value *ContactField
  14413. )
  14414. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  14415. once.Do(func() {
  14416. if m.done {
  14417. err = errors.New("querying old values post mutation is not allowed")
  14418. } else {
  14419. value, err = m.Client().ContactField.Get(ctx, id)
  14420. }
  14421. })
  14422. return value, err
  14423. }
  14424. m.id = &id
  14425. }
  14426. }
  14427. // withContactField sets the old ContactField of the mutation.
  14428. func withContactField(node *ContactField) contactfieldOption {
  14429. return func(m *ContactFieldMutation) {
  14430. m.oldValue = func(context.Context) (*ContactField, error) {
  14431. return node, nil
  14432. }
  14433. m.id = &node.ID
  14434. }
  14435. }
  14436. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14437. // executed in a transaction (ent.Tx), a transactional client is returned.
  14438. func (m ContactFieldMutation) Client() *Client {
  14439. client := &Client{config: m.config}
  14440. client.init()
  14441. return client
  14442. }
  14443. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14444. // it returns an error otherwise.
  14445. func (m ContactFieldMutation) Tx() (*Tx, error) {
  14446. if _, ok := m.driver.(*txDriver); !ok {
  14447. return nil, errors.New("ent: mutation is not running in a transaction")
  14448. }
  14449. tx := &Tx{config: m.config}
  14450. tx.init()
  14451. return tx, nil
  14452. }
  14453. // SetID sets the value of the id field. Note that this
  14454. // operation is only accepted on creation of ContactField entities.
  14455. func (m *ContactFieldMutation) SetID(id uint64) {
  14456. m.id = &id
  14457. }
  14458. // ID returns the ID value in the mutation. Note that the ID is only available
  14459. // if it was provided to the builder or after it was returned from the database.
  14460. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  14461. if m.id == nil {
  14462. return
  14463. }
  14464. return *m.id, true
  14465. }
  14466. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14467. // That means, if the mutation is applied within a transaction with an isolation level such
  14468. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14469. // or updated by the mutation.
  14470. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  14471. switch {
  14472. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14473. id, exists := m.ID()
  14474. if exists {
  14475. return []uint64{id}, nil
  14476. }
  14477. fallthrough
  14478. case m.op.Is(OpUpdate | OpDelete):
  14479. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  14480. default:
  14481. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14482. }
  14483. }
  14484. // SetCreatedAt sets the "created_at" field.
  14485. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  14486. m.created_at = &t
  14487. }
  14488. // CreatedAt returns the value of the "created_at" field in the mutation.
  14489. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  14490. v := m.created_at
  14491. if v == nil {
  14492. return
  14493. }
  14494. return *v, true
  14495. }
  14496. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  14497. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14499. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14500. if !m.op.Is(OpUpdateOne) {
  14501. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14502. }
  14503. if m.id == nil || m.oldValue == nil {
  14504. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14505. }
  14506. oldValue, err := m.oldValue(ctx)
  14507. if err != nil {
  14508. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14509. }
  14510. return oldValue.CreatedAt, nil
  14511. }
  14512. // ResetCreatedAt resets all changes to the "created_at" field.
  14513. func (m *ContactFieldMutation) ResetCreatedAt() {
  14514. m.created_at = nil
  14515. }
  14516. // SetUpdatedAt sets the "updated_at" field.
  14517. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  14518. m.updated_at = &t
  14519. }
  14520. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14521. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  14522. v := m.updated_at
  14523. if v == nil {
  14524. return
  14525. }
  14526. return *v, true
  14527. }
  14528. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  14529. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14531. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14532. if !m.op.Is(OpUpdateOne) {
  14533. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14534. }
  14535. if m.id == nil || m.oldValue == nil {
  14536. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14537. }
  14538. oldValue, err := m.oldValue(ctx)
  14539. if err != nil {
  14540. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14541. }
  14542. return oldValue.UpdatedAt, nil
  14543. }
  14544. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14545. func (m *ContactFieldMutation) ResetUpdatedAt() {
  14546. m.updated_at = nil
  14547. }
  14548. // SetStatus sets the "status" field.
  14549. func (m *ContactFieldMutation) SetStatus(u uint8) {
  14550. m.status = &u
  14551. m.addstatus = nil
  14552. }
  14553. // Status returns the value of the "status" field in the mutation.
  14554. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  14555. v := m.status
  14556. if v == nil {
  14557. return
  14558. }
  14559. return *v, true
  14560. }
  14561. // OldStatus returns the old "status" field's value of the ContactField entity.
  14562. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14564. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14565. if !m.op.Is(OpUpdateOne) {
  14566. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14567. }
  14568. if m.id == nil || m.oldValue == nil {
  14569. return v, errors.New("OldStatus requires an ID field in the mutation")
  14570. }
  14571. oldValue, err := m.oldValue(ctx)
  14572. if err != nil {
  14573. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14574. }
  14575. return oldValue.Status, nil
  14576. }
  14577. // AddStatus adds u to the "status" field.
  14578. func (m *ContactFieldMutation) AddStatus(u int8) {
  14579. if m.addstatus != nil {
  14580. *m.addstatus += u
  14581. } else {
  14582. m.addstatus = &u
  14583. }
  14584. }
  14585. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14586. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  14587. v := m.addstatus
  14588. if v == nil {
  14589. return
  14590. }
  14591. return *v, true
  14592. }
  14593. // ClearStatus clears the value of the "status" field.
  14594. func (m *ContactFieldMutation) ClearStatus() {
  14595. m.status = nil
  14596. m.addstatus = nil
  14597. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  14598. }
  14599. // StatusCleared returns if the "status" field was cleared in this mutation.
  14600. func (m *ContactFieldMutation) StatusCleared() bool {
  14601. _, ok := m.clearedFields[contactfield.FieldStatus]
  14602. return ok
  14603. }
  14604. // ResetStatus resets all changes to the "status" field.
  14605. func (m *ContactFieldMutation) ResetStatus() {
  14606. m.status = nil
  14607. m.addstatus = nil
  14608. delete(m.clearedFields, contactfield.FieldStatus)
  14609. }
  14610. // SetDeletedAt sets the "deleted_at" field.
  14611. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  14612. m.deleted_at = &t
  14613. }
  14614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14615. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  14616. v := m.deleted_at
  14617. if v == nil {
  14618. return
  14619. }
  14620. return *v, true
  14621. }
  14622. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  14623. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14625. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14626. if !m.op.Is(OpUpdateOne) {
  14627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14628. }
  14629. if m.id == nil || m.oldValue == nil {
  14630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14631. }
  14632. oldValue, err := m.oldValue(ctx)
  14633. if err != nil {
  14634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14635. }
  14636. return oldValue.DeletedAt, nil
  14637. }
  14638. // ClearDeletedAt clears the value of the "deleted_at" field.
  14639. func (m *ContactFieldMutation) ClearDeletedAt() {
  14640. m.deleted_at = nil
  14641. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  14642. }
  14643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14644. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  14645. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  14646. return ok
  14647. }
  14648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14649. func (m *ContactFieldMutation) ResetDeletedAt() {
  14650. m.deleted_at = nil
  14651. delete(m.clearedFields, contactfield.FieldDeletedAt)
  14652. }
  14653. // SetContactID sets the "contact_id" field.
  14654. func (m *ContactFieldMutation) SetContactID(u uint64) {
  14655. m.field_contact = &u
  14656. }
  14657. // ContactID returns the value of the "contact_id" field in the mutation.
  14658. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  14659. v := m.field_contact
  14660. if v == nil {
  14661. return
  14662. }
  14663. return *v, true
  14664. }
  14665. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  14666. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14668. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14669. if !m.op.Is(OpUpdateOne) {
  14670. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14671. }
  14672. if m.id == nil || m.oldValue == nil {
  14673. return v, errors.New("OldContactID requires an ID field in the mutation")
  14674. }
  14675. oldValue, err := m.oldValue(ctx)
  14676. if err != nil {
  14677. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14678. }
  14679. return oldValue.ContactID, nil
  14680. }
  14681. // ResetContactID resets all changes to the "contact_id" field.
  14682. func (m *ContactFieldMutation) ResetContactID() {
  14683. m.field_contact = nil
  14684. }
  14685. // SetFormID sets the "form_id" field.
  14686. func (m *ContactFieldMutation) SetFormID(s string) {
  14687. m.form_id = &s
  14688. }
  14689. // FormID returns the value of the "form_id" field in the mutation.
  14690. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  14691. v := m.form_id
  14692. if v == nil {
  14693. return
  14694. }
  14695. return *v, true
  14696. }
  14697. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  14698. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14700. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  14701. if !m.op.Is(OpUpdateOne) {
  14702. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  14703. }
  14704. if m.id == nil || m.oldValue == nil {
  14705. return v, errors.New("OldFormID requires an ID field in the mutation")
  14706. }
  14707. oldValue, err := m.oldValue(ctx)
  14708. if err != nil {
  14709. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  14710. }
  14711. return oldValue.FormID, nil
  14712. }
  14713. // ResetFormID resets all changes to the "form_id" field.
  14714. func (m *ContactFieldMutation) ResetFormID() {
  14715. m.form_id = nil
  14716. }
  14717. // SetValue sets the "value" field.
  14718. func (m *ContactFieldMutation) SetValue(s []string) {
  14719. m.value = &s
  14720. m.appendvalue = nil
  14721. }
  14722. // Value returns the value of the "value" field in the mutation.
  14723. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  14724. v := m.value
  14725. if v == nil {
  14726. return
  14727. }
  14728. return *v, true
  14729. }
  14730. // OldValue returns the old "value" field's value of the ContactField entity.
  14731. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14733. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  14734. if !m.op.Is(OpUpdateOne) {
  14735. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  14736. }
  14737. if m.id == nil || m.oldValue == nil {
  14738. return v, errors.New("OldValue requires an ID field in the mutation")
  14739. }
  14740. oldValue, err := m.oldValue(ctx)
  14741. if err != nil {
  14742. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  14743. }
  14744. return oldValue.Value, nil
  14745. }
  14746. // AppendValue adds s to the "value" field.
  14747. func (m *ContactFieldMutation) AppendValue(s []string) {
  14748. m.appendvalue = append(m.appendvalue, s...)
  14749. }
  14750. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  14751. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  14752. if len(m.appendvalue) == 0 {
  14753. return nil, false
  14754. }
  14755. return m.appendvalue, true
  14756. }
  14757. // ResetValue resets all changes to the "value" field.
  14758. func (m *ContactFieldMutation) ResetValue() {
  14759. m.value = nil
  14760. m.appendvalue = nil
  14761. }
  14762. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  14763. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  14764. m.field_contact = &id
  14765. }
  14766. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  14767. func (m *ContactFieldMutation) ClearFieldContact() {
  14768. m.clearedfield_contact = true
  14769. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  14770. }
  14771. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  14772. func (m *ContactFieldMutation) FieldContactCleared() bool {
  14773. return m.clearedfield_contact
  14774. }
  14775. // FieldContactID returns the "field_contact" edge ID in the mutation.
  14776. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  14777. if m.field_contact != nil {
  14778. return *m.field_contact, true
  14779. }
  14780. return
  14781. }
  14782. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  14783. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14784. // FieldContactID instead. It exists only for internal usage by the builders.
  14785. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  14786. if id := m.field_contact; id != nil {
  14787. ids = append(ids, *id)
  14788. }
  14789. return
  14790. }
  14791. // ResetFieldContact resets all changes to the "field_contact" edge.
  14792. func (m *ContactFieldMutation) ResetFieldContact() {
  14793. m.field_contact = nil
  14794. m.clearedfield_contact = false
  14795. }
  14796. // Where appends a list predicates to the ContactFieldMutation builder.
  14797. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  14798. m.predicates = append(m.predicates, ps...)
  14799. }
  14800. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  14801. // users can use type-assertion to append predicates that do not depend on any generated package.
  14802. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  14803. p := make([]predicate.ContactField, len(ps))
  14804. for i := range ps {
  14805. p[i] = ps[i]
  14806. }
  14807. m.Where(p...)
  14808. }
  14809. // Op returns the operation name.
  14810. func (m *ContactFieldMutation) Op() Op {
  14811. return m.op
  14812. }
  14813. // SetOp allows setting the mutation operation.
  14814. func (m *ContactFieldMutation) SetOp(op Op) {
  14815. m.op = op
  14816. }
  14817. // Type returns the node type of this mutation (ContactField).
  14818. func (m *ContactFieldMutation) Type() string {
  14819. return m.typ
  14820. }
  14821. // Fields returns all fields that were changed during this mutation. Note that in
  14822. // order to get all numeric fields that were incremented/decremented, call
  14823. // AddedFields().
  14824. func (m *ContactFieldMutation) Fields() []string {
  14825. fields := make([]string, 0, 7)
  14826. if m.created_at != nil {
  14827. fields = append(fields, contactfield.FieldCreatedAt)
  14828. }
  14829. if m.updated_at != nil {
  14830. fields = append(fields, contactfield.FieldUpdatedAt)
  14831. }
  14832. if m.status != nil {
  14833. fields = append(fields, contactfield.FieldStatus)
  14834. }
  14835. if m.deleted_at != nil {
  14836. fields = append(fields, contactfield.FieldDeletedAt)
  14837. }
  14838. if m.field_contact != nil {
  14839. fields = append(fields, contactfield.FieldContactID)
  14840. }
  14841. if m.form_id != nil {
  14842. fields = append(fields, contactfield.FieldFormID)
  14843. }
  14844. if m.value != nil {
  14845. fields = append(fields, contactfield.FieldValue)
  14846. }
  14847. return fields
  14848. }
  14849. // Field returns the value of a field with the given name. The second boolean
  14850. // return value indicates that this field was not set, or was not defined in the
  14851. // schema.
  14852. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  14853. switch name {
  14854. case contactfield.FieldCreatedAt:
  14855. return m.CreatedAt()
  14856. case contactfield.FieldUpdatedAt:
  14857. return m.UpdatedAt()
  14858. case contactfield.FieldStatus:
  14859. return m.Status()
  14860. case contactfield.FieldDeletedAt:
  14861. return m.DeletedAt()
  14862. case contactfield.FieldContactID:
  14863. return m.ContactID()
  14864. case contactfield.FieldFormID:
  14865. return m.FormID()
  14866. case contactfield.FieldValue:
  14867. return m.Value()
  14868. }
  14869. return nil, false
  14870. }
  14871. // OldField returns the old value of the field from the database. An error is
  14872. // returned if the mutation operation is not UpdateOne, or the query to the
  14873. // database failed.
  14874. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14875. switch name {
  14876. case contactfield.FieldCreatedAt:
  14877. return m.OldCreatedAt(ctx)
  14878. case contactfield.FieldUpdatedAt:
  14879. return m.OldUpdatedAt(ctx)
  14880. case contactfield.FieldStatus:
  14881. return m.OldStatus(ctx)
  14882. case contactfield.FieldDeletedAt:
  14883. return m.OldDeletedAt(ctx)
  14884. case contactfield.FieldContactID:
  14885. return m.OldContactID(ctx)
  14886. case contactfield.FieldFormID:
  14887. return m.OldFormID(ctx)
  14888. case contactfield.FieldValue:
  14889. return m.OldValue(ctx)
  14890. }
  14891. return nil, fmt.Errorf("unknown ContactField field %s", name)
  14892. }
  14893. // SetField sets the value of a field with the given name. It returns an error if
  14894. // the field is not defined in the schema, or if the type mismatched the field
  14895. // type.
  14896. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  14897. switch name {
  14898. case contactfield.FieldCreatedAt:
  14899. v, ok := value.(time.Time)
  14900. if !ok {
  14901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14902. }
  14903. m.SetCreatedAt(v)
  14904. return nil
  14905. case contactfield.FieldUpdatedAt:
  14906. v, ok := value.(time.Time)
  14907. if !ok {
  14908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14909. }
  14910. m.SetUpdatedAt(v)
  14911. return nil
  14912. case contactfield.FieldStatus:
  14913. v, ok := value.(uint8)
  14914. if !ok {
  14915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14916. }
  14917. m.SetStatus(v)
  14918. return nil
  14919. case contactfield.FieldDeletedAt:
  14920. v, ok := value.(time.Time)
  14921. if !ok {
  14922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14923. }
  14924. m.SetDeletedAt(v)
  14925. return nil
  14926. case contactfield.FieldContactID:
  14927. v, ok := value.(uint64)
  14928. if !ok {
  14929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14930. }
  14931. m.SetContactID(v)
  14932. return nil
  14933. case contactfield.FieldFormID:
  14934. v, ok := value.(string)
  14935. if !ok {
  14936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14937. }
  14938. m.SetFormID(v)
  14939. return nil
  14940. case contactfield.FieldValue:
  14941. v, ok := value.([]string)
  14942. if !ok {
  14943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14944. }
  14945. m.SetValue(v)
  14946. return nil
  14947. }
  14948. return fmt.Errorf("unknown ContactField field %s", name)
  14949. }
  14950. // AddedFields returns all numeric fields that were incremented/decremented during
  14951. // this mutation.
  14952. func (m *ContactFieldMutation) AddedFields() []string {
  14953. var fields []string
  14954. if m.addstatus != nil {
  14955. fields = append(fields, contactfield.FieldStatus)
  14956. }
  14957. return fields
  14958. }
  14959. // AddedField returns the numeric value that was incremented/decremented on a field
  14960. // with the given name. The second boolean return value indicates that this field
  14961. // was not set, or was not defined in the schema.
  14962. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  14963. switch name {
  14964. case contactfield.FieldStatus:
  14965. return m.AddedStatus()
  14966. }
  14967. return nil, false
  14968. }
  14969. // AddField adds the value to the field with the given name. It returns an error if
  14970. // the field is not defined in the schema, or if the type mismatched the field
  14971. // type.
  14972. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  14973. switch name {
  14974. case contactfield.FieldStatus:
  14975. v, ok := value.(int8)
  14976. if !ok {
  14977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14978. }
  14979. m.AddStatus(v)
  14980. return nil
  14981. }
  14982. return fmt.Errorf("unknown ContactField numeric field %s", name)
  14983. }
  14984. // ClearedFields returns all nullable fields that were cleared during this
  14985. // mutation.
  14986. func (m *ContactFieldMutation) ClearedFields() []string {
  14987. var fields []string
  14988. if m.FieldCleared(contactfield.FieldStatus) {
  14989. fields = append(fields, contactfield.FieldStatus)
  14990. }
  14991. if m.FieldCleared(contactfield.FieldDeletedAt) {
  14992. fields = append(fields, contactfield.FieldDeletedAt)
  14993. }
  14994. return fields
  14995. }
  14996. // FieldCleared returns a boolean indicating if a field with the given name was
  14997. // cleared in this mutation.
  14998. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  14999. _, ok := m.clearedFields[name]
  15000. return ok
  15001. }
  15002. // ClearField clears the value of the field with the given name. It returns an
  15003. // error if the field is not defined in the schema.
  15004. func (m *ContactFieldMutation) ClearField(name string) error {
  15005. switch name {
  15006. case contactfield.FieldStatus:
  15007. m.ClearStatus()
  15008. return nil
  15009. case contactfield.FieldDeletedAt:
  15010. m.ClearDeletedAt()
  15011. return nil
  15012. }
  15013. return fmt.Errorf("unknown ContactField nullable field %s", name)
  15014. }
  15015. // ResetField resets all changes in the mutation for the field with the given name.
  15016. // It returns an error if the field is not defined in the schema.
  15017. func (m *ContactFieldMutation) ResetField(name string) error {
  15018. switch name {
  15019. case contactfield.FieldCreatedAt:
  15020. m.ResetCreatedAt()
  15021. return nil
  15022. case contactfield.FieldUpdatedAt:
  15023. m.ResetUpdatedAt()
  15024. return nil
  15025. case contactfield.FieldStatus:
  15026. m.ResetStatus()
  15027. return nil
  15028. case contactfield.FieldDeletedAt:
  15029. m.ResetDeletedAt()
  15030. return nil
  15031. case contactfield.FieldContactID:
  15032. m.ResetContactID()
  15033. return nil
  15034. case contactfield.FieldFormID:
  15035. m.ResetFormID()
  15036. return nil
  15037. case contactfield.FieldValue:
  15038. m.ResetValue()
  15039. return nil
  15040. }
  15041. return fmt.Errorf("unknown ContactField field %s", name)
  15042. }
  15043. // AddedEdges returns all edge names that were set/added in this mutation.
  15044. func (m *ContactFieldMutation) AddedEdges() []string {
  15045. edges := make([]string, 0, 1)
  15046. if m.field_contact != nil {
  15047. edges = append(edges, contactfield.EdgeFieldContact)
  15048. }
  15049. return edges
  15050. }
  15051. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15052. // name in this mutation.
  15053. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  15054. switch name {
  15055. case contactfield.EdgeFieldContact:
  15056. if id := m.field_contact; id != nil {
  15057. return []ent.Value{*id}
  15058. }
  15059. }
  15060. return nil
  15061. }
  15062. // RemovedEdges returns all edge names that were removed in this mutation.
  15063. func (m *ContactFieldMutation) RemovedEdges() []string {
  15064. edges := make([]string, 0, 1)
  15065. return edges
  15066. }
  15067. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15068. // the given name in this mutation.
  15069. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  15070. return nil
  15071. }
  15072. // ClearedEdges returns all edge names that were cleared in this mutation.
  15073. func (m *ContactFieldMutation) ClearedEdges() []string {
  15074. edges := make([]string, 0, 1)
  15075. if m.clearedfield_contact {
  15076. edges = append(edges, contactfield.EdgeFieldContact)
  15077. }
  15078. return edges
  15079. }
  15080. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15081. // was cleared in this mutation.
  15082. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  15083. switch name {
  15084. case contactfield.EdgeFieldContact:
  15085. return m.clearedfield_contact
  15086. }
  15087. return false
  15088. }
  15089. // ClearEdge clears the value of the edge with the given name. It returns an error
  15090. // if that edge is not defined in the schema.
  15091. func (m *ContactFieldMutation) ClearEdge(name string) error {
  15092. switch name {
  15093. case contactfield.EdgeFieldContact:
  15094. m.ClearFieldContact()
  15095. return nil
  15096. }
  15097. return fmt.Errorf("unknown ContactField unique edge %s", name)
  15098. }
  15099. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15100. // It returns an error if the edge is not defined in the schema.
  15101. func (m *ContactFieldMutation) ResetEdge(name string) error {
  15102. switch name {
  15103. case contactfield.EdgeFieldContact:
  15104. m.ResetFieldContact()
  15105. return nil
  15106. }
  15107. return fmt.Errorf("unknown ContactField edge %s", name)
  15108. }
  15109. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  15110. type ContactFieldTemplateMutation struct {
  15111. config
  15112. op Op
  15113. typ string
  15114. id *uint64
  15115. created_at *time.Time
  15116. updated_at *time.Time
  15117. status *uint8
  15118. addstatus *int8
  15119. deleted_at *time.Time
  15120. organization_id *uint64
  15121. addorganization_id *int64
  15122. template *[]custom_types.ContactFieldTemplate
  15123. appendtemplate []custom_types.ContactFieldTemplate
  15124. clearedFields map[string]struct{}
  15125. done bool
  15126. oldValue func(context.Context) (*ContactFieldTemplate, error)
  15127. predicates []predicate.ContactFieldTemplate
  15128. }
  15129. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  15130. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  15131. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  15132. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  15133. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  15134. m := &ContactFieldTemplateMutation{
  15135. config: c,
  15136. op: op,
  15137. typ: TypeContactFieldTemplate,
  15138. clearedFields: make(map[string]struct{}),
  15139. }
  15140. for _, opt := range opts {
  15141. opt(m)
  15142. }
  15143. return m
  15144. }
  15145. // withContactFieldTemplateID sets the ID field of the mutation.
  15146. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  15147. return func(m *ContactFieldTemplateMutation) {
  15148. var (
  15149. err error
  15150. once sync.Once
  15151. value *ContactFieldTemplate
  15152. )
  15153. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  15154. once.Do(func() {
  15155. if m.done {
  15156. err = errors.New("querying old values post mutation is not allowed")
  15157. } else {
  15158. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  15159. }
  15160. })
  15161. return value, err
  15162. }
  15163. m.id = &id
  15164. }
  15165. }
  15166. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  15167. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  15168. return func(m *ContactFieldTemplateMutation) {
  15169. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  15170. return node, nil
  15171. }
  15172. m.id = &node.ID
  15173. }
  15174. }
  15175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15176. // executed in a transaction (ent.Tx), a transactional client is returned.
  15177. func (m ContactFieldTemplateMutation) Client() *Client {
  15178. client := &Client{config: m.config}
  15179. client.init()
  15180. return client
  15181. }
  15182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15183. // it returns an error otherwise.
  15184. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  15185. if _, ok := m.driver.(*txDriver); !ok {
  15186. return nil, errors.New("ent: mutation is not running in a transaction")
  15187. }
  15188. tx := &Tx{config: m.config}
  15189. tx.init()
  15190. return tx, nil
  15191. }
  15192. // SetID sets the value of the id field. Note that this
  15193. // operation is only accepted on creation of ContactFieldTemplate entities.
  15194. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  15195. m.id = &id
  15196. }
  15197. // ID returns the ID value in the mutation. Note that the ID is only available
  15198. // if it was provided to the builder or after it was returned from the database.
  15199. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  15200. if m.id == nil {
  15201. return
  15202. }
  15203. return *m.id, true
  15204. }
  15205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15206. // That means, if the mutation is applied within a transaction with an isolation level such
  15207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15208. // or updated by the mutation.
  15209. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  15210. switch {
  15211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15212. id, exists := m.ID()
  15213. if exists {
  15214. return []uint64{id}, nil
  15215. }
  15216. fallthrough
  15217. case m.op.Is(OpUpdate | OpDelete):
  15218. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  15219. default:
  15220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15221. }
  15222. }
  15223. // SetCreatedAt sets the "created_at" field.
  15224. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  15225. m.created_at = &t
  15226. }
  15227. // CreatedAt returns the value of the "created_at" field in the mutation.
  15228. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  15229. v := m.created_at
  15230. if v == nil {
  15231. return
  15232. }
  15233. return *v, true
  15234. }
  15235. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  15236. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15238. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15239. if !m.op.Is(OpUpdateOne) {
  15240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15241. }
  15242. if m.id == nil || m.oldValue == nil {
  15243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15244. }
  15245. oldValue, err := m.oldValue(ctx)
  15246. if err != nil {
  15247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15248. }
  15249. return oldValue.CreatedAt, nil
  15250. }
  15251. // ResetCreatedAt resets all changes to the "created_at" field.
  15252. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  15253. m.created_at = nil
  15254. }
  15255. // SetUpdatedAt sets the "updated_at" field.
  15256. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  15257. m.updated_at = &t
  15258. }
  15259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15260. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  15261. v := m.updated_at
  15262. if v == nil {
  15263. return
  15264. }
  15265. return *v, true
  15266. }
  15267. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  15268. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15270. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15271. if !m.op.Is(OpUpdateOne) {
  15272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15273. }
  15274. if m.id == nil || m.oldValue == nil {
  15275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15276. }
  15277. oldValue, err := m.oldValue(ctx)
  15278. if err != nil {
  15279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15280. }
  15281. return oldValue.UpdatedAt, nil
  15282. }
  15283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15284. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  15285. m.updated_at = nil
  15286. }
  15287. // SetStatus sets the "status" field.
  15288. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  15289. m.status = &u
  15290. m.addstatus = nil
  15291. }
  15292. // Status returns the value of the "status" field in the mutation.
  15293. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  15294. v := m.status
  15295. if v == nil {
  15296. return
  15297. }
  15298. return *v, true
  15299. }
  15300. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  15301. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15303. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15304. if !m.op.Is(OpUpdateOne) {
  15305. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15306. }
  15307. if m.id == nil || m.oldValue == nil {
  15308. return v, errors.New("OldStatus requires an ID field in the mutation")
  15309. }
  15310. oldValue, err := m.oldValue(ctx)
  15311. if err != nil {
  15312. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15313. }
  15314. return oldValue.Status, nil
  15315. }
  15316. // AddStatus adds u to the "status" field.
  15317. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  15318. if m.addstatus != nil {
  15319. *m.addstatus += u
  15320. } else {
  15321. m.addstatus = &u
  15322. }
  15323. }
  15324. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15325. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  15326. v := m.addstatus
  15327. if v == nil {
  15328. return
  15329. }
  15330. return *v, true
  15331. }
  15332. // ClearStatus clears the value of the "status" field.
  15333. func (m *ContactFieldTemplateMutation) ClearStatus() {
  15334. m.status = nil
  15335. m.addstatus = nil
  15336. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  15337. }
  15338. // StatusCleared returns if the "status" field was cleared in this mutation.
  15339. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  15340. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  15341. return ok
  15342. }
  15343. // ResetStatus resets all changes to the "status" field.
  15344. func (m *ContactFieldTemplateMutation) ResetStatus() {
  15345. m.status = nil
  15346. m.addstatus = nil
  15347. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  15348. }
  15349. // SetDeletedAt sets the "deleted_at" field.
  15350. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  15351. m.deleted_at = &t
  15352. }
  15353. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15354. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  15355. v := m.deleted_at
  15356. if v == nil {
  15357. return
  15358. }
  15359. return *v, true
  15360. }
  15361. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  15362. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15364. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15365. if !m.op.Is(OpUpdateOne) {
  15366. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15367. }
  15368. if m.id == nil || m.oldValue == nil {
  15369. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15370. }
  15371. oldValue, err := m.oldValue(ctx)
  15372. if err != nil {
  15373. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15374. }
  15375. return oldValue.DeletedAt, nil
  15376. }
  15377. // ClearDeletedAt clears the value of the "deleted_at" field.
  15378. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  15379. m.deleted_at = nil
  15380. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  15381. }
  15382. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15383. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  15384. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  15385. return ok
  15386. }
  15387. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15388. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  15389. m.deleted_at = nil
  15390. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  15391. }
  15392. // SetOrganizationID sets the "organization_id" field.
  15393. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  15394. m.organization_id = &u
  15395. m.addorganization_id = nil
  15396. }
  15397. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15398. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  15399. v := m.organization_id
  15400. if v == nil {
  15401. return
  15402. }
  15403. return *v, true
  15404. }
  15405. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  15406. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15408. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15409. if !m.op.Is(OpUpdateOne) {
  15410. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15411. }
  15412. if m.id == nil || m.oldValue == nil {
  15413. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15414. }
  15415. oldValue, err := m.oldValue(ctx)
  15416. if err != nil {
  15417. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15418. }
  15419. return oldValue.OrganizationID, nil
  15420. }
  15421. // AddOrganizationID adds u to the "organization_id" field.
  15422. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  15423. if m.addorganization_id != nil {
  15424. *m.addorganization_id += u
  15425. } else {
  15426. m.addorganization_id = &u
  15427. }
  15428. }
  15429. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15430. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  15431. v := m.addorganization_id
  15432. if v == nil {
  15433. return
  15434. }
  15435. return *v, true
  15436. }
  15437. // ResetOrganizationID resets all changes to the "organization_id" field.
  15438. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  15439. m.organization_id = nil
  15440. m.addorganization_id = nil
  15441. }
  15442. // SetTemplate sets the "template" field.
  15443. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  15444. m.template = &ctft
  15445. m.appendtemplate = nil
  15446. }
  15447. // Template returns the value of the "template" field in the mutation.
  15448. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  15449. v := m.template
  15450. if v == nil {
  15451. return
  15452. }
  15453. return *v, true
  15454. }
  15455. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  15456. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15458. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  15459. if !m.op.Is(OpUpdateOne) {
  15460. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  15461. }
  15462. if m.id == nil || m.oldValue == nil {
  15463. return v, errors.New("OldTemplate requires an ID field in the mutation")
  15464. }
  15465. oldValue, err := m.oldValue(ctx)
  15466. if err != nil {
  15467. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  15468. }
  15469. return oldValue.Template, nil
  15470. }
  15471. // AppendTemplate adds ctft to the "template" field.
  15472. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  15473. m.appendtemplate = append(m.appendtemplate, ctft...)
  15474. }
  15475. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  15476. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  15477. if len(m.appendtemplate) == 0 {
  15478. return nil, false
  15479. }
  15480. return m.appendtemplate, true
  15481. }
  15482. // ResetTemplate resets all changes to the "template" field.
  15483. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  15484. m.template = nil
  15485. m.appendtemplate = nil
  15486. }
  15487. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  15488. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  15489. m.predicates = append(m.predicates, ps...)
  15490. }
  15491. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  15492. // users can use type-assertion to append predicates that do not depend on any generated package.
  15493. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  15494. p := make([]predicate.ContactFieldTemplate, len(ps))
  15495. for i := range ps {
  15496. p[i] = ps[i]
  15497. }
  15498. m.Where(p...)
  15499. }
  15500. // Op returns the operation name.
  15501. func (m *ContactFieldTemplateMutation) Op() Op {
  15502. return m.op
  15503. }
  15504. // SetOp allows setting the mutation operation.
  15505. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  15506. m.op = op
  15507. }
  15508. // Type returns the node type of this mutation (ContactFieldTemplate).
  15509. func (m *ContactFieldTemplateMutation) Type() string {
  15510. return m.typ
  15511. }
  15512. // Fields returns all fields that were changed during this mutation. Note that in
  15513. // order to get all numeric fields that were incremented/decremented, call
  15514. // AddedFields().
  15515. func (m *ContactFieldTemplateMutation) Fields() []string {
  15516. fields := make([]string, 0, 6)
  15517. if m.created_at != nil {
  15518. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  15519. }
  15520. if m.updated_at != nil {
  15521. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  15522. }
  15523. if m.status != nil {
  15524. fields = append(fields, contactfieldtemplate.FieldStatus)
  15525. }
  15526. if m.deleted_at != nil {
  15527. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15528. }
  15529. if m.organization_id != nil {
  15530. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15531. }
  15532. if m.template != nil {
  15533. fields = append(fields, contactfieldtemplate.FieldTemplate)
  15534. }
  15535. return fields
  15536. }
  15537. // Field returns the value of a field with the given name. The second boolean
  15538. // return value indicates that this field was not set, or was not defined in the
  15539. // schema.
  15540. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  15541. switch name {
  15542. case contactfieldtemplate.FieldCreatedAt:
  15543. return m.CreatedAt()
  15544. case contactfieldtemplate.FieldUpdatedAt:
  15545. return m.UpdatedAt()
  15546. case contactfieldtemplate.FieldStatus:
  15547. return m.Status()
  15548. case contactfieldtemplate.FieldDeletedAt:
  15549. return m.DeletedAt()
  15550. case contactfieldtemplate.FieldOrganizationID:
  15551. return m.OrganizationID()
  15552. case contactfieldtemplate.FieldTemplate:
  15553. return m.Template()
  15554. }
  15555. return nil, false
  15556. }
  15557. // OldField returns the old value of the field from the database. An error is
  15558. // returned if the mutation operation is not UpdateOne, or the query to the
  15559. // database failed.
  15560. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15561. switch name {
  15562. case contactfieldtemplate.FieldCreatedAt:
  15563. return m.OldCreatedAt(ctx)
  15564. case contactfieldtemplate.FieldUpdatedAt:
  15565. return m.OldUpdatedAt(ctx)
  15566. case contactfieldtemplate.FieldStatus:
  15567. return m.OldStatus(ctx)
  15568. case contactfieldtemplate.FieldDeletedAt:
  15569. return m.OldDeletedAt(ctx)
  15570. case contactfieldtemplate.FieldOrganizationID:
  15571. return m.OldOrganizationID(ctx)
  15572. case contactfieldtemplate.FieldTemplate:
  15573. return m.OldTemplate(ctx)
  15574. }
  15575. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15576. }
  15577. // SetField sets the value of a field with the given name. It returns an error if
  15578. // the field is not defined in the schema, or if the type mismatched the field
  15579. // type.
  15580. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  15581. switch name {
  15582. case contactfieldtemplate.FieldCreatedAt:
  15583. v, ok := value.(time.Time)
  15584. if !ok {
  15585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15586. }
  15587. m.SetCreatedAt(v)
  15588. return nil
  15589. case contactfieldtemplate.FieldUpdatedAt:
  15590. v, ok := value.(time.Time)
  15591. if !ok {
  15592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15593. }
  15594. m.SetUpdatedAt(v)
  15595. return nil
  15596. case contactfieldtemplate.FieldStatus:
  15597. v, ok := value.(uint8)
  15598. if !ok {
  15599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15600. }
  15601. m.SetStatus(v)
  15602. return nil
  15603. case contactfieldtemplate.FieldDeletedAt:
  15604. v, ok := value.(time.Time)
  15605. if !ok {
  15606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15607. }
  15608. m.SetDeletedAt(v)
  15609. return nil
  15610. case contactfieldtemplate.FieldOrganizationID:
  15611. v, ok := value.(uint64)
  15612. if !ok {
  15613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15614. }
  15615. m.SetOrganizationID(v)
  15616. return nil
  15617. case contactfieldtemplate.FieldTemplate:
  15618. v, ok := value.([]custom_types.ContactFieldTemplate)
  15619. if !ok {
  15620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15621. }
  15622. m.SetTemplate(v)
  15623. return nil
  15624. }
  15625. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15626. }
  15627. // AddedFields returns all numeric fields that were incremented/decremented during
  15628. // this mutation.
  15629. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  15630. var fields []string
  15631. if m.addstatus != nil {
  15632. fields = append(fields, contactfieldtemplate.FieldStatus)
  15633. }
  15634. if m.addorganization_id != nil {
  15635. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15636. }
  15637. return fields
  15638. }
  15639. // AddedField returns the numeric value that was incremented/decremented on a field
  15640. // with the given name. The second boolean return value indicates that this field
  15641. // was not set, or was not defined in the schema.
  15642. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  15643. switch name {
  15644. case contactfieldtemplate.FieldStatus:
  15645. return m.AddedStatus()
  15646. case contactfieldtemplate.FieldOrganizationID:
  15647. return m.AddedOrganizationID()
  15648. }
  15649. return nil, false
  15650. }
  15651. // AddField adds the value to the field with the given name. It returns an error if
  15652. // the field is not defined in the schema, or if the type mismatched the field
  15653. // type.
  15654. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  15655. switch name {
  15656. case contactfieldtemplate.FieldStatus:
  15657. v, ok := value.(int8)
  15658. if !ok {
  15659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15660. }
  15661. m.AddStatus(v)
  15662. return nil
  15663. case contactfieldtemplate.FieldOrganizationID:
  15664. v, ok := value.(int64)
  15665. if !ok {
  15666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15667. }
  15668. m.AddOrganizationID(v)
  15669. return nil
  15670. }
  15671. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  15672. }
  15673. // ClearedFields returns all nullable fields that were cleared during this
  15674. // mutation.
  15675. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  15676. var fields []string
  15677. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  15678. fields = append(fields, contactfieldtemplate.FieldStatus)
  15679. }
  15680. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  15681. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15682. }
  15683. return fields
  15684. }
  15685. // FieldCleared returns a boolean indicating if a field with the given name was
  15686. // cleared in this mutation.
  15687. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  15688. _, ok := m.clearedFields[name]
  15689. return ok
  15690. }
  15691. // ClearField clears the value of the field with the given name. It returns an
  15692. // error if the field is not defined in the schema.
  15693. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  15694. switch name {
  15695. case contactfieldtemplate.FieldStatus:
  15696. m.ClearStatus()
  15697. return nil
  15698. case contactfieldtemplate.FieldDeletedAt:
  15699. m.ClearDeletedAt()
  15700. return nil
  15701. }
  15702. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  15703. }
  15704. // ResetField resets all changes in the mutation for the field with the given name.
  15705. // It returns an error if the field is not defined in the schema.
  15706. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  15707. switch name {
  15708. case contactfieldtemplate.FieldCreatedAt:
  15709. m.ResetCreatedAt()
  15710. return nil
  15711. case contactfieldtemplate.FieldUpdatedAt:
  15712. m.ResetUpdatedAt()
  15713. return nil
  15714. case contactfieldtemplate.FieldStatus:
  15715. m.ResetStatus()
  15716. return nil
  15717. case contactfieldtemplate.FieldDeletedAt:
  15718. m.ResetDeletedAt()
  15719. return nil
  15720. case contactfieldtemplate.FieldOrganizationID:
  15721. m.ResetOrganizationID()
  15722. return nil
  15723. case contactfieldtemplate.FieldTemplate:
  15724. m.ResetTemplate()
  15725. return nil
  15726. }
  15727. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15728. }
  15729. // AddedEdges returns all edge names that were set/added in this mutation.
  15730. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  15731. edges := make([]string, 0, 0)
  15732. return edges
  15733. }
  15734. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15735. // name in this mutation.
  15736. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  15737. return nil
  15738. }
  15739. // RemovedEdges returns all edge names that were removed in this mutation.
  15740. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  15741. edges := make([]string, 0, 0)
  15742. return edges
  15743. }
  15744. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15745. // the given name in this mutation.
  15746. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  15747. return nil
  15748. }
  15749. // ClearedEdges returns all edge names that were cleared in this mutation.
  15750. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  15751. edges := make([]string, 0, 0)
  15752. return edges
  15753. }
  15754. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15755. // was cleared in this mutation.
  15756. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  15757. return false
  15758. }
  15759. // ClearEdge clears the value of the edge with the given name. It returns an error
  15760. // if that edge is not defined in the schema.
  15761. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  15762. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  15763. }
  15764. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15765. // It returns an error if the edge is not defined in the schema.
  15766. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  15767. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  15768. }
  15769. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  15770. type CreditBalanceMutation struct {
  15771. config
  15772. op Op
  15773. typ string
  15774. id *uint64
  15775. created_at *time.Time
  15776. updated_at *time.Time
  15777. deleted_at *time.Time
  15778. user_id *string
  15779. balance *float64
  15780. addbalance *float64
  15781. status *int
  15782. addstatus *int
  15783. organization_id *uint64
  15784. addorganization_id *int64
  15785. clearedFields map[string]struct{}
  15786. done bool
  15787. oldValue func(context.Context) (*CreditBalance, error)
  15788. predicates []predicate.CreditBalance
  15789. }
  15790. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  15791. // creditbalanceOption allows management of the mutation configuration using functional options.
  15792. type creditbalanceOption func(*CreditBalanceMutation)
  15793. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  15794. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  15795. m := &CreditBalanceMutation{
  15796. config: c,
  15797. op: op,
  15798. typ: TypeCreditBalance,
  15799. clearedFields: make(map[string]struct{}),
  15800. }
  15801. for _, opt := range opts {
  15802. opt(m)
  15803. }
  15804. return m
  15805. }
  15806. // withCreditBalanceID sets the ID field of the mutation.
  15807. func withCreditBalanceID(id uint64) creditbalanceOption {
  15808. return func(m *CreditBalanceMutation) {
  15809. var (
  15810. err error
  15811. once sync.Once
  15812. value *CreditBalance
  15813. )
  15814. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  15815. once.Do(func() {
  15816. if m.done {
  15817. err = errors.New("querying old values post mutation is not allowed")
  15818. } else {
  15819. value, err = m.Client().CreditBalance.Get(ctx, id)
  15820. }
  15821. })
  15822. return value, err
  15823. }
  15824. m.id = &id
  15825. }
  15826. }
  15827. // withCreditBalance sets the old CreditBalance of the mutation.
  15828. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  15829. return func(m *CreditBalanceMutation) {
  15830. m.oldValue = func(context.Context) (*CreditBalance, error) {
  15831. return node, nil
  15832. }
  15833. m.id = &node.ID
  15834. }
  15835. }
  15836. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15837. // executed in a transaction (ent.Tx), a transactional client is returned.
  15838. func (m CreditBalanceMutation) Client() *Client {
  15839. client := &Client{config: m.config}
  15840. client.init()
  15841. return client
  15842. }
  15843. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15844. // it returns an error otherwise.
  15845. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  15846. if _, ok := m.driver.(*txDriver); !ok {
  15847. return nil, errors.New("ent: mutation is not running in a transaction")
  15848. }
  15849. tx := &Tx{config: m.config}
  15850. tx.init()
  15851. return tx, nil
  15852. }
  15853. // SetID sets the value of the id field. Note that this
  15854. // operation is only accepted on creation of CreditBalance entities.
  15855. func (m *CreditBalanceMutation) SetID(id uint64) {
  15856. m.id = &id
  15857. }
  15858. // ID returns the ID value in the mutation. Note that the ID is only available
  15859. // if it was provided to the builder or after it was returned from the database.
  15860. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  15861. if m.id == nil {
  15862. return
  15863. }
  15864. return *m.id, true
  15865. }
  15866. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15867. // That means, if the mutation is applied within a transaction with an isolation level such
  15868. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15869. // or updated by the mutation.
  15870. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  15871. switch {
  15872. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15873. id, exists := m.ID()
  15874. if exists {
  15875. return []uint64{id}, nil
  15876. }
  15877. fallthrough
  15878. case m.op.Is(OpUpdate | OpDelete):
  15879. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  15880. default:
  15881. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15882. }
  15883. }
  15884. // SetCreatedAt sets the "created_at" field.
  15885. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  15886. m.created_at = &t
  15887. }
  15888. // CreatedAt returns the value of the "created_at" field in the mutation.
  15889. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  15890. v := m.created_at
  15891. if v == nil {
  15892. return
  15893. }
  15894. return *v, true
  15895. }
  15896. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  15897. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15899. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15900. if !m.op.Is(OpUpdateOne) {
  15901. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15902. }
  15903. if m.id == nil || m.oldValue == nil {
  15904. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15905. }
  15906. oldValue, err := m.oldValue(ctx)
  15907. if err != nil {
  15908. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15909. }
  15910. return oldValue.CreatedAt, nil
  15911. }
  15912. // ResetCreatedAt resets all changes to the "created_at" field.
  15913. func (m *CreditBalanceMutation) ResetCreatedAt() {
  15914. m.created_at = nil
  15915. }
  15916. // SetUpdatedAt sets the "updated_at" field.
  15917. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  15918. m.updated_at = &t
  15919. }
  15920. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15921. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  15922. v := m.updated_at
  15923. if v == nil {
  15924. return
  15925. }
  15926. return *v, true
  15927. }
  15928. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  15929. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15931. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15932. if !m.op.Is(OpUpdateOne) {
  15933. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15934. }
  15935. if m.id == nil || m.oldValue == nil {
  15936. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15937. }
  15938. oldValue, err := m.oldValue(ctx)
  15939. if err != nil {
  15940. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15941. }
  15942. return oldValue.UpdatedAt, nil
  15943. }
  15944. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15945. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  15946. m.updated_at = nil
  15947. }
  15948. // SetDeletedAt sets the "deleted_at" field.
  15949. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  15950. m.deleted_at = &t
  15951. }
  15952. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15953. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  15954. v := m.deleted_at
  15955. if v == nil {
  15956. return
  15957. }
  15958. return *v, true
  15959. }
  15960. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  15961. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15963. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15964. if !m.op.Is(OpUpdateOne) {
  15965. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15966. }
  15967. if m.id == nil || m.oldValue == nil {
  15968. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15969. }
  15970. oldValue, err := m.oldValue(ctx)
  15971. if err != nil {
  15972. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15973. }
  15974. return oldValue.DeletedAt, nil
  15975. }
  15976. // ClearDeletedAt clears the value of the "deleted_at" field.
  15977. func (m *CreditBalanceMutation) ClearDeletedAt() {
  15978. m.deleted_at = nil
  15979. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  15980. }
  15981. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15982. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  15983. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  15984. return ok
  15985. }
  15986. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15987. func (m *CreditBalanceMutation) ResetDeletedAt() {
  15988. m.deleted_at = nil
  15989. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  15990. }
  15991. // SetUserID sets the "user_id" field.
  15992. func (m *CreditBalanceMutation) SetUserID(s string) {
  15993. m.user_id = &s
  15994. }
  15995. // UserID returns the value of the "user_id" field in the mutation.
  15996. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  15997. v := m.user_id
  15998. if v == nil {
  15999. return
  16000. }
  16001. return *v, true
  16002. }
  16003. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  16004. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16006. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  16007. if !m.op.Is(OpUpdateOne) {
  16008. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16009. }
  16010. if m.id == nil || m.oldValue == nil {
  16011. return v, errors.New("OldUserID requires an ID field in the mutation")
  16012. }
  16013. oldValue, err := m.oldValue(ctx)
  16014. if err != nil {
  16015. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16016. }
  16017. return oldValue.UserID, nil
  16018. }
  16019. // ClearUserID clears the value of the "user_id" field.
  16020. func (m *CreditBalanceMutation) ClearUserID() {
  16021. m.user_id = nil
  16022. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  16023. }
  16024. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16025. func (m *CreditBalanceMutation) UserIDCleared() bool {
  16026. _, ok := m.clearedFields[creditbalance.FieldUserID]
  16027. return ok
  16028. }
  16029. // ResetUserID resets all changes to the "user_id" field.
  16030. func (m *CreditBalanceMutation) ResetUserID() {
  16031. m.user_id = nil
  16032. delete(m.clearedFields, creditbalance.FieldUserID)
  16033. }
  16034. // SetBalance sets the "balance" field.
  16035. func (m *CreditBalanceMutation) SetBalance(f float64) {
  16036. m.balance = &f
  16037. m.addbalance = nil
  16038. }
  16039. // Balance returns the value of the "balance" field in the mutation.
  16040. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  16041. v := m.balance
  16042. if v == nil {
  16043. return
  16044. }
  16045. return *v, true
  16046. }
  16047. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  16048. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16050. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  16051. if !m.op.Is(OpUpdateOne) {
  16052. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  16053. }
  16054. if m.id == nil || m.oldValue == nil {
  16055. return v, errors.New("OldBalance requires an ID field in the mutation")
  16056. }
  16057. oldValue, err := m.oldValue(ctx)
  16058. if err != nil {
  16059. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  16060. }
  16061. return oldValue.Balance, nil
  16062. }
  16063. // AddBalance adds f to the "balance" field.
  16064. func (m *CreditBalanceMutation) AddBalance(f float64) {
  16065. if m.addbalance != nil {
  16066. *m.addbalance += f
  16067. } else {
  16068. m.addbalance = &f
  16069. }
  16070. }
  16071. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  16072. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  16073. v := m.addbalance
  16074. if v == nil {
  16075. return
  16076. }
  16077. return *v, true
  16078. }
  16079. // ResetBalance resets all changes to the "balance" field.
  16080. func (m *CreditBalanceMutation) ResetBalance() {
  16081. m.balance = nil
  16082. m.addbalance = nil
  16083. }
  16084. // SetStatus sets the "status" field.
  16085. func (m *CreditBalanceMutation) SetStatus(i int) {
  16086. m.status = &i
  16087. m.addstatus = nil
  16088. }
  16089. // Status returns the value of the "status" field in the mutation.
  16090. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  16091. v := m.status
  16092. if v == nil {
  16093. return
  16094. }
  16095. return *v, true
  16096. }
  16097. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  16098. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16100. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  16101. if !m.op.Is(OpUpdateOne) {
  16102. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16103. }
  16104. if m.id == nil || m.oldValue == nil {
  16105. return v, errors.New("OldStatus requires an ID field in the mutation")
  16106. }
  16107. oldValue, err := m.oldValue(ctx)
  16108. if err != nil {
  16109. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16110. }
  16111. return oldValue.Status, nil
  16112. }
  16113. // AddStatus adds i to the "status" field.
  16114. func (m *CreditBalanceMutation) AddStatus(i int) {
  16115. if m.addstatus != nil {
  16116. *m.addstatus += i
  16117. } else {
  16118. m.addstatus = &i
  16119. }
  16120. }
  16121. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16122. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  16123. v := m.addstatus
  16124. if v == nil {
  16125. return
  16126. }
  16127. return *v, true
  16128. }
  16129. // ClearStatus clears the value of the "status" field.
  16130. func (m *CreditBalanceMutation) ClearStatus() {
  16131. m.status = nil
  16132. m.addstatus = nil
  16133. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  16134. }
  16135. // StatusCleared returns if the "status" field was cleared in this mutation.
  16136. func (m *CreditBalanceMutation) StatusCleared() bool {
  16137. _, ok := m.clearedFields[creditbalance.FieldStatus]
  16138. return ok
  16139. }
  16140. // ResetStatus resets all changes to the "status" field.
  16141. func (m *CreditBalanceMutation) ResetStatus() {
  16142. m.status = nil
  16143. m.addstatus = nil
  16144. delete(m.clearedFields, creditbalance.FieldStatus)
  16145. }
  16146. // SetOrganizationID sets the "organization_id" field.
  16147. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  16148. m.organization_id = &u
  16149. m.addorganization_id = nil
  16150. }
  16151. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16152. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  16153. v := m.organization_id
  16154. if v == nil {
  16155. return
  16156. }
  16157. return *v, true
  16158. }
  16159. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  16160. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16162. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16163. if !m.op.Is(OpUpdateOne) {
  16164. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16165. }
  16166. if m.id == nil || m.oldValue == nil {
  16167. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16168. }
  16169. oldValue, err := m.oldValue(ctx)
  16170. if err != nil {
  16171. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16172. }
  16173. return oldValue.OrganizationID, nil
  16174. }
  16175. // AddOrganizationID adds u to the "organization_id" field.
  16176. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  16177. if m.addorganization_id != nil {
  16178. *m.addorganization_id += u
  16179. } else {
  16180. m.addorganization_id = &u
  16181. }
  16182. }
  16183. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16184. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  16185. v := m.addorganization_id
  16186. if v == nil {
  16187. return
  16188. }
  16189. return *v, true
  16190. }
  16191. // ClearOrganizationID clears the value of the "organization_id" field.
  16192. func (m *CreditBalanceMutation) ClearOrganizationID() {
  16193. m.organization_id = nil
  16194. m.addorganization_id = nil
  16195. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  16196. }
  16197. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16198. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  16199. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  16200. return ok
  16201. }
  16202. // ResetOrganizationID resets all changes to the "organization_id" field.
  16203. func (m *CreditBalanceMutation) ResetOrganizationID() {
  16204. m.organization_id = nil
  16205. m.addorganization_id = nil
  16206. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  16207. }
  16208. // Where appends a list predicates to the CreditBalanceMutation builder.
  16209. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  16210. m.predicates = append(m.predicates, ps...)
  16211. }
  16212. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  16213. // users can use type-assertion to append predicates that do not depend on any generated package.
  16214. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  16215. p := make([]predicate.CreditBalance, len(ps))
  16216. for i := range ps {
  16217. p[i] = ps[i]
  16218. }
  16219. m.Where(p...)
  16220. }
  16221. // Op returns the operation name.
  16222. func (m *CreditBalanceMutation) Op() Op {
  16223. return m.op
  16224. }
  16225. // SetOp allows setting the mutation operation.
  16226. func (m *CreditBalanceMutation) SetOp(op Op) {
  16227. m.op = op
  16228. }
  16229. // Type returns the node type of this mutation (CreditBalance).
  16230. func (m *CreditBalanceMutation) Type() string {
  16231. return m.typ
  16232. }
  16233. // Fields returns all fields that were changed during this mutation. Note that in
  16234. // order to get all numeric fields that were incremented/decremented, call
  16235. // AddedFields().
  16236. func (m *CreditBalanceMutation) Fields() []string {
  16237. fields := make([]string, 0, 7)
  16238. if m.created_at != nil {
  16239. fields = append(fields, creditbalance.FieldCreatedAt)
  16240. }
  16241. if m.updated_at != nil {
  16242. fields = append(fields, creditbalance.FieldUpdatedAt)
  16243. }
  16244. if m.deleted_at != nil {
  16245. fields = append(fields, creditbalance.FieldDeletedAt)
  16246. }
  16247. if m.user_id != nil {
  16248. fields = append(fields, creditbalance.FieldUserID)
  16249. }
  16250. if m.balance != nil {
  16251. fields = append(fields, creditbalance.FieldBalance)
  16252. }
  16253. if m.status != nil {
  16254. fields = append(fields, creditbalance.FieldStatus)
  16255. }
  16256. if m.organization_id != nil {
  16257. fields = append(fields, creditbalance.FieldOrganizationID)
  16258. }
  16259. return fields
  16260. }
  16261. // Field returns the value of a field with the given name. The second boolean
  16262. // return value indicates that this field was not set, or was not defined in the
  16263. // schema.
  16264. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  16265. switch name {
  16266. case creditbalance.FieldCreatedAt:
  16267. return m.CreatedAt()
  16268. case creditbalance.FieldUpdatedAt:
  16269. return m.UpdatedAt()
  16270. case creditbalance.FieldDeletedAt:
  16271. return m.DeletedAt()
  16272. case creditbalance.FieldUserID:
  16273. return m.UserID()
  16274. case creditbalance.FieldBalance:
  16275. return m.Balance()
  16276. case creditbalance.FieldStatus:
  16277. return m.Status()
  16278. case creditbalance.FieldOrganizationID:
  16279. return m.OrganizationID()
  16280. }
  16281. return nil, false
  16282. }
  16283. // OldField returns the old value of the field from the database. An error is
  16284. // returned if the mutation operation is not UpdateOne, or the query to the
  16285. // database failed.
  16286. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16287. switch name {
  16288. case creditbalance.FieldCreatedAt:
  16289. return m.OldCreatedAt(ctx)
  16290. case creditbalance.FieldUpdatedAt:
  16291. return m.OldUpdatedAt(ctx)
  16292. case creditbalance.FieldDeletedAt:
  16293. return m.OldDeletedAt(ctx)
  16294. case creditbalance.FieldUserID:
  16295. return m.OldUserID(ctx)
  16296. case creditbalance.FieldBalance:
  16297. return m.OldBalance(ctx)
  16298. case creditbalance.FieldStatus:
  16299. return m.OldStatus(ctx)
  16300. case creditbalance.FieldOrganizationID:
  16301. return m.OldOrganizationID(ctx)
  16302. }
  16303. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  16304. }
  16305. // SetField sets the value of a field with the given name. It returns an error if
  16306. // the field is not defined in the schema, or if the type mismatched the field
  16307. // type.
  16308. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  16309. switch name {
  16310. case creditbalance.FieldCreatedAt:
  16311. v, ok := value.(time.Time)
  16312. if !ok {
  16313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16314. }
  16315. m.SetCreatedAt(v)
  16316. return nil
  16317. case creditbalance.FieldUpdatedAt:
  16318. v, ok := value.(time.Time)
  16319. if !ok {
  16320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16321. }
  16322. m.SetUpdatedAt(v)
  16323. return nil
  16324. case creditbalance.FieldDeletedAt:
  16325. v, ok := value.(time.Time)
  16326. if !ok {
  16327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16328. }
  16329. m.SetDeletedAt(v)
  16330. return nil
  16331. case creditbalance.FieldUserID:
  16332. v, ok := value.(string)
  16333. if !ok {
  16334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16335. }
  16336. m.SetUserID(v)
  16337. return nil
  16338. case creditbalance.FieldBalance:
  16339. v, ok := value.(float64)
  16340. if !ok {
  16341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16342. }
  16343. m.SetBalance(v)
  16344. return nil
  16345. case creditbalance.FieldStatus:
  16346. v, ok := value.(int)
  16347. if !ok {
  16348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16349. }
  16350. m.SetStatus(v)
  16351. return nil
  16352. case creditbalance.FieldOrganizationID:
  16353. v, ok := value.(uint64)
  16354. if !ok {
  16355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16356. }
  16357. m.SetOrganizationID(v)
  16358. return nil
  16359. }
  16360. return fmt.Errorf("unknown CreditBalance field %s", name)
  16361. }
  16362. // AddedFields returns all numeric fields that were incremented/decremented during
  16363. // this mutation.
  16364. func (m *CreditBalanceMutation) AddedFields() []string {
  16365. var fields []string
  16366. if m.addbalance != nil {
  16367. fields = append(fields, creditbalance.FieldBalance)
  16368. }
  16369. if m.addstatus != nil {
  16370. fields = append(fields, creditbalance.FieldStatus)
  16371. }
  16372. if m.addorganization_id != nil {
  16373. fields = append(fields, creditbalance.FieldOrganizationID)
  16374. }
  16375. return fields
  16376. }
  16377. // AddedField returns the numeric value that was incremented/decremented on a field
  16378. // with the given name. The second boolean return value indicates that this field
  16379. // was not set, or was not defined in the schema.
  16380. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  16381. switch name {
  16382. case creditbalance.FieldBalance:
  16383. return m.AddedBalance()
  16384. case creditbalance.FieldStatus:
  16385. return m.AddedStatus()
  16386. case creditbalance.FieldOrganizationID:
  16387. return m.AddedOrganizationID()
  16388. }
  16389. return nil, false
  16390. }
  16391. // AddField adds the value to the field with the given name. It returns an error if
  16392. // the field is not defined in the schema, or if the type mismatched the field
  16393. // type.
  16394. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  16395. switch name {
  16396. case creditbalance.FieldBalance:
  16397. v, ok := value.(float64)
  16398. if !ok {
  16399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16400. }
  16401. m.AddBalance(v)
  16402. return nil
  16403. case creditbalance.FieldStatus:
  16404. v, ok := value.(int)
  16405. if !ok {
  16406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16407. }
  16408. m.AddStatus(v)
  16409. return nil
  16410. case creditbalance.FieldOrganizationID:
  16411. v, ok := value.(int64)
  16412. if !ok {
  16413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16414. }
  16415. m.AddOrganizationID(v)
  16416. return nil
  16417. }
  16418. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  16419. }
  16420. // ClearedFields returns all nullable fields that were cleared during this
  16421. // mutation.
  16422. func (m *CreditBalanceMutation) ClearedFields() []string {
  16423. var fields []string
  16424. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  16425. fields = append(fields, creditbalance.FieldDeletedAt)
  16426. }
  16427. if m.FieldCleared(creditbalance.FieldUserID) {
  16428. fields = append(fields, creditbalance.FieldUserID)
  16429. }
  16430. if m.FieldCleared(creditbalance.FieldStatus) {
  16431. fields = append(fields, creditbalance.FieldStatus)
  16432. }
  16433. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  16434. fields = append(fields, creditbalance.FieldOrganizationID)
  16435. }
  16436. return fields
  16437. }
  16438. // FieldCleared returns a boolean indicating if a field with the given name was
  16439. // cleared in this mutation.
  16440. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  16441. _, ok := m.clearedFields[name]
  16442. return ok
  16443. }
  16444. // ClearField clears the value of the field with the given name. It returns an
  16445. // error if the field is not defined in the schema.
  16446. func (m *CreditBalanceMutation) ClearField(name string) error {
  16447. switch name {
  16448. case creditbalance.FieldDeletedAt:
  16449. m.ClearDeletedAt()
  16450. return nil
  16451. case creditbalance.FieldUserID:
  16452. m.ClearUserID()
  16453. return nil
  16454. case creditbalance.FieldStatus:
  16455. m.ClearStatus()
  16456. return nil
  16457. case creditbalance.FieldOrganizationID:
  16458. m.ClearOrganizationID()
  16459. return nil
  16460. }
  16461. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  16462. }
  16463. // ResetField resets all changes in the mutation for the field with the given name.
  16464. // It returns an error if the field is not defined in the schema.
  16465. func (m *CreditBalanceMutation) ResetField(name string) error {
  16466. switch name {
  16467. case creditbalance.FieldCreatedAt:
  16468. m.ResetCreatedAt()
  16469. return nil
  16470. case creditbalance.FieldUpdatedAt:
  16471. m.ResetUpdatedAt()
  16472. return nil
  16473. case creditbalance.FieldDeletedAt:
  16474. m.ResetDeletedAt()
  16475. return nil
  16476. case creditbalance.FieldUserID:
  16477. m.ResetUserID()
  16478. return nil
  16479. case creditbalance.FieldBalance:
  16480. m.ResetBalance()
  16481. return nil
  16482. case creditbalance.FieldStatus:
  16483. m.ResetStatus()
  16484. return nil
  16485. case creditbalance.FieldOrganizationID:
  16486. m.ResetOrganizationID()
  16487. return nil
  16488. }
  16489. return fmt.Errorf("unknown CreditBalance field %s", name)
  16490. }
  16491. // AddedEdges returns all edge names that were set/added in this mutation.
  16492. func (m *CreditBalanceMutation) AddedEdges() []string {
  16493. edges := make([]string, 0, 0)
  16494. return edges
  16495. }
  16496. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16497. // name in this mutation.
  16498. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  16499. return nil
  16500. }
  16501. // RemovedEdges returns all edge names that were removed in this mutation.
  16502. func (m *CreditBalanceMutation) RemovedEdges() []string {
  16503. edges := make([]string, 0, 0)
  16504. return edges
  16505. }
  16506. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16507. // the given name in this mutation.
  16508. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  16509. return nil
  16510. }
  16511. // ClearedEdges returns all edge names that were cleared in this mutation.
  16512. func (m *CreditBalanceMutation) ClearedEdges() []string {
  16513. edges := make([]string, 0, 0)
  16514. return edges
  16515. }
  16516. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16517. // was cleared in this mutation.
  16518. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  16519. return false
  16520. }
  16521. // ClearEdge clears the value of the edge with the given name. It returns an error
  16522. // if that edge is not defined in the schema.
  16523. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  16524. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  16525. }
  16526. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16527. // It returns an error if the edge is not defined in the schema.
  16528. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  16529. return fmt.Errorf("unknown CreditBalance edge %s", name)
  16530. }
  16531. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  16532. type CreditUsageMutation struct {
  16533. config
  16534. op Op
  16535. typ string
  16536. id *uint64
  16537. created_at *time.Time
  16538. updated_at *time.Time
  16539. deleted_at *time.Time
  16540. user_id *string
  16541. number *float64
  16542. addnumber *float64
  16543. pay_number *float64
  16544. addpay_number *float64
  16545. before_number *float64
  16546. addbefore_number *float64
  16547. after_number *float64
  16548. addafter_number *float64
  16549. pay_method *int
  16550. addpay_method *int
  16551. status *int
  16552. addstatus *int
  16553. ntype *int
  16554. addntype *int
  16555. table *string
  16556. organization_id *uint64
  16557. addorganization_id *int64
  16558. nid *uint64
  16559. addnid *int64
  16560. reason *string
  16561. operator *string
  16562. clearedFields map[string]struct{}
  16563. done bool
  16564. oldValue func(context.Context) (*CreditUsage, error)
  16565. predicates []predicate.CreditUsage
  16566. }
  16567. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  16568. // creditusageOption allows management of the mutation configuration using functional options.
  16569. type creditusageOption func(*CreditUsageMutation)
  16570. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  16571. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  16572. m := &CreditUsageMutation{
  16573. config: c,
  16574. op: op,
  16575. typ: TypeCreditUsage,
  16576. clearedFields: make(map[string]struct{}),
  16577. }
  16578. for _, opt := range opts {
  16579. opt(m)
  16580. }
  16581. return m
  16582. }
  16583. // withCreditUsageID sets the ID field of the mutation.
  16584. func withCreditUsageID(id uint64) creditusageOption {
  16585. return func(m *CreditUsageMutation) {
  16586. var (
  16587. err error
  16588. once sync.Once
  16589. value *CreditUsage
  16590. )
  16591. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  16592. once.Do(func() {
  16593. if m.done {
  16594. err = errors.New("querying old values post mutation is not allowed")
  16595. } else {
  16596. value, err = m.Client().CreditUsage.Get(ctx, id)
  16597. }
  16598. })
  16599. return value, err
  16600. }
  16601. m.id = &id
  16602. }
  16603. }
  16604. // withCreditUsage sets the old CreditUsage of the mutation.
  16605. func withCreditUsage(node *CreditUsage) creditusageOption {
  16606. return func(m *CreditUsageMutation) {
  16607. m.oldValue = func(context.Context) (*CreditUsage, error) {
  16608. return node, nil
  16609. }
  16610. m.id = &node.ID
  16611. }
  16612. }
  16613. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16614. // executed in a transaction (ent.Tx), a transactional client is returned.
  16615. func (m CreditUsageMutation) Client() *Client {
  16616. client := &Client{config: m.config}
  16617. client.init()
  16618. return client
  16619. }
  16620. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16621. // it returns an error otherwise.
  16622. func (m CreditUsageMutation) Tx() (*Tx, error) {
  16623. if _, ok := m.driver.(*txDriver); !ok {
  16624. return nil, errors.New("ent: mutation is not running in a transaction")
  16625. }
  16626. tx := &Tx{config: m.config}
  16627. tx.init()
  16628. return tx, nil
  16629. }
  16630. // SetID sets the value of the id field. Note that this
  16631. // operation is only accepted on creation of CreditUsage entities.
  16632. func (m *CreditUsageMutation) SetID(id uint64) {
  16633. m.id = &id
  16634. }
  16635. // ID returns the ID value in the mutation. Note that the ID is only available
  16636. // if it was provided to the builder or after it was returned from the database.
  16637. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  16638. if m.id == nil {
  16639. return
  16640. }
  16641. return *m.id, true
  16642. }
  16643. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16644. // That means, if the mutation is applied within a transaction with an isolation level such
  16645. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16646. // or updated by the mutation.
  16647. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16648. switch {
  16649. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16650. id, exists := m.ID()
  16651. if exists {
  16652. return []uint64{id}, nil
  16653. }
  16654. fallthrough
  16655. case m.op.Is(OpUpdate | OpDelete):
  16656. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  16657. default:
  16658. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16659. }
  16660. }
  16661. // SetCreatedAt sets the "created_at" field.
  16662. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  16663. m.created_at = &t
  16664. }
  16665. // CreatedAt returns the value of the "created_at" field in the mutation.
  16666. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  16667. v := m.created_at
  16668. if v == nil {
  16669. return
  16670. }
  16671. return *v, true
  16672. }
  16673. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  16674. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16676. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16677. if !m.op.Is(OpUpdateOne) {
  16678. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16679. }
  16680. if m.id == nil || m.oldValue == nil {
  16681. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16682. }
  16683. oldValue, err := m.oldValue(ctx)
  16684. if err != nil {
  16685. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16686. }
  16687. return oldValue.CreatedAt, nil
  16688. }
  16689. // ResetCreatedAt resets all changes to the "created_at" field.
  16690. func (m *CreditUsageMutation) ResetCreatedAt() {
  16691. m.created_at = nil
  16692. }
  16693. // SetUpdatedAt sets the "updated_at" field.
  16694. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  16695. m.updated_at = &t
  16696. }
  16697. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16698. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  16699. v := m.updated_at
  16700. if v == nil {
  16701. return
  16702. }
  16703. return *v, true
  16704. }
  16705. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  16706. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16708. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16709. if !m.op.Is(OpUpdateOne) {
  16710. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16711. }
  16712. if m.id == nil || m.oldValue == nil {
  16713. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16714. }
  16715. oldValue, err := m.oldValue(ctx)
  16716. if err != nil {
  16717. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16718. }
  16719. return oldValue.UpdatedAt, nil
  16720. }
  16721. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16722. func (m *CreditUsageMutation) ResetUpdatedAt() {
  16723. m.updated_at = nil
  16724. }
  16725. // SetDeletedAt sets the "deleted_at" field.
  16726. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  16727. m.deleted_at = &t
  16728. }
  16729. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16730. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  16731. v := m.deleted_at
  16732. if v == nil {
  16733. return
  16734. }
  16735. return *v, true
  16736. }
  16737. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  16738. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16740. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16741. if !m.op.Is(OpUpdateOne) {
  16742. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16743. }
  16744. if m.id == nil || m.oldValue == nil {
  16745. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16746. }
  16747. oldValue, err := m.oldValue(ctx)
  16748. if err != nil {
  16749. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16750. }
  16751. return oldValue.DeletedAt, nil
  16752. }
  16753. // ClearDeletedAt clears the value of the "deleted_at" field.
  16754. func (m *CreditUsageMutation) ClearDeletedAt() {
  16755. m.deleted_at = nil
  16756. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  16757. }
  16758. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16759. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  16760. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  16761. return ok
  16762. }
  16763. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16764. func (m *CreditUsageMutation) ResetDeletedAt() {
  16765. m.deleted_at = nil
  16766. delete(m.clearedFields, creditusage.FieldDeletedAt)
  16767. }
  16768. // SetUserID sets the "user_id" field.
  16769. func (m *CreditUsageMutation) SetUserID(s string) {
  16770. m.user_id = &s
  16771. }
  16772. // UserID returns the value of the "user_id" field in the mutation.
  16773. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  16774. v := m.user_id
  16775. if v == nil {
  16776. return
  16777. }
  16778. return *v, true
  16779. }
  16780. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  16781. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16783. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  16784. if !m.op.Is(OpUpdateOne) {
  16785. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16786. }
  16787. if m.id == nil || m.oldValue == nil {
  16788. return v, errors.New("OldUserID requires an ID field in the mutation")
  16789. }
  16790. oldValue, err := m.oldValue(ctx)
  16791. if err != nil {
  16792. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16793. }
  16794. return oldValue.UserID, nil
  16795. }
  16796. // ClearUserID clears the value of the "user_id" field.
  16797. func (m *CreditUsageMutation) ClearUserID() {
  16798. m.user_id = nil
  16799. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  16800. }
  16801. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16802. func (m *CreditUsageMutation) UserIDCleared() bool {
  16803. _, ok := m.clearedFields[creditusage.FieldUserID]
  16804. return ok
  16805. }
  16806. // ResetUserID resets all changes to the "user_id" field.
  16807. func (m *CreditUsageMutation) ResetUserID() {
  16808. m.user_id = nil
  16809. delete(m.clearedFields, creditusage.FieldUserID)
  16810. }
  16811. // SetNumber sets the "number" field.
  16812. func (m *CreditUsageMutation) SetNumber(f float64) {
  16813. m.number = &f
  16814. m.addnumber = nil
  16815. }
  16816. // Number returns the value of the "number" field in the mutation.
  16817. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  16818. v := m.number
  16819. if v == nil {
  16820. return
  16821. }
  16822. return *v, true
  16823. }
  16824. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  16825. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16827. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  16828. if !m.op.Is(OpUpdateOne) {
  16829. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  16830. }
  16831. if m.id == nil || m.oldValue == nil {
  16832. return v, errors.New("OldNumber requires an ID field in the mutation")
  16833. }
  16834. oldValue, err := m.oldValue(ctx)
  16835. if err != nil {
  16836. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  16837. }
  16838. return oldValue.Number, nil
  16839. }
  16840. // AddNumber adds f to the "number" field.
  16841. func (m *CreditUsageMutation) AddNumber(f float64) {
  16842. if m.addnumber != nil {
  16843. *m.addnumber += f
  16844. } else {
  16845. m.addnumber = &f
  16846. }
  16847. }
  16848. // AddedNumber returns the value that was added to the "number" field in this mutation.
  16849. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  16850. v := m.addnumber
  16851. if v == nil {
  16852. return
  16853. }
  16854. return *v, true
  16855. }
  16856. // ResetNumber resets all changes to the "number" field.
  16857. func (m *CreditUsageMutation) ResetNumber() {
  16858. m.number = nil
  16859. m.addnumber = nil
  16860. }
  16861. // SetPayNumber sets the "pay_number" field.
  16862. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  16863. m.pay_number = &f
  16864. m.addpay_number = nil
  16865. }
  16866. // PayNumber returns the value of the "pay_number" field in the mutation.
  16867. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  16868. v := m.pay_number
  16869. if v == nil {
  16870. return
  16871. }
  16872. return *v, true
  16873. }
  16874. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  16875. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16877. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  16878. if !m.op.Is(OpUpdateOne) {
  16879. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  16880. }
  16881. if m.id == nil || m.oldValue == nil {
  16882. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  16883. }
  16884. oldValue, err := m.oldValue(ctx)
  16885. if err != nil {
  16886. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  16887. }
  16888. return oldValue.PayNumber, nil
  16889. }
  16890. // AddPayNumber adds f to the "pay_number" field.
  16891. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  16892. if m.addpay_number != nil {
  16893. *m.addpay_number += f
  16894. } else {
  16895. m.addpay_number = &f
  16896. }
  16897. }
  16898. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  16899. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  16900. v := m.addpay_number
  16901. if v == nil {
  16902. return
  16903. }
  16904. return *v, true
  16905. }
  16906. // ClearPayNumber clears the value of the "pay_number" field.
  16907. func (m *CreditUsageMutation) ClearPayNumber() {
  16908. m.pay_number = nil
  16909. m.addpay_number = nil
  16910. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  16911. }
  16912. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  16913. func (m *CreditUsageMutation) PayNumberCleared() bool {
  16914. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  16915. return ok
  16916. }
  16917. // ResetPayNumber resets all changes to the "pay_number" field.
  16918. func (m *CreditUsageMutation) ResetPayNumber() {
  16919. m.pay_number = nil
  16920. m.addpay_number = nil
  16921. delete(m.clearedFields, creditusage.FieldPayNumber)
  16922. }
  16923. // SetBeforeNumber sets the "before_number" field.
  16924. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  16925. m.before_number = &f
  16926. m.addbefore_number = nil
  16927. }
  16928. // BeforeNumber returns the value of the "before_number" field in the mutation.
  16929. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  16930. v := m.before_number
  16931. if v == nil {
  16932. return
  16933. }
  16934. return *v, true
  16935. }
  16936. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  16937. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16939. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  16940. if !m.op.Is(OpUpdateOne) {
  16941. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  16942. }
  16943. if m.id == nil || m.oldValue == nil {
  16944. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  16945. }
  16946. oldValue, err := m.oldValue(ctx)
  16947. if err != nil {
  16948. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  16949. }
  16950. return oldValue.BeforeNumber, nil
  16951. }
  16952. // AddBeforeNumber adds f to the "before_number" field.
  16953. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  16954. if m.addbefore_number != nil {
  16955. *m.addbefore_number += f
  16956. } else {
  16957. m.addbefore_number = &f
  16958. }
  16959. }
  16960. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  16961. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  16962. v := m.addbefore_number
  16963. if v == nil {
  16964. return
  16965. }
  16966. return *v, true
  16967. }
  16968. // ClearBeforeNumber clears the value of the "before_number" field.
  16969. func (m *CreditUsageMutation) ClearBeforeNumber() {
  16970. m.before_number = nil
  16971. m.addbefore_number = nil
  16972. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  16973. }
  16974. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  16975. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  16976. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  16977. return ok
  16978. }
  16979. // ResetBeforeNumber resets all changes to the "before_number" field.
  16980. func (m *CreditUsageMutation) ResetBeforeNumber() {
  16981. m.before_number = nil
  16982. m.addbefore_number = nil
  16983. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  16984. }
  16985. // SetAfterNumber sets the "after_number" field.
  16986. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  16987. m.after_number = &f
  16988. m.addafter_number = nil
  16989. }
  16990. // AfterNumber returns the value of the "after_number" field in the mutation.
  16991. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  16992. v := m.after_number
  16993. if v == nil {
  16994. return
  16995. }
  16996. return *v, true
  16997. }
  16998. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  16999. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17001. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  17002. if !m.op.Is(OpUpdateOne) {
  17003. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  17004. }
  17005. if m.id == nil || m.oldValue == nil {
  17006. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  17007. }
  17008. oldValue, err := m.oldValue(ctx)
  17009. if err != nil {
  17010. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  17011. }
  17012. return oldValue.AfterNumber, nil
  17013. }
  17014. // AddAfterNumber adds f to the "after_number" field.
  17015. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  17016. if m.addafter_number != nil {
  17017. *m.addafter_number += f
  17018. } else {
  17019. m.addafter_number = &f
  17020. }
  17021. }
  17022. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  17023. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  17024. v := m.addafter_number
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // ClearAfterNumber clears the value of the "after_number" field.
  17031. func (m *CreditUsageMutation) ClearAfterNumber() {
  17032. m.after_number = nil
  17033. m.addafter_number = nil
  17034. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  17035. }
  17036. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  17037. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  17038. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  17039. return ok
  17040. }
  17041. // ResetAfterNumber resets all changes to the "after_number" field.
  17042. func (m *CreditUsageMutation) ResetAfterNumber() {
  17043. m.after_number = nil
  17044. m.addafter_number = nil
  17045. delete(m.clearedFields, creditusage.FieldAfterNumber)
  17046. }
  17047. // SetPayMethod sets the "pay_method" field.
  17048. func (m *CreditUsageMutation) SetPayMethod(i int) {
  17049. m.pay_method = &i
  17050. m.addpay_method = nil
  17051. }
  17052. // PayMethod returns the value of the "pay_method" field in the mutation.
  17053. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  17054. v := m.pay_method
  17055. if v == nil {
  17056. return
  17057. }
  17058. return *v, true
  17059. }
  17060. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  17061. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17063. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  17064. if !m.op.Is(OpUpdateOne) {
  17065. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  17066. }
  17067. if m.id == nil || m.oldValue == nil {
  17068. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  17069. }
  17070. oldValue, err := m.oldValue(ctx)
  17071. if err != nil {
  17072. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  17073. }
  17074. return oldValue.PayMethod, nil
  17075. }
  17076. // AddPayMethod adds i to the "pay_method" field.
  17077. func (m *CreditUsageMutation) AddPayMethod(i int) {
  17078. if m.addpay_method != nil {
  17079. *m.addpay_method += i
  17080. } else {
  17081. m.addpay_method = &i
  17082. }
  17083. }
  17084. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  17085. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  17086. v := m.addpay_method
  17087. if v == nil {
  17088. return
  17089. }
  17090. return *v, true
  17091. }
  17092. // ClearPayMethod clears the value of the "pay_method" field.
  17093. func (m *CreditUsageMutation) ClearPayMethod() {
  17094. m.pay_method = nil
  17095. m.addpay_method = nil
  17096. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  17097. }
  17098. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  17099. func (m *CreditUsageMutation) PayMethodCleared() bool {
  17100. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  17101. return ok
  17102. }
  17103. // ResetPayMethod resets all changes to the "pay_method" field.
  17104. func (m *CreditUsageMutation) ResetPayMethod() {
  17105. m.pay_method = nil
  17106. m.addpay_method = nil
  17107. delete(m.clearedFields, creditusage.FieldPayMethod)
  17108. }
  17109. // SetStatus sets the "status" field.
  17110. func (m *CreditUsageMutation) SetStatus(i int) {
  17111. m.status = &i
  17112. m.addstatus = nil
  17113. }
  17114. // Status returns the value of the "status" field in the mutation.
  17115. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  17116. v := m.status
  17117. if v == nil {
  17118. return
  17119. }
  17120. return *v, true
  17121. }
  17122. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  17123. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17125. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  17126. if !m.op.Is(OpUpdateOne) {
  17127. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17128. }
  17129. if m.id == nil || m.oldValue == nil {
  17130. return v, errors.New("OldStatus requires an ID field in the mutation")
  17131. }
  17132. oldValue, err := m.oldValue(ctx)
  17133. if err != nil {
  17134. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17135. }
  17136. return oldValue.Status, nil
  17137. }
  17138. // AddStatus adds i to the "status" field.
  17139. func (m *CreditUsageMutation) AddStatus(i int) {
  17140. if m.addstatus != nil {
  17141. *m.addstatus += i
  17142. } else {
  17143. m.addstatus = &i
  17144. }
  17145. }
  17146. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17147. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  17148. v := m.addstatus
  17149. if v == nil {
  17150. return
  17151. }
  17152. return *v, true
  17153. }
  17154. // ClearStatus clears the value of the "status" field.
  17155. func (m *CreditUsageMutation) ClearStatus() {
  17156. m.status = nil
  17157. m.addstatus = nil
  17158. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  17159. }
  17160. // StatusCleared returns if the "status" field was cleared in this mutation.
  17161. func (m *CreditUsageMutation) StatusCleared() bool {
  17162. _, ok := m.clearedFields[creditusage.FieldStatus]
  17163. return ok
  17164. }
  17165. // ResetStatus resets all changes to the "status" field.
  17166. func (m *CreditUsageMutation) ResetStatus() {
  17167. m.status = nil
  17168. m.addstatus = nil
  17169. delete(m.clearedFields, creditusage.FieldStatus)
  17170. }
  17171. // SetNtype sets the "ntype" field.
  17172. func (m *CreditUsageMutation) SetNtype(i int) {
  17173. m.ntype = &i
  17174. m.addntype = nil
  17175. }
  17176. // Ntype returns the value of the "ntype" field in the mutation.
  17177. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  17178. v := m.ntype
  17179. if v == nil {
  17180. return
  17181. }
  17182. return *v, true
  17183. }
  17184. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  17185. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17187. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  17188. if !m.op.Is(OpUpdateOne) {
  17189. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  17190. }
  17191. if m.id == nil || m.oldValue == nil {
  17192. return v, errors.New("OldNtype requires an ID field in the mutation")
  17193. }
  17194. oldValue, err := m.oldValue(ctx)
  17195. if err != nil {
  17196. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  17197. }
  17198. return oldValue.Ntype, nil
  17199. }
  17200. // AddNtype adds i to the "ntype" field.
  17201. func (m *CreditUsageMutation) AddNtype(i int) {
  17202. if m.addntype != nil {
  17203. *m.addntype += i
  17204. } else {
  17205. m.addntype = &i
  17206. }
  17207. }
  17208. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  17209. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  17210. v := m.addntype
  17211. if v == nil {
  17212. return
  17213. }
  17214. return *v, true
  17215. }
  17216. // ResetNtype resets all changes to the "ntype" field.
  17217. func (m *CreditUsageMutation) ResetNtype() {
  17218. m.ntype = nil
  17219. m.addntype = nil
  17220. }
  17221. // SetTable sets the "table" field.
  17222. func (m *CreditUsageMutation) SetTable(s string) {
  17223. m.table = &s
  17224. }
  17225. // Table returns the value of the "table" field in the mutation.
  17226. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  17227. v := m.table
  17228. if v == nil {
  17229. return
  17230. }
  17231. return *v, true
  17232. }
  17233. // OldTable returns the old "table" field's value of the CreditUsage entity.
  17234. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17236. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  17237. if !m.op.Is(OpUpdateOne) {
  17238. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  17239. }
  17240. if m.id == nil || m.oldValue == nil {
  17241. return v, errors.New("OldTable requires an ID field in the mutation")
  17242. }
  17243. oldValue, err := m.oldValue(ctx)
  17244. if err != nil {
  17245. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  17246. }
  17247. return oldValue.Table, nil
  17248. }
  17249. // ResetTable resets all changes to the "table" field.
  17250. func (m *CreditUsageMutation) ResetTable() {
  17251. m.table = nil
  17252. }
  17253. // SetOrganizationID sets the "organization_id" field.
  17254. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  17255. m.organization_id = &u
  17256. m.addorganization_id = nil
  17257. }
  17258. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17259. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  17260. v := m.organization_id
  17261. if v == nil {
  17262. return
  17263. }
  17264. return *v, true
  17265. }
  17266. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  17267. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17269. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17270. if !m.op.Is(OpUpdateOne) {
  17271. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17272. }
  17273. if m.id == nil || m.oldValue == nil {
  17274. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17275. }
  17276. oldValue, err := m.oldValue(ctx)
  17277. if err != nil {
  17278. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17279. }
  17280. return oldValue.OrganizationID, nil
  17281. }
  17282. // AddOrganizationID adds u to the "organization_id" field.
  17283. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  17284. if m.addorganization_id != nil {
  17285. *m.addorganization_id += u
  17286. } else {
  17287. m.addorganization_id = &u
  17288. }
  17289. }
  17290. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17291. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  17292. v := m.addorganization_id
  17293. if v == nil {
  17294. return
  17295. }
  17296. return *v, true
  17297. }
  17298. // ClearOrganizationID clears the value of the "organization_id" field.
  17299. func (m *CreditUsageMutation) ClearOrganizationID() {
  17300. m.organization_id = nil
  17301. m.addorganization_id = nil
  17302. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  17303. }
  17304. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17305. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  17306. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  17307. return ok
  17308. }
  17309. // ResetOrganizationID resets all changes to the "organization_id" field.
  17310. func (m *CreditUsageMutation) ResetOrganizationID() {
  17311. m.organization_id = nil
  17312. m.addorganization_id = nil
  17313. delete(m.clearedFields, creditusage.FieldOrganizationID)
  17314. }
  17315. // SetNid sets the "nid" field.
  17316. func (m *CreditUsageMutation) SetNid(u uint64) {
  17317. m.nid = &u
  17318. m.addnid = nil
  17319. }
  17320. // Nid returns the value of the "nid" field in the mutation.
  17321. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  17322. v := m.nid
  17323. if v == nil {
  17324. return
  17325. }
  17326. return *v, true
  17327. }
  17328. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  17329. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17331. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  17332. if !m.op.Is(OpUpdateOne) {
  17333. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  17334. }
  17335. if m.id == nil || m.oldValue == nil {
  17336. return v, errors.New("OldNid requires an ID field in the mutation")
  17337. }
  17338. oldValue, err := m.oldValue(ctx)
  17339. if err != nil {
  17340. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  17341. }
  17342. return oldValue.Nid, nil
  17343. }
  17344. // AddNid adds u to the "nid" field.
  17345. func (m *CreditUsageMutation) AddNid(u int64) {
  17346. if m.addnid != nil {
  17347. *m.addnid += u
  17348. } else {
  17349. m.addnid = &u
  17350. }
  17351. }
  17352. // AddedNid returns the value that was added to the "nid" field in this mutation.
  17353. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  17354. v := m.addnid
  17355. if v == nil {
  17356. return
  17357. }
  17358. return *v, true
  17359. }
  17360. // ResetNid resets all changes to the "nid" field.
  17361. func (m *CreditUsageMutation) ResetNid() {
  17362. m.nid = nil
  17363. m.addnid = nil
  17364. }
  17365. // SetReason sets the "reason" field.
  17366. func (m *CreditUsageMutation) SetReason(s string) {
  17367. m.reason = &s
  17368. }
  17369. // Reason returns the value of the "reason" field in the mutation.
  17370. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  17371. v := m.reason
  17372. if v == nil {
  17373. return
  17374. }
  17375. return *v, true
  17376. }
  17377. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  17378. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17380. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  17381. if !m.op.Is(OpUpdateOne) {
  17382. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  17383. }
  17384. if m.id == nil || m.oldValue == nil {
  17385. return v, errors.New("OldReason requires an ID field in the mutation")
  17386. }
  17387. oldValue, err := m.oldValue(ctx)
  17388. if err != nil {
  17389. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  17390. }
  17391. return oldValue.Reason, nil
  17392. }
  17393. // ResetReason resets all changes to the "reason" field.
  17394. func (m *CreditUsageMutation) ResetReason() {
  17395. m.reason = nil
  17396. }
  17397. // SetOperator sets the "operator" field.
  17398. func (m *CreditUsageMutation) SetOperator(s string) {
  17399. m.operator = &s
  17400. }
  17401. // Operator returns the value of the "operator" field in the mutation.
  17402. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  17403. v := m.operator
  17404. if v == nil {
  17405. return
  17406. }
  17407. return *v, true
  17408. }
  17409. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  17410. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17412. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  17413. if !m.op.Is(OpUpdateOne) {
  17414. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  17415. }
  17416. if m.id == nil || m.oldValue == nil {
  17417. return v, errors.New("OldOperator requires an ID field in the mutation")
  17418. }
  17419. oldValue, err := m.oldValue(ctx)
  17420. if err != nil {
  17421. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  17422. }
  17423. return oldValue.Operator, nil
  17424. }
  17425. // ResetOperator resets all changes to the "operator" field.
  17426. func (m *CreditUsageMutation) ResetOperator() {
  17427. m.operator = nil
  17428. }
  17429. // Where appends a list predicates to the CreditUsageMutation builder.
  17430. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  17431. m.predicates = append(m.predicates, ps...)
  17432. }
  17433. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  17434. // users can use type-assertion to append predicates that do not depend on any generated package.
  17435. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  17436. p := make([]predicate.CreditUsage, len(ps))
  17437. for i := range ps {
  17438. p[i] = ps[i]
  17439. }
  17440. m.Where(p...)
  17441. }
  17442. // Op returns the operation name.
  17443. func (m *CreditUsageMutation) Op() Op {
  17444. return m.op
  17445. }
  17446. // SetOp allows setting the mutation operation.
  17447. func (m *CreditUsageMutation) SetOp(op Op) {
  17448. m.op = op
  17449. }
  17450. // Type returns the node type of this mutation (CreditUsage).
  17451. func (m *CreditUsageMutation) Type() string {
  17452. return m.typ
  17453. }
  17454. // Fields returns all fields that were changed during this mutation. Note that in
  17455. // order to get all numeric fields that were incremented/decremented, call
  17456. // AddedFields().
  17457. func (m *CreditUsageMutation) Fields() []string {
  17458. fields := make([]string, 0, 16)
  17459. if m.created_at != nil {
  17460. fields = append(fields, creditusage.FieldCreatedAt)
  17461. }
  17462. if m.updated_at != nil {
  17463. fields = append(fields, creditusage.FieldUpdatedAt)
  17464. }
  17465. if m.deleted_at != nil {
  17466. fields = append(fields, creditusage.FieldDeletedAt)
  17467. }
  17468. if m.user_id != nil {
  17469. fields = append(fields, creditusage.FieldUserID)
  17470. }
  17471. if m.number != nil {
  17472. fields = append(fields, creditusage.FieldNumber)
  17473. }
  17474. if m.pay_number != nil {
  17475. fields = append(fields, creditusage.FieldPayNumber)
  17476. }
  17477. if m.before_number != nil {
  17478. fields = append(fields, creditusage.FieldBeforeNumber)
  17479. }
  17480. if m.after_number != nil {
  17481. fields = append(fields, creditusage.FieldAfterNumber)
  17482. }
  17483. if m.pay_method != nil {
  17484. fields = append(fields, creditusage.FieldPayMethod)
  17485. }
  17486. if m.status != nil {
  17487. fields = append(fields, creditusage.FieldStatus)
  17488. }
  17489. if m.ntype != nil {
  17490. fields = append(fields, creditusage.FieldNtype)
  17491. }
  17492. if m.table != nil {
  17493. fields = append(fields, creditusage.FieldTable)
  17494. }
  17495. if m.organization_id != nil {
  17496. fields = append(fields, creditusage.FieldOrganizationID)
  17497. }
  17498. if m.nid != nil {
  17499. fields = append(fields, creditusage.FieldNid)
  17500. }
  17501. if m.reason != nil {
  17502. fields = append(fields, creditusage.FieldReason)
  17503. }
  17504. if m.operator != nil {
  17505. fields = append(fields, creditusage.FieldOperator)
  17506. }
  17507. return fields
  17508. }
  17509. // Field returns the value of a field with the given name. The second boolean
  17510. // return value indicates that this field was not set, or was not defined in the
  17511. // schema.
  17512. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  17513. switch name {
  17514. case creditusage.FieldCreatedAt:
  17515. return m.CreatedAt()
  17516. case creditusage.FieldUpdatedAt:
  17517. return m.UpdatedAt()
  17518. case creditusage.FieldDeletedAt:
  17519. return m.DeletedAt()
  17520. case creditusage.FieldUserID:
  17521. return m.UserID()
  17522. case creditusage.FieldNumber:
  17523. return m.Number()
  17524. case creditusage.FieldPayNumber:
  17525. return m.PayNumber()
  17526. case creditusage.FieldBeforeNumber:
  17527. return m.BeforeNumber()
  17528. case creditusage.FieldAfterNumber:
  17529. return m.AfterNumber()
  17530. case creditusage.FieldPayMethod:
  17531. return m.PayMethod()
  17532. case creditusage.FieldStatus:
  17533. return m.Status()
  17534. case creditusage.FieldNtype:
  17535. return m.Ntype()
  17536. case creditusage.FieldTable:
  17537. return m.Table()
  17538. case creditusage.FieldOrganizationID:
  17539. return m.OrganizationID()
  17540. case creditusage.FieldNid:
  17541. return m.Nid()
  17542. case creditusage.FieldReason:
  17543. return m.Reason()
  17544. case creditusage.FieldOperator:
  17545. return m.Operator()
  17546. }
  17547. return nil, false
  17548. }
  17549. // OldField returns the old value of the field from the database. An error is
  17550. // returned if the mutation operation is not UpdateOne, or the query to the
  17551. // database failed.
  17552. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17553. switch name {
  17554. case creditusage.FieldCreatedAt:
  17555. return m.OldCreatedAt(ctx)
  17556. case creditusage.FieldUpdatedAt:
  17557. return m.OldUpdatedAt(ctx)
  17558. case creditusage.FieldDeletedAt:
  17559. return m.OldDeletedAt(ctx)
  17560. case creditusage.FieldUserID:
  17561. return m.OldUserID(ctx)
  17562. case creditusage.FieldNumber:
  17563. return m.OldNumber(ctx)
  17564. case creditusage.FieldPayNumber:
  17565. return m.OldPayNumber(ctx)
  17566. case creditusage.FieldBeforeNumber:
  17567. return m.OldBeforeNumber(ctx)
  17568. case creditusage.FieldAfterNumber:
  17569. return m.OldAfterNumber(ctx)
  17570. case creditusage.FieldPayMethod:
  17571. return m.OldPayMethod(ctx)
  17572. case creditusage.FieldStatus:
  17573. return m.OldStatus(ctx)
  17574. case creditusage.FieldNtype:
  17575. return m.OldNtype(ctx)
  17576. case creditusage.FieldTable:
  17577. return m.OldTable(ctx)
  17578. case creditusage.FieldOrganizationID:
  17579. return m.OldOrganizationID(ctx)
  17580. case creditusage.FieldNid:
  17581. return m.OldNid(ctx)
  17582. case creditusage.FieldReason:
  17583. return m.OldReason(ctx)
  17584. case creditusage.FieldOperator:
  17585. return m.OldOperator(ctx)
  17586. }
  17587. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  17588. }
  17589. // SetField sets the value of a field with the given name. It returns an error if
  17590. // the field is not defined in the schema, or if the type mismatched the field
  17591. // type.
  17592. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  17593. switch name {
  17594. case creditusage.FieldCreatedAt:
  17595. v, ok := value.(time.Time)
  17596. if !ok {
  17597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17598. }
  17599. m.SetCreatedAt(v)
  17600. return nil
  17601. case creditusage.FieldUpdatedAt:
  17602. v, ok := value.(time.Time)
  17603. if !ok {
  17604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17605. }
  17606. m.SetUpdatedAt(v)
  17607. return nil
  17608. case creditusage.FieldDeletedAt:
  17609. v, ok := value.(time.Time)
  17610. if !ok {
  17611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17612. }
  17613. m.SetDeletedAt(v)
  17614. return nil
  17615. case creditusage.FieldUserID:
  17616. v, ok := value.(string)
  17617. if !ok {
  17618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17619. }
  17620. m.SetUserID(v)
  17621. return nil
  17622. case creditusage.FieldNumber:
  17623. v, ok := value.(float64)
  17624. if !ok {
  17625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17626. }
  17627. m.SetNumber(v)
  17628. return nil
  17629. case creditusage.FieldPayNumber:
  17630. v, ok := value.(float64)
  17631. if !ok {
  17632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17633. }
  17634. m.SetPayNumber(v)
  17635. return nil
  17636. case creditusage.FieldBeforeNumber:
  17637. v, ok := value.(float64)
  17638. if !ok {
  17639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17640. }
  17641. m.SetBeforeNumber(v)
  17642. return nil
  17643. case creditusage.FieldAfterNumber:
  17644. v, ok := value.(float64)
  17645. if !ok {
  17646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17647. }
  17648. m.SetAfterNumber(v)
  17649. return nil
  17650. case creditusage.FieldPayMethod:
  17651. v, ok := value.(int)
  17652. if !ok {
  17653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17654. }
  17655. m.SetPayMethod(v)
  17656. return nil
  17657. case creditusage.FieldStatus:
  17658. v, ok := value.(int)
  17659. if !ok {
  17660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17661. }
  17662. m.SetStatus(v)
  17663. return nil
  17664. case creditusage.FieldNtype:
  17665. v, ok := value.(int)
  17666. if !ok {
  17667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17668. }
  17669. m.SetNtype(v)
  17670. return nil
  17671. case creditusage.FieldTable:
  17672. v, ok := value.(string)
  17673. if !ok {
  17674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17675. }
  17676. m.SetTable(v)
  17677. return nil
  17678. case creditusage.FieldOrganizationID:
  17679. v, ok := value.(uint64)
  17680. if !ok {
  17681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17682. }
  17683. m.SetOrganizationID(v)
  17684. return nil
  17685. case creditusage.FieldNid:
  17686. v, ok := value.(uint64)
  17687. if !ok {
  17688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17689. }
  17690. m.SetNid(v)
  17691. return nil
  17692. case creditusage.FieldReason:
  17693. v, ok := value.(string)
  17694. if !ok {
  17695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17696. }
  17697. m.SetReason(v)
  17698. return nil
  17699. case creditusage.FieldOperator:
  17700. v, ok := value.(string)
  17701. if !ok {
  17702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17703. }
  17704. m.SetOperator(v)
  17705. return nil
  17706. }
  17707. return fmt.Errorf("unknown CreditUsage field %s", name)
  17708. }
  17709. // AddedFields returns all numeric fields that were incremented/decremented during
  17710. // this mutation.
  17711. func (m *CreditUsageMutation) AddedFields() []string {
  17712. var fields []string
  17713. if m.addnumber != nil {
  17714. fields = append(fields, creditusage.FieldNumber)
  17715. }
  17716. if m.addpay_number != nil {
  17717. fields = append(fields, creditusage.FieldPayNumber)
  17718. }
  17719. if m.addbefore_number != nil {
  17720. fields = append(fields, creditusage.FieldBeforeNumber)
  17721. }
  17722. if m.addafter_number != nil {
  17723. fields = append(fields, creditusage.FieldAfterNumber)
  17724. }
  17725. if m.addpay_method != nil {
  17726. fields = append(fields, creditusage.FieldPayMethod)
  17727. }
  17728. if m.addstatus != nil {
  17729. fields = append(fields, creditusage.FieldStatus)
  17730. }
  17731. if m.addntype != nil {
  17732. fields = append(fields, creditusage.FieldNtype)
  17733. }
  17734. if m.addorganization_id != nil {
  17735. fields = append(fields, creditusage.FieldOrganizationID)
  17736. }
  17737. if m.addnid != nil {
  17738. fields = append(fields, creditusage.FieldNid)
  17739. }
  17740. return fields
  17741. }
  17742. // AddedField returns the numeric value that was incremented/decremented on a field
  17743. // with the given name. The second boolean return value indicates that this field
  17744. // was not set, or was not defined in the schema.
  17745. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  17746. switch name {
  17747. case creditusage.FieldNumber:
  17748. return m.AddedNumber()
  17749. case creditusage.FieldPayNumber:
  17750. return m.AddedPayNumber()
  17751. case creditusage.FieldBeforeNumber:
  17752. return m.AddedBeforeNumber()
  17753. case creditusage.FieldAfterNumber:
  17754. return m.AddedAfterNumber()
  17755. case creditusage.FieldPayMethod:
  17756. return m.AddedPayMethod()
  17757. case creditusage.FieldStatus:
  17758. return m.AddedStatus()
  17759. case creditusage.FieldNtype:
  17760. return m.AddedNtype()
  17761. case creditusage.FieldOrganizationID:
  17762. return m.AddedOrganizationID()
  17763. case creditusage.FieldNid:
  17764. return m.AddedNid()
  17765. }
  17766. return nil, false
  17767. }
  17768. // AddField adds the value to the field with the given name. It returns an error if
  17769. // the field is not defined in the schema, or if the type mismatched the field
  17770. // type.
  17771. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  17772. switch name {
  17773. case creditusage.FieldNumber:
  17774. v, ok := value.(float64)
  17775. if !ok {
  17776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17777. }
  17778. m.AddNumber(v)
  17779. return nil
  17780. case creditusage.FieldPayNumber:
  17781. v, ok := value.(float64)
  17782. if !ok {
  17783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17784. }
  17785. m.AddPayNumber(v)
  17786. return nil
  17787. case creditusage.FieldBeforeNumber:
  17788. v, ok := value.(float64)
  17789. if !ok {
  17790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17791. }
  17792. m.AddBeforeNumber(v)
  17793. return nil
  17794. case creditusage.FieldAfterNumber:
  17795. v, ok := value.(float64)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.AddAfterNumber(v)
  17800. return nil
  17801. case creditusage.FieldPayMethod:
  17802. v, ok := value.(int)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.AddPayMethod(v)
  17807. return nil
  17808. case creditusage.FieldStatus:
  17809. v, ok := value.(int)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.AddStatus(v)
  17814. return nil
  17815. case creditusage.FieldNtype:
  17816. v, ok := value.(int)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.AddNtype(v)
  17821. return nil
  17822. case creditusage.FieldOrganizationID:
  17823. v, ok := value.(int64)
  17824. if !ok {
  17825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17826. }
  17827. m.AddOrganizationID(v)
  17828. return nil
  17829. case creditusage.FieldNid:
  17830. v, ok := value.(int64)
  17831. if !ok {
  17832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17833. }
  17834. m.AddNid(v)
  17835. return nil
  17836. }
  17837. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  17838. }
  17839. // ClearedFields returns all nullable fields that were cleared during this
  17840. // mutation.
  17841. func (m *CreditUsageMutation) ClearedFields() []string {
  17842. var fields []string
  17843. if m.FieldCleared(creditusage.FieldDeletedAt) {
  17844. fields = append(fields, creditusage.FieldDeletedAt)
  17845. }
  17846. if m.FieldCleared(creditusage.FieldUserID) {
  17847. fields = append(fields, creditusage.FieldUserID)
  17848. }
  17849. if m.FieldCleared(creditusage.FieldPayNumber) {
  17850. fields = append(fields, creditusage.FieldPayNumber)
  17851. }
  17852. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  17853. fields = append(fields, creditusage.FieldBeforeNumber)
  17854. }
  17855. if m.FieldCleared(creditusage.FieldAfterNumber) {
  17856. fields = append(fields, creditusage.FieldAfterNumber)
  17857. }
  17858. if m.FieldCleared(creditusage.FieldPayMethod) {
  17859. fields = append(fields, creditusage.FieldPayMethod)
  17860. }
  17861. if m.FieldCleared(creditusage.FieldStatus) {
  17862. fields = append(fields, creditusage.FieldStatus)
  17863. }
  17864. if m.FieldCleared(creditusage.FieldOrganizationID) {
  17865. fields = append(fields, creditusage.FieldOrganizationID)
  17866. }
  17867. return fields
  17868. }
  17869. // FieldCleared returns a boolean indicating if a field with the given name was
  17870. // cleared in this mutation.
  17871. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  17872. _, ok := m.clearedFields[name]
  17873. return ok
  17874. }
  17875. // ClearField clears the value of the field with the given name. It returns an
  17876. // error if the field is not defined in the schema.
  17877. func (m *CreditUsageMutation) ClearField(name string) error {
  17878. switch name {
  17879. case creditusage.FieldDeletedAt:
  17880. m.ClearDeletedAt()
  17881. return nil
  17882. case creditusage.FieldUserID:
  17883. m.ClearUserID()
  17884. return nil
  17885. case creditusage.FieldPayNumber:
  17886. m.ClearPayNumber()
  17887. return nil
  17888. case creditusage.FieldBeforeNumber:
  17889. m.ClearBeforeNumber()
  17890. return nil
  17891. case creditusage.FieldAfterNumber:
  17892. m.ClearAfterNumber()
  17893. return nil
  17894. case creditusage.FieldPayMethod:
  17895. m.ClearPayMethod()
  17896. return nil
  17897. case creditusage.FieldStatus:
  17898. m.ClearStatus()
  17899. return nil
  17900. case creditusage.FieldOrganizationID:
  17901. m.ClearOrganizationID()
  17902. return nil
  17903. }
  17904. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  17905. }
  17906. // ResetField resets all changes in the mutation for the field with the given name.
  17907. // It returns an error if the field is not defined in the schema.
  17908. func (m *CreditUsageMutation) ResetField(name string) error {
  17909. switch name {
  17910. case creditusage.FieldCreatedAt:
  17911. m.ResetCreatedAt()
  17912. return nil
  17913. case creditusage.FieldUpdatedAt:
  17914. m.ResetUpdatedAt()
  17915. return nil
  17916. case creditusage.FieldDeletedAt:
  17917. m.ResetDeletedAt()
  17918. return nil
  17919. case creditusage.FieldUserID:
  17920. m.ResetUserID()
  17921. return nil
  17922. case creditusage.FieldNumber:
  17923. m.ResetNumber()
  17924. return nil
  17925. case creditusage.FieldPayNumber:
  17926. m.ResetPayNumber()
  17927. return nil
  17928. case creditusage.FieldBeforeNumber:
  17929. m.ResetBeforeNumber()
  17930. return nil
  17931. case creditusage.FieldAfterNumber:
  17932. m.ResetAfterNumber()
  17933. return nil
  17934. case creditusage.FieldPayMethod:
  17935. m.ResetPayMethod()
  17936. return nil
  17937. case creditusage.FieldStatus:
  17938. m.ResetStatus()
  17939. return nil
  17940. case creditusage.FieldNtype:
  17941. m.ResetNtype()
  17942. return nil
  17943. case creditusage.FieldTable:
  17944. m.ResetTable()
  17945. return nil
  17946. case creditusage.FieldOrganizationID:
  17947. m.ResetOrganizationID()
  17948. return nil
  17949. case creditusage.FieldNid:
  17950. m.ResetNid()
  17951. return nil
  17952. case creditusage.FieldReason:
  17953. m.ResetReason()
  17954. return nil
  17955. case creditusage.FieldOperator:
  17956. m.ResetOperator()
  17957. return nil
  17958. }
  17959. return fmt.Errorf("unknown CreditUsage field %s", name)
  17960. }
  17961. // AddedEdges returns all edge names that were set/added in this mutation.
  17962. func (m *CreditUsageMutation) AddedEdges() []string {
  17963. edges := make([]string, 0, 0)
  17964. return edges
  17965. }
  17966. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17967. // name in this mutation.
  17968. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  17969. return nil
  17970. }
  17971. // RemovedEdges returns all edge names that were removed in this mutation.
  17972. func (m *CreditUsageMutation) RemovedEdges() []string {
  17973. edges := make([]string, 0, 0)
  17974. return edges
  17975. }
  17976. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17977. // the given name in this mutation.
  17978. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  17979. return nil
  17980. }
  17981. // ClearedEdges returns all edge names that were cleared in this mutation.
  17982. func (m *CreditUsageMutation) ClearedEdges() []string {
  17983. edges := make([]string, 0, 0)
  17984. return edges
  17985. }
  17986. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17987. // was cleared in this mutation.
  17988. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  17989. return false
  17990. }
  17991. // ClearEdge clears the value of the edge with the given name. It returns an error
  17992. // if that edge is not defined in the schema.
  17993. func (m *CreditUsageMutation) ClearEdge(name string) error {
  17994. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  17995. }
  17996. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17997. // It returns an error if the edge is not defined in the schema.
  17998. func (m *CreditUsageMutation) ResetEdge(name string) error {
  17999. return fmt.Errorf("unknown CreditUsage edge %s", name)
  18000. }
  18001. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  18002. type EmployeeMutation struct {
  18003. config
  18004. op Op
  18005. typ string
  18006. id *uint64
  18007. created_at *time.Time
  18008. updated_at *time.Time
  18009. deleted_at *time.Time
  18010. title *string
  18011. avatar *string
  18012. tags *string
  18013. hire_count *int
  18014. addhire_count *int
  18015. service_count *int
  18016. addservice_count *int
  18017. achievement_count *int
  18018. addachievement_count *int
  18019. intro *string
  18020. estimate *string
  18021. skill *string
  18022. ability_type *string
  18023. scene *string
  18024. switch_in *string
  18025. video_url *string
  18026. organization_id *uint64
  18027. addorganization_id *int64
  18028. category_id *uint64
  18029. addcategory_id *int64
  18030. api_base *string
  18031. api_key *string
  18032. ai_info *string
  18033. is_vip *int
  18034. addis_vip *int
  18035. chat_url *string
  18036. clearedFields map[string]struct{}
  18037. em_work_experiences map[uint64]struct{}
  18038. removedem_work_experiences map[uint64]struct{}
  18039. clearedem_work_experiences bool
  18040. em_tutorial map[uint64]struct{}
  18041. removedem_tutorial map[uint64]struct{}
  18042. clearedem_tutorial bool
  18043. done bool
  18044. oldValue func(context.Context) (*Employee, error)
  18045. predicates []predicate.Employee
  18046. }
  18047. var _ ent.Mutation = (*EmployeeMutation)(nil)
  18048. // employeeOption allows management of the mutation configuration using functional options.
  18049. type employeeOption func(*EmployeeMutation)
  18050. // newEmployeeMutation creates new mutation for the Employee entity.
  18051. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  18052. m := &EmployeeMutation{
  18053. config: c,
  18054. op: op,
  18055. typ: TypeEmployee,
  18056. clearedFields: make(map[string]struct{}),
  18057. }
  18058. for _, opt := range opts {
  18059. opt(m)
  18060. }
  18061. return m
  18062. }
  18063. // withEmployeeID sets the ID field of the mutation.
  18064. func withEmployeeID(id uint64) employeeOption {
  18065. return func(m *EmployeeMutation) {
  18066. var (
  18067. err error
  18068. once sync.Once
  18069. value *Employee
  18070. )
  18071. m.oldValue = func(ctx context.Context) (*Employee, error) {
  18072. once.Do(func() {
  18073. if m.done {
  18074. err = errors.New("querying old values post mutation is not allowed")
  18075. } else {
  18076. value, err = m.Client().Employee.Get(ctx, id)
  18077. }
  18078. })
  18079. return value, err
  18080. }
  18081. m.id = &id
  18082. }
  18083. }
  18084. // withEmployee sets the old Employee of the mutation.
  18085. func withEmployee(node *Employee) employeeOption {
  18086. return func(m *EmployeeMutation) {
  18087. m.oldValue = func(context.Context) (*Employee, error) {
  18088. return node, nil
  18089. }
  18090. m.id = &node.ID
  18091. }
  18092. }
  18093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18094. // executed in a transaction (ent.Tx), a transactional client is returned.
  18095. func (m EmployeeMutation) Client() *Client {
  18096. client := &Client{config: m.config}
  18097. client.init()
  18098. return client
  18099. }
  18100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18101. // it returns an error otherwise.
  18102. func (m EmployeeMutation) Tx() (*Tx, error) {
  18103. if _, ok := m.driver.(*txDriver); !ok {
  18104. return nil, errors.New("ent: mutation is not running in a transaction")
  18105. }
  18106. tx := &Tx{config: m.config}
  18107. tx.init()
  18108. return tx, nil
  18109. }
  18110. // SetID sets the value of the id field. Note that this
  18111. // operation is only accepted on creation of Employee entities.
  18112. func (m *EmployeeMutation) SetID(id uint64) {
  18113. m.id = &id
  18114. }
  18115. // ID returns the ID value in the mutation. Note that the ID is only available
  18116. // if it was provided to the builder or after it was returned from the database.
  18117. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  18118. if m.id == nil {
  18119. return
  18120. }
  18121. return *m.id, true
  18122. }
  18123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18124. // That means, if the mutation is applied within a transaction with an isolation level such
  18125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18126. // or updated by the mutation.
  18127. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  18128. switch {
  18129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18130. id, exists := m.ID()
  18131. if exists {
  18132. return []uint64{id}, nil
  18133. }
  18134. fallthrough
  18135. case m.op.Is(OpUpdate | OpDelete):
  18136. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  18137. default:
  18138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18139. }
  18140. }
  18141. // SetCreatedAt sets the "created_at" field.
  18142. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  18143. m.created_at = &t
  18144. }
  18145. // CreatedAt returns the value of the "created_at" field in the mutation.
  18146. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  18147. v := m.created_at
  18148. if v == nil {
  18149. return
  18150. }
  18151. return *v, true
  18152. }
  18153. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  18154. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18156. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18157. if !m.op.Is(OpUpdateOne) {
  18158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18159. }
  18160. if m.id == nil || m.oldValue == nil {
  18161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18162. }
  18163. oldValue, err := m.oldValue(ctx)
  18164. if err != nil {
  18165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18166. }
  18167. return oldValue.CreatedAt, nil
  18168. }
  18169. // ResetCreatedAt resets all changes to the "created_at" field.
  18170. func (m *EmployeeMutation) ResetCreatedAt() {
  18171. m.created_at = nil
  18172. }
  18173. // SetUpdatedAt sets the "updated_at" field.
  18174. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  18175. m.updated_at = &t
  18176. }
  18177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18178. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  18179. v := m.updated_at
  18180. if v == nil {
  18181. return
  18182. }
  18183. return *v, true
  18184. }
  18185. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  18186. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18188. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18189. if !m.op.Is(OpUpdateOne) {
  18190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18191. }
  18192. if m.id == nil || m.oldValue == nil {
  18193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18194. }
  18195. oldValue, err := m.oldValue(ctx)
  18196. if err != nil {
  18197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18198. }
  18199. return oldValue.UpdatedAt, nil
  18200. }
  18201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18202. func (m *EmployeeMutation) ResetUpdatedAt() {
  18203. m.updated_at = nil
  18204. }
  18205. // SetDeletedAt sets the "deleted_at" field.
  18206. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  18207. m.deleted_at = &t
  18208. }
  18209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18210. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  18211. v := m.deleted_at
  18212. if v == nil {
  18213. return
  18214. }
  18215. return *v, true
  18216. }
  18217. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  18218. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18220. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18221. if !m.op.Is(OpUpdateOne) {
  18222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18223. }
  18224. if m.id == nil || m.oldValue == nil {
  18225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18226. }
  18227. oldValue, err := m.oldValue(ctx)
  18228. if err != nil {
  18229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18230. }
  18231. return oldValue.DeletedAt, nil
  18232. }
  18233. // ClearDeletedAt clears the value of the "deleted_at" field.
  18234. func (m *EmployeeMutation) ClearDeletedAt() {
  18235. m.deleted_at = nil
  18236. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  18237. }
  18238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18239. func (m *EmployeeMutation) DeletedAtCleared() bool {
  18240. _, ok := m.clearedFields[employee.FieldDeletedAt]
  18241. return ok
  18242. }
  18243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18244. func (m *EmployeeMutation) ResetDeletedAt() {
  18245. m.deleted_at = nil
  18246. delete(m.clearedFields, employee.FieldDeletedAt)
  18247. }
  18248. // SetTitle sets the "title" field.
  18249. func (m *EmployeeMutation) SetTitle(s string) {
  18250. m.title = &s
  18251. }
  18252. // Title returns the value of the "title" field in the mutation.
  18253. func (m *EmployeeMutation) Title() (r string, exists bool) {
  18254. v := m.title
  18255. if v == nil {
  18256. return
  18257. }
  18258. return *v, true
  18259. }
  18260. // OldTitle returns the old "title" field's value of the Employee entity.
  18261. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18263. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  18264. if !m.op.Is(OpUpdateOne) {
  18265. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18266. }
  18267. if m.id == nil || m.oldValue == nil {
  18268. return v, errors.New("OldTitle requires an ID field in the mutation")
  18269. }
  18270. oldValue, err := m.oldValue(ctx)
  18271. if err != nil {
  18272. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18273. }
  18274. return oldValue.Title, nil
  18275. }
  18276. // ResetTitle resets all changes to the "title" field.
  18277. func (m *EmployeeMutation) ResetTitle() {
  18278. m.title = nil
  18279. }
  18280. // SetAvatar sets the "avatar" field.
  18281. func (m *EmployeeMutation) SetAvatar(s string) {
  18282. m.avatar = &s
  18283. }
  18284. // Avatar returns the value of the "avatar" field in the mutation.
  18285. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  18286. v := m.avatar
  18287. if v == nil {
  18288. return
  18289. }
  18290. return *v, true
  18291. }
  18292. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  18293. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18295. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  18296. if !m.op.Is(OpUpdateOne) {
  18297. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  18298. }
  18299. if m.id == nil || m.oldValue == nil {
  18300. return v, errors.New("OldAvatar requires an ID field in the mutation")
  18301. }
  18302. oldValue, err := m.oldValue(ctx)
  18303. if err != nil {
  18304. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  18305. }
  18306. return oldValue.Avatar, nil
  18307. }
  18308. // ResetAvatar resets all changes to the "avatar" field.
  18309. func (m *EmployeeMutation) ResetAvatar() {
  18310. m.avatar = nil
  18311. }
  18312. // SetTags sets the "tags" field.
  18313. func (m *EmployeeMutation) SetTags(s string) {
  18314. m.tags = &s
  18315. }
  18316. // Tags returns the value of the "tags" field in the mutation.
  18317. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  18318. v := m.tags
  18319. if v == nil {
  18320. return
  18321. }
  18322. return *v, true
  18323. }
  18324. // OldTags returns the old "tags" field's value of the Employee entity.
  18325. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18327. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  18328. if !m.op.Is(OpUpdateOne) {
  18329. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  18330. }
  18331. if m.id == nil || m.oldValue == nil {
  18332. return v, errors.New("OldTags requires an ID field in the mutation")
  18333. }
  18334. oldValue, err := m.oldValue(ctx)
  18335. if err != nil {
  18336. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  18337. }
  18338. return oldValue.Tags, nil
  18339. }
  18340. // ResetTags resets all changes to the "tags" field.
  18341. func (m *EmployeeMutation) ResetTags() {
  18342. m.tags = nil
  18343. }
  18344. // SetHireCount sets the "hire_count" field.
  18345. func (m *EmployeeMutation) SetHireCount(i int) {
  18346. m.hire_count = &i
  18347. m.addhire_count = nil
  18348. }
  18349. // HireCount returns the value of the "hire_count" field in the mutation.
  18350. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  18351. v := m.hire_count
  18352. if v == nil {
  18353. return
  18354. }
  18355. return *v, true
  18356. }
  18357. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  18358. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18360. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  18361. if !m.op.Is(OpUpdateOne) {
  18362. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  18363. }
  18364. if m.id == nil || m.oldValue == nil {
  18365. return v, errors.New("OldHireCount requires an ID field in the mutation")
  18366. }
  18367. oldValue, err := m.oldValue(ctx)
  18368. if err != nil {
  18369. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  18370. }
  18371. return oldValue.HireCount, nil
  18372. }
  18373. // AddHireCount adds i to the "hire_count" field.
  18374. func (m *EmployeeMutation) AddHireCount(i int) {
  18375. if m.addhire_count != nil {
  18376. *m.addhire_count += i
  18377. } else {
  18378. m.addhire_count = &i
  18379. }
  18380. }
  18381. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  18382. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  18383. v := m.addhire_count
  18384. if v == nil {
  18385. return
  18386. }
  18387. return *v, true
  18388. }
  18389. // ResetHireCount resets all changes to the "hire_count" field.
  18390. func (m *EmployeeMutation) ResetHireCount() {
  18391. m.hire_count = nil
  18392. m.addhire_count = nil
  18393. }
  18394. // SetServiceCount sets the "service_count" field.
  18395. func (m *EmployeeMutation) SetServiceCount(i int) {
  18396. m.service_count = &i
  18397. m.addservice_count = nil
  18398. }
  18399. // ServiceCount returns the value of the "service_count" field in the mutation.
  18400. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  18401. v := m.service_count
  18402. if v == nil {
  18403. return
  18404. }
  18405. return *v, true
  18406. }
  18407. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  18408. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18410. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  18411. if !m.op.Is(OpUpdateOne) {
  18412. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  18413. }
  18414. if m.id == nil || m.oldValue == nil {
  18415. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  18416. }
  18417. oldValue, err := m.oldValue(ctx)
  18418. if err != nil {
  18419. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  18420. }
  18421. return oldValue.ServiceCount, nil
  18422. }
  18423. // AddServiceCount adds i to the "service_count" field.
  18424. func (m *EmployeeMutation) AddServiceCount(i int) {
  18425. if m.addservice_count != nil {
  18426. *m.addservice_count += i
  18427. } else {
  18428. m.addservice_count = &i
  18429. }
  18430. }
  18431. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  18432. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  18433. v := m.addservice_count
  18434. if v == nil {
  18435. return
  18436. }
  18437. return *v, true
  18438. }
  18439. // ResetServiceCount resets all changes to the "service_count" field.
  18440. func (m *EmployeeMutation) ResetServiceCount() {
  18441. m.service_count = nil
  18442. m.addservice_count = nil
  18443. }
  18444. // SetAchievementCount sets the "achievement_count" field.
  18445. func (m *EmployeeMutation) SetAchievementCount(i int) {
  18446. m.achievement_count = &i
  18447. m.addachievement_count = nil
  18448. }
  18449. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  18450. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  18451. v := m.achievement_count
  18452. if v == nil {
  18453. return
  18454. }
  18455. return *v, true
  18456. }
  18457. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  18458. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18460. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  18461. if !m.op.Is(OpUpdateOne) {
  18462. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  18463. }
  18464. if m.id == nil || m.oldValue == nil {
  18465. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  18466. }
  18467. oldValue, err := m.oldValue(ctx)
  18468. if err != nil {
  18469. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  18470. }
  18471. return oldValue.AchievementCount, nil
  18472. }
  18473. // AddAchievementCount adds i to the "achievement_count" field.
  18474. func (m *EmployeeMutation) AddAchievementCount(i int) {
  18475. if m.addachievement_count != nil {
  18476. *m.addachievement_count += i
  18477. } else {
  18478. m.addachievement_count = &i
  18479. }
  18480. }
  18481. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  18482. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  18483. v := m.addachievement_count
  18484. if v == nil {
  18485. return
  18486. }
  18487. return *v, true
  18488. }
  18489. // ResetAchievementCount resets all changes to the "achievement_count" field.
  18490. func (m *EmployeeMutation) ResetAchievementCount() {
  18491. m.achievement_count = nil
  18492. m.addachievement_count = nil
  18493. }
  18494. // SetIntro sets the "intro" field.
  18495. func (m *EmployeeMutation) SetIntro(s string) {
  18496. m.intro = &s
  18497. }
  18498. // Intro returns the value of the "intro" field in the mutation.
  18499. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  18500. v := m.intro
  18501. if v == nil {
  18502. return
  18503. }
  18504. return *v, true
  18505. }
  18506. // OldIntro returns the old "intro" field's value of the Employee entity.
  18507. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18509. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  18510. if !m.op.Is(OpUpdateOne) {
  18511. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  18512. }
  18513. if m.id == nil || m.oldValue == nil {
  18514. return v, errors.New("OldIntro requires an ID field in the mutation")
  18515. }
  18516. oldValue, err := m.oldValue(ctx)
  18517. if err != nil {
  18518. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  18519. }
  18520. return oldValue.Intro, nil
  18521. }
  18522. // ResetIntro resets all changes to the "intro" field.
  18523. func (m *EmployeeMutation) ResetIntro() {
  18524. m.intro = nil
  18525. }
  18526. // SetEstimate sets the "estimate" field.
  18527. func (m *EmployeeMutation) SetEstimate(s string) {
  18528. m.estimate = &s
  18529. }
  18530. // Estimate returns the value of the "estimate" field in the mutation.
  18531. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  18532. v := m.estimate
  18533. if v == nil {
  18534. return
  18535. }
  18536. return *v, true
  18537. }
  18538. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  18539. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18541. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  18542. if !m.op.Is(OpUpdateOne) {
  18543. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  18544. }
  18545. if m.id == nil || m.oldValue == nil {
  18546. return v, errors.New("OldEstimate requires an ID field in the mutation")
  18547. }
  18548. oldValue, err := m.oldValue(ctx)
  18549. if err != nil {
  18550. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  18551. }
  18552. return oldValue.Estimate, nil
  18553. }
  18554. // ResetEstimate resets all changes to the "estimate" field.
  18555. func (m *EmployeeMutation) ResetEstimate() {
  18556. m.estimate = nil
  18557. }
  18558. // SetSkill sets the "skill" field.
  18559. func (m *EmployeeMutation) SetSkill(s string) {
  18560. m.skill = &s
  18561. }
  18562. // Skill returns the value of the "skill" field in the mutation.
  18563. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  18564. v := m.skill
  18565. if v == nil {
  18566. return
  18567. }
  18568. return *v, true
  18569. }
  18570. // OldSkill returns the old "skill" field's value of the Employee entity.
  18571. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18573. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  18574. if !m.op.Is(OpUpdateOne) {
  18575. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  18576. }
  18577. if m.id == nil || m.oldValue == nil {
  18578. return v, errors.New("OldSkill requires an ID field in the mutation")
  18579. }
  18580. oldValue, err := m.oldValue(ctx)
  18581. if err != nil {
  18582. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  18583. }
  18584. return oldValue.Skill, nil
  18585. }
  18586. // ResetSkill resets all changes to the "skill" field.
  18587. func (m *EmployeeMutation) ResetSkill() {
  18588. m.skill = nil
  18589. }
  18590. // SetAbilityType sets the "ability_type" field.
  18591. func (m *EmployeeMutation) SetAbilityType(s string) {
  18592. m.ability_type = &s
  18593. }
  18594. // AbilityType returns the value of the "ability_type" field in the mutation.
  18595. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  18596. v := m.ability_type
  18597. if v == nil {
  18598. return
  18599. }
  18600. return *v, true
  18601. }
  18602. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  18603. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18605. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  18606. if !m.op.Is(OpUpdateOne) {
  18607. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  18608. }
  18609. if m.id == nil || m.oldValue == nil {
  18610. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  18611. }
  18612. oldValue, err := m.oldValue(ctx)
  18613. if err != nil {
  18614. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  18615. }
  18616. return oldValue.AbilityType, nil
  18617. }
  18618. // ResetAbilityType resets all changes to the "ability_type" field.
  18619. func (m *EmployeeMutation) ResetAbilityType() {
  18620. m.ability_type = nil
  18621. }
  18622. // SetScene sets the "scene" field.
  18623. func (m *EmployeeMutation) SetScene(s string) {
  18624. m.scene = &s
  18625. }
  18626. // Scene returns the value of the "scene" field in the mutation.
  18627. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  18628. v := m.scene
  18629. if v == nil {
  18630. return
  18631. }
  18632. return *v, true
  18633. }
  18634. // OldScene returns the old "scene" field's value of the Employee entity.
  18635. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18637. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  18638. if !m.op.Is(OpUpdateOne) {
  18639. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  18640. }
  18641. if m.id == nil || m.oldValue == nil {
  18642. return v, errors.New("OldScene requires an ID field in the mutation")
  18643. }
  18644. oldValue, err := m.oldValue(ctx)
  18645. if err != nil {
  18646. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  18647. }
  18648. return oldValue.Scene, nil
  18649. }
  18650. // ResetScene resets all changes to the "scene" field.
  18651. func (m *EmployeeMutation) ResetScene() {
  18652. m.scene = nil
  18653. }
  18654. // SetSwitchIn sets the "switch_in" field.
  18655. func (m *EmployeeMutation) SetSwitchIn(s string) {
  18656. m.switch_in = &s
  18657. }
  18658. // SwitchIn returns the value of the "switch_in" field in the mutation.
  18659. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  18660. v := m.switch_in
  18661. if v == nil {
  18662. return
  18663. }
  18664. return *v, true
  18665. }
  18666. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  18667. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18669. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  18670. if !m.op.Is(OpUpdateOne) {
  18671. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  18672. }
  18673. if m.id == nil || m.oldValue == nil {
  18674. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  18675. }
  18676. oldValue, err := m.oldValue(ctx)
  18677. if err != nil {
  18678. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  18679. }
  18680. return oldValue.SwitchIn, nil
  18681. }
  18682. // ResetSwitchIn resets all changes to the "switch_in" field.
  18683. func (m *EmployeeMutation) ResetSwitchIn() {
  18684. m.switch_in = nil
  18685. }
  18686. // SetVideoURL sets the "video_url" field.
  18687. func (m *EmployeeMutation) SetVideoURL(s string) {
  18688. m.video_url = &s
  18689. }
  18690. // VideoURL returns the value of the "video_url" field in the mutation.
  18691. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  18692. v := m.video_url
  18693. if v == nil {
  18694. return
  18695. }
  18696. return *v, true
  18697. }
  18698. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  18699. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18701. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  18702. if !m.op.Is(OpUpdateOne) {
  18703. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  18704. }
  18705. if m.id == nil || m.oldValue == nil {
  18706. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  18707. }
  18708. oldValue, err := m.oldValue(ctx)
  18709. if err != nil {
  18710. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  18711. }
  18712. return oldValue.VideoURL, nil
  18713. }
  18714. // ResetVideoURL resets all changes to the "video_url" field.
  18715. func (m *EmployeeMutation) ResetVideoURL() {
  18716. m.video_url = nil
  18717. }
  18718. // SetOrganizationID sets the "organization_id" field.
  18719. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  18720. m.organization_id = &u
  18721. m.addorganization_id = nil
  18722. }
  18723. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18724. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  18725. v := m.organization_id
  18726. if v == nil {
  18727. return
  18728. }
  18729. return *v, true
  18730. }
  18731. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  18732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18734. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18735. if !m.op.Is(OpUpdateOne) {
  18736. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18737. }
  18738. if m.id == nil || m.oldValue == nil {
  18739. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18740. }
  18741. oldValue, err := m.oldValue(ctx)
  18742. if err != nil {
  18743. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18744. }
  18745. return oldValue.OrganizationID, nil
  18746. }
  18747. // AddOrganizationID adds u to the "organization_id" field.
  18748. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  18749. if m.addorganization_id != nil {
  18750. *m.addorganization_id += u
  18751. } else {
  18752. m.addorganization_id = &u
  18753. }
  18754. }
  18755. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18756. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  18757. v := m.addorganization_id
  18758. if v == nil {
  18759. return
  18760. }
  18761. return *v, true
  18762. }
  18763. // ResetOrganizationID resets all changes to the "organization_id" field.
  18764. func (m *EmployeeMutation) ResetOrganizationID() {
  18765. m.organization_id = nil
  18766. m.addorganization_id = nil
  18767. }
  18768. // SetCategoryID sets the "category_id" field.
  18769. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  18770. m.category_id = &u
  18771. m.addcategory_id = nil
  18772. }
  18773. // CategoryID returns the value of the "category_id" field in the mutation.
  18774. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  18775. v := m.category_id
  18776. if v == nil {
  18777. return
  18778. }
  18779. return *v, true
  18780. }
  18781. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  18782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18784. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  18785. if !m.op.Is(OpUpdateOne) {
  18786. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  18787. }
  18788. if m.id == nil || m.oldValue == nil {
  18789. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  18790. }
  18791. oldValue, err := m.oldValue(ctx)
  18792. if err != nil {
  18793. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  18794. }
  18795. return oldValue.CategoryID, nil
  18796. }
  18797. // AddCategoryID adds u to the "category_id" field.
  18798. func (m *EmployeeMutation) AddCategoryID(u int64) {
  18799. if m.addcategory_id != nil {
  18800. *m.addcategory_id += u
  18801. } else {
  18802. m.addcategory_id = &u
  18803. }
  18804. }
  18805. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  18806. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  18807. v := m.addcategory_id
  18808. if v == nil {
  18809. return
  18810. }
  18811. return *v, true
  18812. }
  18813. // ResetCategoryID resets all changes to the "category_id" field.
  18814. func (m *EmployeeMutation) ResetCategoryID() {
  18815. m.category_id = nil
  18816. m.addcategory_id = nil
  18817. }
  18818. // SetAPIBase sets the "api_base" field.
  18819. func (m *EmployeeMutation) SetAPIBase(s string) {
  18820. m.api_base = &s
  18821. }
  18822. // APIBase returns the value of the "api_base" field in the mutation.
  18823. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  18824. v := m.api_base
  18825. if v == nil {
  18826. return
  18827. }
  18828. return *v, true
  18829. }
  18830. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  18831. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18833. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18834. if !m.op.Is(OpUpdateOne) {
  18835. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18836. }
  18837. if m.id == nil || m.oldValue == nil {
  18838. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18839. }
  18840. oldValue, err := m.oldValue(ctx)
  18841. if err != nil {
  18842. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18843. }
  18844. return oldValue.APIBase, nil
  18845. }
  18846. // ResetAPIBase resets all changes to the "api_base" field.
  18847. func (m *EmployeeMutation) ResetAPIBase() {
  18848. m.api_base = nil
  18849. }
  18850. // SetAPIKey sets the "api_key" field.
  18851. func (m *EmployeeMutation) SetAPIKey(s string) {
  18852. m.api_key = &s
  18853. }
  18854. // APIKey returns the value of the "api_key" field in the mutation.
  18855. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  18856. v := m.api_key
  18857. if v == nil {
  18858. return
  18859. }
  18860. return *v, true
  18861. }
  18862. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  18863. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18865. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18866. if !m.op.Is(OpUpdateOne) {
  18867. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18868. }
  18869. if m.id == nil || m.oldValue == nil {
  18870. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18871. }
  18872. oldValue, err := m.oldValue(ctx)
  18873. if err != nil {
  18874. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  18875. }
  18876. return oldValue.APIKey, nil
  18877. }
  18878. // ResetAPIKey resets all changes to the "api_key" field.
  18879. func (m *EmployeeMutation) ResetAPIKey() {
  18880. m.api_key = nil
  18881. }
  18882. // SetAiInfo sets the "ai_info" field.
  18883. func (m *EmployeeMutation) SetAiInfo(s string) {
  18884. m.ai_info = &s
  18885. }
  18886. // AiInfo returns the value of the "ai_info" field in the mutation.
  18887. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  18888. v := m.ai_info
  18889. if v == nil {
  18890. return
  18891. }
  18892. return *v, true
  18893. }
  18894. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  18895. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18897. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  18898. if !m.op.Is(OpUpdateOne) {
  18899. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  18900. }
  18901. if m.id == nil || m.oldValue == nil {
  18902. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  18903. }
  18904. oldValue, err := m.oldValue(ctx)
  18905. if err != nil {
  18906. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  18907. }
  18908. return oldValue.AiInfo, nil
  18909. }
  18910. // ClearAiInfo clears the value of the "ai_info" field.
  18911. func (m *EmployeeMutation) ClearAiInfo() {
  18912. m.ai_info = nil
  18913. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  18914. }
  18915. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  18916. func (m *EmployeeMutation) AiInfoCleared() bool {
  18917. _, ok := m.clearedFields[employee.FieldAiInfo]
  18918. return ok
  18919. }
  18920. // ResetAiInfo resets all changes to the "ai_info" field.
  18921. func (m *EmployeeMutation) ResetAiInfo() {
  18922. m.ai_info = nil
  18923. delete(m.clearedFields, employee.FieldAiInfo)
  18924. }
  18925. // SetIsVip sets the "is_vip" field.
  18926. func (m *EmployeeMutation) SetIsVip(i int) {
  18927. m.is_vip = &i
  18928. m.addis_vip = nil
  18929. }
  18930. // IsVip returns the value of the "is_vip" field in the mutation.
  18931. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  18932. v := m.is_vip
  18933. if v == nil {
  18934. return
  18935. }
  18936. return *v, true
  18937. }
  18938. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  18939. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18941. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  18942. if !m.op.Is(OpUpdateOne) {
  18943. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  18944. }
  18945. if m.id == nil || m.oldValue == nil {
  18946. return v, errors.New("OldIsVip requires an ID field in the mutation")
  18947. }
  18948. oldValue, err := m.oldValue(ctx)
  18949. if err != nil {
  18950. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  18951. }
  18952. return oldValue.IsVip, nil
  18953. }
  18954. // AddIsVip adds i to the "is_vip" field.
  18955. func (m *EmployeeMutation) AddIsVip(i int) {
  18956. if m.addis_vip != nil {
  18957. *m.addis_vip += i
  18958. } else {
  18959. m.addis_vip = &i
  18960. }
  18961. }
  18962. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  18963. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  18964. v := m.addis_vip
  18965. if v == nil {
  18966. return
  18967. }
  18968. return *v, true
  18969. }
  18970. // ResetIsVip resets all changes to the "is_vip" field.
  18971. func (m *EmployeeMutation) ResetIsVip() {
  18972. m.is_vip = nil
  18973. m.addis_vip = nil
  18974. }
  18975. // SetChatURL sets the "chat_url" field.
  18976. func (m *EmployeeMutation) SetChatURL(s string) {
  18977. m.chat_url = &s
  18978. }
  18979. // ChatURL returns the value of the "chat_url" field in the mutation.
  18980. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  18981. v := m.chat_url
  18982. if v == nil {
  18983. return
  18984. }
  18985. return *v, true
  18986. }
  18987. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  18988. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18990. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  18991. if !m.op.Is(OpUpdateOne) {
  18992. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  18993. }
  18994. if m.id == nil || m.oldValue == nil {
  18995. return v, errors.New("OldChatURL requires an ID field in the mutation")
  18996. }
  18997. oldValue, err := m.oldValue(ctx)
  18998. if err != nil {
  18999. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  19000. }
  19001. return oldValue.ChatURL, nil
  19002. }
  19003. // ResetChatURL resets all changes to the "chat_url" field.
  19004. func (m *EmployeeMutation) ResetChatURL() {
  19005. m.chat_url = nil
  19006. }
  19007. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  19008. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  19009. if m.em_work_experiences == nil {
  19010. m.em_work_experiences = make(map[uint64]struct{})
  19011. }
  19012. for i := range ids {
  19013. m.em_work_experiences[ids[i]] = struct{}{}
  19014. }
  19015. }
  19016. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  19017. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  19018. m.clearedem_work_experiences = true
  19019. }
  19020. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  19021. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  19022. return m.clearedem_work_experiences
  19023. }
  19024. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  19025. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  19026. if m.removedem_work_experiences == nil {
  19027. m.removedem_work_experiences = make(map[uint64]struct{})
  19028. }
  19029. for i := range ids {
  19030. delete(m.em_work_experiences, ids[i])
  19031. m.removedem_work_experiences[ids[i]] = struct{}{}
  19032. }
  19033. }
  19034. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  19035. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  19036. for id := range m.removedem_work_experiences {
  19037. ids = append(ids, id)
  19038. }
  19039. return
  19040. }
  19041. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  19042. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  19043. for id := range m.em_work_experiences {
  19044. ids = append(ids, id)
  19045. }
  19046. return
  19047. }
  19048. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  19049. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  19050. m.em_work_experiences = nil
  19051. m.clearedem_work_experiences = false
  19052. m.removedem_work_experiences = nil
  19053. }
  19054. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  19055. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  19056. if m.em_tutorial == nil {
  19057. m.em_tutorial = make(map[uint64]struct{})
  19058. }
  19059. for i := range ids {
  19060. m.em_tutorial[ids[i]] = struct{}{}
  19061. }
  19062. }
  19063. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  19064. func (m *EmployeeMutation) ClearEmTutorial() {
  19065. m.clearedem_tutorial = true
  19066. }
  19067. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  19068. func (m *EmployeeMutation) EmTutorialCleared() bool {
  19069. return m.clearedem_tutorial
  19070. }
  19071. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  19072. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  19073. if m.removedem_tutorial == nil {
  19074. m.removedem_tutorial = make(map[uint64]struct{})
  19075. }
  19076. for i := range ids {
  19077. delete(m.em_tutorial, ids[i])
  19078. m.removedem_tutorial[ids[i]] = struct{}{}
  19079. }
  19080. }
  19081. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  19082. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  19083. for id := range m.removedem_tutorial {
  19084. ids = append(ids, id)
  19085. }
  19086. return
  19087. }
  19088. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  19089. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  19090. for id := range m.em_tutorial {
  19091. ids = append(ids, id)
  19092. }
  19093. return
  19094. }
  19095. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  19096. func (m *EmployeeMutation) ResetEmTutorial() {
  19097. m.em_tutorial = nil
  19098. m.clearedem_tutorial = false
  19099. m.removedem_tutorial = nil
  19100. }
  19101. // Where appends a list predicates to the EmployeeMutation builder.
  19102. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  19103. m.predicates = append(m.predicates, ps...)
  19104. }
  19105. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  19106. // users can use type-assertion to append predicates that do not depend on any generated package.
  19107. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  19108. p := make([]predicate.Employee, len(ps))
  19109. for i := range ps {
  19110. p[i] = ps[i]
  19111. }
  19112. m.Where(p...)
  19113. }
  19114. // Op returns the operation name.
  19115. func (m *EmployeeMutation) Op() Op {
  19116. return m.op
  19117. }
  19118. // SetOp allows setting the mutation operation.
  19119. func (m *EmployeeMutation) SetOp(op Op) {
  19120. m.op = op
  19121. }
  19122. // Type returns the node type of this mutation (Employee).
  19123. func (m *EmployeeMutation) Type() string {
  19124. return m.typ
  19125. }
  19126. // Fields returns all fields that were changed during this mutation. Note that in
  19127. // order to get all numeric fields that were incremented/decremented, call
  19128. // AddedFields().
  19129. func (m *EmployeeMutation) Fields() []string {
  19130. fields := make([]string, 0, 23)
  19131. if m.created_at != nil {
  19132. fields = append(fields, employee.FieldCreatedAt)
  19133. }
  19134. if m.updated_at != nil {
  19135. fields = append(fields, employee.FieldUpdatedAt)
  19136. }
  19137. if m.deleted_at != nil {
  19138. fields = append(fields, employee.FieldDeletedAt)
  19139. }
  19140. if m.title != nil {
  19141. fields = append(fields, employee.FieldTitle)
  19142. }
  19143. if m.avatar != nil {
  19144. fields = append(fields, employee.FieldAvatar)
  19145. }
  19146. if m.tags != nil {
  19147. fields = append(fields, employee.FieldTags)
  19148. }
  19149. if m.hire_count != nil {
  19150. fields = append(fields, employee.FieldHireCount)
  19151. }
  19152. if m.service_count != nil {
  19153. fields = append(fields, employee.FieldServiceCount)
  19154. }
  19155. if m.achievement_count != nil {
  19156. fields = append(fields, employee.FieldAchievementCount)
  19157. }
  19158. if m.intro != nil {
  19159. fields = append(fields, employee.FieldIntro)
  19160. }
  19161. if m.estimate != nil {
  19162. fields = append(fields, employee.FieldEstimate)
  19163. }
  19164. if m.skill != nil {
  19165. fields = append(fields, employee.FieldSkill)
  19166. }
  19167. if m.ability_type != nil {
  19168. fields = append(fields, employee.FieldAbilityType)
  19169. }
  19170. if m.scene != nil {
  19171. fields = append(fields, employee.FieldScene)
  19172. }
  19173. if m.switch_in != nil {
  19174. fields = append(fields, employee.FieldSwitchIn)
  19175. }
  19176. if m.video_url != nil {
  19177. fields = append(fields, employee.FieldVideoURL)
  19178. }
  19179. if m.organization_id != nil {
  19180. fields = append(fields, employee.FieldOrganizationID)
  19181. }
  19182. if m.category_id != nil {
  19183. fields = append(fields, employee.FieldCategoryID)
  19184. }
  19185. if m.api_base != nil {
  19186. fields = append(fields, employee.FieldAPIBase)
  19187. }
  19188. if m.api_key != nil {
  19189. fields = append(fields, employee.FieldAPIKey)
  19190. }
  19191. if m.ai_info != nil {
  19192. fields = append(fields, employee.FieldAiInfo)
  19193. }
  19194. if m.is_vip != nil {
  19195. fields = append(fields, employee.FieldIsVip)
  19196. }
  19197. if m.chat_url != nil {
  19198. fields = append(fields, employee.FieldChatURL)
  19199. }
  19200. return fields
  19201. }
  19202. // Field returns the value of a field with the given name. The second boolean
  19203. // return value indicates that this field was not set, or was not defined in the
  19204. // schema.
  19205. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  19206. switch name {
  19207. case employee.FieldCreatedAt:
  19208. return m.CreatedAt()
  19209. case employee.FieldUpdatedAt:
  19210. return m.UpdatedAt()
  19211. case employee.FieldDeletedAt:
  19212. return m.DeletedAt()
  19213. case employee.FieldTitle:
  19214. return m.Title()
  19215. case employee.FieldAvatar:
  19216. return m.Avatar()
  19217. case employee.FieldTags:
  19218. return m.Tags()
  19219. case employee.FieldHireCount:
  19220. return m.HireCount()
  19221. case employee.FieldServiceCount:
  19222. return m.ServiceCount()
  19223. case employee.FieldAchievementCount:
  19224. return m.AchievementCount()
  19225. case employee.FieldIntro:
  19226. return m.Intro()
  19227. case employee.FieldEstimate:
  19228. return m.Estimate()
  19229. case employee.FieldSkill:
  19230. return m.Skill()
  19231. case employee.FieldAbilityType:
  19232. return m.AbilityType()
  19233. case employee.FieldScene:
  19234. return m.Scene()
  19235. case employee.FieldSwitchIn:
  19236. return m.SwitchIn()
  19237. case employee.FieldVideoURL:
  19238. return m.VideoURL()
  19239. case employee.FieldOrganizationID:
  19240. return m.OrganizationID()
  19241. case employee.FieldCategoryID:
  19242. return m.CategoryID()
  19243. case employee.FieldAPIBase:
  19244. return m.APIBase()
  19245. case employee.FieldAPIKey:
  19246. return m.APIKey()
  19247. case employee.FieldAiInfo:
  19248. return m.AiInfo()
  19249. case employee.FieldIsVip:
  19250. return m.IsVip()
  19251. case employee.FieldChatURL:
  19252. return m.ChatURL()
  19253. }
  19254. return nil, false
  19255. }
  19256. // OldField returns the old value of the field from the database. An error is
  19257. // returned if the mutation operation is not UpdateOne, or the query to the
  19258. // database failed.
  19259. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19260. switch name {
  19261. case employee.FieldCreatedAt:
  19262. return m.OldCreatedAt(ctx)
  19263. case employee.FieldUpdatedAt:
  19264. return m.OldUpdatedAt(ctx)
  19265. case employee.FieldDeletedAt:
  19266. return m.OldDeletedAt(ctx)
  19267. case employee.FieldTitle:
  19268. return m.OldTitle(ctx)
  19269. case employee.FieldAvatar:
  19270. return m.OldAvatar(ctx)
  19271. case employee.FieldTags:
  19272. return m.OldTags(ctx)
  19273. case employee.FieldHireCount:
  19274. return m.OldHireCount(ctx)
  19275. case employee.FieldServiceCount:
  19276. return m.OldServiceCount(ctx)
  19277. case employee.FieldAchievementCount:
  19278. return m.OldAchievementCount(ctx)
  19279. case employee.FieldIntro:
  19280. return m.OldIntro(ctx)
  19281. case employee.FieldEstimate:
  19282. return m.OldEstimate(ctx)
  19283. case employee.FieldSkill:
  19284. return m.OldSkill(ctx)
  19285. case employee.FieldAbilityType:
  19286. return m.OldAbilityType(ctx)
  19287. case employee.FieldScene:
  19288. return m.OldScene(ctx)
  19289. case employee.FieldSwitchIn:
  19290. return m.OldSwitchIn(ctx)
  19291. case employee.FieldVideoURL:
  19292. return m.OldVideoURL(ctx)
  19293. case employee.FieldOrganizationID:
  19294. return m.OldOrganizationID(ctx)
  19295. case employee.FieldCategoryID:
  19296. return m.OldCategoryID(ctx)
  19297. case employee.FieldAPIBase:
  19298. return m.OldAPIBase(ctx)
  19299. case employee.FieldAPIKey:
  19300. return m.OldAPIKey(ctx)
  19301. case employee.FieldAiInfo:
  19302. return m.OldAiInfo(ctx)
  19303. case employee.FieldIsVip:
  19304. return m.OldIsVip(ctx)
  19305. case employee.FieldChatURL:
  19306. return m.OldChatURL(ctx)
  19307. }
  19308. return nil, fmt.Errorf("unknown Employee field %s", name)
  19309. }
  19310. // SetField sets the value of a field with the given name. It returns an error if
  19311. // the field is not defined in the schema, or if the type mismatched the field
  19312. // type.
  19313. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  19314. switch name {
  19315. case employee.FieldCreatedAt:
  19316. v, ok := value.(time.Time)
  19317. if !ok {
  19318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19319. }
  19320. m.SetCreatedAt(v)
  19321. return nil
  19322. case employee.FieldUpdatedAt:
  19323. v, ok := value.(time.Time)
  19324. if !ok {
  19325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19326. }
  19327. m.SetUpdatedAt(v)
  19328. return nil
  19329. case employee.FieldDeletedAt:
  19330. v, ok := value.(time.Time)
  19331. if !ok {
  19332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19333. }
  19334. m.SetDeletedAt(v)
  19335. return nil
  19336. case employee.FieldTitle:
  19337. v, ok := value.(string)
  19338. if !ok {
  19339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19340. }
  19341. m.SetTitle(v)
  19342. return nil
  19343. case employee.FieldAvatar:
  19344. v, ok := value.(string)
  19345. if !ok {
  19346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19347. }
  19348. m.SetAvatar(v)
  19349. return nil
  19350. case employee.FieldTags:
  19351. v, ok := value.(string)
  19352. if !ok {
  19353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19354. }
  19355. m.SetTags(v)
  19356. return nil
  19357. case employee.FieldHireCount:
  19358. v, ok := value.(int)
  19359. if !ok {
  19360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19361. }
  19362. m.SetHireCount(v)
  19363. return nil
  19364. case employee.FieldServiceCount:
  19365. v, ok := value.(int)
  19366. if !ok {
  19367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19368. }
  19369. m.SetServiceCount(v)
  19370. return nil
  19371. case employee.FieldAchievementCount:
  19372. v, ok := value.(int)
  19373. if !ok {
  19374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19375. }
  19376. m.SetAchievementCount(v)
  19377. return nil
  19378. case employee.FieldIntro:
  19379. v, ok := value.(string)
  19380. if !ok {
  19381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19382. }
  19383. m.SetIntro(v)
  19384. return nil
  19385. case employee.FieldEstimate:
  19386. v, ok := value.(string)
  19387. if !ok {
  19388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19389. }
  19390. m.SetEstimate(v)
  19391. return nil
  19392. case employee.FieldSkill:
  19393. v, ok := value.(string)
  19394. if !ok {
  19395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19396. }
  19397. m.SetSkill(v)
  19398. return nil
  19399. case employee.FieldAbilityType:
  19400. v, ok := value.(string)
  19401. if !ok {
  19402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19403. }
  19404. m.SetAbilityType(v)
  19405. return nil
  19406. case employee.FieldScene:
  19407. v, ok := value.(string)
  19408. if !ok {
  19409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19410. }
  19411. m.SetScene(v)
  19412. return nil
  19413. case employee.FieldSwitchIn:
  19414. v, ok := value.(string)
  19415. if !ok {
  19416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19417. }
  19418. m.SetSwitchIn(v)
  19419. return nil
  19420. case employee.FieldVideoURL:
  19421. v, ok := value.(string)
  19422. if !ok {
  19423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19424. }
  19425. m.SetVideoURL(v)
  19426. return nil
  19427. case employee.FieldOrganizationID:
  19428. v, ok := value.(uint64)
  19429. if !ok {
  19430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19431. }
  19432. m.SetOrganizationID(v)
  19433. return nil
  19434. case employee.FieldCategoryID:
  19435. v, ok := value.(uint64)
  19436. if !ok {
  19437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19438. }
  19439. m.SetCategoryID(v)
  19440. return nil
  19441. case employee.FieldAPIBase:
  19442. v, ok := value.(string)
  19443. if !ok {
  19444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19445. }
  19446. m.SetAPIBase(v)
  19447. return nil
  19448. case employee.FieldAPIKey:
  19449. v, ok := value.(string)
  19450. if !ok {
  19451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19452. }
  19453. m.SetAPIKey(v)
  19454. return nil
  19455. case employee.FieldAiInfo:
  19456. v, ok := value.(string)
  19457. if !ok {
  19458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19459. }
  19460. m.SetAiInfo(v)
  19461. return nil
  19462. case employee.FieldIsVip:
  19463. v, ok := value.(int)
  19464. if !ok {
  19465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19466. }
  19467. m.SetIsVip(v)
  19468. return nil
  19469. case employee.FieldChatURL:
  19470. v, ok := value.(string)
  19471. if !ok {
  19472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19473. }
  19474. m.SetChatURL(v)
  19475. return nil
  19476. }
  19477. return fmt.Errorf("unknown Employee field %s", name)
  19478. }
  19479. // AddedFields returns all numeric fields that were incremented/decremented during
  19480. // this mutation.
  19481. func (m *EmployeeMutation) AddedFields() []string {
  19482. var fields []string
  19483. if m.addhire_count != nil {
  19484. fields = append(fields, employee.FieldHireCount)
  19485. }
  19486. if m.addservice_count != nil {
  19487. fields = append(fields, employee.FieldServiceCount)
  19488. }
  19489. if m.addachievement_count != nil {
  19490. fields = append(fields, employee.FieldAchievementCount)
  19491. }
  19492. if m.addorganization_id != nil {
  19493. fields = append(fields, employee.FieldOrganizationID)
  19494. }
  19495. if m.addcategory_id != nil {
  19496. fields = append(fields, employee.FieldCategoryID)
  19497. }
  19498. if m.addis_vip != nil {
  19499. fields = append(fields, employee.FieldIsVip)
  19500. }
  19501. return fields
  19502. }
  19503. // AddedField returns the numeric value that was incremented/decremented on a field
  19504. // with the given name. The second boolean return value indicates that this field
  19505. // was not set, or was not defined in the schema.
  19506. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  19507. switch name {
  19508. case employee.FieldHireCount:
  19509. return m.AddedHireCount()
  19510. case employee.FieldServiceCount:
  19511. return m.AddedServiceCount()
  19512. case employee.FieldAchievementCount:
  19513. return m.AddedAchievementCount()
  19514. case employee.FieldOrganizationID:
  19515. return m.AddedOrganizationID()
  19516. case employee.FieldCategoryID:
  19517. return m.AddedCategoryID()
  19518. case employee.FieldIsVip:
  19519. return m.AddedIsVip()
  19520. }
  19521. return nil, false
  19522. }
  19523. // AddField adds the value to the field with the given name. It returns an error if
  19524. // the field is not defined in the schema, or if the type mismatched the field
  19525. // type.
  19526. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  19527. switch name {
  19528. case employee.FieldHireCount:
  19529. v, ok := value.(int)
  19530. if !ok {
  19531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19532. }
  19533. m.AddHireCount(v)
  19534. return nil
  19535. case employee.FieldServiceCount:
  19536. v, ok := value.(int)
  19537. if !ok {
  19538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19539. }
  19540. m.AddServiceCount(v)
  19541. return nil
  19542. case employee.FieldAchievementCount:
  19543. v, ok := value.(int)
  19544. if !ok {
  19545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19546. }
  19547. m.AddAchievementCount(v)
  19548. return nil
  19549. case employee.FieldOrganizationID:
  19550. v, ok := value.(int64)
  19551. if !ok {
  19552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19553. }
  19554. m.AddOrganizationID(v)
  19555. return nil
  19556. case employee.FieldCategoryID:
  19557. v, ok := value.(int64)
  19558. if !ok {
  19559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19560. }
  19561. m.AddCategoryID(v)
  19562. return nil
  19563. case employee.FieldIsVip:
  19564. v, ok := value.(int)
  19565. if !ok {
  19566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19567. }
  19568. m.AddIsVip(v)
  19569. return nil
  19570. }
  19571. return fmt.Errorf("unknown Employee numeric field %s", name)
  19572. }
  19573. // ClearedFields returns all nullable fields that were cleared during this
  19574. // mutation.
  19575. func (m *EmployeeMutation) ClearedFields() []string {
  19576. var fields []string
  19577. if m.FieldCleared(employee.FieldDeletedAt) {
  19578. fields = append(fields, employee.FieldDeletedAt)
  19579. }
  19580. if m.FieldCleared(employee.FieldAiInfo) {
  19581. fields = append(fields, employee.FieldAiInfo)
  19582. }
  19583. return fields
  19584. }
  19585. // FieldCleared returns a boolean indicating if a field with the given name was
  19586. // cleared in this mutation.
  19587. func (m *EmployeeMutation) FieldCleared(name string) bool {
  19588. _, ok := m.clearedFields[name]
  19589. return ok
  19590. }
  19591. // ClearField clears the value of the field with the given name. It returns an
  19592. // error if the field is not defined in the schema.
  19593. func (m *EmployeeMutation) ClearField(name string) error {
  19594. switch name {
  19595. case employee.FieldDeletedAt:
  19596. m.ClearDeletedAt()
  19597. return nil
  19598. case employee.FieldAiInfo:
  19599. m.ClearAiInfo()
  19600. return nil
  19601. }
  19602. return fmt.Errorf("unknown Employee nullable field %s", name)
  19603. }
  19604. // ResetField resets all changes in the mutation for the field with the given name.
  19605. // It returns an error if the field is not defined in the schema.
  19606. func (m *EmployeeMutation) ResetField(name string) error {
  19607. switch name {
  19608. case employee.FieldCreatedAt:
  19609. m.ResetCreatedAt()
  19610. return nil
  19611. case employee.FieldUpdatedAt:
  19612. m.ResetUpdatedAt()
  19613. return nil
  19614. case employee.FieldDeletedAt:
  19615. m.ResetDeletedAt()
  19616. return nil
  19617. case employee.FieldTitle:
  19618. m.ResetTitle()
  19619. return nil
  19620. case employee.FieldAvatar:
  19621. m.ResetAvatar()
  19622. return nil
  19623. case employee.FieldTags:
  19624. m.ResetTags()
  19625. return nil
  19626. case employee.FieldHireCount:
  19627. m.ResetHireCount()
  19628. return nil
  19629. case employee.FieldServiceCount:
  19630. m.ResetServiceCount()
  19631. return nil
  19632. case employee.FieldAchievementCount:
  19633. m.ResetAchievementCount()
  19634. return nil
  19635. case employee.FieldIntro:
  19636. m.ResetIntro()
  19637. return nil
  19638. case employee.FieldEstimate:
  19639. m.ResetEstimate()
  19640. return nil
  19641. case employee.FieldSkill:
  19642. m.ResetSkill()
  19643. return nil
  19644. case employee.FieldAbilityType:
  19645. m.ResetAbilityType()
  19646. return nil
  19647. case employee.FieldScene:
  19648. m.ResetScene()
  19649. return nil
  19650. case employee.FieldSwitchIn:
  19651. m.ResetSwitchIn()
  19652. return nil
  19653. case employee.FieldVideoURL:
  19654. m.ResetVideoURL()
  19655. return nil
  19656. case employee.FieldOrganizationID:
  19657. m.ResetOrganizationID()
  19658. return nil
  19659. case employee.FieldCategoryID:
  19660. m.ResetCategoryID()
  19661. return nil
  19662. case employee.FieldAPIBase:
  19663. m.ResetAPIBase()
  19664. return nil
  19665. case employee.FieldAPIKey:
  19666. m.ResetAPIKey()
  19667. return nil
  19668. case employee.FieldAiInfo:
  19669. m.ResetAiInfo()
  19670. return nil
  19671. case employee.FieldIsVip:
  19672. m.ResetIsVip()
  19673. return nil
  19674. case employee.FieldChatURL:
  19675. m.ResetChatURL()
  19676. return nil
  19677. }
  19678. return fmt.Errorf("unknown Employee field %s", name)
  19679. }
  19680. // AddedEdges returns all edge names that were set/added in this mutation.
  19681. func (m *EmployeeMutation) AddedEdges() []string {
  19682. edges := make([]string, 0, 2)
  19683. if m.em_work_experiences != nil {
  19684. edges = append(edges, employee.EdgeEmWorkExperiences)
  19685. }
  19686. if m.em_tutorial != nil {
  19687. edges = append(edges, employee.EdgeEmTutorial)
  19688. }
  19689. return edges
  19690. }
  19691. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19692. // name in this mutation.
  19693. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  19694. switch name {
  19695. case employee.EdgeEmWorkExperiences:
  19696. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  19697. for id := range m.em_work_experiences {
  19698. ids = append(ids, id)
  19699. }
  19700. return ids
  19701. case employee.EdgeEmTutorial:
  19702. ids := make([]ent.Value, 0, len(m.em_tutorial))
  19703. for id := range m.em_tutorial {
  19704. ids = append(ids, id)
  19705. }
  19706. return ids
  19707. }
  19708. return nil
  19709. }
  19710. // RemovedEdges returns all edge names that were removed in this mutation.
  19711. func (m *EmployeeMutation) RemovedEdges() []string {
  19712. edges := make([]string, 0, 2)
  19713. if m.removedem_work_experiences != nil {
  19714. edges = append(edges, employee.EdgeEmWorkExperiences)
  19715. }
  19716. if m.removedem_tutorial != nil {
  19717. edges = append(edges, employee.EdgeEmTutorial)
  19718. }
  19719. return edges
  19720. }
  19721. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19722. // the given name in this mutation.
  19723. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  19724. switch name {
  19725. case employee.EdgeEmWorkExperiences:
  19726. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  19727. for id := range m.removedem_work_experiences {
  19728. ids = append(ids, id)
  19729. }
  19730. return ids
  19731. case employee.EdgeEmTutorial:
  19732. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  19733. for id := range m.removedem_tutorial {
  19734. ids = append(ids, id)
  19735. }
  19736. return ids
  19737. }
  19738. return nil
  19739. }
  19740. // ClearedEdges returns all edge names that were cleared in this mutation.
  19741. func (m *EmployeeMutation) ClearedEdges() []string {
  19742. edges := make([]string, 0, 2)
  19743. if m.clearedem_work_experiences {
  19744. edges = append(edges, employee.EdgeEmWorkExperiences)
  19745. }
  19746. if m.clearedem_tutorial {
  19747. edges = append(edges, employee.EdgeEmTutorial)
  19748. }
  19749. return edges
  19750. }
  19751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19752. // was cleared in this mutation.
  19753. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  19754. switch name {
  19755. case employee.EdgeEmWorkExperiences:
  19756. return m.clearedem_work_experiences
  19757. case employee.EdgeEmTutorial:
  19758. return m.clearedem_tutorial
  19759. }
  19760. return false
  19761. }
  19762. // ClearEdge clears the value of the edge with the given name. It returns an error
  19763. // if that edge is not defined in the schema.
  19764. func (m *EmployeeMutation) ClearEdge(name string) error {
  19765. switch name {
  19766. }
  19767. return fmt.Errorf("unknown Employee unique edge %s", name)
  19768. }
  19769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19770. // It returns an error if the edge is not defined in the schema.
  19771. func (m *EmployeeMutation) ResetEdge(name string) error {
  19772. switch name {
  19773. case employee.EdgeEmWorkExperiences:
  19774. m.ResetEmWorkExperiences()
  19775. return nil
  19776. case employee.EdgeEmTutorial:
  19777. m.ResetEmTutorial()
  19778. return nil
  19779. }
  19780. return fmt.Errorf("unknown Employee edge %s", name)
  19781. }
  19782. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  19783. type EmployeeConfigMutation struct {
  19784. config
  19785. op Op
  19786. typ string
  19787. id *uint64
  19788. created_at *time.Time
  19789. updated_at *time.Time
  19790. deleted_at *time.Time
  19791. stype *string
  19792. title *string
  19793. photo *string
  19794. organization_id *uint64
  19795. addorganization_id *int64
  19796. clearedFields map[string]struct{}
  19797. done bool
  19798. oldValue func(context.Context) (*EmployeeConfig, error)
  19799. predicates []predicate.EmployeeConfig
  19800. }
  19801. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  19802. // employeeconfigOption allows management of the mutation configuration using functional options.
  19803. type employeeconfigOption func(*EmployeeConfigMutation)
  19804. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  19805. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  19806. m := &EmployeeConfigMutation{
  19807. config: c,
  19808. op: op,
  19809. typ: TypeEmployeeConfig,
  19810. clearedFields: make(map[string]struct{}),
  19811. }
  19812. for _, opt := range opts {
  19813. opt(m)
  19814. }
  19815. return m
  19816. }
  19817. // withEmployeeConfigID sets the ID field of the mutation.
  19818. func withEmployeeConfigID(id uint64) employeeconfigOption {
  19819. return func(m *EmployeeConfigMutation) {
  19820. var (
  19821. err error
  19822. once sync.Once
  19823. value *EmployeeConfig
  19824. )
  19825. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  19826. once.Do(func() {
  19827. if m.done {
  19828. err = errors.New("querying old values post mutation is not allowed")
  19829. } else {
  19830. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  19831. }
  19832. })
  19833. return value, err
  19834. }
  19835. m.id = &id
  19836. }
  19837. }
  19838. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  19839. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  19840. return func(m *EmployeeConfigMutation) {
  19841. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  19842. return node, nil
  19843. }
  19844. m.id = &node.ID
  19845. }
  19846. }
  19847. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19848. // executed in a transaction (ent.Tx), a transactional client is returned.
  19849. func (m EmployeeConfigMutation) Client() *Client {
  19850. client := &Client{config: m.config}
  19851. client.init()
  19852. return client
  19853. }
  19854. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19855. // it returns an error otherwise.
  19856. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  19857. if _, ok := m.driver.(*txDriver); !ok {
  19858. return nil, errors.New("ent: mutation is not running in a transaction")
  19859. }
  19860. tx := &Tx{config: m.config}
  19861. tx.init()
  19862. return tx, nil
  19863. }
  19864. // SetID sets the value of the id field. Note that this
  19865. // operation is only accepted on creation of EmployeeConfig entities.
  19866. func (m *EmployeeConfigMutation) SetID(id uint64) {
  19867. m.id = &id
  19868. }
  19869. // ID returns the ID value in the mutation. Note that the ID is only available
  19870. // if it was provided to the builder or after it was returned from the database.
  19871. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  19872. if m.id == nil {
  19873. return
  19874. }
  19875. return *m.id, true
  19876. }
  19877. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19878. // That means, if the mutation is applied within a transaction with an isolation level such
  19879. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19880. // or updated by the mutation.
  19881. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  19882. switch {
  19883. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19884. id, exists := m.ID()
  19885. if exists {
  19886. return []uint64{id}, nil
  19887. }
  19888. fallthrough
  19889. case m.op.Is(OpUpdate | OpDelete):
  19890. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  19891. default:
  19892. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19893. }
  19894. }
  19895. // SetCreatedAt sets the "created_at" field.
  19896. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  19897. m.created_at = &t
  19898. }
  19899. // CreatedAt returns the value of the "created_at" field in the mutation.
  19900. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  19901. v := m.created_at
  19902. if v == nil {
  19903. return
  19904. }
  19905. return *v, true
  19906. }
  19907. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  19908. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19910. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19911. if !m.op.Is(OpUpdateOne) {
  19912. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19913. }
  19914. if m.id == nil || m.oldValue == nil {
  19915. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19916. }
  19917. oldValue, err := m.oldValue(ctx)
  19918. if err != nil {
  19919. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19920. }
  19921. return oldValue.CreatedAt, nil
  19922. }
  19923. // ResetCreatedAt resets all changes to the "created_at" field.
  19924. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  19925. m.created_at = nil
  19926. }
  19927. // SetUpdatedAt sets the "updated_at" field.
  19928. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  19929. m.updated_at = &t
  19930. }
  19931. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19932. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  19933. v := m.updated_at
  19934. if v == nil {
  19935. return
  19936. }
  19937. return *v, true
  19938. }
  19939. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  19940. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19942. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19943. if !m.op.Is(OpUpdateOne) {
  19944. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19945. }
  19946. if m.id == nil || m.oldValue == nil {
  19947. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19948. }
  19949. oldValue, err := m.oldValue(ctx)
  19950. if err != nil {
  19951. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19952. }
  19953. return oldValue.UpdatedAt, nil
  19954. }
  19955. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19956. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  19957. m.updated_at = nil
  19958. }
  19959. // SetDeletedAt sets the "deleted_at" field.
  19960. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  19961. m.deleted_at = &t
  19962. }
  19963. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19964. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  19965. v := m.deleted_at
  19966. if v == nil {
  19967. return
  19968. }
  19969. return *v, true
  19970. }
  19971. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  19972. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19974. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19975. if !m.op.Is(OpUpdateOne) {
  19976. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19977. }
  19978. if m.id == nil || m.oldValue == nil {
  19979. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19980. }
  19981. oldValue, err := m.oldValue(ctx)
  19982. if err != nil {
  19983. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19984. }
  19985. return oldValue.DeletedAt, nil
  19986. }
  19987. // ClearDeletedAt clears the value of the "deleted_at" field.
  19988. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  19989. m.deleted_at = nil
  19990. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  19991. }
  19992. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19993. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  19994. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  19995. return ok
  19996. }
  19997. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19998. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  19999. m.deleted_at = nil
  20000. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  20001. }
  20002. // SetStype sets the "stype" field.
  20003. func (m *EmployeeConfigMutation) SetStype(s string) {
  20004. m.stype = &s
  20005. }
  20006. // Stype returns the value of the "stype" field in the mutation.
  20007. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  20008. v := m.stype
  20009. if v == nil {
  20010. return
  20011. }
  20012. return *v, true
  20013. }
  20014. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  20015. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20017. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  20018. if !m.op.Is(OpUpdateOne) {
  20019. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  20020. }
  20021. if m.id == nil || m.oldValue == nil {
  20022. return v, errors.New("OldStype requires an ID field in the mutation")
  20023. }
  20024. oldValue, err := m.oldValue(ctx)
  20025. if err != nil {
  20026. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  20027. }
  20028. return oldValue.Stype, nil
  20029. }
  20030. // ResetStype resets all changes to the "stype" field.
  20031. func (m *EmployeeConfigMutation) ResetStype() {
  20032. m.stype = nil
  20033. }
  20034. // SetTitle sets the "title" field.
  20035. func (m *EmployeeConfigMutation) SetTitle(s string) {
  20036. m.title = &s
  20037. }
  20038. // Title returns the value of the "title" field in the mutation.
  20039. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  20040. v := m.title
  20041. if v == nil {
  20042. return
  20043. }
  20044. return *v, true
  20045. }
  20046. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  20047. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20049. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  20050. if !m.op.Is(OpUpdateOne) {
  20051. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  20052. }
  20053. if m.id == nil || m.oldValue == nil {
  20054. return v, errors.New("OldTitle requires an ID field in the mutation")
  20055. }
  20056. oldValue, err := m.oldValue(ctx)
  20057. if err != nil {
  20058. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  20059. }
  20060. return oldValue.Title, nil
  20061. }
  20062. // ResetTitle resets all changes to the "title" field.
  20063. func (m *EmployeeConfigMutation) ResetTitle() {
  20064. m.title = nil
  20065. }
  20066. // SetPhoto sets the "photo" field.
  20067. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  20068. m.photo = &s
  20069. }
  20070. // Photo returns the value of the "photo" field in the mutation.
  20071. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  20072. v := m.photo
  20073. if v == nil {
  20074. return
  20075. }
  20076. return *v, true
  20077. }
  20078. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  20079. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20081. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  20082. if !m.op.Is(OpUpdateOne) {
  20083. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  20084. }
  20085. if m.id == nil || m.oldValue == nil {
  20086. return v, errors.New("OldPhoto requires an ID field in the mutation")
  20087. }
  20088. oldValue, err := m.oldValue(ctx)
  20089. if err != nil {
  20090. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  20091. }
  20092. return oldValue.Photo, nil
  20093. }
  20094. // ResetPhoto resets all changes to the "photo" field.
  20095. func (m *EmployeeConfigMutation) ResetPhoto() {
  20096. m.photo = nil
  20097. }
  20098. // SetOrganizationID sets the "organization_id" field.
  20099. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  20100. m.organization_id = &u
  20101. m.addorganization_id = nil
  20102. }
  20103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20104. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  20105. v := m.organization_id
  20106. if v == nil {
  20107. return
  20108. }
  20109. return *v, true
  20110. }
  20111. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  20112. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20114. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20115. if !m.op.Is(OpUpdateOne) {
  20116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20117. }
  20118. if m.id == nil || m.oldValue == nil {
  20119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20120. }
  20121. oldValue, err := m.oldValue(ctx)
  20122. if err != nil {
  20123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20124. }
  20125. return oldValue.OrganizationID, nil
  20126. }
  20127. // AddOrganizationID adds u to the "organization_id" field.
  20128. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  20129. if m.addorganization_id != nil {
  20130. *m.addorganization_id += u
  20131. } else {
  20132. m.addorganization_id = &u
  20133. }
  20134. }
  20135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20136. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  20137. v := m.addorganization_id
  20138. if v == nil {
  20139. return
  20140. }
  20141. return *v, true
  20142. }
  20143. // ClearOrganizationID clears the value of the "organization_id" field.
  20144. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  20145. m.organization_id = nil
  20146. m.addorganization_id = nil
  20147. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  20148. }
  20149. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20150. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  20151. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  20152. return ok
  20153. }
  20154. // ResetOrganizationID resets all changes to the "organization_id" field.
  20155. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  20156. m.organization_id = nil
  20157. m.addorganization_id = nil
  20158. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  20159. }
  20160. // Where appends a list predicates to the EmployeeConfigMutation builder.
  20161. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  20162. m.predicates = append(m.predicates, ps...)
  20163. }
  20164. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  20165. // users can use type-assertion to append predicates that do not depend on any generated package.
  20166. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  20167. p := make([]predicate.EmployeeConfig, len(ps))
  20168. for i := range ps {
  20169. p[i] = ps[i]
  20170. }
  20171. m.Where(p...)
  20172. }
  20173. // Op returns the operation name.
  20174. func (m *EmployeeConfigMutation) Op() Op {
  20175. return m.op
  20176. }
  20177. // SetOp allows setting the mutation operation.
  20178. func (m *EmployeeConfigMutation) SetOp(op Op) {
  20179. m.op = op
  20180. }
  20181. // Type returns the node type of this mutation (EmployeeConfig).
  20182. func (m *EmployeeConfigMutation) Type() string {
  20183. return m.typ
  20184. }
  20185. // Fields returns all fields that were changed during this mutation. Note that in
  20186. // order to get all numeric fields that were incremented/decremented, call
  20187. // AddedFields().
  20188. func (m *EmployeeConfigMutation) Fields() []string {
  20189. fields := make([]string, 0, 7)
  20190. if m.created_at != nil {
  20191. fields = append(fields, employeeconfig.FieldCreatedAt)
  20192. }
  20193. if m.updated_at != nil {
  20194. fields = append(fields, employeeconfig.FieldUpdatedAt)
  20195. }
  20196. if m.deleted_at != nil {
  20197. fields = append(fields, employeeconfig.FieldDeletedAt)
  20198. }
  20199. if m.stype != nil {
  20200. fields = append(fields, employeeconfig.FieldStype)
  20201. }
  20202. if m.title != nil {
  20203. fields = append(fields, employeeconfig.FieldTitle)
  20204. }
  20205. if m.photo != nil {
  20206. fields = append(fields, employeeconfig.FieldPhoto)
  20207. }
  20208. if m.organization_id != nil {
  20209. fields = append(fields, employeeconfig.FieldOrganizationID)
  20210. }
  20211. return fields
  20212. }
  20213. // Field returns the value of a field with the given name. The second boolean
  20214. // return value indicates that this field was not set, or was not defined in the
  20215. // schema.
  20216. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  20217. switch name {
  20218. case employeeconfig.FieldCreatedAt:
  20219. return m.CreatedAt()
  20220. case employeeconfig.FieldUpdatedAt:
  20221. return m.UpdatedAt()
  20222. case employeeconfig.FieldDeletedAt:
  20223. return m.DeletedAt()
  20224. case employeeconfig.FieldStype:
  20225. return m.Stype()
  20226. case employeeconfig.FieldTitle:
  20227. return m.Title()
  20228. case employeeconfig.FieldPhoto:
  20229. return m.Photo()
  20230. case employeeconfig.FieldOrganizationID:
  20231. return m.OrganizationID()
  20232. }
  20233. return nil, false
  20234. }
  20235. // OldField returns the old value of the field from the database. An error is
  20236. // returned if the mutation operation is not UpdateOne, or the query to the
  20237. // database failed.
  20238. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20239. switch name {
  20240. case employeeconfig.FieldCreatedAt:
  20241. return m.OldCreatedAt(ctx)
  20242. case employeeconfig.FieldUpdatedAt:
  20243. return m.OldUpdatedAt(ctx)
  20244. case employeeconfig.FieldDeletedAt:
  20245. return m.OldDeletedAt(ctx)
  20246. case employeeconfig.FieldStype:
  20247. return m.OldStype(ctx)
  20248. case employeeconfig.FieldTitle:
  20249. return m.OldTitle(ctx)
  20250. case employeeconfig.FieldPhoto:
  20251. return m.OldPhoto(ctx)
  20252. case employeeconfig.FieldOrganizationID:
  20253. return m.OldOrganizationID(ctx)
  20254. }
  20255. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  20256. }
  20257. // SetField sets the value of a field with the given name. It returns an error if
  20258. // the field is not defined in the schema, or if the type mismatched the field
  20259. // type.
  20260. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  20261. switch name {
  20262. case employeeconfig.FieldCreatedAt:
  20263. v, ok := value.(time.Time)
  20264. if !ok {
  20265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20266. }
  20267. m.SetCreatedAt(v)
  20268. return nil
  20269. case employeeconfig.FieldUpdatedAt:
  20270. v, ok := value.(time.Time)
  20271. if !ok {
  20272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20273. }
  20274. m.SetUpdatedAt(v)
  20275. return nil
  20276. case employeeconfig.FieldDeletedAt:
  20277. v, ok := value.(time.Time)
  20278. if !ok {
  20279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20280. }
  20281. m.SetDeletedAt(v)
  20282. return nil
  20283. case employeeconfig.FieldStype:
  20284. v, ok := value.(string)
  20285. if !ok {
  20286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20287. }
  20288. m.SetStype(v)
  20289. return nil
  20290. case employeeconfig.FieldTitle:
  20291. v, ok := value.(string)
  20292. if !ok {
  20293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20294. }
  20295. m.SetTitle(v)
  20296. return nil
  20297. case employeeconfig.FieldPhoto:
  20298. v, ok := value.(string)
  20299. if !ok {
  20300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20301. }
  20302. m.SetPhoto(v)
  20303. return nil
  20304. case employeeconfig.FieldOrganizationID:
  20305. v, ok := value.(uint64)
  20306. if !ok {
  20307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20308. }
  20309. m.SetOrganizationID(v)
  20310. return nil
  20311. }
  20312. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20313. }
  20314. // AddedFields returns all numeric fields that were incremented/decremented during
  20315. // this mutation.
  20316. func (m *EmployeeConfigMutation) AddedFields() []string {
  20317. var fields []string
  20318. if m.addorganization_id != nil {
  20319. fields = append(fields, employeeconfig.FieldOrganizationID)
  20320. }
  20321. return fields
  20322. }
  20323. // AddedField returns the numeric value that was incremented/decremented on a field
  20324. // with the given name. The second boolean return value indicates that this field
  20325. // was not set, or was not defined in the schema.
  20326. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  20327. switch name {
  20328. case employeeconfig.FieldOrganizationID:
  20329. return m.AddedOrganizationID()
  20330. }
  20331. return nil, false
  20332. }
  20333. // AddField adds the value to the field with the given name. It returns an error if
  20334. // the field is not defined in the schema, or if the type mismatched the field
  20335. // type.
  20336. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  20337. switch name {
  20338. case employeeconfig.FieldOrganizationID:
  20339. v, ok := value.(int64)
  20340. if !ok {
  20341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20342. }
  20343. m.AddOrganizationID(v)
  20344. return nil
  20345. }
  20346. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  20347. }
  20348. // ClearedFields returns all nullable fields that were cleared during this
  20349. // mutation.
  20350. func (m *EmployeeConfigMutation) ClearedFields() []string {
  20351. var fields []string
  20352. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  20353. fields = append(fields, employeeconfig.FieldDeletedAt)
  20354. }
  20355. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  20356. fields = append(fields, employeeconfig.FieldOrganizationID)
  20357. }
  20358. return fields
  20359. }
  20360. // FieldCleared returns a boolean indicating if a field with the given name was
  20361. // cleared in this mutation.
  20362. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  20363. _, ok := m.clearedFields[name]
  20364. return ok
  20365. }
  20366. // ClearField clears the value of the field with the given name. It returns an
  20367. // error if the field is not defined in the schema.
  20368. func (m *EmployeeConfigMutation) ClearField(name string) error {
  20369. switch name {
  20370. case employeeconfig.FieldDeletedAt:
  20371. m.ClearDeletedAt()
  20372. return nil
  20373. case employeeconfig.FieldOrganizationID:
  20374. m.ClearOrganizationID()
  20375. return nil
  20376. }
  20377. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  20378. }
  20379. // ResetField resets all changes in the mutation for the field with the given name.
  20380. // It returns an error if the field is not defined in the schema.
  20381. func (m *EmployeeConfigMutation) ResetField(name string) error {
  20382. switch name {
  20383. case employeeconfig.FieldCreatedAt:
  20384. m.ResetCreatedAt()
  20385. return nil
  20386. case employeeconfig.FieldUpdatedAt:
  20387. m.ResetUpdatedAt()
  20388. return nil
  20389. case employeeconfig.FieldDeletedAt:
  20390. m.ResetDeletedAt()
  20391. return nil
  20392. case employeeconfig.FieldStype:
  20393. m.ResetStype()
  20394. return nil
  20395. case employeeconfig.FieldTitle:
  20396. m.ResetTitle()
  20397. return nil
  20398. case employeeconfig.FieldPhoto:
  20399. m.ResetPhoto()
  20400. return nil
  20401. case employeeconfig.FieldOrganizationID:
  20402. m.ResetOrganizationID()
  20403. return nil
  20404. }
  20405. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20406. }
  20407. // AddedEdges returns all edge names that were set/added in this mutation.
  20408. func (m *EmployeeConfigMutation) AddedEdges() []string {
  20409. edges := make([]string, 0, 0)
  20410. return edges
  20411. }
  20412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20413. // name in this mutation.
  20414. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  20415. return nil
  20416. }
  20417. // RemovedEdges returns all edge names that were removed in this mutation.
  20418. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  20419. edges := make([]string, 0, 0)
  20420. return edges
  20421. }
  20422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20423. // the given name in this mutation.
  20424. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  20425. return nil
  20426. }
  20427. // ClearedEdges returns all edge names that were cleared in this mutation.
  20428. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  20429. edges := make([]string, 0, 0)
  20430. return edges
  20431. }
  20432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20433. // was cleared in this mutation.
  20434. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  20435. return false
  20436. }
  20437. // ClearEdge clears the value of the edge with the given name. It returns an error
  20438. // if that edge is not defined in the schema.
  20439. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  20440. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  20441. }
  20442. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20443. // It returns an error if the edge is not defined in the schema.
  20444. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  20445. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  20446. }
  20447. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  20448. type LabelMutation struct {
  20449. config
  20450. op Op
  20451. typ string
  20452. id *uint64
  20453. created_at *time.Time
  20454. updated_at *time.Time
  20455. status *uint8
  20456. addstatus *int8
  20457. deleted_at *time.Time
  20458. _type *int
  20459. add_type *int
  20460. name *string
  20461. from *int
  20462. addfrom *int
  20463. mode *int
  20464. addmode *int
  20465. conditions *string
  20466. organization_id *uint64
  20467. addorganization_id *int64
  20468. clearedFields map[string]struct{}
  20469. label_relationships map[uint64]struct{}
  20470. removedlabel_relationships map[uint64]struct{}
  20471. clearedlabel_relationships bool
  20472. done bool
  20473. oldValue func(context.Context) (*Label, error)
  20474. predicates []predicate.Label
  20475. }
  20476. var _ ent.Mutation = (*LabelMutation)(nil)
  20477. // labelOption allows management of the mutation configuration using functional options.
  20478. type labelOption func(*LabelMutation)
  20479. // newLabelMutation creates new mutation for the Label entity.
  20480. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  20481. m := &LabelMutation{
  20482. config: c,
  20483. op: op,
  20484. typ: TypeLabel,
  20485. clearedFields: make(map[string]struct{}),
  20486. }
  20487. for _, opt := range opts {
  20488. opt(m)
  20489. }
  20490. return m
  20491. }
  20492. // withLabelID sets the ID field of the mutation.
  20493. func withLabelID(id uint64) labelOption {
  20494. return func(m *LabelMutation) {
  20495. var (
  20496. err error
  20497. once sync.Once
  20498. value *Label
  20499. )
  20500. m.oldValue = func(ctx context.Context) (*Label, error) {
  20501. once.Do(func() {
  20502. if m.done {
  20503. err = errors.New("querying old values post mutation is not allowed")
  20504. } else {
  20505. value, err = m.Client().Label.Get(ctx, id)
  20506. }
  20507. })
  20508. return value, err
  20509. }
  20510. m.id = &id
  20511. }
  20512. }
  20513. // withLabel sets the old Label of the mutation.
  20514. func withLabel(node *Label) labelOption {
  20515. return func(m *LabelMutation) {
  20516. m.oldValue = func(context.Context) (*Label, error) {
  20517. return node, nil
  20518. }
  20519. m.id = &node.ID
  20520. }
  20521. }
  20522. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20523. // executed in a transaction (ent.Tx), a transactional client is returned.
  20524. func (m LabelMutation) Client() *Client {
  20525. client := &Client{config: m.config}
  20526. client.init()
  20527. return client
  20528. }
  20529. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20530. // it returns an error otherwise.
  20531. func (m LabelMutation) Tx() (*Tx, error) {
  20532. if _, ok := m.driver.(*txDriver); !ok {
  20533. return nil, errors.New("ent: mutation is not running in a transaction")
  20534. }
  20535. tx := &Tx{config: m.config}
  20536. tx.init()
  20537. return tx, nil
  20538. }
  20539. // SetID sets the value of the id field. Note that this
  20540. // operation is only accepted on creation of Label entities.
  20541. func (m *LabelMutation) SetID(id uint64) {
  20542. m.id = &id
  20543. }
  20544. // ID returns the ID value in the mutation. Note that the ID is only available
  20545. // if it was provided to the builder or after it was returned from the database.
  20546. func (m *LabelMutation) ID() (id uint64, exists bool) {
  20547. if m.id == nil {
  20548. return
  20549. }
  20550. return *m.id, true
  20551. }
  20552. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20553. // That means, if the mutation is applied within a transaction with an isolation level such
  20554. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20555. // or updated by the mutation.
  20556. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  20557. switch {
  20558. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20559. id, exists := m.ID()
  20560. if exists {
  20561. return []uint64{id}, nil
  20562. }
  20563. fallthrough
  20564. case m.op.Is(OpUpdate | OpDelete):
  20565. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  20566. default:
  20567. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20568. }
  20569. }
  20570. // SetCreatedAt sets the "created_at" field.
  20571. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  20572. m.created_at = &t
  20573. }
  20574. // CreatedAt returns the value of the "created_at" field in the mutation.
  20575. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  20576. v := m.created_at
  20577. if v == nil {
  20578. return
  20579. }
  20580. return *v, true
  20581. }
  20582. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  20583. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20585. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20586. if !m.op.Is(OpUpdateOne) {
  20587. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20588. }
  20589. if m.id == nil || m.oldValue == nil {
  20590. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20591. }
  20592. oldValue, err := m.oldValue(ctx)
  20593. if err != nil {
  20594. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20595. }
  20596. return oldValue.CreatedAt, nil
  20597. }
  20598. // ResetCreatedAt resets all changes to the "created_at" field.
  20599. func (m *LabelMutation) ResetCreatedAt() {
  20600. m.created_at = nil
  20601. }
  20602. // SetUpdatedAt sets the "updated_at" field.
  20603. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  20604. m.updated_at = &t
  20605. }
  20606. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20607. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  20608. v := m.updated_at
  20609. if v == nil {
  20610. return
  20611. }
  20612. return *v, true
  20613. }
  20614. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  20615. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20617. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20618. if !m.op.Is(OpUpdateOne) {
  20619. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20620. }
  20621. if m.id == nil || m.oldValue == nil {
  20622. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20623. }
  20624. oldValue, err := m.oldValue(ctx)
  20625. if err != nil {
  20626. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20627. }
  20628. return oldValue.UpdatedAt, nil
  20629. }
  20630. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20631. func (m *LabelMutation) ResetUpdatedAt() {
  20632. m.updated_at = nil
  20633. }
  20634. // SetStatus sets the "status" field.
  20635. func (m *LabelMutation) SetStatus(u uint8) {
  20636. m.status = &u
  20637. m.addstatus = nil
  20638. }
  20639. // Status returns the value of the "status" field in the mutation.
  20640. func (m *LabelMutation) Status() (r uint8, exists bool) {
  20641. v := m.status
  20642. if v == nil {
  20643. return
  20644. }
  20645. return *v, true
  20646. }
  20647. // OldStatus returns the old "status" field's value of the Label entity.
  20648. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20650. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20651. if !m.op.Is(OpUpdateOne) {
  20652. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20653. }
  20654. if m.id == nil || m.oldValue == nil {
  20655. return v, errors.New("OldStatus requires an ID field in the mutation")
  20656. }
  20657. oldValue, err := m.oldValue(ctx)
  20658. if err != nil {
  20659. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20660. }
  20661. return oldValue.Status, nil
  20662. }
  20663. // AddStatus adds u to the "status" field.
  20664. func (m *LabelMutation) AddStatus(u int8) {
  20665. if m.addstatus != nil {
  20666. *m.addstatus += u
  20667. } else {
  20668. m.addstatus = &u
  20669. }
  20670. }
  20671. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20672. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  20673. v := m.addstatus
  20674. if v == nil {
  20675. return
  20676. }
  20677. return *v, true
  20678. }
  20679. // ClearStatus clears the value of the "status" field.
  20680. func (m *LabelMutation) ClearStatus() {
  20681. m.status = nil
  20682. m.addstatus = nil
  20683. m.clearedFields[label.FieldStatus] = struct{}{}
  20684. }
  20685. // StatusCleared returns if the "status" field was cleared in this mutation.
  20686. func (m *LabelMutation) StatusCleared() bool {
  20687. _, ok := m.clearedFields[label.FieldStatus]
  20688. return ok
  20689. }
  20690. // ResetStatus resets all changes to the "status" field.
  20691. func (m *LabelMutation) ResetStatus() {
  20692. m.status = nil
  20693. m.addstatus = nil
  20694. delete(m.clearedFields, label.FieldStatus)
  20695. }
  20696. // SetDeletedAt sets the "deleted_at" field.
  20697. func (m *LabelMutation) SetDeletedAt(t time.Time) {
  20698. m.deleted_at = &t
  20699. }
  20700. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20701. func (m *LabelMutation) DeletedAt() (r time.Time, exists bool) {
  20702. v := m.deleted_at
  20703. if v == nil {
  20704. return
  20705. }
  20706. return *v, true
  20707. }
  20708. // OldDeletedAt returns the old "deleted_at" field's value of the Label entity.
  20709. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20711. func (m *LabelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20712. if !m.op.Is(OpUpdateOne) {
  20713. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20714. }
  20715. if m.id == nil || m.oldValue == nil {
  20716. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20717. }
  20718. oldValue, err := m.oldValue(ctx)
  20719. if err != nil {
  20720. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20721. }
  20722. return oldValue.DeletedAt, nil
  20723. }
  20724. // ClearDeletedAt clears the value of the "deleted_at" field.
  20725. func (m *LabelMutation) ClearDeletedAt() {
  20726. m.deleted_at = nil
  20727. m.clearedFields[label.FieldDeletedAt] = struct{}{}
  20728. }
  20729. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20730. func (m *LabelMutation) DeletedAtCleared() bool {
  20731. _, ok := m.clearedFields[label.FieldDeletedAt]
  20732. return ok
  20733. }
  20734. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20735. func (m *LabelMutation) ResetDeletedAt() {
  20736. m.deleted_at = nil
  20737. delete(m.clearedFields, label.FieldDeletedAt)
  20738. }
  20739. // SetType sets the "type" field.
  20740. func (m *LabelMutation) SetType(i int) {
  20741. m._type = &i
  20742. m.add_type = nil
  20743. }
  20744. // GetType returns the value of the "type" field in the mutation.
  20745. func (m *LabelMutation) GetType() (r int, exists bool) {
  20746. v := m._type
  20747. if v == nil {
  20748. return
  20749. }
  20750. return *v, true
  20751. }
  20752. // OldType returns the old "type" field's value of the Label entity.
  20753. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20755. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  20756. if !m.op.Is(OpUpdateOne) {
  20757. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20758. }
  20759. if m.id == nil || m.oldValue == nil {
  20760. return v, errors.New("OldType requires an ID field in the mutation")
  20761. }
  20762. oldValue, err := m.oldValue(ctx)
  20763. if err != nil {
  20764. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20765. }
  20766. return oldValue.Type, nil
  20767. }
  20768. // AddType adds i to the "type" field.
  20769. func (m *LabelMutation) AddType(i int) {
  20770. if m.add_type != nil {
  20771. *m.add_type += i
  20772. } else {
  20773. m.add_type = &i
  20774. }
  20775. }
  20776. // AddedType returns the value that was added to the "type" field in this mutation.
  20777. func (m *LabelMutation) AddedType() (r int, exists bool) {
  20778. v := m.add_type
  20779. if v == nil {
  20780. return
  20781. }
  20782. return *v, true
  20783. }
  20784. // ResetType resets all changes to the "type" field.
  20785. func (m *LabelMutation) ResetType() {
  20786. m._type = nil
  20787. m.add_type = nil
  20788. }
  20789. // SetName sets the "name" field.
  20790. func (m *LabelMutation) SetName(s string) {
  20791. m.name = &s
  20792. }
  20793. // Name returns the value of the "name" field in the mutation.
  20794. func (m *LabelMutation) Name() (r string, exists bool) {
  20795. v := m.name
  20796. if v == nil {
  20797. return
  20798. }
  20799. return *v, true
  20800. }
  20801. // OldName returns the old "name" field's value of the Label entity.
  20802. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20804. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  20805. if !m.op.Is(OpUpdateOne) {
  20806. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20807. }
  20808. if m.id == nil || m.oldValue == nil {
  20809. return v, errors.New("OldName requires an ID field in the mutation")
  20810. }
  20811. oldValue, err := m.oldValue(ctx)
  20812. if err != nil {
  20813. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20814. }
  20815. return oldValue.Name, nil
  20816. }
  20817. // ResetName resets all changes to the "name" field.
  20818. func (m *LabelMutation) ResetName() {
  20819. m.name = nil
  20820. }
  20821. // SetFrom sets the "from" field.
  20822. func (m *LabelMutation) SetFrom(i int) {
  20823. m.from = &i
  20824. m.addfrom = nil
  20825. }
  20826. // From returns the value of the "from" field in the mutation.
  20827. func (m *LabelMutation) From() (r int, exists bool) {
  20828. v := m.from
  20829. if v == nil {
  20830. return
  20831. }
  20832. return *v, true
  20833. }
  20834. // OldFrom returns the old "from" field's value of the Label entity.
  20835. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20837. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  20838. if !m.op.Is(OpUpdateOne) {
  20839. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  20840. }
  20841. if m.id == nil || m.oldValue == nil {
  20842. return v, errors.New("OldFrom requires an ID field in the mutation")
  20843. }
  20844. oldValue, err := m.oldValue(ctx)
  20845. if err != nil {
  20846. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  20847. }
  20848. return oldValue.From, nil
  20849. }
  20850. // AddFrom adds i to the "from" field.
  20851. func (m *LabelMutation) AddFrom(i int) {
  20852. if m.addfrom != nil {
  20853. *m.addfrom += i
  20854. } else {
  20855. m.addfrom = &i
  20856. }
  20857. }
  20858. // AddedFrom returns the value that was added to the "from" field in this mutation.
  20859. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  20860. v := m.addfrom
  20861. if v == nil {
  20862. return
  20863. }
  20864. return *v, true
  20865. }
  20866. // ResetFrom resets all changes to the "from" field.
  20867. func (m *LabelMutation) ResetFrom() {
  20868. m.from = nil
  20869. m.addfrom = nil
  20870. }
  20871. // SetMode sets the "mode" field.
  20872. func (m *LabelMutation) SetMode(i int) {
  20873. m.mode = &i
  20874. m.addmode = nil
  20875. }
  20876. // Mode returns the value of the "mode" field in the mutation.
  20877. func (m *LabelMutation) Mode() (r int, exists bool) {
  20878. v := m.mode
  20879. if v == nil {
  20880. return
  20881. }
  20882. return *v, true
  20883. }
  20884. // OldMode returns the old "mode" field's value of the Label entity.
  20885. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20887. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  20888. if !m.op.Is(OpUpdateOne) {
  20889. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  20890. }
  20891. if m.id == nil || m.oldValue == nil {
  20892. return v, errors.New("OldMode requires an ID field in the mutation")
  20893. }
  20894. oldValue, err := m.oldValue(ctx)
  20895. if err != nil {
  20896. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  20897. }
  20898. return oldValue.Mode, nil
  20899. }
  20900. // AddMode adds i to the "mode" field.
  20901. func (m *LabelMutation) AddMode(i int) {
  20902. if m.addmode != nil {
  20903. *m.addmode += i
  20904. } else {
  20905. m.addmode = &i
  20906. }
  20907. }
  20908. // AddedMode returns the value that was added to the "mode" field in this mutation.
  20909. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  20910. v := m.addmode
  20911. if v == nil {
  20912. return
  20913. }
  20914. return *v, true
  20915. }
  20916. // ResetMode resets all changes to the "mode" field.
  20917. func (m *LabelMutation) ResetMode() {
  20918. m.mode = nil
  20919. m.addmode = nil
  20920. }
  20921. // SetConditions sets the "conditions" field.
  20922. func (m *LabelMutation) SetConditions(s string) {
  20923. m.conditions = &s
  20924. }
  20925. // Conditions returns the value of the "conditions" field in the mutation.
  20926. func (m *LabelMutation) Conditions() (r string, exists bool) {
  20927. v := m.conditions
  20928. if v == nil {
  20929. return
  20930. }
  20931. return *v, true
  20932. }
  20933. // OldConditions returns the old "conditions" field's value of the Label entity.
  20934. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20936. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  20937. if !m.op.Is(OpUpdateOne) {
  20938. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20939. }
  20940. if m.id == nil || m.oldValue == nil {
  20941. return v, errors.New("OldConditions requires an ID field in the mutation")
  20942. }
  20943. oldValue, err := m.oldValue(ctx)
  20944. if err != nil {
  20945. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20946. }
  20947. return oldValue.Conditions, nil
  20948. }
  20949. // ClearConditions clears the value of the "conditions" field.
  20950. func (m *LabelMutation) ClearConditions() {
  20951. m.conditions = nil
  20952. m.clearedFields[label.FieldConditions] = struct{}{}
  20953. }
  20954. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  20955. func (m *LabelMutation) ConditionsCleared() bool {
  20956. _, ok := m.clearedFields[label.FieldConditions]
  20957. return ok
  20958. }
  20959. // ResetConditions resets all changes to the "conditions" field.
  20960. func (m *LabelMutation) ResetConditions() {
  20961. m.conditions = nil
  20962. delete(m.clearedFields, label.FieldConditions)
  20963. }
  20964. // SetOrganizationID sets the "organization_id" field.
  20965. func (m *LabelMutation) SetOrganizationID(u uint64) {
  20966. m.organization_id = &u
  20967. m.addorganization_id = nil
  20968. }
  20969. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20970. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  20971. v := m.organization_id
  20972. if v == nil {
  20973. return
  20974. }
  20975. return *v, true
  20976. }
  20977. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  20978. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20980. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20981. if !m.op.Is(OpUpdateOne) {
  20982. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20983. }
  20984. if m.id == nil || m.oldValue == nil {
  20985. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20986. }
  20987. oldValue, err := m.oldValue(ctx)
  20988. if err != nil {
  20989. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20990. }
  20991. return oldValue.OrganizationID, nil
  20992. }
  20993. // AddOrganizationID adds u to the "organization_id" field.
  20994. func (m *LabelMutation) AddOrganizationID(u int64) {
  20995. if m.addorganization_id != nil {
  20996. *m.addorganization_id += u
  20997. } else {
  20998. m.addorganization_id = &u
  20999. }
  21000. }
  21001. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21002. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  21003. v := m.addorganization_id
  21004. if v == nil {
  21005. return
  21006. }
  21007. return *v, true
  21008. }
  21009. // ClearOrganizationID clears the value of the "organization_id" field.
  21010. func (m *LabelMutation) ClearOrganizationID() {
  21011. m.organization_id = nil
  21012. m.addorganization_id = nil
  21013. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  21014. }
  21015. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21016. func (m *LabelMutation) OrganizationIDCleared() bool {
  21017. _, ok := m.clearedFields[label.FieldOrganizationID]
  21018. return ok
  21019. }
  21020. // ResetOrganizationID resets all changes to the "organization_id" field.
  21021. func (m *LabelMutation) ResetOrganizationID() {
  21022. m.organization_id = nil
  21023. m.addorganization_id = nil
  21024. delete(m.clearedFields, label.FieldOrganizationID)
  21025. }
  21026. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  21027. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  21028. if m.label_relationships == nil {
  21029. m.label_relationships = make(map[uint64]struct{})
  21030. }
  21031. for i := range ids {
  21032. m.label_relationships[ids[i]] = struct{}{}
  21033. }
  21034. }
  21035. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  21036. func (m *LabelMutation) ClearLabelRelationships() {
  21037. m.clearedlabel_relationships = true
  21038. }
  21039. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  21040. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  21041. return m.clearedlabel_relationships
  21042. }
  21043. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  21044. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  21045. if m.removedlabel_relationships == nil {
  21046. m.removedlabel_relationships = make(map[uint64]struct{})
  21047. }
  21048. for i := range ids {
  21049. delete(m.label_relationships, ids[i])
  21050. m.removedlabel_relationships[ids[i]] = struct{}{}
  21051. }
  21052. }
  21053. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  21054. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  21055. for id := range m.removedlabel_relationships {
  21056. ids = append(ids, id)
  21057. }
  21058. return
  21059. }
  21060. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  21061. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  21062. for id := range m.label_relationships {
  21063. ids = append(ids, id)
  21064. }
  21065. return
  21066. }
  21067. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  21068. func (m *LabelMutation) ResetLabelRelationships() {
  21069. m.label_relationships = nil
  21070. m.clearedlabel_relationships = false
  21071. m.removedlabel_relationships = nil
  21072. }
  21073. // Where appends a list predicates to the LabelMutation builder.
  21074. func (m *LabelMutation) Where(ps ...predicate.Label) {
  21075. m.predicates = append(m.predicates, ps...)
  21076. }
  21077. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  21078. // users can use type-assertion to append predicates that do not depend on any generated package.
  21079. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  21080. p := make([]predicate.Label, len(ps))
  21081. for i := range ps {
  21082. p[i] = ps[i]
  21083. }
  21084. m.Where(p...)
  21085. }
  21086. // Op returns the operation name.
  21087. func (m *LabelMutation) Op() Op {
  21088. return m.op
  21089. }
  21090. // SetOp allows setting the mutation operation.
  21091. func (m *LabelMutation) SetOp(op Op) {
  21092. m.op = op
  21093. }
  21094. // Type returns the node type of this mutation (Label).
  21095. func (m *LabelMutation) Type() string {
  21096. return m.typ
  21097. }
  21098. // Fields returns all fields that were changed during this mutation. Note that in
  21099. // order to get all numeric fields that were incremented/decremented, call
  21100. // AddedFields().
  21101. func (m *LabelMutation) Fields() []string {
  21102. fields := make([]string, 0, 10)
  21103. if m.created_at != nil {
  21104. fields = append(fields, label.FieldCreatedAt)
  21105. }
  21106. if m.updated_at != nil {
  21107. fields = append(fields, label.FieldUpdatedAt)
  21108. }
  21109. if m.status != nil {
  21110. fields = append(fields, label.FieldStatus)
  21111. }
  21112. if m.deleted_at != nil {
  21113. fields = append(fields, label.FieldDeletedAt)
  21114. }
  21115. if m._type != nil {
  21116. fields = append(fields, label.FieldType)
  21117. }
  21118. if m.name != nil {
  21119. fields = append(fields, label.FieldName)
  21120. }
  21121. if m.from != nil {
  21122. fields = append(fields, label.FieldFrom)
  21123. }
  21124. if m.mode != nil {
  21125. fields = append(fields, label.FieldMode)
  21126. }
  21127. if m.conditions != nil {
  21128. fields = append(fields, label.FieldConditions)
  21129. }
  21130. if m.organization_id != nil {
  21131. fields = append(fields, label.FieldOrganizationID)
  21132. }
  21133. return fields
  21134. }
  21135. // Field returns the value of a field with the given name. The second boolean
  21136. // return value indicates that this field was not set, or was not defined in the
  21137. // schema.
  21138. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  21139. switch name {
  21140. case label.FieldCreatedAt:
  21141. return m.CreatedAt()
  21142. case label.FieldUpdatedAt:
  21143. return m.UpdatedAt()
  21144. case label.FieldStatus:
  21145. return m.Status()
  21146. case label.FieldDeletedAt:
  21147. return m.DeletedAt()
  21148. case label.FieldType:
  21149. return m.GetType()
  21150. case label.FieldName:
  21151. return m.Name()
  21152. case label.FieldFrom:
  21153. return m.From()
  21154. case label.FieldMode:
  21155. return m.Mode()
  21156. case label.FieldConditions:
  21157. return m.Conditions()
  21158. case label.FieldOrganizationID:
  21159. return m.OrganizationID()
  21160. }
  21161. return nil, false
  21162. }
  21163. // OldField returns the old value of the field from the database. An error is
  21164. // returned if the mutation operation is not UpdateOne, or the query to the
  21165. // database failed.
  21166. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21167. switch name {
  21168. case label.FieldCreatedAt:
  21169. return m.OldCreatedAt(ctx)
  21170. case label.FieldUpdatedAt:
  21171. return m.OldUpdatedAt(ctx)
  21172. case label.FieldStatus:
  21173. return m.OldStatus(ctx)
  21174. case label.FieldDeletedAt:
  21175. return m.OldDeletedAt(ctx)
  21176. case label.FieldType:
  21177. return m.OldType(ctx)
  21178. case label.FieldName:
  21179. return m.OldName(ctx)
  21180. case label.FieldFrom:
  21181. return m.OldFrom(ctx)
  21182. case label.FieldMode:
  21183. return m.OldMode(ctx)
  21184. case label.FieldConditions:
  21185. return m.OldConditions(ctx)
  21186. case label.FieldOrganizationID:
  21187. return m.OldOrganizationID(ctx)
  21188. }
  21189. return nil, fmt.Errorf("unknown Label field %s", name)
  21190. }
  21191. // SetField sets the value of a field with the given name. It returns an error if
  21192. // the field is not defined in the schema, or if the type mismatched the field
  21193. // type.
  21194. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  21195. switch name {
  21196. case label.FieldCreatedAt:
  21197. v, ok := value.(time.Time)
  21198. if !ok {
  21199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21200. }
  21201. m.SetCreatedAt(v)
  21202. return nil
  21203. case label.FieldUpdatedAt:
  21204. v, ok := value.(time.Time)
  21205. if !ok {
  21206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21207. }
  21208. m.SetUpdatedAt(v)
  21209. return nil
  21210. case label.FieldStatus:
  21211. v, ok := value.(uint8)
  21212. if !ok {
  21213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21214. }
  21215. m.SetStatus(v)
  21216. return nil
  21217. case label.FieldDeletedAt:
  21218. v, ok := value.(time.Time)
  21219. if !ok {
  21220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21221. }
  21222. m.SetDeletedAt(v)
  21223. return nil
  21224. case label.FieldType:
  21225. v, ok := value.(int)
  21226. if !ok {
  21227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21228. }
  21229. m.SetType(v)
  21230. return nil
  21231. case label.FieldName:
  21232. v, ok := value.(string)
  21233. if !ok {
  21234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21235. }
  21236. m.SetName(v)
  21237. return nil
  21238. case label.FieldFrom:
  21239. v, ok := value.(int)
  21240. if !ok {
  21241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21242. }
  21243. m.SetFrom(v)
  21244. return nil
  21245. case label.FieldMode:
  21246. v, ok := value.(int)
  21247. if !ok {
  21248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21249. }
  21250. m.SetMode(v)
  21251. return nil
  21252. case label.FieldConditions:
  21253. v, ok := value.(string)
  21254. if !ok {
  21255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21256. }
  21257. m.SetConditions(v)
  21258. return nil
  21259. case label.FieldOrganizationID:
  21260. v, ok := value.(uint64)
  21261. if !ok {
  21262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21263. }
  21264. m.SetOrganizationID(v)
  21265. return nil
  21266. }
  21267. return fmt.Errorf("unknown Label field %s", name)
  21268. }
  21269. // AddedFields returns all numeric fields that were incremented/decremented during
  21270. // this mutation.
  21271. func (m *LabelMutation) AddedFields() []string {
  21272. var fields []string
  21273. if m.addstatus != nil {
  21274. fields = append(fields, label.FieldStatus)
  21275. }
  21276. if m.add_type != nil {
  21277. fields = append(fields, label.FieldType)
  21278. }
  21279. if m.addfrom != nil {
  21280. fields = append(fields, label.FieldFrom)
  21281. }
  21282. if m.addmode != nil {
  21283. fields = append(fields, label.FieldMode)
  21284. }
  21285. if m.addorganization_id != nil {
  21286. fields = append(fields, label.FieldOrganizationID)
  21287. }
  21288. return fields
  21289. }
  21290. // AddedField returns the numeric value that was incremented/decremented on a field
  21291. // with the given name. The second boolean return value indicates that this field
  21292. // was not set, or was not defined in the schema.
  21293. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  21294. switch name {
  21295. case label.FieldStatus:
  21296. return m.AddedStatus()
  21297. case label.FieldType:
  21298. return m.AddedType()
  21299. case label.FieldFrom:
  21300. return m.AddedFrom()
  21301. case label.FieldMode:
  21302. return m.AddedMode()
  21303. case label.FieldOrganizationID:
  21304. return m.AddedOrganizationID()
  21305. }
  21306. return nil, false
  21307. }
  21308. // AddField adds the value to the field with the given name. It returns an error if
  21309. // the field is not defined in the schema, or if the type mismatched the field
  21310. // type.
  21311. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  21312. switch name {
  21313. case label.FieldStatus:
  21314. v, ok := value.(int8)
  21315. if !ok {
  21316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21317. }
  21318. m.AddStatus(v)
  21319. return nil
  21320. case label.FieldType:
  21321. v, ok := value.(int)
  21322. if !ok {
  21323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21324. }
  21325. m.AddType(v)
  21326. return nil
  21327. case label.FieldFrom:
  21328. v, ok := value.(int)
  21329. if !ok {
  21330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21331. }
  21332. m.AddFrom(v)
  21333. return nil
  21334. case label.FieldMode:
  21335. v, ok := value.(int)
  21336. if !ok {
  21337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21338. }
  21339. m.AddMode(v)
  21340. return nil
  21341. case label.FieldOrganizationID:
  21342. v, ok := value.(int64)
  21343. if !ok {
  21344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21345. }
  21346. m.AddOrganizationID(v)
  21347. return nil
  21348. }
  21349. return fmt.Errorf("unknown Label numeric field %s", name)
  21350. }
  21351. // ClearedFields returns all nullable fields that were cleared during this
  21352. // mutation.
  21353. func (m *LabelMutation) ClearedFields() []string {
  21354. var fields []string
  21355. if m.FieldCleared(label.FieldStatus) {
  21356. fields = append(fields, label.FieldStatus)
  21357. }
  21358. if m.FieldCleared(label.FieldDeletedAt) {
  21359. fields = append(fields, label.FieldDeletedAt)
  21360. }
  21361. if m.FieldCleared(label.FieldConditions) {
  21362. fields = append(fields, label.FieldConditions)
  21363. }
  21364. if m.FieldCleared(label.FieldOrganizationID) {
  21365. fields = append(fields, label.FieldOrganizationID)
  21366. }
  21367. return fields
  21368. }
  21369. // FieldCleared returns a boolean indicating if a field with the given name was
  21370. // cleared in this mutation.
  21371. func (m *LabelMutation) FieldCleared(name string) bool {
  21372. _, ok := m.clearedFields[name]
  21373. return ok
  21374. }
  21375. // ClearField clears the value of the field with the given name. It returns an
  21376. // error if the field is not defined in the schema.
  21377. func (m *LabelMutation) ClearField(name string) error {
  21378. switch name {
  21379. case label.FieldStatus:
  21380. m.ClearStatus()
  21381. return nil
  21382. case label.FieldDeletedAt:
  21383. m.ClearDeletedAt()
  21384. return nil
  21385. case label.FieldConditions:
  21386. m.ClearConditions()
  21387. return nil
  21388. case label.FieldOrganizationID:
  21389. m.ClearOrganizationID()
  21390. return nil
  21391. }
  21392. return fmt.Errorf("unknown Label nullable field %s", name)
  21393. }
  21394. // ResetField resets all changes in the mutation for the field with the given name.
  21395. // It returns an error if the field is not defined in the schema.
  21396. func (m *LabelMutation) ResetField(name string) error {
  21397. switch name {
  21398. case label.FieldCreatedAt:
  21399. m.ResetCreatedAt()
  21400. return nil
  21401. case label.FieldUpdatedAt:
  21402. m.ResetUpdatedAt()
  21403. return nil
  21404. case label.FieldStatus:
  21405. m.ResetStatus()
  21406. return nil
  21407. case label.FieldDeletedAt:
  21408. m.ResetDeletedAt()
  21409. return nil
  21410. case label.FieldType:
  21411. m.ResetType()
  21412. return nil
  21413. case label.FieldName:
  21414. m.ResetName()
  21415. return nil
  21416. case label.FieldFrom:
  21417. m.ResetFrom()
  21418. return nil
  21419. case label.FieldMode:
  21420. m.ResetMode()
  21421. return nil
  21422. case label.FieldConditions:
  21423. m.ResetConditions()
  21424. return nil
  21425. case label.FieldOrganizationID:
  21426. m.ResetOrganizationID()
  21427. return nil
  21428. }
  21429. return fmt.Errorf("unknown Label field %s", name)
  21430. }
  21431. // AddedEdges returns all edge names that were set/added in this mutation.
  21432. func (m *LabelMutation) AddedEdges() []string {
  21433. edges := make([]string, 0, 1)
  21434. if m.label_relationships != nil {
  21435. edges = append(edges, label.EdgeLabelRelationships)
  21436. }
  21437. return edges
  21438. }
  21439. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21440. // name in this mutation.
  21441. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  21442. switch name {
  21443. case label.EdgeLabelRelationships:
  21444. ids := make([]ent.Value, 0, len(m.label_relationships))
  21445. for id := range m.label_relationships {
  21446. ids = append(ids, id)
  21447. }
  21448. return ids
  21449. }
  21450. return nil
  21451. }
  21452. // RemovedEdges returns all edge names that were removed in this mutation.
  21453. func (m *LabelMutation) RemovedEdges() []string {
  21454. edges := make([]string, 0, 1)
  21455. if m.removedlabel_relationships != nil {
  21456. edges = append(edges, label.EdgeLabelRelationships)
  21457. }
  21458. return edges
  21459. }
  21460. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21461. // the given name in this mutation.
  21462. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  21463. switch name {
  21464. case label.EdgeLabelRelationships:
  21465. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  21466. for id := range m.removedlabel_relationships {
  21467. ids = append(ids, id)
  21468. }
  21469. return ids
  21470. }
  21471. return nil
  21472. }
  21473. // ClearedEdges returns all edge names that were cleared in this mutation.
  21474. func (m *LabelMutation) ClearedEdges() []string {
  21475. edges := make([]string, 0, 1)
  21476. if m.clearedlabel_relationships {
  21477. edges = append(edges, label.EdgeLabelRelationships)
  21478. }
  21479. return edges
  21480. }
  21481. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21482. // was cleared in this mutation.
  21483. func (m *LabelMutation) EdgeCleared(name string) bool {
  21484. switch name {
  21485. case label.EdgeLabelRelationships:
  21486. return m.clearedlabel_relationships
  21487. }
  21488. return false
  21489. }
  21490. // ClearEdge clears the value of the edge with the given name. It returns an error
  21491. // if that edge is not defined in the schema.
  21492. func (m *LabelMutation) ClearEdge(name string) error {
  21493. switch name {
  21494. }
  21495. return fmt.Errorf("unknown Label unique edge %s", name)
  21496. }
  21497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21498. // It returns an error if the edge is not defined in the schema.
  21499. func (m *LabelMutation) ResetEdge(name string) error {
  21500. switch name {
  21501. case label.EdgeLabelRelationships:
  21502. m.ResetLabelRelationships()
  21503. return nil
  21504. }
  21505. return fmt.Errorf("unknown Label edge %s", name)
  21506. }
  21507. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  21508. type LabelLogMutation struct {
  21509. config
  21510. op Op
  21511. typ string
  21512. id *uint64
  21513. created_at *time.Time
  21514. updated_at *time.Time
  21515. label_name *string
  21516. label_id *int
  21517. addlabel_id *int
  21518. wx_id *string
  21519. organization_id *uint64
  21520. addorganization_id *int64
  21521. clearedFields map[string]struct{}
  21522. done bool
  21523. oldValue func(context.Context) (*LabelLog, error)
  21524. predicates []predicate.LabelLog
  21525. }
  21526. var _ ent.Mutation = (*LabelLogMutation)(nil)
  21527. // labellogOption allows management of the mutation configuration using functional options.
  21528. type labellogOption func(*LabelLogMutation)
  21529. // newLabelLogMutation creates new mutation for the LabelLog entity.
  21530. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  21531. m := &LabelLogMutation{
  21532. config: c,
  21533. op: op,
  21534. typ: TypeLabelLog,
  21535. clearedFields: make(map[string]struct{}),
  21536. }
  21537. for _, opt := range opts {
  21538. opt(m)
  21539. }
  21540. return m
  21541. }
  21542. // withLabelLogID sets the ID field of the mutation.
  21543. func withLabelLogID(id uint64) labellogOption {
  21544. return func(m *LabelLogMutation) {
  21545. var (
  21546. err error
  21547. once sync.Once
  21548. value *LabelLog
  21549. )
  21550. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  21551. once.Do(func() {
  21552. if m.done {
  21553. err = errors.New("querying old values post mutation is not allowed")
  21554. } else {
  21555. value, err = m.Client().LabelLog.Get(ctx, id)
  21556. }
  21557. })
  21558. return value, err
  21559. }
  21560. m.id = &id
  21561. }
  21562. }
  21563. // withLabelLog sets the old LabelLog of the mutation.
  21564. func withLabelLog(node *LabelLog) labellogOption {
  21565. return func(m *LabelLogMutation) {
  21566. m.oldValue = func(context.Context) (*LabelLog, error) {
  21567. return node, nil
  21568. }
  21569. m.id = &node.ID
  21570. }
  21571. }
  21572. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21573. // executed in a transaction (ent.Tx), a transactional client is returned.
  21574. func (m LabelLogMutation) Client() *Client {
  21575. client := &Client{config: m.config}
  21576. client.init()
  21577. return client
  21578. }
  21579. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21580. // it returns an error otherwise.
  21581. func (m LabelLogMutation) Tx() (*Tx, error) {
  21582. if _, ok := m.driver.(*txDriver); !ok {
  21583. return nil, errors.New("ent: mutation is not running in a transaction")
  21584. }
  21585. tx := &Tx{config: m.config}
  21586. tx.init()
  21587. return tx, nil
  21588. }
  21589. // SetID sets the value of the id field. Note that this
  21590. // operation is only accepted on creation of LabelLog entities.
  21591. func (m *LabelLogMutation) SetID(id uint64) {
  21592. m.id = &id
  21593. }
  21594. // ID returns the ID value in the mutation. Note that the ID is only available
  21595. // if it was provided to the builder or after it was returned from the database.
  21596. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  21597. if m.id == nil {
  21598. return
  21599. }
  21600. return *m.id, true
  21601. }
  21602. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21603. // That means, if the mutation is applied within a transaction with an isolation level such
  21604. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21605. // or updated by the mutation.
  21606. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  21607. switch {
  21608. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21609. id, exists := m.ID()
  21610. if exists {
  21611. return []uint64{id}, nil
  21612. }
  21613. fallthrough
  21614. case m.op.Is(OpUpdate | OpDelete):
  21615. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  21616. default:
  21617. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21618. }
  21619. }
  21620. // SetCreatedAt sets the "created_at" field.
  21621. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  21622. m.created_at = &t
  21623. }
  21624. // CreatedAt returns the value of the "created_at" field in the mutation.
  21625. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  21626. v := m.created_at
  21627. if v == nil {
  21628. return
  21629. }
  21630. return *v, true
  21631. }
  21632. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  21633. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21635. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21636. if !m.op.Is(OpUpdateOne) {
  21637. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21638. }
  21639. if m.id == nil || m.oldValue == nil {
  21640. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21641. }
  21642. oldValue, err := m.oldValue(ctx)
  21643. if err != nil {
  21644. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21645. }
  21646. return oldValue.CreatedAt, nil
  21647. }
  21648. // ResetCreatedAt resets all changes to the "created_at" field.
  21649. func (m *LabelLogMutation) ResetCreatedAt() {
  21650. m.created_at = nil
  21651. }
  21652. // SetUpdatedAt sets the "updated_at" field.
  21653. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  21654. m.updated_at = &t
  21655. }
  21656. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21657. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  21658. v := m.updated_at
  21659. if v == nil {
  21660. return
  21661. }
  21662. return *v, true
  21663. }
  21664. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  21665. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21667. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21668. if !m.op.Is(OpUpdateOne) {
  21669. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21670. }
  21671. if m.id == nil || m.oldValue == nil {
  21672. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21673. }
  21674. oldValue, err := m.oldValue(ctx)
  21675. if err != nil {
  21676. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21677. }
  21678. return oldValue.UpdatedAt, nil
  21679. }
  21680. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21681. func (m *LabelLogMutation) ResetUpdatedAt() {
  21682. m.updated_at = nil
  21683. }
  21684. // SetLabelName sets the "label_name" field.
  21685. func (m *LabelLogMutation) SetLabelName(s string) {
  21686. m.label_name = &s
  21687. }
  21688. // LabelName returns the value of the "label_name" field in the mutation.
  21689. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  21690. v := m.label_name
  21691. if v == nil {
  21692. return
  21693. }
  21694. return *v, true
  21695. }
  21696. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  21697. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21699. func (m *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  21700. if !m.op.Is(OpUpdateOne) {
  21701. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  21702. }
  21703. if m.id == nil || m.oldValue == nil {
  21704. return v, errors.New("OldLabelName requires an ID field in the mutation")
  21705. }
  21706. oldValue, err := m.oldValue(ctx)
  21707. if err != nil {
  21708. return v, fmt.Errorf("querying old value for OldLabelName: %w", err)
  21709. }
  21710. return oldValue.LabelName, nil
  21711. }
  21712. // ResetLabelName resets all changes to the "label_name" field.
  21713. func (m *LabelLogMutation) ResetLabelName() {
  21714. m.label_name = nil
  21715. }
  21716. // SetLabelID sets the "label_id" field.
  21717. func (m *LabelLogMutation) SetLabelID(i int) {
  21718. m.label_id = &i
  21719. m.addlabel_id = nil
  21720. }
  21721. // LabelID returns the value of the "label_id" field in the mutation.
  21722. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  21723. v := m.label_id
  21724. if v == nil {
  21725. return
  21726. }
  21727. return *v, true
  21728. }
  21729. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  21730. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21732. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  21733. if !m.op.Is(OpUpdateOne) {
  21734. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  21735. }
  21736. if m.id == nil || m.oldValue == nil {
  21737. return v, errors.New("OldLabelID requires an ID field in the mutation")
  21738. }
  21739. oldValue, err := m.oldValue(ctx)
  21740. if err != nil {
  21741. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  21742. }
  21743. return oldValue.LabelID, nil
  21744. }
  21745. // AddLabelID adds i to the "label_id" field.
  21746. func (m *LabelLogMutation) AddLabelID(i int) {
  21747. if m.addlabel_id != nil {
  21748. *m.addlabel_id += i
  21749. } else {
  21750. m.addlabel_id = &i
  21751. }
  21752. }
  21753. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  21754. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  21755. v := m.addlabel_id
  21756. if v == nil {
  21757. return
  21758. }
  21759. return *v, true
  21760. }
  21761. // ResetLabelID resets all changes to the "label_id" field.
  21762. func (m *LabelLogMutation) ResetLabelID() {
  21763. m.label_id = nil
  21764. m.addlabel_id = nil
  21765. }
  21766. // SetWxID sets the "wx_id" field.
  21767. func (m *LabelLogMutation) SetWxID(s string) {
  21768. m.wx_id = &s
  21769. }
  21770. // WxID returns the value of the "wx_id" field in the mutation.
  21771. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  21772. v := m.wx_id
  21773. if v == nil {
  21774. return
  21775. }
  21776. return *v, true
  21777. }
  21778. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  21779. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21781. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  21782. if !m.op.Is(OpUpdateOne) {
  21783. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  21784. }
  21785. if m.id == nil || m.oldValue == nil {
  21786. return v, errors.New("OldWxID requires an ID field in the mutation")
  21787. }
  21788. oldValue, err := m.oldValue(ctx)
  21789. if err != nil {
  21790. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  21791. }
  21792. return oldValue.WxID, nil
  21793. }
  21794. // ResetWxID resets all changes to the "wx_id" field.
  21795. func (m *LabelLogMutation) ResetWxID() {
  21796. m.wx_id = nil
  21797. }
  21798. // SetOrganizationID sets the "organization_id" field.
  21799. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  21800. m.organization_id = &u
  21801. m.addorganization_id = nil
  21802. }
  21803. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21804. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  21805. v := m.organization_id
  21806. if v == nil {
  21807. return
  21808. }
  21809. return *v, true
  21810. }
  21811. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  21812. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21814. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21815. if !m.op.Is(OpUpdateOne) {
  21816. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21817. }
  21818. if m.id == nil || m.oldValue == nil {
  21819. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21820. }
  21821. oldValue, err := m.oldValue(ctx)
  21822. if err != nil {
  21823. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21824. }
  21825. return oldValue.OrganizationID, nil
  21826. }
  21827. // AddOrganizationID adds u to the "organization_id" field.
  21828. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  21829. if m.addorganization_id != nil {
  21830. *m.addorganization_id += u
  21831. } else {
  21832. m.addorganization_id = &u
  21833. }
  21834. }
  21835. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21836. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  21837. v := m.addorganization_id
  21838. if v == nil {
  21839. return
  21840. }
  21841. return *v, true
  21842. }
  21843. // ClearOrganizationID clears the value of the "organization_id" field.
  21844. func (m *LabelLogMutation) ClearOrganizationID() {
  21845. m.organization_id = nil
  21846. m.addorganization_id = nil
  21847. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  21848. }
  21849. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21850. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  21851. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  21852. return ok
  21853. }
  21854. // ResetOrganizationID resets all changes to the "organization_id" field.
  21855. func (m *LabelLogMutation) ResetOrganizationID() {
  21856. m.organization_id = nil
  21857. m.addorganization_id = nil
  21858. delete(m.clearedFields, labellog.FieldOrganizationID)
  21859. }
  21860. // Where appends a list predicates to the LabelLogMutation builder.
  21861. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  21862. m.predicates = append(m.predicates, ps...)
  21863. }
  21864. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  21865. // users can use type-assertion to append predicates that do not depend on any generated package.
  21866. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  21867. p := make([]predicate.LabelLog, len(ps))
  21868. for i := range ps {
  21869. p[i] = ps[i]
  21870. }
  21871. m.Where(p...)
  21872. }
  21873. // Op returns the operation name.
  21874. func (m *LabelLogMutation) Op() Op {
  21875. return m.op
  21876. }
  21877. // SetOp allows setting the mutation operation.
  21878. func (m *LabelLogMutation) SetOp(op Op) {
  21879. m.op = op
  21880. }
  21881. // Type returns the node type of this mutation (LabelLog).
  21882. func (m *LabelLogMutation) Type() string {
  21883. return m.typ
  21884. }
  21885. // Fields returns all fields that were changed during this mutation. Note that in
  21886. // order to get all numeric fields that were incremented/decremented, call
  21887. // AddedFields().
  21888. func (m *LabelLogMutation) Fields() []string {
  21889. fields := make([]string, 0, 6)
  21890. if m.created_at != nil {
  21891. fields = append(fields, labellog.FieldCreatedAt)
  21892. }
  21893. if m.updated_at != nil {
  21894. fields = append(fields, labellog.FieldUpdatedAt)
  21895. }
  21896. if m.label_name != nil {
  21897. fields = append(fields, labellog.FieldLabelName)
  21898. }
  21899. if m.label_id != nil {
  21900. fields = append(fields, labellog.FieldLabelID)
  21901. }
  21902. if m.wx_id != nil {
  21903. fields = append(fields, labellog.FieldWxID)
  21904. }
  21905. if m.organization_id != nil {
  21906. fields = append(fields, labellog.FieldOrganizationID)
  21907. }
  21908. return fields
  21909. }
  21910. // Field returns the value of a field with the given name. The second boolean
  21911. // return value indicates that this field was not set, or was not defined in the
  21912. // schema.
  21913. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  21914. switch name {
  21915. case labellog.FieldCreatedAt:
  21916. return m.CreatedAt()
  21917. case labellog.FieldUpdatedAt:
  21918. return m.UpdatedAt()
  21919. case labellog.FieldLabelName:
  21920. return m.LabelName()
  21921. case labellog.FieldLabelID:
  21922. return m.LabelID()
  21923. case labellog.FieldWxID:
  21924. return m.WxID()
  21925. case labellog.FieldOrganizationID:
  21926. return m.OrganizationID()
  21927. }
  21928. return nil, false
  21929. }
  21930. // OldField returns the old value of the field from the database. An error is
  21931. // returned if the mutation operation is not UpdateOne, or the query to the
  21932. // database failed.
  21933. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21934. switch name {
  21935. case labellog.FieldCreatedAt:
  21936. return m.OldCreatedAt(ctx)
  21937. case labellog.FieldUpdatedAt:
  21938. return m.OldUpdatedAt(ctx)
  21939. case labellog.FieldLabelName:
  21940. return m.OldLabelName(ctx)
  21941. case labellog.FieldLabelID:
  21942. return m.OldLabelID(ctx)
  21943. case labellog.FieldWxID:
  21944. return m.OldWxID(ctx)
  21945. case labellog.FieldOrganizationID:
  21946. return m.OldOrganizationID(ctx)
  21947. }
  21948. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  21949. }
  21950. // SetField sets the value of a field with the given name. It returns an error if
  21951. // the field is not defined in the schema, or if the type mismatched the field
  21952. // type.
  21953. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  21954. switch name {
  21955. case labellog.FieldCreatedAt:
  21956. v, ok := value.(time.Time)
  21957. if !ok {
  21958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21959. }
  21960. m.SetCreatedAt(v)
  21961. return nil
  21962. case labellog.FieldUpdatedAt:
  21963. v, ok := value.(time.Time)
  21964. if !ok {
  21965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21966. }
  21967. m.SetUpdatedAt(v)
  21968. return nil
  21969. case labellog.FieldLabelName:
  21970. v, ok := value.(string)
  21971. if !ok {
  21972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21973. }
  21974. m.SetLabelName(v)
  21975. return nil
  21976. case labellog.FieldLabelID:
  21977. v, ok := value.(int)
  21978. if !ok {
  21979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21980. }
  21981. m.SetLabelID(v)
  21982. return nil
  21983. case labellog.FieldWxID:
  21984. v, ok := value.(string)
  21985. if !ok {
  21986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21987. }
  21988. m.SetWxID(v)
  21989. return nil
  21990. case labellog.FieldOrganizationID:
  21991. v, ok := value.(uint64)
  21992. if !ok {
  21993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21994. }
  21995. m.SetOrganizationID(v)
  21996. return nil
  21997. }
  21998. return fmt.Errorf("unknown LabelLog field %s", name)
  21999. }
  22000. // AddedFields returns all numeric fields that were incremented/decremented during
  22001. // this mutation.
  22002. func (m *LabelLogMutation) AddedFields() []string {
  22003. var fields []string
  22004. if m.addlabel_id != nil {
  22005. fields = append(fields, labellog.FieldLabelID)
  22006. }
  22007. if m.addorganization_id != nil {
  22008. fields = append(fields, labellog.FieldOrganizationID)
  22009. }
  22010. return fields
  22011. }
  22012. // AddedField returns the numeric value that was incremented/decremented on a field
  22013. // with the given name. The second boolean return value indicates that this field
  22014. // was not set, or was not defined in the schema.
  22015. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  22016. switch name {
  22017. case labellog.FieldLabelID:
  22018. return m.AddedLabelID()
  22019. case labellog.FieldOrganizationID:
  22020. return m.AddedOrganizationID()
  22021. }
  22022. return nil, false
  22023. }
  22024. // AddField adds the value to the field with the given name. It returns an error if
  22025. // the field is not defined in the schema, or if the type mismatched the field
  22026. // type.
  22027. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  22028. switch name {
  22029. case labellog.FieldLabelID:
  22030. v, ok := value.(int)
  22031. if !ok {
  22032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22033. }
  22034. m.AddLabelID(v)
  22035. return nil
  22036. case labellog.FieldOrganizationID:
  22037. v, ok := value.(int64)
  22038. if !ok {
  22039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22040. }
  22041. m.AddOrganizationID(v)
  22042. return nil
  22043. }
  22044. return fmt.Errorf("unknown LabelLog numeric field %s", name)
  22045. }
  22046. // ClearedFields returns all nullable fields that were cleared during this
  22047. // mutation.
  22048. func (m *LabelLogMutation) ClearedFields() []string {
  22049. var fields []string
  22050. if m.FieldCleared(labellog.FieldOrganizationID) {
  22051. fields = append(fields, labellog.FieldOrganizationID)
  22052. }
  22053. return fields
  22054. }
  22055. // FieldCleared returns a boolean indicating if a field with the given name was
  22056. // cleared in this mutation.
  22057. func (m *LabelLogMutation) FieldCleared(name string) bool {
  22058. _, ok := m.clearedFields[name]
  22059. return ok
  22060. }
  22061. // ClearField clears the value of the field with the given name. It returns an
  22062. // error if the field is not defined in the schema.
  22063. func (m *LabelLogMutation) ClearField(name string) error {
  22064. switch name {
  22065. case labellog.FieldOrganizationID:
  22066. m.ClearOrganizationID()
  22067. return nil
  22068. }
  22069. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  22070. }
  22071. // ResetField resets all changes in the mutation for the field with the given name.
  22072. // It returns an error if the field is not defined in the schema.
  22073. func (m *LabelLogMutation) ResetField(name string) error {
  22074. switch name {
  22075. case labellog.FieldCreatedAt:
  22076. m.ResetCreatedAt()
  22077. return nil
  22078. case labellog.FieldUpdatedAt:
  22079. m.ResetUpdatedAt()
  22080. return nil
  22081. case labellog.FieldLabelName:
  22082. m.ResetLabelName()
  22083. return nil
  22084. case labellog.FieldLabelID:
  22085. m.ResetLabelID()
  22086. return nil
  22087. case labellog.FieldWxID:
  22088. m.ResetWxID()
  22089. return nil
  22090. case labellog.FieldOrganizationID:
  22091. m.ResetOrganizationID()
  22092. return nil
  22093. }
  22094. return fmt.Errorf("unknown LabelLog field %s", name)
  22095. }
  22096. // AddedEdges returns all edge names that were set/added in this mutation.
  22097. func (m *LabelLogMutation) AddedEdges() []string {
  22098. edges := make([]string, 0, 0)
  22099. return edges
  22100. }
  22101. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22102. // name in this mutation.
  22103. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  22104. return nil
  22105. }
  22106. // RemovedEdges returns all edge names that were removed in this mutation.
  22107. func (m *LabelLogMutation) RemovedEdges() []string {
  22108. edges := make([]string, 0, 0)
  22109. return edges
  22110. }
  22111. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22112. // the given name in this mutation.
  22113. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  22114. return nil
  22115. }
  22116. // ClearedEdges returns all edge names that were cleared in this mutation.
  22117. func (m *LabelLogMutation) ClearedEdges() []string {
  22118. edges := make([]string, 0, 0)
  22119. return edges
  22120. }
  22121. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22122. // was cleared in this mutation.
  22123. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  22124. return false
  22125. }
  22126. // ClearEdge clears the value of the edge with the given name. It returns an error
  22127. // if that edge is not defined in the schema.
  22128. func (m *LabelLogMutation) ClearEdge(name string) error {
  22129. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  22130. }
  22131. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22132. // It returns an error if the edge is not defined in the schema.
  22133. func (m *LabelLogMutation) ResetEdge(name string) error {
  22134. return fmt.Errorf("unknown LabelLog edge %s", name)
  22135. }
  22136. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  22137. type LabelRelationshipMutation struct {
  22138. config
  22139. op Op
  22140. typ string
  22141. id *uint64
  22142. created_at *time.Time
  22143. updated_at *time.Time
  22144. status *uint8
  22145. addstatus *int8
  22146. deleted_at *time.Time
  22147. organization_id *uint64
  22148. addorganization_id *int64
  22149. clearedFields map[string]struct{}
  22150. contacts *uint64
  22151. clearedcontacts bool
  22152. labels *uint64
  22153. clearedlabels bool
  22154. done bool
  22155. oldValue func(context.Context) (*LabelRelationship, error)
  22156. predicates []predicate.LabelRelationship
  22157. }
  22158. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  22159. // labelrelationshipOption allows management of the mutation configuration using functional options.
  22160. type labelrelationshipOption func(*LabelRelationshipMutation)
  22161. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  22162. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  22163. m := &LabelRelationshipMutation{
  22164. config: c,
  22165. op: op,
  22166. typ: TypeLabelRelationship,
  22167. clearedFields: make(map[string]struct{}),
  22168. }
  22169. for _, opt := range opts {
  22170. opt(m)
  22171. }
  22172. return m
  22173. }
  22174. // withLabelRelationshipID sets the ID field of the mutation.
  22175. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  22176. return func(m *LabelRelationshipMutation) {
  22177. var (
  22178. err error
  22179. once sync.Once
  22180. value *LabelRelationship
  22181. )
  22182. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  22183. once.Do(func() {
  22184. if m.done {
  22185. err = errors.New("querying old values post mutation is not allowed")
  22186. } else {
  22187. value, err = m.Client().LabelRelationship.Get(ctx, id)
  22188. }
  22189. })
  22190. return value, err
  22191. }
  22192. m.id = &id
  22193. }
  22194. }
  22195. // withLabelRelationship sets the old LabelRelationship of the mutation.
  22196. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  22197. return func(m *LabelRelationshipMutation) {
  22198. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  22199. return node, nil
  22200. }
  22201. m.id = &node.ID
  22202. }
  22203. }
  22204. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22205. // executed in a transaction (ent.Tx), a transactional client is returned.
  22206. func (m LabelRelationshipMutation) Client() *Client {
  22207. client := &Client{config: m.config}
  22208. client.init()
  22209. return client
  22210. }
  22211. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22212. // it returns an error otherwise.
  22213. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  22214. if _, ok := m.driver.(*txDriver); !ok {
  22215. return nil, errors.New("ent: mutation is not running in a transaction")
  22216. }
  22217. tx := &Tx{config: m.config}
  22218. tx.init()
  22219. return tx, nil
  22220. }
  22221. // SetID sets the value of the id field. Note that this
  22222. // operation is only accepted on creation of LabelRelationship entities.
  22223. func (m *LabelRelationshipMutation) SetID(id uint64) {
  22224. m.id = &id
  22225. }
  22226. // ID returns the ID value in the mutation. Note that the ID is only available
  22227. // if it was provided to the builder or after it was returned from the database.
  22228. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  22229. if m.id == nil {
  22230. return
  22231. }
  22232. return *m.id, true
  22233. }
  22234. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22235. // That means, if the mutation is applied within a transaction with an isolation level such
  22236. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22237. // or updated by the mutation.
  22238. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  22239. switch {
  22240. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22241. id, exists := m.ID()
  22242. if exists {
  22243. return []uint64{id}, nil
  22244. }
  22245. fallthrough
  22246. case m.op.Is(OpUpdate | OpDelete):
  22247. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  22248. default:
  22249. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22250. }
  22251. }
  22252. // SetCreatedAt sets the "created_at" field.
  22253. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  22254. m.created_at = &t
  22255. }
  22256. // CreatedAt returns the value of the "created_at" field in the mutation.
  22257. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  22258. v := m.created_at
  22259. if v == nil {
  22260. return
  22261. }
  22262. return *v, true
  22263. }
  22264. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  22265. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22267. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22268. if !m.op.Is(OpUpdateOne) {
  22269. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22270. }
  22271. if m.id == nil || m.oldValue == nil {
  22272. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22273. }
  22274. oldValue, err := m.oldValue(ctx)
  22275. if err != nil {
  22276. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22277. }
  22278. return oldValue.CreatedAt, nil
  22279. }
  22280. // ResetCreatedAt resets all changes to the "created_at" field.
  22281. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  22282. m.created_at = nil
  22283. }
  22284. // SetUpdatedAt sets the "updated_at" field.
  22285. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  22286. m.updated_at = &t
  22287. }
  22288. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22289. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  22290. v := m.updated_at
  22291. if v == nil {
  22292. return
  22293. }
  22294. return *v, true
  22295. }
  22296. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  22297. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22299. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22300. if !m.op.Is(OpUpdateOne) {
  22301. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22302. }
  22303. if m.id == nil || m.oldValue == nil {
  22304. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22305. }
  22306. oldValue, err := m.oldValue(ctx)
  22307. if err != nil {
  22308. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22309. }
  22310. return oldValue.UpdatedAt, nil
  22311. }
  22312. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22313. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  22314. m.updated_at = nil
  22315. }
  22316. // SetStatus sets the "status" field.
  22317. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  22318. m.status = &u
  22319. m.addstatus = nil
  22320. }
  22321. // Status returns the value of the "status" field in the mutation.
  22322. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  22323. v := m.status
  22324. if v == nil {
  22325. return
  22326. }
  22327. return *v, true
  22328. }
  22329. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  22330. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22332. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22333. if !m.op.Is(OpUpdateOne) {
  22334. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22335. }
  22336. if m.id == nil || m.oldValue == nil {
  22337. return v, errors.New("OldStatus requires an ID field in the mutation")
  22338. }
  22339. oldValue, err := m.oldValue(ctx)
  22340. if err != nil {
  22341. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22342. }
  22343. return oldValue.Status, nil
  22344. }
  22345. // AddStatus adds u to the "status" field.
  22346. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  22347. if m.addstatus != nil {
  22348. *m.addstatus += u
  22349. } else {
  22350. m.addstatus = &u
  22351. }
  22352. }
  22353. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22354. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  22355. v := m.addstatus
  22356. if v == nil {
  22357. return
  22358. }
  22359. return *v, true
  22360. }
  22361. // ClearStatus clears the value of the "status" field.
  22362. func (m *LabelRelationshipMutation) ClearStatus() {
  22363. m.status = nil
  22364. m.addstatus = nil
  22365. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  22366. }
  22367. // StatusCleared returns if the "status" field was cleared in this mutation.
  22368. func (m *LabelRelationshipMutation) StatusCleared() bool {
  22369. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  22370. return ok
  22371. }
  22372. // ResetStatus resets all changes to the "status" field.
  22373. func (m *LabelRelationshipMutation) ResetStatus() {
  22374. m.status = nil
  22375. m.addstatus = nil
  22376. delete(m.clearedFields, labelrelationship.FieldStatus)
  22377. }
  22378. // SetDeletedAt sets the "deleted_at" field.
  22379. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  22380. m.deleted_at = &t
  22381. }
  22382. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22383. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  22384. v := m.deleted_at
  22385. if v == nil {
  22386. return
  22387. }
  22388. return *v, true
  22389. }
  22390. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  22391. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22393. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22394. if !m.op.Is(OpUpdateOne) {
  22395. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22396. }
  22397. if m.id == nil || m.oldValue == nil {
  22398. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22399. }
  22400. oldValue, err := m.oldValue(ctx)
  22401. if err != nil {
  22402. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22403. }
  22404. return oldValue.DeletedAt, nil
  22405. }
  22406. // ClearDeletedAt clears the value of the "deleted_at" field.
  22407. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  22408. m.deleted_at = nil
  22409. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  22410. }
  22411. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22412. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  22413. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  22414. return ok
  22415. }
  22416. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22417. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  22418. m.deleted_at = nil
  22419. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  22420. }
  22421. // SetLabelID sets the "label_id" field.
  22422. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  22423. m.labels = &u
  22424. }
  22425. // LabelID returns the value of the "label_id" field in the mutation.
  22426. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  22427. v := m.labels
  22428. if v == nil {
  22429. return
  22430. }
  22431. return *v, true
  22432. }
  22433. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  22434. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22436. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  22437. if !m.op.Is(OpUpdateOne) {
  22438. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  22439. }
  22440. if m.id == nil || m.oldValue == nil {
  22441. return v, errors.New("OldLabelID requires an ID field in the mutation")
  22442. }
  22443. oldValue, err := m.oldValue(ctx)
  22444. if err != nil {
  22445. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  22446. }
  22447. return oldValue.LabelID, nil
  22448. }
  22449. // ResetLabelID resets all changes to the "label_id" field.
  22450. func (m *LabelRelationshipMutation) ResetLabelID() {
  22451. m.labels = nil
  22452. }
  22453. // SetContactID sets the "contact_id" field.
  22454. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  22455. m.contacts = &u
  22456. }
  22457. // ContactID returns the value of the "contact_id" field in the mutation.
  22458. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  22459. v := m.contacts
  22460. if v == nil {
  22461. return
  22462. }
  22463. return *v, true
  22464. }
  22465. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  22466. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22468. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22469. if !m.op.Is(OpUpdateOne) {
  22470. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22471. }
  22472. if m.id == nil || m.oldValue == nil {
  22473. return v, errors.New("OldContactID requires an ID field in the mutation")
  22474. }
  22475. oldValue, err := m.oldValue(ctx)
  22476. if err != nil {
  22477. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22478. }
  22479. return oldValue.ContactID, nil
  22480. }
  22481. // ResetContactID resets all changes to the "contact_id" field.
  22482. func (m *LabelRelationshipMutation) ResetContactID() {
  22483. m.contacts = nil
  22484. }
  22485. // SetOrganizationID sets the "organization_id" field.
  22486. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  22487. m.organization_id = &u
  22488. m.addorganization_id = nil
  22489. }
  22490. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22491. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  22492. v := m.organization_id
  22493. if v == nil {
  22494. return
  22495. }
  22496. return *v, true
  22497. }
  22498. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  22499. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22501. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22502. if !m.op.Is(OpUpdateOne) {
  22503. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22504. }
  22505. if m.id == nil || m.oldValue == nil {
  22506. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22507. }
  22508. oldValue, err := m.oldValue(ctx)
  22509. if err != nil {
  22510. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22511. }
  22512. return oldValue.OrganizationID, nil
  22513. }
  22514. // AddOrganizationID adds u to the "organization_id" field.
  22515. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  22516. if m.addorganization_id != nil {
  22517. *m.addorganization_id += u
  22518. } else {
  22519. m.addorganization_id = &u
  22520. }
  22521. }
  22522. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22523. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  22524. v := m.addorganization_id
  22525. if v == nil {
  22526. return
  22527. }
  22528. return *v, true
  22529. }
  22530. // ClearOrganizationID clears the value of the "organization_id" field.
  22531. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  22532. m.organization_id = nil
  22533. m.addorganization_id = nil
  22534. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  22535. }
  22536. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22537. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  22538. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  22539. return ok
  22540. }
  22541. // ResetOrganizationID resets all changes to the "organization_id" field.
  22542. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  22543. m.organization_id = nil
  22544. m.addorganization_id = nil
  22545. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  22546. }
  22547. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  22548. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  22549. m.contacts = &id
  22550. }
  22551. // ClearContacts clears the "contacts" edge to the Contact entity.
  22552. func (m *LabelRelationshipMutation) ClearContacts() {
  22553. m.clearedcontacts = true
  22554. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  22555. }
  22556. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  22557. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  22558. return m.clearedcontacts
  22559. }
  22560. // ContactsID returns the "contacts" edge ID in the mutation.
  22561. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  22562. if m.contacts != nil {
  22563. return *m.contacts, true
  22564. }
  22565. return
  22566. }
  22567. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  22568. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22569. // ContactsID instead. It exists only for internal usage by the builders.
  22570. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  22571. if id := m.contacts; id != nil {
  22572. ids = append(ids, *id)
  22573. }
  22574. return
  22575. }
  22576. // ResetContacts resets all changes to the "contacts" edge.
  22577. func (m *LabelRelationshipMutation) ResetContacts() {
  22578. m.contacts = nil
  22579. m.clearedcontacts = false
  22580. }
  22581. // SetLabelsID sets the "labels" edge to the Label entity by id.
  22582. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  22583. m.labels = &id
  22584. }
  22585. // ClearLabels clears the "labels" edge to the Label entity.
  22586. func (m *LabelRelationshipMutation) ClearLabels() {
  22587. m.clearedlabels = true
  22588. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  22589. }
  22590. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  22591. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  22592. return m.clearedlabels
  22593. }
  22594. // LabelsID returns the "labels" edge ID in the mutation.
  22595. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  22596. if m.labels != nil {
  22597. return *m.labels, true
  22598. }
  22599. return
  22600. }
  22601. // LabelsIDs returns the "labels" edge IDs in the mutation.
  22602. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22603. // LabelsID instead. It exists only for internal usage by the builders.
  22604. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  22605. if id := m.labels; id != nil {
  22606. ids = append(ids, *id)
  22607. }
  22608. return
  22609. }
  22610. // ResetLabels resets all changes to the "labels" edge.
  22611. func (m *LabelRelationshipMutation) ResetLabels() {
  22612. m.labels = nil
  22613. m.clearedlabels = false
  22614. }
  22615. // Where appends a list predicates to the LabelRelationshipMutation builder.
  22616. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  22617. m.predicates = append(m.predicates, ps...)
  22618. }
  22619. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  22620. // users can use type-assertion to append predicates that do not depend on any generated package.
  22621. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  22622. p := make([]predicate.LabelRelationship, len(ps))
  22623. for i := range ps {
  22624. p[i] = ps[i]
  22625. }
  22626. m.Where(p...)
  22627. }
  22628. // Op returns the operation name.
  22629. func (m *LabelRelationshipMutation) Op() Op {
  22630. return m.op
  22631. }
  22632. // SetOp allows setting the mutation operation.
  22633. func (m *LabelRelationshipMutation) SetOp(op Op) {
  22634. m.op = op
  22635. }
  22636. // Type returns the node type of this mutation (LabelRelationship).
  22637. func (m *LabelRelationshipMutation) Type() string {
  22638. return m.typ
  22639. }
  22640. // Fields returns all fields that were changed during this mutation. Note that in
  22641. // order to get all numeric fields that were incremented/decremented, call
  22642. // AddedFields().
  22643. func (m *LabelRelationshipMutation) Fields() []string {
  22644. fields := make([]string, 0, 7)
  22645. if m.created_at != nil {
  22646. fields = append(fields, labelrelationship.FieldCreatedAt)
  22647. }
  22648. if m.updated_at != nil {
  22649. fields = append(fields, labelrelationship.FieldUpdatedAt)
  22650. }
  22651. if m.status != nil {
  22652. fields = append(fields, labelrelationship.FieldStatus)
  22653. }
  22654. if m.deleted_at != nil {
  22655. fields = append(fields, labelrelationship.FieldDeletedAt)
  22656. }
  22657. if m.labels != nil {
  22658. fields = append(fields, labelrelationship.FieldLabelID)
  22659. }
  22660. if m.contacts != nil {
  22661. fields = append(fields, labelrelationship.FieldContactID)
  22662. }
  22663. if m.organization_id != nil {
  22664. fields = append(fields, labelrelationship.FieldOrganizationID)
  22665. }
  22666. return fields
  22667. }
  22668. // Field returns the value of a field with the given name. The second boolean
  22669. // return value indicates that this field was not set, or was not defined in the
  22670. // schema.
  22671. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  22672. switch name {
  22673. case labelrelationship.FieldCreatedAt:
  22674. return m.CreatedAt()
  22675. case labelrelationship.FieldUpdatedAt:
  22676. return m.UpdatedAt()
  22677. case labelrelationship.FieldStatus:
  22678. return m.Status()
  22679. case labelrelationship.FieldDeletedAt:
  22680. return m.DeletedAt()
  22681. case labelrelationship.FieldLabelID:
  22682. return m.LabelID()
  22683. case labelrelationship.FieldContactID:
  22684. return m.ContactID()
  22685. case labelrelationship.FieldOrganizationID:
  22686. return m.OrganizationID()
  22687. }
  22688. return nil, false
  22689. }
  22690. // OldField returns the old value of the field from the database. An error is
  22691. // returned if the mutation operation is not UpdateOne, or the query to the
  22692. // database failed.
  22693. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22694. switch name {
  22695. case labelrelationship.FieldCreatedAt:
  22696. return m.OldCreatedAt(ctx)
  22697. case labelrelationship.FieldUpdatedAt:
  22698. return m.OldUpdatedAt(ctx)
  22699. case labelrelationship.FieldStatus:
  22700. return m.OldStatus(ctx)
  22701. case labelrelationship.FieldDeletedAt:
  22702. return m.OldDeletedAt(ctx)
  22703. case labelrelationship.FieldLabelID:
  22704. return m.OldLabelID(ctx)
  22705. case labelrelationship.FieldContactID:
  22706. return m.OldContactID(ctx)
  22707. case labelrelationship.FieldOrganizationID:
  22708. return m.OldOrganizationID(ctx)
  22709. }
  22710. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  22711. }
  22712. // SetField sets the value of a field with the given name. It returns an error if
  22713. // the field is not defined in the schema, or if the type mismatched the field
  22714. // type.
  22715. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  22716. switch name {
  22717. case labelrelationship.FieldCreatedAt:
  22718. v, ok := value.(time.Time)
  22719. if !ok {
  22720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22721. }
  22722. m.SetCreatedAt(v)
  22723. return nil
  22724. case labelrelationship.FieldUpdatedAt:
  22725. v, ok := value.(time.Time)
  22726. if !ok {
  22727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22728. }
  22729. m.SetUpdatedAt(v)
  22730. return nil
  22731. case labelrelationship.FieldStatus:
  22732. v, ok := value.(uint8)
  22733. if !ok {
  22734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22735. }
  22736. m.SetStatus(v)
  22737. return nil
  22738. case labelrelationship.FieldDeletedAt:
  22739. v, ok := value.(time.Time)
  22740. if !ok {
  22741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22742. }
  22743. m.SetDeletedAt(v)
  22744. return nil
  22745. case labelrelationship.FieldLabelID:
  22746. v, ok := value.(uint64)
  22747. if !ok {
  22748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22749. }
  22750. m.SetLabelID(v)
  22751. return nil
  22752. case labelrelationship.FieldContactID:
  22753. v, ok := value.(uint64)
  22754. if !ok {
  22755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22756. }
  22757. m.SetContactID(v)
  22758. return nil
  22759. case labelrelationship.FieldOrganizationID:
  22760. v, ok := value.(uint64)
  22761. if !ok {
  22762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22763. }
  22764. m.SetOrganizationID(v)
  22765. return nil
  22766. }
  22767. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22768. }
  22769. // AddedFields returns all numeric fields that were incremented/decremented during
  22770. // this mutation.
  22771. func (m *LabelRelationshipMutation) AddedFields() []string {
  22772. var fields []string
  22773. if m.addstatus != nil {
  22774. fields = append(fields, labelrelationship.FieldStatus)
  22775. }
  22776. if m.addorganization_id != nil {
  22777. fields = append(fields, labelrelationship.FieldOrganizationID)
  22778. }
  22779. return fields
  22780. }
  22781. // AddedField returns the numeric value that was incremented/decremented on a field
  22782. // with the given name. The second boolean return value indicates that this field
  22783. // was not set, or was not defined in the schema.
  22784. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  22785. switch name {
  22786. case labelrelationship.FieldStatus:
  22787. return m.AddedStatus()
  22788. case labelrelationship.FieldOrganizationID:
  22789. return m.AddedOrganizationID()
  22790. }
  22791. return nil, false
  22792. }
  22793. // AddField adds the value to the field with the given name. It returns an error if
  22794. // the field is not defined in the schema, or if the type mismatched the field
  22795. // type.
  22796. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  22797. switch name {
  22798. case labelrelationship.FieldStatus:
  22799. v, ok := value.(int8)
  22800. if !ok {
  22801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22802. }
  22803. m.AddStatus(v)
  22804. return nil
  22805. case labelrelationship.FieldOrganizationID:
  22806. v, ok := value.(int64)
  22807. if !ok {
  22808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22809. }
  22810. m.AddOrganizationID(v)
  22811. return nil
  22812. }
  22813. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  22814. }
  22815. // ClearedFields returns all nullable fields that were cleared during this
  22816. // mutation.
  22817. func (m *LabelRelationshipMutation) ClearedFields() []string {
  22818. var fields []string
  22819. if m.FieldCleared(labelrelationship.FieldStatus) {
  22820. fields = append(fields, labelrelationship.FieldStatus)
  22821. }
  22822. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  22823. fields = append(fields, labelrelationship.FieldDeletedAt)
  22824. }
  22825. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  22826. fields = append(fields, labelrelationship.FieldOrganizationID)
  22827. }
  22828. return fields
  22829. }
  22830. // FieldCleared returns a boolean indicating if a field with the given name was
  22831. // cleared in this mutation.
  22832. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  22833. _, ok := m.clearedFields[name]
  22834. return ok
  22835. }
  22836. // ClearField clears the value of the field with the given name. It returns an
  22837. // error if the field is not defined in the schema.
  22838. func (m *LabelRelationshipMutation) ClearField(name string) error {
  22839. switch name {
  22840. case labelrelationship.FieldStatus:
  22841. m.ClearStatus()
  22842. return nil
  22843. case labelrelationship.FieldDeletedAt:
  22844. m.ClearDeletedAt()
  22845. return nil
  22846. case labelrelationship.FieldOrganizationID:
  22847. m.ClearOrganizationID()
  22848. return nil
  22849. }
  22850. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  22851. }
  22852. // ResetField resets all changes in the mutation for the field with the given name.
  22853. // It returns an error if the field is not defined in the schema.
  22854. func (m *LabelRelationshipMutation) ResetField(name string) error {
  22855. switch name {
  22856. case labelrelationship.FieldCreatedAt:
  22857. m.ResetCreatedAt()
  22858. return nil
  22859. case labelrelationship.FieldUpdatedAt:
  22860. m.ResetUpdatedAt()
  22861. return nil
  22862. case labelrelationship.FieldStatus:
  22863. m.ResetStatus()
  22864. return nil
  22865. case labelrelationship.FieldDeletedAt:
  22866. m.ResetDeletedAt()
  22867. return nil
  22868. case labelrelationship.FieldLabelID:
  22869. m.ResetLabelID()
  22870. return nil
  22871. case labelrelationship.FieldContactID:
  22872. m.ResetContactID()
  22873. return nil
  22874. case labelrelationship.FieldOrganizationID:
  22875. m.ResetOrganizationID()
  22876. return nil
  22877. }
  22878. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22879. }
  22880. // AddedEdges returns all edge names that were set/added in this mutation.
  22881. func (m *LabelRelationshipMutation) AddedEdges() []string {
  22882. edges := make([]string, 0, 2)
  22883. if m.contacts != nil {
  22884. edges = append(edges, labelrelationship.EdgeContacts)
  22885. }
  22886. if m.labels != nil {
  22887. edges = append(edges, labelrelationship.EdgeLabels)
  22888. }
  22889. return edges
  22890. }
  22891. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22892. // name in this mutation.
  22893. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  22894. switch name {
  22895. case labelrelationship.EdgeContacts:
  22896. if id := m.contacts; id != nil {
  22897. return []ent.Value{*id}
  22898. }
  22899. case labelrelationship.EdgeLabels:
  22900. if id := m.labels; id != nil {
  22901. return []ent.Value{*id}
  22902. }
  22903. }
  22904. return nil
  22905. }
  22906. // RemovedEdges returns all edge names that were removed in this mutation.
  22907. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  22908. edges := make([]string, 0, 2)
  22909. return edges
  22910. }
  22911. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22912. // the given name in this mutation.
  22913. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  22914. return nil
  22915. }
  22916. // ClearedEdges returns all edge names that were cleared in this mutation.
  22917. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  22918. edges := make([]string, 0, 2)
  22919. if m.clearedcontacts {
  22920. edges = append(edges, labelrelationship.EdgeContacts)
  22921. }
  22922. if m.clearedlabels {
  22923. edges = append(edges, labelrelationship.EdgeLabels)
  22924. }
  22925. return edges
  22926. }
  22927. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22928. // was cleared in this mutation.
  22929. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  22930. switch name {
  22931. case labelrelationship.EdgeContacts:
  22932. return m.clearedcontacts
  22933. case labelrelationship.EdgeLabels:
  22934. return m.clearedlabels
  22935. }
  22936. return false
  22937. }
  22938. // ClearEdge clears the value of the edge with the given name. It returns an error
  22939. // if that edge is not defined in the schema.
  22940. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  22941. switch name {
  22942. case labelrelationship.EdgeContacts:
  22943. m.ClearContacts()
  22944. return nil
  22945. case labelrelationship.EdgeLabels:
  22946. m.ClearLabels()
  22947. return nil
  22948. }
  22949. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  22950. }
  22951. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22952. // It returns an error if the edge is not defined in the schema.
  22953. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  22954. switch name {
  22955. case labelrelationship.EdgeContacts:
  22956. m.ResetContacts()
  22957. return nil
  22958. case labelrelationship.EdgeLabels:
  22959. m.ResetLabels()
  22960. return nil
  22961. }
  22962. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  22963. }
  22964. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  22965. type LabelTaggingMutation struct {
  22966. config
  22967. op Op
  22968. typ string
  22969. id *uint64
  22970. created_at *time.Time
  22971. updated_at *time.Time
  22972. status *uint8
  22973. addstatus *int8
  22974. deleted_at *time.Time
  22975. organization_id *uint64
  22976. addorganization_id *int64
  22977. _type *int
  22978. add_type *int
  22979. conditions *string
  22980. action_label_add *[]uint64
  22981. appendaction_label_add []uint64
  22982. action_label_del *[]uint64
  22983. appendaction_label_del []uint64
  22984. clearedFields map[string]struct{}
  22985. done bool
  22986. oldValue func(context.Context) (*LabelTagging, error)
  22987. predicates []predicate.LabelTagging
  22988. }
  22989. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  22990. // labeltaggingOption allows management of the mutation configuration using functional options.
  22991. type labeltaggingOption func(*LabelTaggingMutation)
  22992. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  22993. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  22994. m := &LabelTaggingMutation{
  22995. config: c,
  22996. op: op,
  22997. typ: TypeLabelTagging,
  22998. clearedFields: make(map[string]struct{}),
  22999. }
  23000. for _, opt := range opts {
  23001. opt(m)
  23002. }
  23003. return m
  23004. }
  23005. // withLabelTaggingID sets the ID field of the mutation.
  23006. func withLabelTaggingID(id uint64) labeltaggingOption {
  23007. return func(m *LabelTaggingMutation) {
  23008. var (
  23009. err error
  23010. once sync.Once
  23011. value *LabelTagging
  23012. )
  23013. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  23014. once.Do(func() {
  23015. if m.done {
  23016. err = errors.New("querying old values post mutation is not allowed")
  23017. } else {
  23018. value, err = m.Client().LabelTagging.Get(ctx, id)
  23019. }
  23020. })
  23021. return value, err
  23022. }
  23023. m.id = &id
  23024. }
  23025. }
  23026. // withLabelTagging sets the old LabelTagging of the mutation.
  23027. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  23028. return func(m *LabelTaggingMutation) {
  23029. m.oldValue = func(context.Context) (*LabelTagging, error) {
  23030. return node, nil
  23031. }
  23032. m.id = &node.ID
  23033. }
  23034. }
  23035. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23036. // executed in a transaction (ent.Tx), a transactional client is returned.
  23037. func (m LabelTaggingMutation) Client() *Client {
  23038. client := &Client{config: m.config}
  23039. client.init()
  23040. return client
  23041. }
  23042. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23043. // it returns an error otherwise.
  23044. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  23045. if _, ok := m.driver.(*txDriver); !ok {
  23046. return nil, errors.New("ent: mutation is not running in a transaction")
  23047. }
  23048. tx := &Tx{config: m.config}
  23049. tx.init()
  23050. return tx, nil
  23051. }
  23052. // SetID sets the value of the id field. Note that this
  23053. // operation is only accepted on creation of LabelTagging entities.
  23054. func (m *LabelTaggingMutation) SetID(id uint64) {
  23055. m.id = &id
  23056. }
  23057. // ID returns the ID value in the mutation. Note that the ID is only available
  23058. // if it was provided to the builder or after it was returned from the database.
  23059. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  23060. if m.id == nil {
  23061. return
  23062. }
  23063. return *m.id, true
  23064. }
  23065. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23066. // That means, if the mutation is applied within a transaction with an isolation level such
  23067. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23068. // or updated by the mutation.
  23069. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  23070. switch {
  23071. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23072. id, exists := m.ID()
  23073. if exists {
  23074. return []uint64{id}, nil
  23075. }
  23076. fallthrough
  23077. case m.op.Is(OpUpdate | OpDelete):
  23078. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  23079. default:
  23080. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23081. }
  23082. }
  23083. // SetCreatedAt sets the "created_at" field.
  23084. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  23085. m.created_at = &t
  23086. }
  23087. // CreatedAt returns the value of the "created_at" field in the mutation.
  23088. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  23089. v := m.created_at
  23090. if v == nil {
  23091. return
  23092. }
  23093. return *v, true
  23094. }
  23095. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  23096. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23098. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23099. if !m.op.Is(OpUpdateOne) {
  23100. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23101. }
  23102. if m.id == nil || m.oldValue == nil {
  23103. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23104. }
  23105. oldValue, err := m.oldValue(ctx)
  23106. if err != nil {
  23107. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23108. }
  23109. return oldValue.CreatedAt, nil
  23110. }
  23111. // ResetCreatedAt resets all changes to the "created_at" field.
  23112. func (m *LabelTaggingMutation) ResetCreatedAt() {
  23113. m.created_at = nil
  23114. }
  23115. // SetUpdatedAt sets the "updated_at" field.
  23116. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  23117. m.updated_at = &t
  23118. }
  23119. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23120. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  23121. v := m.updated_at
  23122. if v == nil {
  23123. return
  23124. }
  23125. return *v, true
  23126. }
  23127. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  23128. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23130. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23131. if !m.op.Is(OpUpdateOne) {
  23132. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23133. }
  23134. if m.id == nil || m.oldValue == nil {
  23135. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23136. }
  23137. oldValue, err := m.oldValue(ctx)
  23138. if err != nil {
  23139. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23140. }
  23141. return oldValue.UpdatedAt, nil
  23142. }
  23143. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23144. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  23145. m.updated_at = nil
  23146. }
  23147. // SetStatus sets the "status" field.
  23148. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  23149. m.status = &u
  23150. m.addstatus = nil
  23151. }
  23152. // Status returns the value of the "status" field in the mutation.
  23153. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  23154. v := m.status
  23155. if v == nil {
  23156. return
  23157. }
  23158. return *v, true
  23159. }
  23160. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  23161. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23163. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23164. if !m.op.Is(OpUpdateOne) {
  23165. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23166. }
  23167. if m.id == nil || m.oldValue == nil {
  23168. return v, errors.New("OldStatus requires an ID field in the mutation")
  23169. }
  23170. oldValue, err := m.oldValue(ctx)
  23171. if err != nil {
  23172. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23173. }
  23174. return oldValue.Status, nil
  23175. }
  23176. // AddStatus adds u to the "status" field.
  23177. func (m *LabelTaggingMutation) AddStatus(u int8) {
  23178. if m.addstatus != nil {
  23179. *m.addstatus += u
  23180. } else {
  23181. m.addstatus = &u
  23182. }
  23183. }
  23184. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23185. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  23186. v := m.addstatus
  23187. if v == nil {
  23188. return
  23189. }
  23190. return *v, true
  23191. }
  23192. // ClearStatus clears the value of the "status" field.
  23193. func (m *LabelTaggingMutation) ClearStatus() {
  23194. m.status = nil
  23195. m.addstatus = nil
  23196. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  23197. }
  23198. // StatusCleared returns if the "status" field was cleared in this mutation.
  23199. func (m *LabelTaggingMutation) StatusCleared() bool {
  23200. _, ok := m.clearedFields[labeltagging.FieldStatus]
  23201. return ok
  23202. }
  23203. // ResetStatus resets all changes to the "status" field.
  23204. func (m *LabelTaggingMutation) ResetStatus() {
  23205. m.status = nil
  23206. m.addstatus = nil
  23207. delete(m.clearedFields, labeltagging.FieldStatus)
  23208. }
  23209. // SetDeletedAt sets the "deleted_at" field.
  23210. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  23211. m.deleted_at = &t
  23212. }
  23213. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23214. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  23215. v := m.deleted_at
  23216. if v == nil {
  23217. return
  23218. }
  23219. return *v, true
  23220. }
  23221. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  23222. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23224. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23225. if !m.op.Is(OpUpdateOne) {
  23226. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23227. }
  23228. if m.id == nil || m.oldValue == nil {
  23229. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23230. }
  23231. oldValue, err := m.oldValue(ctx)
  23232. if err != nil {
  23233. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23234. }
  23235. return oldValue.DeletedAt, nil
  23236. }
  23237. // ClearDeletedAt clears the value of the "deleted_at" field.
  23238. func (m *LabelTaggingMutation) ClearDeletedAt() {
  23239. m.deleted_at = nil
  23240. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  23241. }
  23242. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23243. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  23244. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  23245. return ok
  23246. }
  23247. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23248. func (m *LabelTaggingMutation) ResetDeletedAt() {
  23249. m.deleted_at = nil
  23250. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  23251. }
  23252. // SetOrganizationID sets the "organization_id" field.
  23253. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  23254. m.organization_id = &u
  23255. m.addorganization_id = nil
  23256. }
  23257. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23258. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  23259. v := m.organization_id
  23260. if v == nil {
  23261. return
  23262. }
  23263. return *v, true
  23264. }
  23265. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  23266. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23268. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23269. if !m.op.Is(OpUpdateOne) {
  23270. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23271. }
  23272. if m.id == nil || m.oldValue == nil {
  23273. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23274. }
  23275. oldValue, err := m.oldValue(ctx)
  23276. if err != nil {
  23277. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23278. }
  23279. return oldValue.OrganizationID, nil
  23280. }
  23281. // AddOrganizationID adds u to the "organization_id" field.
  23282. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  23283. if m.addorganization_id != nil {
  23284. *m.addorganization_id += u
  23285. } else {
  23286. m.addorganization_id = &u
  23287. }
  23288. }
  23289. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23290. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  23291. v := m.addorganization_id
  23292. if v == nil {
  23293. return
  23294. }
  23295. return *v, true
  23296. }
  23297. // ResetOrganizationID resets all changes to the "organization_id" field.
  23298. func (m *LabelTaggingMutation) ResetOrganizationID() {
  23299. m.organization_id = nil
  23300. m.addorganization_id = nil
  23301. }
  23302. // SetType sets the "type" field.
  23303. func (m *LabelTaggingMutation) SetType(i int) {
  23304. m._type = &i
  23305. m.add_type = nil
  23306. }
  23307. // GetType returns the value of the "type" field in the mutation.
  23308. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  23309. v := m._type
  23310. if v == nil {
  23311. return
  23312. }
  23313. return *v, true
  23314. }
  23315. // OldType returns the old "type" field's value of the LabelTagging entity.
  23316. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23318. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  23319. if !m.op.Is(OpUpdateOne) {
  23320. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23321. }
  23322. if m.id == nil || m.oldValue == nil {
  23323. return v, errors.New("OldType requires an ID field in the mutation")
  23324. }
  23325. oldValue, err := m.oldValue(ctx)
  23326. if err != nil {
  23327. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23328. }
  23329. return oldValue.Type, nil
  23330. }
  23331. // AddType adds i to the "type" field.
  23332. func (m *LabelTaggingMutation) AddType(i int) {
  23333. if m.add_type != nil {
  23334. *m.add_type += i
  23335. } else {
  23336. m.add_type = &i
  23337. }
  23338. }
  23339. // AddedType returns the value that was added to the "type" field in this mutation.
  23340. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  23341. v := m.add_type
  23342. if v == nil {
  23343. return
  23344. }
  23345. return *v, true
  23346. }
  23347. // ResetType resets all changes to the "type" field.
  23348. func (m *LabelTaggingMutation) ResetType() {
  23349. m._type = nil
  23350. m.add_type = nil
  23351. }
  23352. // SetConditions sets the "conditions" field.
  23353. func (m *LabelTaggingMutation) SetConditions(s string) {
  23354. m.conditions = &s
  23355. }
  23356. // Conditions returns the value of the "conditions" field in the mutation.
  23357. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  23358. v := m.conditions
  23359. if v == nil {
  23360. return
  23361. }
  23362. return *v, true
  23363. }
  23364. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  23365. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23367. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  23368. if !m.op.Is(OpUpdateOne) {
  23369. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  23370. }
  23371. if m.id == nil || m.oldValue == nil {
  23372. return v, errors.New("OldConditions requires an ID field in the mutation")
  23373. }
  23374. oldValue, err := m.oldValue(ctx)
  23375. if err != nil {
  23376. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  23377. }
  23378. return oldValue.Conditions, nil
  23379. }
  23380. // ResetConditions resets all changes to the "conditions" field.
  23381. func (m *LabelTaggingMutation) ResetConditions() {
  23382. m.conditions = nil
  23383. }
  23384. // SetActionLabelAdd sets the "action_label_add" field.
  23385. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  23386. m.action_label_add = &u
  23387. m.appendaction_label_add = nil
  23388. }
  23389. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23390. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23391. v := m.action_label_add
  23392. if v == nil {
  23393. return
  23394. }
  23395. return *v, true
  23396. }
  23397. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  23398. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23400. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23401. if !m.op.Is(OpUpdateOne) {
  23402. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23403. }
  23404. if m.id == nil || m.oldValue == nil {
  23405. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23406. }
  23407. oldValue, err := m.oldValue(ctx)
  23408. if err != nil {
  23409. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23410. }
  23411. return oldValue.ActionLabelAdd, nil
  23412. }
  23413. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23414. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  23415. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23416. }
  23417. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23418. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23419. if len(m.appendaction_label_add) == 0 {
  23420. return nil, false
  23421. }
  23422. return m.appendaction_label_add, true
  23423. }
  23424. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23425. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  23426. m.action_label_add = nil
  23427. m.appendaction_label_add = nil
  23428. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  23429. }
  23430. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23431. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  23432. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  23433. return ok
  23434. }
  23435. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23436. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  23437. m.action_label_add = nil
  23438. m.appendaction_label_add = nil
  23439. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  23440. }
  23441. // SetActionLabelDel sets the "action_label_del" field.
  23442. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  23443. m.action_label_del = &u
  23444. m.appendaction_label_del = nil
  23445. }
  23446. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23447. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  23448. v := m.action_label_del
  23449. if v == nil {
  23450. return
  23451. }
  23452. return *v, true
  23453. }
  23454. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  23455. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23457. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23458. if !m.op.Is(OpUpdateOne) {
  23459. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23460. }
  23461. if m.id == nil || m.oldValue == nil {
  23462. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23463. }
  23464. oldValue, err := m.oldValue(ctx)
  23465. if err != nil {
  23466. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23467. }
  23468. return oldValue.ActionLabelDel, nil
  23469. }
  23470. // AppendActionLabelDel adds u to the "action_label_del" field.
  23471. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  23472. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23473. }
  23474. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23475. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23476. if len(m.appendaction_label_del) == 0 {
  23477. return nil, false
  23478. }
  23479. return m.appendaction_label_del, true
  23480. }
  23481. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23482. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  23483. m.action_label_del = nil
  23484. m.appendaction_label_del = nil
  23485. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  23486. }
  23487. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23488. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  23489. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  23490. return ok
  23491. }
  23492. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23493. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  23494. m.action_label_del = nil
  23495. m.appendaction_label_del = nil
  23496. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  23497. }
  23498. // Where appends a list predicates to the LabelTaggingMutation builder.
  23499. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  23500. m.predicates = append(m.predicates, ps...)
  23501. }
  23502. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  23503. // users can use type-assertion to append predicates that do not depend on any generated package.
  23504. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  23505. p := make([]predicate.LabelTagging, len(ps))
  23506. for i := range ps {
  23507. p[i] = ps[i]
  23508. }
  23509. m.Where(p...)
  23510. }
  23511. // Op returns the operation name.
  23512. func (m *LabelTaggingMutation) Op() Op {
  23513. return m.op
  23514. }
  23515. // SetOp allows setting the mutation operation.
  23516. func (m *LabelTaggingMutation) SetOp(op Op) {
  23517. m.op = op
  23518. }
  23519. // Type returns the node type of this mutation (LabelTagging).
  23520. func (m *LabelTaggingMutation) Type() string {
  23521. return m.typ
  23522. }
  23523. // Fields returns all fields that were changed during this mutation. Note that in
  23524. // order to get all numeric fields that were incremented/decremented, call
  23525. // AddedFields().
  23526. func (m *LabelTaggingMutation) Fields() []string {
  23527. fields := make([]string, 0, 9)
  23528. if m.created_at != nil {
  23529. fields = append(fields, labeltagging.FieldCreatedAt)
  23530. }
  23531. if m.updated_at != nil {
  23532. fields = append(fields, labeltagging.FieldUpdatedAt)
  23533. }
  23534. if m.status != nil {
  23535. fields = append(fields, labeltagging.FieldStatus)
  23536. }
  23537. if m.deleted_at != nil {
  23538. fields = append(fields, labeltagging.FieldDeletedAt)
  23539. }
  23540. if m.organization_id != nil {
  23541. fields = append(fields, labeltagging.FieldOrganizationID)
  23542. }
  23543. if m._type != nil {
  23544. fields = append(fields, labeltagging.FieldType)
  23545. }
  23546. if m.conditions != nil {
  23547. fields = append(fields, labeltagging.FieldConditions)
  23548. }
  23549. if m.action_label_add != nil {
  23550. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23551. }
  23552. if m.action_label_del != nil {
  23553. fields = append(fields, labeltagging.FieldActionLabelDel)
  23554. }
  23555. return fields
  23556. }
  23557. // Field returns the value of a field with the given name. The second boolean
  23558. // return value indicates that this field was not set, or was not defined in the
  23559. // schema.
  23560. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  23561. switch name {
  23562. case labeltagging.FieldCreatedAt:
  23563. return m.CreatedAt()
  23564. case labeltagging.FieldUpdatedAt:
  23565. return m.UpdatedAt()
  23566. case labeltagging.FieldStatus:
  23567. return m.Status()
  23568. case labeltagging.FieldDeletedAt:
  23569. return m.DeletedAt()
  23570. case labeltagging.FieldOrganizationID:
  23571. return m.OrganizationID()
  23572. case labeltagging.FieldType:
  23573. return m.GetType()
  23574. case labeltagging.FieldConditions:
  23575. return m.Conditions()
  23576. case labeltagging.FieldActionLabelAdd:
  23577. return m.ActionLabelAdd()
  23578. case labeltagging.FieldActionLabelDel:
  23579. return m.ActionLabelDel()
  23580. }
  23581. return nil, false
  23582. }
  23583. // OldField returns the old value of the field from the database. An error is
  23584. // returned if the mutation operation is not UpdateOne, or the query to the
  23585. // database failed.
  23586. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23587. switch name {
  23588. case labeltagging.FieldCreatedAt:
  23589. return m.OldCreatedAt(ctx)
  23590. case labeltagging.FieldUpdatedAt:
  23591. return m.OldUpdatedAt(ctx)
  23592. case labeltagging.FieldStatus:
  23593. return m.OldStatus(ctx)
  23594. case labeltagging.FieldDeletedAt:
  23595. return m.OldDeletedAt(ctx)
  23596. case labeltagging.FieldOrganizationID:
  23597. return m.OldOrganizationID(ctx)
  23598. case labeltagging.FieldType:
  23599. return m.OldType(ctx)
  23600. case labeltagging.FieldConditions:
  23601. return m.OldConditions(ctx)
  23602. case labeltagging.FieldActionLabelAdd:
  23603. return m.OldActionLabelAdd(ctx)
  23604. case labeltagging.FieldActionLabelDel:
  23605. return m.OldActionLabelDel(ctx)
  23606. }
  23607. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  23608. }
  23609. // SetField sets the value of a field with the given name. It returns an error if
  23610. // the field is not defined in the schema, or if the type mismatched the field
  23611. // type.
  23612. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  23613. switch name {
  23614. case labeltagging.FieldCreatedAt:
  23615. v, ok := value.(time.Time)
  23616. if !ok {
  23617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23618. }
  23619. m.SetCreatedAt(v)
  23620. return nil
  23621. case labeltagging.FieldUpdatedAt:
  23622. v, ok := value.(time.Time)
  23623. if !ok {
  23624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23625. }
  23626. m.SetUpdatedAt(v)
  23627. return nil
  23628. case labeltagging.FieldStatus:
  23629. v, ok := value.(uint8)
  23630. if !ok {
  23631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23632. }
  23633. m.SetStatus(v)
  23634. return nil
  23635. case labeltagging.FieldDeletedAt:
  23636. v, ok := value.(time.Time)
  23637. if !ok {
  23638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23639. }
  23640. m.SetDeletedAt(v)
  23641. return nil
  23642. case labeltagging.FieldOrganizationID:
  23643. v, ok := value.(uint64)
  23644. if !ok {
  23645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23646. }
  23647. m.SetOrganizationID(v)
  23648. return nil
  23649. case labeltagging.FieldType:
  23650. v, ok := value.(int)
  23651. if !ok {
  23652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23653. }
  23654. m.SetType(v)
  23655. return nil
  23656. case labeltagging.FieldConditions:
  23657. v, ok := value.(string)
  23658. if !ok {
  23659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23660. }
  23661. m.SetConditions(v)
  23662. return nil
  23663. case labeltagging.FieldActionLabelAdd:
  23664. v, ok := value.([]uint64)
  23665. if !ok {
  23666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23667. }
  23668. m.SetActionLabelAdd(v)
  23669. return nil
  23670. case labeltagging.FieldActionLabelDel:
  23671. v, ok := value.([]uint64)
  23672. if !ok {
  23673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23674. }
  23675. m.SetActionLabelDel(v)
  23676. return nil
  23677. }
  23678. return fmt.Errorf("unknown LabelTagging field %s", name)
  23679. }
  23680. // AddedFields returns all numeric fields that were incremented/decremented during
  23681. // this mutation.
  23682. func (m *LabelTaggingMutation) AddedFields() []string {
  23683. var fields []string
  23684. if m.addstatus != nil {
  23685. fields = append(fields, labeltagging.FieldStatus)
  23686. }
  23687. if m.addorganization_id != nil {
  23688. fields = append(fields, labeltagging.FieldOrganizationID)
  23689. }
  23690. if m.add_type != nil {
  23691. fields = append(fields, labeltagging.FieldType)
  23692. }
  23693. return fields
  23694. }
  23695. // AddedField returns the numeric value that was incremented/decremented on a field
  23696. // with the given name. The second boolean return value indicates that this field
  23697. // was not set, or was not defined in the schema.
  23698. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  23699. switch name {
  23700. case labeltagging.FieldStatus:
  23701. return m.AddedStatus()
  23702. case labeltagging.FieldOrganizationID:
  23703. return m.AddedOrganizationID()
  23704. case labeltagging.FieldType:
  23705. return m.AddedType()
  23706. }
  23707. return nil, false
  23708. }
  23709. // AddField adds the value to the field with the given name. It returns an error if
  23710. // the field is not defined in the schema, or if the type mismatched the field
  23711. // type.
  23712. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  23713. switch name {
  23714. case labeltagging.FieldStatus:
  23715. v, ok := value.(int8)
  23716. if !ok {
  23717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23718. }
  23719. m.AddStatus(v)
  23720. return nil
  23721. case labeltagging.FieldOrganizationID:
  23722. v, ok := value.(int64)
  23723. if !ok {
  23724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23725. }
  23726. m.AddOrganizationID(v)
  23727. return nil
  23728. case labeltagging.FieldType:
  23729. v, ok := value.(int)
  23730. if !ok {
  23731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23732. }
  23733. m.AddType(v)
  23734. return nil
  23735. }
  23736. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  23737. }
  23738. // ClearedFields returns all nullable fields that were cleared during this
  23739. // mutation.
  23740. func (m *LabelTaggingMutation) ClearedFields() []string {
  23741. var fields []string
  23742. if m.FieldCleared(labeltagging.FieldStatus) {
  23743. fields = append(fields, labeltagging.FieldStatus)
  23744. }
  23745. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  23746. fields = append(fields, labeltagging.FieldDeletedAt)
  23747. }
  23748. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  23749. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23750. }
  23751. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  23752. fields = append(fields, labeltagging.FieldActionLabelDel)
  23753. }
  23754. return fields
  23755. }
  23756. // FieldCleared returns a boolean indicating if a field with the given name was
  23757. // cleared in this mutation.
  23758. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  23759. _, ok := m.clearedFields[name]
  23760. return ok
  23761. }
  23762. // ClearField clears the value of the field with the given name. It returns an
  23763. // error if the field is not defined in the schema.
  23764. func (m *LabelTaggingMutation) ClearField(name string) error {
  23765. switch name {
  23766. case labeltagging.FieldStatus:
  23767. m.ClearStatus()
  23768. return nil
  23769. case labeltagging.FieldDeletedAt:
  23770. m.ClearDeletedAt()
  23771. return nil
  23772. case labeltagging.FieldActionLabelAdd:
  23773. m.ClearActionLabelAdd()
  23774. return nil
  23775. case labeltagging.FieldActionLabelDel:
  23776. m.ClearActionLabelDel()
  23777. return nil
  23778. }
  23779. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  23780. }
  23781. // ResetField resets all changes in the mutation for the field with the given name.
  23782. // It returns an error if the field is not defined in the schema.
  23783. func (m *LabelTaggingMutation) ResetField(name string) error {
  23784. switch name {
  23785. case labeltagging.FieldCreatedAt:
  23786. m.ResetCreatedAt()
  23787. return nil
  23788. case labeltagging.FieldUpdatedAt:
  23789. m.ResetUpdatedAt()
  23790. return nil
  23791. case labeltagging.FieldStatus:
  23792. m.ResetStatus()
  23793. return nil
  23794. case labeltagging.FieldDeletedAt:
  23795. m.ResetDeletedAt()
  23796. return nil
  23797. case labeltagging.FieldOrganizationID:
  23798. m.ResetOrganizationID()
  23799. return nil
  23800. case labeltagging.FieldType:
  23801. m.ResetType()
  23802. return nil
  23803. case labeltagging.FieldConditions:
  23804. m.ResetConditions()
  23805. return nil
  23806. case labeltagging.FieldActionLabelAdd:
  23807. m.ResetActionLabelAdd()
  23808. return nil
  23809. case labeltagging.FieldActionLabelDel:
  23810. m.ResetActionLabelDel()
  23811. return nil
  23812. }
  23813. return fmt.Errorf("unknown LabelTagging field %s", name)
  23814. }
  23815. // AddedEdges returns all edge names that were set/added in this mutation.
  23816. func (m *LabelTaggingMutation) AddedEdges() []string {
  23817. edges := make([]string, 0, 0)
  23818. return edges
  23819. }
  23820. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23821. // name in this mutation.
  23822. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  23823. return nil
  23824. }
  23825. // RemovedEdges returns all edge names that were removed in this mutation.
  23826. func (m *LabelTaggingMutation) RemovedEdges() []string {
  23827. edges := make([]string, 0, 0)
  23828. return edges
  23829. }
  23830. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23831. // the given name in this mutation.
  23832. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  23833. return nil
  23834. }
  23835. // ClearedEdges returns all edge names that were cleared in this mutation.
  23836. func (m *LabelTaggingMutation) ClearedEdges() []string {
  23837. edges := make([]string, 0, 0)
  23838. return edges
  23839. }
  23840. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23841. // was cleared in this mutation.
  23842. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  23843. return false
  23844. }
  23845. // ClearEdge clears the value of the edge with the given name. It returns an error
  23846. // if that edge is not defined in the schema.
  23847. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  23848. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  23849. }
  23850. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23851. // It returns an error if the edge is not defined in the schema.
  23852. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  23853. return fmt.Errorf("unknown LabelTagging edge %s", name)
  23854. }
  23855. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  23856. type MessageMutation struct {
  23857. config
  23858. op Op
  23859. typ string
  23860. id *int
  23861. wx_wxid *string
  23862. wxid *string
  23863. content *string
  23864. clearedFields map[string]struct{}
  23865. done bool
  23866. oldValue func(context.Context) (*Message, error)
  23867. predicates []predicate.Message
  23868. }
  23869. var _ ent.Mutation = (*MessageMutation)(nil)
  23870. // messageOption allows management of the mutation configuration using functional options.
  23871. type messageOption func(*MessageMutation)
  23872. // newMessageMutation creates new mutation for the Message entity.
  23873. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  23874. m := &MessageMutation{
  23875. config: c,
  23876. op: op,
  23877. typ: TypeMessage,
  23878. clearedFields: make(map[string]struct{}),
  23879. }
  23880. for _, opt := range opts {
  23881. opt(m)
  23882. }
  23883. return m
  23884. }
  23885. // withMessageID sets the ID field of the mutation.
  23886. func withMessageID(id int) messageOption {
  23887. return func(m *MessageMutation) {
  23888. var (
  23889. err error
  23890. once sync.Once
  23891. value *Message
  23892. )
  23893. m.oldValue = func(ctx context.Context) (*Message, error) {
  23894. once.Do(func() {
  23895. if m.done {
  23896. err = errors.New("querying old values post mutation is not allowed")
  23897. } else {
  23898. value, err = m.Client().Message.Get(ctx, id)
  23899. }
  23900. })
  23901. return value, err
  23902. }
  23903. m.id = &id
  23904. }
  23905. }
  23906. // withMessage sets the old Message of the mutation.
  23907. func withMessage(node *Message) messageOption {
  23908. return func(m *MessageMutation) {
  23909. m.oldValue = func(context.Context) (*Message, error) {
  23910. return node, nil
  23911. }
  23912. m.id = &node.ID
  23913. }
  23914. }
  23915. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23916. // executed in a transaction (ent.Tx), a transactional client is returned.
  23917. func (m MessageMutation) Client() *Client {
  23918. client := &Client{config: m.config}
  23919. client.init()
  23920. return client
  23921. }
  23922. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23923. // it returns an error otherwise.
  23924. func (m MessageMutation) Tx() (*Tx, error) {
  23925. if _, ok := m.driver.(*txDriver); !ok {
  23926. return nil, errors.New("ent: mutation is not running in a transaction")
  23927. }
  23928. tx := &Tx{config: m.config}
  23929. tx.init()
  23930. return tx, nil
  23931. }
  23932. // ID returns the ID value in the mutation. Note that the ID is only available
  23933. // if it was provided to the builder or after it was returned from the database.
  23934. func (m *MessageMutation) ID() (id int, exists bool) {
  23935. if m.id == nil {
  23936. return
  23937. }
  23938. return *m.id, true
  23939. }
  23940. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23941. // That means, if the mutation is applied within a transaction with an isolation level such
  23942. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23943. // or updated by the mutation.
  23944. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  23945. switch {
  23946. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23947. id, exists := m.ID()
  23948. if exists {
  23949. return []int{id}, nil
  23950. }
  23951. fallthrough
  23952. case m.op.Is(OpUpdate | OpDelete):
  23953. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  23954. default:
  23955. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23956. }
  23957. }
  23958. // SetWxWxid sets the "wx_wxid" field.
  23959. func (m *MessageMutation) SetWxWxid(s string) {
  23960. m.wx_wxid = &s
  23961. }
  23962. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  23963. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  23964. v := m.wx_wxid
  23965. if v == nil {
  23966. return
  23967. }
  23968. return *v, true
  23969. }
  23970. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  23971. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23973. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  23974. if !m.op.Is(OpUpdateOne) {
  23975. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  23976. }
  23977. if m.id == nil || m.oldValue == nil {
  23978. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  23979. }
  23980. oldValue, err := m.oldValue(ctx)
  23981. if err != nil {
  23982. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  23983. }
  23984. return oldValue.WxWxid, nil
  23985. }
  23986. // ClearWxWxid clears the value of the "wx_wxid" field.
  23987. func (m *MessageMutation) ClearWxWxid() {
  23988. m.wx_wxid = nil
  23989. m.clearedFields[message.FieldWxWxid] = struct{}{}
  23990. }
  23991. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  23992. func (m *MessageMutation) WxWxidCleared() bool {
  23993. _, ok := m.clearedFields[message.FieldWxWxid]
  23994. return ok
  23995. }
  23996. // ResetWxWxid resets all changes to the "wx_wxid" field.
  23997. func (m *MessageMutation) ResetWxWxid() {
  23998. m.wx_wxid = nil
  23999. delete(m.clearedFields, message.FieldWxWxid)
  24000. }
  24001. // SetWxid sets the "wxid" field.
  24002. func (m *MessageMutation) SetWxid(s string) {
  24003. m.wxid = &s
  24004. }
  24005. // Wxid returns the value of the "wxid" field in the mutation.
  24006. func (m *MessageMutation) Wxid() (r string, exists bool) {
  24007. v := m.wxid
  24008. if v == nil {
  24009. return
  24010. }
  24011. return *v, true
  24012. }
  24013. // OldWxid returns the old "wxid" field's value of the Message entity.
  24014. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  24015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24016. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  24017. if !m.op.Is(OpUpdateOne) {
  24018. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  24019. }
  24020. if m.id == nil || m.oldValue == nil {
  24021. return v, errors.New("OldWxid requires an ID field in the mutation")
  24022. }
  24023. oldValue, err := m.oldValue(ctx)
  24024. if err != nil {
  24025. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  24026. }
  24027. return oldValue.Wxid, nil
  24028. }
  24029. // ResetWxid resets all changes to the "wxid" field.
  24030. func (m *MessageMutation) ResetWxid() {
  24031. m.wxid = nil
  24032. }
  24033. // SetContent sets the "content" field.
  24034. func (m *MessageMutation) SetContent(s string) {
  24035. m.content = &s
  24036. }
  24037. // Content returns the value of the "content" field in the mutation.
  24038. func (m *MessageMutation) Content() (r string, exists bool) {
  24039. v := m.content
  24040. if v == nil {
  24041. return
  24042. }
  24043. return *v, true
  24044. }
  24045. // OldContent returns the old "content" field's value of the Message entity.
  24046. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  24047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24048. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  24049. if !m.op.Is(OpUpdateOne) {
  24050. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  24051. }
  24052. if m.id == nil || m.oldValue == nil {
  24053. return v, errors.New("OldContent requires an ID field in the mutation")
  24054. }
  24055. oldValue, err := m.oldValue(ctx)
  24056. if err != nil {
  24057. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  24058. }
  24059. return oldValue.Content, nil
  24060. }
  24061. // ResetContent resets all changes to the "content" field.
  24062. func (m *MessageMutation) ResetContent() {
  24063. m.content = nil
  24064. }
  24065. // Where appends a list predicates to the MessageMutation builder.
  24066. func (m *MessageMutation) Where(ps ...predicate.Message) {
  24067. m.predicates = append(m.predicates, ps...)
  24068. }
  24069. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  24070. // users can use type-assertion to append predicates that do not depend on any generated package.
  24071. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  24072. p := make([]predicate.Message, len(ps))
  24073. for i := range ps {
  24074. p[i] = ps[i]
  24075. }
  24076. m.Where(p...)
  24077. }
  24078. // Op returns the operation name.
  24079. func (m *MessageMutation) Op() Op {
  24080. return m.op
  24081. }
  24082. // SetOp allows setting the mutation operation.
  24083. func (m *MessageMutation) SetOp(op Op) {
  24084. m.op = op
  24085. }
  24086. // Type returns the node type of this mutation (Message).
  24087. func (m *MessageMutation) Type() string {
  24088. return m.typ
  24089. }
  24090. // Fields returns all fields that were changed during this mutation. Note that in
  24091. // order to get all numeric fields that were incremented/decremented, call
  24092. // AddedFields().
  24093. func (m *MessageMutation) Fields() []string {
  24094. fields := make([]string, 0, 3)
  24095. if m.wx_wxid != nil {
  24096. fields = append(fields, message.FieldWxWxid)
  24097. }
  24098. if m.wxid != nil {
  24099. fields = append(fields, message.FieldWxid)
  24100. }
  24101. if m.content != nil {
  24102. fields = append(fields, message.FieldContent)
  24103. }
  24104. return fields
  24105. }
  24106. // Field returns the value of a field with the given name. The second boolean
  24107. // return value indicates that this field was not set, or was not defined in the
  24108. // schema.
  24109. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  24110. switch name {
  24111. case message.FieldWxWxid:
  24112. return m.WxWxid()
  24113. case message.FieldWxid:
  24114. return m.Wxid()
  24115. case message.FieldContent:
  24116. return m.Content()
  24117. }
  24118. return nil, false
  24119. }
  24120. // OldField returns the old value of the field from the database. An error is
  24121. // returned if the mutation operation is not UpdateOne, or the query to the
  24122. // database failed.
  24123. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24124. switch name {
  24125. case message.FieldWxWxid:
  24126. return m.OldWxWxid(ctx)
  24127. case message.FieldWxid:
  24128. return m.OldWxid(ctx)
  24129. case message.FieldContent:
  24130. return m.OldContent(ctx)
  24131. }
  24132. return nil, fmt.Errorf("unknown Message field %s", name)
  24133. }
  24134. // SetField sets the value of a field with the given name. It returns an error if
  24135. // the field is not defined in the schema, or if the type mismatched the field
  24136. // type.
  24137. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  24138. switch name {
  24139. case message.FieldWxWxid:
  24140. v, ok := value.(string)
  24141. if !ok {
  24142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24143. }
  24144. m.SetWxWxid(v)
  24145. return nil
  24146. case message.FieldWxid:
  24147. v, ok := value.(string)
  24148. if !ok {
  24149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24150. }
  24151. m.SetWxid(v)
  24152. return nil
  24153. case message.FieldContent:
  24154. v, ok := value.(string)
  24155. if !ok {
  24156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24157. }
  24158. m.SetContent(v)
  24159. return nil
  24160. }
  24161. return fmt.Errorf("unknown Message field %s", name)
  24162. }
  24163. // AddedFields returns all numeric fields that were incremented/decremented during
  24164. // this mutation.
  24165. func (m *MessageMutation) AddedFields() []string {
  24166. return nil
  24167. }
  24168. // AddedField returns the numeric value that was incremented/decremented on a field
  24169. // with the given name. The second boolean return value indicates that this field
  24170. // was not set, or was not defined in the schema.
  24171. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  24172. return nil, false
  24173. }
  24174. // AddField adds the value to the field with the given name. It returns an error if
  24175. // the field is not defined in the schema, or if the type mismatched the field
  24176. // type.
  24177. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  24178. switch name {
  24179. }
  24180. return fmt.Errorf("unknown Message numeric field %s", name)
  24181. }
  24182. // ClearedFields returns all nullable fields that were cleared during this
  24183. // mutation.
  24184. func (m *MessageMutation) ClearedFields() []string {
  24185. var fields []string
  24186. if m.FieldCleared(message.FieldWxWxid) {
  24187. fields = append(fields, message.FieldWxWxid)
  24188. }
  24189. return fields
  24190. }
  24191. // FieldCleared returns a boolean indicating if a field with the given name was
  24192. // cleared in this mutation.
  24193. func (m *MessageMutation) FieldCleared(name string) bool {
  24194. _, ok := m.clearedFields[name]
  24195. return ok
  24196. }
  24197. // ClearField clears the value of the field with the given name. It returns an
  24198. // error if the field is not defined in the schema.
  24199. func (m *MessageMutation) ClearField(name string) error {
  24200. switch name {
  24201. case message.FieldWxWxid:
  24202. m.ClearWxWxid()
  24203. return nil
  24204. }
  24205. return fmt.Errorf("unknown Message nullable field %s", name)
  24206. }
  24207. // ResetField resets all changes in the mutation for the field with the given name.
  24208. // It returns an error if the field is not defined in the schema.
  24209. func (m *MessageMutation) ResetField(name string) error {
  24210. switch name {
  24211. case message.FieldWxWxid:
  24212. m.ResetWxWxid()
  24213. return nil
  24214. case message.FieldWxid:
  24215. m.ResetWxid()
  24216. return nil
  24217. case message.FieldContent:
  24218. m.ResetContent()
  24219. return nil
  24220. }
  24221. return fmt.Errorf("unknown Message field %s", name)
  24222. }
  24223. // AddedEdges returns all edge names that were set/added in this mutation.
  24224. func (m *MessageMutation) AddedEdges() []string {
  24225. edges := make([]string, 0, 0)
  24226. return edges
  24227. }
  24228. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24229. // name in this mutation.
  24230. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  24231. return nil
  24232. }
  24233. // RemovedEdges returns all edge names that were removed in this mutation.
  24234. func (m *MessageMutation) RemovedEdges() []string {
  24235. edges := make([]string, 0, 0)
  24236. return edges
  24237. }
  24238. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24239. // the given name in this mutation.
  24240. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  24241. return nil
  24242. }
  24243. // ClearedEdges returns all edge names that were cleared in this mutation.
  24244. func (m *MessageMutation) ClearedEdges() []string {
  24245. edges := make([]string, 0, 0)
  24246. return edges
  24247. }
  24248. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24249. // was cleared in this mutation.
  24250. func (m *MessageMutation) EdgeCleared(name string) bool {
  24251. return false
  24252. }
  24253. // ClearEdge clears the value of the edge with the given name. It returns an error
  24254. // if that edge is not defined in the schema.
  24255. func (m *MessageMutation) ClearEdge(name string) error {
  24256. return fmt.Errorf("unknown Message unique edge %s", name)
  24257. }
  24258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24259. // It returns an error if the edge is not defined in the schema.
  24260. func (m *MessageMutation) ResetEdge(name string) error {
  24261. return fmt.Errorf("unknown Message edge %s", name)
  24262. }
  24263. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  24264. type MessageRecordsMutation struct {
  24265. config
  24266. op Op
  24267. typ string
  24268. id *uint64
  24269. created_at *time.Time
  24270. updated_at *time.Time
  24271. status *uint8
  24272. addstatus *int8
  24273. bot_wxid *string
  24274. contact_type *int
  24275. addcontact_type *int
  24276. contact_wxid *string
  24277. content_type *int
  24278. addcontent_type *int
  24279. content *string
  24280. meta *custom_types.Meta
  24281. error_detail *string
  24282. send_time *time.Time
  24283. source_type *int
  24284. addsource_type *int
  24285. organization_id *uint64
  24286. addorganization_id *int64
  24287. clearedFields map[string]struct{}
  24288. sop_stage *uint64
  24289. clearedsop_stage bool
  24290. sop_node *uint64
  24291. clearedsop_node bool
  24292. message_contact *uint64
  24293. clearedmessage_contact bool
  24294. done bool
  24295. oldValue func(context.Context) (*MessageRecords, error)
  24296. predicates []predicate.MessageRecords
  24297. }
  24298. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  24299. // messagerecordsOption allows management of the mutation configuration using functional options.
  24300. type messagerecordsOption func(*MessageRecordsMutation)
  24301. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  24302. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  24303. m := &MessageRecordsMutation{
  24304. config: c,
  24305. op: op,
  24306. typ: TypeMessageRecords,
  24307. clearedFields: make(map[string]struct{}),
  24308. }
  24309. for _, opt := range opts {
  24310. opt(m)
  24311. }
  24312. return m
  24313. }
  24314. // withMessageRecordsID sets the ID field of the mutation.
  24315. func withMessageRecordsID(id uint64) messagerecordsOption {
  24316. return func(m *MessageRecordsMutation) {
  24317. var (
  24318. err error
  24319. once sync.Once
  24320. value *MessageRecords
  24321. )
  24322. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  24323. once.Do(func() {
  24324. if m.done {
  24325. err = errors.New("querying old values post mutation is not allowed")
  24326. } else {
  24327. value, err = m.Client().MessageRecords.Get(ctx, id)
  24328. }
  24329. })
  24330. return value, err
  24331. }
  24332. m.id = &id
  24333. }
  24334. }
  24335. // withMessageRecords sets the old MessageRecords of the mutation.
  24336. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  24337. return func(m *MessageRecordsMutation) {
  24338. m.oldValue = func(context.Context) (*MessageRecords, error) {
  24339. return node, nil
  24340. }
  24341. m.id = &node.ID
  24342. }
  24343. }
  24344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24345. // executed in a transaction (ent.Tx), a transactional client is returned.
  24346. func (m MessageRecordsMutation) Client() *Client {
  24347. client := &Client{config: m.config}
  24348. client.init()
  24349. return client
  24350. }
  24351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24352. // it returns an error otherwise.
  24353. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  24354. if _, ok := m.driver.(*txDriver); !ok {
  24355. return nil, errors.New("ent: mutation is not running in a transaction")
  24356. }
  24357. tx := &Tx{config: m.config}
  24358. tx.init()
  24359. return tx, nil
  24360. }
  24361. // SetID sets the value of the id field. Note that this
  24362. // operation is only accepted on creation of MessageRecords entities.
  24363. func (m *MessageRecordsMutation) SetID(id uint64) {
  24364. m.id = &id
  24365. }
  24366. // ID returns the ID value in the mutation. Note that the ID is only available
  24367. // if it was provided to the builder or after it was returned from the database.
  24368. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  24369. if m.id == nil {
  24370. return
  24371. }
  24372. return *m.id, true
  24373. }
  24374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24375. // That means, if the mutation is applied within a transaction with an isolation level such
  24376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24377. // or updated by the mutation.
  24378. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  24379. switch {
  24380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24381. id, exists := m.ID()
  24382. if exists {
  24383. return []uint64{id}, nil
  24384. }
  24385. fallthrough
  24386. case m.op.Is(OpUpdate | OpDelete):
  24387. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  24388. default:
  24389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24390. }
  24391. }
  24392. // SetCreatedAt sets the "created_at" field.
  24393. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  24394. m.created_at = &t
  24395. }
  24396. // CreatedAt returns the value of the "created_at" field in the mutation.
  24397. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  24398. v := m.created_at
  24399. if v == nil {
  24400. return
  24401. }
  24402. return *v, true
  24403. }
  24404. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  24405. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24407. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24408. if !m.op.Is(OpUpdateOne) {
  24409. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24410. }
  24411. if m.id == nil || m.oldValue == nil {
  24412. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24413. }
  24414. oldValue, err := m.oldValue(ctx)
  24415. if err != nil {
  24416. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24417. }
  24418. return oldValue.CreatedAt, nil
  24419. }
  24420. // ResetCreatedAt resets all changes to the "created_at" field.
  24421. func (m *MessageRecordsMutation) ResetCreatedAt() {
  24422. m.created_at = nil
  24423. }
  24424. // SetUpdatedAt sets the "updated_at" field.
  24425. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  24426. m.updated_at = &t
  24427. }
  24428. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24429. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  24430. v := m.updated_at
  24431. if v == nil {
  24432. return
  24433. }
  24434. return *v, true
  24435. }
  24436. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  24437. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24439. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24440. if !m.op.Is(OpUpdateOne) {
  24441. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24442. }
  24443. if m.id == nil || m.oldValue == nil {
  24444. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24445. }
  24446. oldValue, err := m.oldValue(ctx)
  24447. if err != nil {
  24448. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24449. }
  24450. return oldValue.UpdatedAt, nil
  24451. }
  24452. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24453. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  24454. m.updated_at = nil
  24455. }
  24456. // SetStatus sets the "status" field.
  24457. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  24458. m.status = &u
  24459. m.addstatus = nil
  24460. }
  24461. // Status returns the value of the "status" field in the mutation.
  24462. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  24463. v := m.status
  24464. if v == nil {
  24465. return
  24466. }
  24467. return *v, true
  24468. }
  24469. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  24470. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24472. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24473. if !m.op.Is(OpUpdateOne) {
  24474. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24475. }
  24476. if m.id == nil || m.oldValue == nil {
  24477. return v, errors.New("OldStatus requires an ID field in the mutation")
  24478. }
  24479. oldValue, err := m.oldValue(ctx)
  24480. if err != nil {
  24481. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24482. }
  24483. return oldValue.Status, nil
  24484. }
  24485. // AddStatus adds u to the "status" field.
  24486. func (m *MessageRecordsMutation) AddStatus(u int8) {
  24487. if m.addstatus != nil {
  24488. *m.addstatus += u
  24489. } else {
  24490. m.addstatus = &u
  24491. }
  24492. }
  24493. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24494. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  24495. v := m.addstatus
  24496. if v == nil {
  24497. return
  24498. }
  24499. return *v, true
  24500. }
  24501. // ClearStatus clears the value of the "status" field.
  24502. func (m *MessageRecordsMutation) ClearStatus() {
  24503. m.status = nil
  24504. m.addstatus = nil
  24505. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  24506. }
  24507. // StatusCleared returns if the "status" field was cleared in this mutation.
  24508. func (m *MessageRecordsMutation) StatusCleared() bool {
  24509. _, ok := m.clearedFields[messagerecords.FieldStatus]
  24510. return ok
  24511. }
  24512. // ResetStatus resets all changes to the "status" field.
  24513. func (m *MessageRecordsMutation) ResetStatus() {
  24514. m.status = nil
  24515. m.addstatus = nil
  24516. delete(m.clearedFields, messagerecords.FieldStatus)
  24517. }
  24518. // SetBotWxid sets the "bot_wxid" field.
  24519. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  24520. m.bot_wxid = &s
  24521. }
  24522. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  24523. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  24524. v := m.bot_wxid
  24525. if v == nil {
  24526. return
  24527. }
  24528. return *v, true
  24529. }
  24530. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  24531. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24533. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  24534. if !m.op.Is(OpUpdateOne) {
  24535. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  24536. }
  24537. if m.id == nil || m.oldValue == nil {
  24538. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  24539. }
  24540. oldValue, err := m.oldValue(ctx)
  24541. if err != nil {
  24542. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  24543. }
  24544. return oldValue.BotWxid, nil
  24545. }
  24546. // ResetBotWxid resets all changes to the "bot_wxid" field.
  24547. func (m *MessageRecordsMutation) ResetBotWxid() {
  24548. m.bot_wxid = nil
  24549. }
  24550. // SetContactID sets the "contact_id" field.
  24551. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  24552. m.message_contact = &u
  24553. }
  24554. // ContactID returns the value of the "contact_id" field in the mutation.
  24555. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  24556. v := m.message_contact
  24557. if v == nil {
  24558. return
  24559. }
  24560. return *v, true
  24561. }
  24562. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  24563. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24565. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  24566. if !m.op.Is(OpUpdateOne) {
  24567. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  24568. }
  24569. if m.id == nil || m.oldValue == nil {
  24570. return v, errors.New("OldContactID requires an ID field in the mutation")
  24571. }
  24572. oldValue, err := m.oldValue(ctx)
  24573. if err != nil {
  24574. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  24575. }
  24576. return oldValue.ContactID, nil
  24577. }
  24578. // ClearContactID clears the value of the "contact_id" field.
  24579. func (m *MessageRecordsMutation) ClearContactID() {
  24580. m.message_contact = nil
  24581. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  24582. }
  24583. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  24584. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  24585. _, ok := m.clearedFields[messagerecords.FieldContactID]
  24586. return ok
  24587. }
  24588. // ResetContactID resets all changes to the "contact_id" field.
  24589. func (m *MessageRecordsMutation) ResetContactID() {
  24590. m.message_contact = nil
  24591. delete(m.clearedFields, messagerecords.FieldContactID)
  24592. }
  24593. // SetContactType sets the "contact_type" field.
  24594. func (m *MessageRecordsMutation) SetContactType(i int) {
  24595. m.contact_type = &i
  24596. m.addcontact_type = nil
  24597. }
  24598. // ContactType returns the value of the "contact_type" field in the mutation.
  24599. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  24600. v := m.contact_type
  24601. if v == nil {
  24602. return
  24603. }
  24604. return *v, true
  24605. }
  24606. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  24607. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24609. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  24610. if !m.op.Is(OpUpdateOne) {
  24611. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  24612. }
  24613. if m.id == nil || m.oldValue == nil {
  24614. return v, errors.New("OldContactType requires an ID field in the mutation")
  24615. }
  24616. oldValue, err := m.oldValue(ctx)
  24617. if err != nil {
  24618. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  24619. }
  24620. return oldValue.ContactType, nil
  24621. }
  24622. // AddContactType adds i to the "contact_type" field.
  24623. func (m *MessageRecordsMutation) AddContactType(i int) {
  24624. if m.addcontact_type != nil {
  24625. *m.addcontact_type += i
  24626. } else {
  24627. m.addcontact_type = &i
  24628. }
  24629. }
  24630. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  24631. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  24632. v := m.addcontact_type
  24633. if v == nil {
  24634. return
  24635. }
  24636. return *v, true
  24637. }
  24638. // ResetContactType resets all changes to the "contact_type" field.
  24639. func (m *MessageRecordsMutation) ResetContactType() {
  24640. m.contact_type = nil
  24641. m.addcontact_type = nil
  24642. }
  24643. // SetContactWxid sets the "contact_wxid" field.
  24644. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  24645. m.contact_wxid = &s
  24646. }
  24647. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  24648. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  24649. v := m.contact_wxid
  24650. if v == nil {
  24651. return
  24652. }
  24653. return *v, true
  24654. }
  24655. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  24656. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24658. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  24659. if !m.op.Is(OpUpdateOne) {
  24660. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  24661. }
  24662. if m.id == nil || m.oldValue == nil {
  24663. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  24664. }
  24665. oldValue, err := m.oldValue(ctx)
  24666. if err != nil {
  24667. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  24668. }
  24669. return oldValue.ContactWxid, nil
  24670. }
  24671. // ResetContactWxid resets all changes to the "contact_wxid" field.
  24672. func (m *MessageRecordsMutation) ResetContactWxid() {
  24673. m.contact_wxid = nil
  24674. }
  24675. // SetContentType sets the "content_type" field.
  24676. func (m *MessageRecordsMutation) SetContentType(i int) {
  24677. m.content_type = &i
  24678. m.addcontent_type = nil
  24679. }
  24680. // ContentType returns the value of the "content_type" field in the mutation.
  24681. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  24682. v := m.content_type
  24683. if v == nil {
  24684. return
  24685. }
  24686. return *v, true
  24687. }
  24688. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  24689. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24691. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  24692. if !m.op.Is(OpUpdateOne) {
  24693. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  24694. }
  24695. if m.id == nil || m.oldValue == nil {
  24696. return v, errors.New("OldContentType requires an ID field in the mutation")
  24697. }
  24698. oldValue, err := m.oldValue(ctx)
  24699. if err != nil {
  24700. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  24701. }
  24702. return oldValue.ContentType, nil
  24703. }
  24704. // AddContentType adds i to the "content_type" field.
  24705. func (m *MessageRecordsMutation) AddContentType(i int) {
  24706. if m.addcontent_type != nil {
  24707. *m.addcontent_type += i
  24708. } else {
  24709. m.addcontent_type = &i
  24710. }
  24711. }
  24712. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  24713. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  24714. v := m.addcontent_type
  24715. if v == nil {
  24716. return
  24717. }
  24718. return *v, true
  24719. }
  24720. // ResetContentType resets all changes to the "content_type" field.
  24721. func (m *MessageRecordsMutation) ResetContentType() {
  24722. m.content_type = nil
  24723. m.addcontent_type = nil
  24724. }
  24725. // SetContent sets the "content" field.
  24726. func (m *MessageRecordsMutation) SetContent(s string) {
  24727. m.content = &s
  24728. }
  24729. // Content returns the value of the "content" field in the mutation.
  24730. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  24731. v := m.content
  24732. if v == nil {
  24733. return
  24734. }
  24735. return *v, true
  24736. }
  24737. // OldContent returns the old "content" field's value of the MessageRecords entity.
  24738. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24740. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  24741. if !m.op.Is(OpUpdateOne) {
  24742. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  24743. }
  24744. if m.id == nil || m.oldValue == nil {
  24745. return v, errors.New("OldContent requires an ID field in the mutation")
  24746. }
  24747. oldValue, err := m.oldValue(ctx)
  24748. if err != nil {
  24749. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  24750. }
  24751. return oldValue.Content, nil
  24752. }
  24753. // ResetContent resets all changes to the "content" field.
  24754. func (m *MessageRecordsMutation) ResetContent() {
  24755. m.content = nil
  24756. }
  24757. // SetMeta sets the "meta" field.
  24758. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  24759. m.meta = &ct
  24760. }
  24761. // Meta returns the value of the "meta" field in the mutation.
  24762. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  24763. v := m.meta
  24764. if v == nil {
  24765. return
  24766. }
  24767. return *v, true
  24768. }
  24769. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  24770. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24772. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  24773. if !m.op.Is(OpUpdateOne) {
  24774. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  24775. }
  24776. if m.id == nil || m.oldValue == nil {
  24777. return v, errors.New("OldMeta requires an ID field in the mutation")
  24778. }
  24779. oldValue, err := m.oldValue(ctx)
  24780. if err != nil {
  24781. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  24782. }
  24783. return oldValue.Meta, nil
  24784. }
  24785. // ClearMeta clears the value of the "meta" field.
  24786. func (m *MessageRecordsMutation) ClearMeta() {
  24787. m.meta = nil
  24788. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  24789. }
  24790. // MetaCleared returns if the "meta" field was cleared in this mutation.
  24791. func (m *MessageRecordsMutation) MetaCleared() bool {
  24792. _, ok := m.clearedFields[messagerecords.FieldMeta]
  24793. return ok
  24794. }
  24795. // ResetMeta resets all changes to the "meta" field.
  24796. func (m *MessageRecordsMutation) ResetMeta() {
  24797. m.meta = nil
  24798. delete(m.clearedFields, messagerecords.FieldMeta)
  24799. }
  24800. // SetErrorDetail sets the "error_detail" field.
  24801. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  24802. m.error_detail = &s
  24803. }
  24804. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  24805. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  24806. v := m.error_detail
  24807. if v == nil {
  24808. return
  24809. }
  24810. return *v, true
  24811. }
  24812. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  24813. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24815. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  24816. if !m.op.Is(OpUpdateOne) {
  24817. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  24818. }
  24819. if m.id == nil || m.oldValue == nil {
  24820. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  24821. }
  24822. oldValue, err := m.oldValue(ctx)
  24823. if err != nil {
  24824. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  24825. }
  24826. return oldValue.ErrorDetail, nil
  24827. }
  24828. // ResetErrorDetail resets all changes to the "error_detail" field.
  24829. func (m *MessageRecordsMutation) ResetErrorDetail() {
  24830. m.error_detail = nil
  24831. }
  24832. // SetSendTime sets the "send_time" field.
  24833. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  24834. m.send_time = &t
  24835. }
  24836. // SendTime returns the value of the "send_time" field in the mutation.
  24837. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  24838. v := m.send_time
  24839. if v == nil {
  24840. return
  24841. }
  24842. return *v, true
  24843. }
  24844. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  24845. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24847. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  24848. if !m.op.Is(OpUpdateOne) {
  24849. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  24850. }
  24851. if m.id == nil || m.oldValue == nil {
  24852. return v, errors.New("OldSendTime requires an ID field in the mutation")
  24853. }
  24854. oldValue, err := m.oldValue(ctx)
  24855. if err != nil {
  24856. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  24857. }
  24858. return oldValue.SendTime, nil
  24859. }
  24860. // ClearSendTime clears the value of the "send_time" field.
  24861. func (m *MessageRecordsMutation) ClearSendTime() {
  24862. m.send_time = nil
  24863. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  24864. }
  24865. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  24866. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  24867. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  24868. return ok
  24869. }
  24870. // ResetSendTime resets all changes to the "send_time" field.
  24871. func (m *MessageRecordsMutation) ResetSendTime() {
  24872. m.send_time = nil
  24873. delete(m.clearedFields, messagerecords.FieldSendTime)
  24874. }
  24875. // SetSourceType sets the "source_type" field.
  24876. func (m *MessageRecordsMutation) SetSourceType(i int) {
  24877. m.source_type = &i
  24878. m.addsource_type = nil
  24879. }
  24880. // SourceType returns the value of the "source_type" field in the mutation.
  24881. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  24882. v := m.source_type
  24883. if v == nil {
  24884. return
  24885. }
  24886. return *v, true
  24887. }
  24888. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  24889. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24891. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  24892. if !m.op.Is(OpUpdateOne) {
  24893. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  24894. }
  24895. if m.id == nil || m.oldValue == nil {
  24896. return v, errors.New("OldSourceType requires an ID field in the mutation")
  24897. }
  24898. oldValue, err := m.oldValue(ctx)
  24899. if err != nil {
  24900. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  24901. }
  24902. return oldValue.SourceType, nil
  24903. }
  24904. // AddSourceType adds i to the "source_type" field.
  24905. func (m *MessageRecordsMutation) AddSourceType(i int) {
  24906. if m.addsource_type != nil {
  24907. *m.addsource_type += i
  24908. } else {
  24909. m.addsource_type = &i
  24910. }
  24911. }
  24912. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  24913. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  24914. v := m.addsource_type
  24915. if v == nil {
  24916. return
  24917. }
  24918. return *v, true
  24919. }
  24920. // ResetSourceType resets all changes to the "source_type" field.
  24921. func (m *MessageRecordsMutation) ResetSourceType() {
  24922. m.source_type = nil
  24923. m.addsource_type = nil
  24924. }
  24925. // SetSourceID sets the "source_id" field.
  24926. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  24927. m.sop_stage = &u
  24928. }
  24929. // SourceID returns the value of the "source_id" field in the mutation.
  24930. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  24931. v := m.sop_stage
  24932. if v == nil {
  24933. return
  24934. }
  24935. return *v, true
  24936. }
  24937. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  24938. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24940. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  24941. if !m.op.Is(OpUpdateOne) {
  24942. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  24943. }
  24944. if m.id == nil || m.oldValue == nil {
  24945. return v, errors.New("OldSourceID requires an ID field in the mutation")
  24946. }
  24947. oldValue, err := m.oldValue(ctx)
  24948. if err != nil {
  24949. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  24950. }
  24951. return oldValue.SourceID, nil
  24952. }
  24953. // ClearSourceID clears the value of the "source_id" field.
  24954. func (m *MessageRecordsMutation) ClearSourceID() {
  24955. m.sop_stage = nil
  24956. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24957. }
  24958. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  24959. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  24960. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  24961. return ok
  24962. }
  24963. // ResetSourceID resets all changes to the "source_id" field.
  24964. func (m *MessageRecordsMutation) ResetSourceID() {
  24965. m.sop_stage = nil
  24966. delete(m.clearedFields, messagerecords.FieldSourceID)
  24967. }
  24968. // SetSubSourceID sets the "sub_source_id" field.
  24969. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  24970. m.sop_node = &u
  24971. }
  24972. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  24973. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  24974. v := m.sop_node
  24975. if v == nil {
  24976. return
  24977. }
  24978. return *v, true
  24979. }
  24980. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  24981. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24983. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  24984. if !m.op.Is(OpUpdateOne) {
  24985. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  24986. }
  24987. if m.id == nil || m.oldValue == nil {
  24988. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  24989. }
  24990. oldValue, err := m.oldValue(ctx)
  24991. if err != nil {
  24992. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  24993. }
  24994. return oldValue.SubSourceID, nil
  24995. }
  24996. // ClearSubSourceID clears the value of the "sub_source_id" field.
  24997. func (m *MessageRecordsMutation) ClearSubSourceID() {
  24998. m.sop_node = nil
  24999. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  25000. }
  25001. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  25002. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  25003. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  25004. return ok
  25005. }
  25006. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  25007. func (m *MessageRecordsMutation) ResetSubSourceID() {
  25008. m.sop_node = nil
  25009. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  25010. }
  25011. // SetOrganizationID sets the "organization_id" field.
  25012. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  25013. m.organization_id = &u
  25014. m.addorganization_id = nil
  25015. }
  25016. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25017. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  25018. v := m.organization_id
  25019. if v == nil {
  25020. return
  25021. }
  25022. return *v, true
  25023. }
  25024. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  25025. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  25026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25027. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25028. if !m.op.Is(OpUpdateOne) {
  25029. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25030. }
  25031. if m.id == nil || m.oldValue == nil {
  25032. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25033. }
  25034. oldValue, err := m.oldValue(ctx)
  25035. if err != nil {
  25036. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25037. }
  25038. return oldValue.OrganizationID, nil
  25039. }
  25040. // AddOrganizationID adds u to the "organization_id" field.
  25041. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  25042. if m.addorganization_id != nil {
  25043. *m.addorganization_id += u
  25044. } else {
  25045. m.addorganization_id = &u
  25046. }
  25047. }
  25048. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25049. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  25050. v := m.addorganization_id
  25051. if v == nil {
  25052. return
  25053. }
  25054. return *v, true
  25055. }
  25056. // ClearOrganizationID clears the value of the "organization_id" field.
  25057. func (m *MessageRecordsMutation) ClearOrganizationID() {
  25058. m.organization_id = nil
  25059. m.addorganization_id = nil
  25060. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  25061. }
  25062. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25063. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  25064. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  25065. return ok
  25066. }
  25067. // ResetOrganizationID resets all changes to the "organization_id" field.
  25068. func (m *MessageRecordsMutation) ResetOrganizationID() {
  25069. m.organization_id = nil
  25070. m.addorganization_id = nil
  25071. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  25072. }
  25073. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  25074. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  25075. m.sop_stage = &id
  25076. }
  25077. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  25078. func (m *MessageRecordsMutation) ClearSopStage() {
  25079. m.clearedsop_stage = true
  25080. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  25081. }
  25082. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  25083. func (m *MessageRecordsMutation) SopStageCleared() bool {
  25084. return m.SourceIDCleared() || m.clearedsop_stage
  25085. }
  25086. // SopStageID returns the "sop_stage" edge ID in the mutation.
  25087. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  25088. if m.sop_stage != nil {
  25089. return *m.sop_stage, true
  25090. }
  25091. return
  25092. }
  25093. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  25094. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25095. // SopStageID instead. It exists only for internal usage by the builders.
  25096. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  25097. if id := m.sop_stage; id != nil {
  25098. ids = append(ids, *id)
  25099. }
  25100. return
  25101. }
  25102. // ResetSopStage resets all changes to the "sop_stage" edge.
  25103. func (m *MessageRecordsMutation) ResetSopStage() {
  25104. m.sop_stage = nil
  25105. m.clearedsop_stage = false
  25106. }
  25107. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  25108. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  25109. m.sop_node = &id
  25110. }
  25111. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  25112. func (m *MessageRecordsMutation) ClearSopNode() {
  25113. m.clearedsop_node = true
  25114. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  25115. }
  25116. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  25117. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  25118. return m.SubSourceIDCleared() || m.clearedsop_node
  25119. }
  25120. // SopNodeID returns the "sop_node" edge ID in the mutation.
  25121. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  25122. if m.sop_node != nil {
  25123. return *m.sop_node, true
  25124. }
  25125. return
  25126. }
  25127. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  25128. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25129. // SopNodeID instead. It exists only for internal usage by the builders.
  25130. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  25131. if id := m.sop_node; id != nil {
  25132. ids = append(ids, *id)
  25133. }
  25134. return
  25135. }
  25136. // ResetSopNode resets all changes to the "sop_node" edge.
  25137. func (m *MessageRecordsMutation) ResetSopNode() {
  25138. m.sop_node = nil
  25139. m.clearedsop_node = false
  25140. }
  25141. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  25142. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  25143. m.message_contact = &id
  25144. }
  25145. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  25146. func (m *MessageRecordsMutation) ClearMessageContact() {
  25147. m.clearedmessage_contact = true
  25148. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  25149. }
  25150. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  25151. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  25152. return m.ContactIDCleared() || m.clearedmessage_contact
  25153. }
  25154. // MessageContactID returns the "message_contact" edge ID in the mutation.
  25155. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  25156. if m.message_contact != nil {
  25157. return *m.message_contact, true
  25158. }
  25159. return
  25160. }
  25161. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  25162. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25163. // MessageContactID instead. It exists only for internal usage by the builders.
  25164. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  25165. if id := m.message_contact; id != nil {
  25166. ids = append(ids, *id)
  25167. }
  25168. return
  25169. }
  25170. // ResetMessageContact resets all changes to the "message_contact" edge.
  25171. func (m *MessageRecordsMutation) ResetMessageContact() {
  25172. m.message_contact = nil
  25173. m.clearedmessage_contact = false
  25174. }
  25175. // Where appends a list predicates to the MessageRecordsMutation builder.
  25176. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  25177. m.predicates = append(m.predicates, ps...)
  25178. }
  25179. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  25180. // users can use type-assertion to append predicates that do not depend on any generated package.
  25181. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  25182. p := make([]predicate.MessageRecords, len(ps))
  25183. for i := range ps {
  25184. p[i] = ps[i]
  25185. }
  25186. m.Where(p...)
  25187. }
  25188. // Op returns the operation name.
  25189. func (m *MessageRecordsMutation) Op() Op {
  25190. return m.op
  25191. }
  25192. // SetOp allows setting the mutation operation.
  25193. func (m *MessageRecordsMutation) SetOp(op Op) {
  25194. m.op = op
  25195. }
  25196. // Type returns the node type of this mutation (MessageRecords).
  25197. func (m *MessageRecordsMutation) Type() string {
  25198. return m.typ
  25199. }
  25200. // Fields returns all fields that were changed during this mutation. Note that in
  25201. // order to get all numeric fields that were incremented/decremented, call
  25202. // AddedFields().
  25203. func (m *MessageRecordsMutation) Fields() []string {
  25204. fields := make([]string, 0, 16)
  25205. if m.created_at != nil {
  25206. fields = append(fields, messagerecords.FieldCreatedAt)
  25207. }
  25208. if m.updated_at != nil {
  25209. fields = append(fields, messagerecords.FieldUpdatedAt)
  25210. }
  25211. if m.status != nil {
  25212. fields = append(fields, messagerecords.FieldStatus)
  25213. }
  25214. if m.bot_wxid != nil {
  25215. fields = append(fields, messagerecords.FieldBotWxid)
  25216. }
  25217. if m.message_contact != nil {
  25218. fields = append(fields, messagerecords.FieldContactID)
  25219. }
  25220. if m.contact_type != nil {
  25221. fields = append(fields, messagerecords.FieldContactType)
  25222. }
  25223. if m.contact_wxid != nil {
  25224. fields = append(fields, messagerecords.FieldContactWxid)
  25225. }
  25226. if m.content_type != nil {
  25227. fields = append(fields, messagerecords.FieldContentType)
  25228. }
  25229. if m.content != nil {
  25230. fields = append(fields, messagerecords.FieldContent)
  25231. }
  25232. if m.meta != nil {
  25233. fields = append(fields, messagerecords.FieldMeta)
  25234. }
  25235. if m.error_detail != nil {
  25236. fields = append(fields, messagerecords.FieldErrorDetail)
  25237. }
  25238. if m.send_time != nil {
  25239. fields = append(fields, messagerecords.FieldSendTime)
  25240. }
  25241. if m.source_type != nil {
  25242. fields = append(fields, messagerecords.FieldSourceType)
  25243. }
  25244. if m.sop_stage != nil {
  25245. fields = append(fields, messagerecords.FieldSourceID)
  25246. }
  25247. if m.sop_node != nil {
  25248. fields = append(fields, messagerecords.FieldSubSourceID)
  25249. }
  25250. if m.organization_id != nil {
  25251. fields = append(fields, messagerecords.FieldOrganizationID)
  25252. }
  25253. return fields
  25254. }
  25255. // Field returns the value of a field with the given name. The second boolean
  25256. // return value indicates that this field was not set, or was not defined in the
  25257. // schema.
  25258. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  25259. switch name {
  25260. case messagerecords.FieldCreatedAt:
  25261. return m.CreatedAt()
  25262. case messagerecords.FieldUpdatedAt:
  25263. return m.UpdatedAt()
  25264. case messagerecords.FieldStatus:
  25265. return m.Status()
  25266. case messagerecords.FieldBotWxid:
  25267. return m.BotWxid()
  25268. case messagerecords.FieldContactID:
  25269. return m.ContactID()
  25270. case messagerecords.FieldContactType:
  25271. return m.ContactType()
  25272. case messagerecords.FieldContactWxid:
  25273. return m.ContactWxid()
  25274. case messagerecords.FieldContentType:
  25275. return m.ContentType()
  25276. case messagerecords.FieldContent:
  25277. return m.Content()
  25278. case messagerecords.FieldMeta:
  25279. return m.Meta()
  25280. case messagerecords.FieldErrorDetail:
  25281. return m.ErrorDetail()
  25282. case messagerecords.FieldSendTime:
  25283. return m.SendTime()
  25284. case messagerecords.FieldSourceType:
  25285. return m.SourceType()
  25286. case messagerecords.FieldSourceID:
  25287. return m.SourceID()
  25288. case messagerecords.FieldSubSourceID:
  25289. return m.SubSourceID()
  25290. case messagerecords.FieldOrganizationID:
  25291. return m.OrganizationID()
  25292. }
  25293. return nil, false
  25294. }
  25295. // OldField returns the old value of the field from the database. An error is
  25296. // returned if the mutation operation is not UpdateOne, or the query to the
  25297. // database failed.
  25298. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25299. switch name {
  25300. case messagerecords.FieldCreatedAt:
  25301. return m.OldCreatedAt(ctx)
  25302. case messagerecords.FieldUpdatedAt:
  25303. return m.OldUpdatedAt(ctx)
  25304. case messagerecords.FieldStatus:
  25305. return m.OldStatus(ctx)
  25306. case messagerecords.FieldBotWxid:
  25307. return m.OldBotWxid(ctx)
  25308. case messagerecords.FieldContactID:
  25309. return m.OldContactID(ctx)
  25310. case messagerecords.FieldContactType:
  25311. return m.OldContactType(ctx)
  25312. case messagerecords.FieldContactWxid:
  25313. return m.OldContactWxid(ctx)
  25314. case messagerecords.FieldContentType:
  25315. return m.OldContentType(ctx)
  25316. case messagerecords.FieldContent:
  25317. return m.OldContent(ctx)
  25318. case messagerecords.FieldMeta:
  25319. return m.OldMeta(ctx)
  25320. case messagerecords.FieldErrorDetail:
  25321. return m.OldErrorDetail(ctx)
  25322. case messagerecords.FieldSendTime:
  25323. return m.OldSendTime(ctx)
  25324. case messagerecords.FieldSourceType:
  25325. return m.OldSourceType(ctx)
  25326. case messagerecords.FieldSourceID:
  25327. return m.OldSourceID(ctx)
  25328. case messagerecords.FieldSubSourceID:
  25329. return m.OldSubSourceID(ctx)
  25330. case messagerecords.FieldOrganizationID:
  25331. return m.OldOrganizationID(ctx)
  25332. }
  25333. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  25334. }
  25335. // SetField sets the value of a field with the given name. It returns an error if
  25336. // the field is not defined in the schema, or if the type mismatched the field
  25337. // type.
  25338. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  25339. switch name {
  25340. case messagerecords.FieldCreatedAt:
  25341. v, ok := value.(time.Time)
  25342. if !ok {
  25343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25344. }
  25345. m.SetCreatedAt(v)
  25346. return nil
  25347. case messagerecords.FieldUpdatedAt:
  25348. v, ok := value.(time.Time)
  25349. if !ok {
  25350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25351. }
  25352. m.SetUpdatedAt(v)
  25353. return nil
  25354. case messagerecords.FieldStatus:
  25355. v, ok := value.(uint8)
  25356. if !ok {
  25357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25358. }
  25359. m.SetStatus(v)
  25360. return nil
  25361. case messagerecords.FieldBotWxid:
  25362. v, ok := value.(string)
  25363. if !ok {
  25364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25365. }
  25366. m.SetBotWxid(v)
  25367. return nil
  25368. case messagerecords.FieldContactID:
  25369. v, ok := value.(uint64)
  25370. if !ok {
  25371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25372. }
  25373. m.SetContactID(v)
  25374. return nil
  25375. case messagerecords.FieldContactType:
  25376. v, ok := value.(int)
  25377. if !ok {
  25378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25379. }
  25380. m.SetContactType(v)
  25381. return nil
  25382. case messagerecords.FieldContactWxid:
  25383. v, ok := value.(string)
  25384. if !ok {
  25385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25386. }
  25387. m.SetContactWxid(v)
  25388. return nil
  25389. case messagerecords.FieldContentType:
  25390. v, ok := value.(int)
  25391. if !ok {
  25392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25393. }
  25394. m.SetContentType(v)
  25395. return nil
  25396. case messagerecords.FieldContent:
  25397. v, ok := value.(string)
  25398. if !ok {
  25399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25400. }
  25401. m.SetContent(v)
  25402. return nil
  25403. case messagerecords.FieldMeta:
  25404. v, ok := value.(custom_types.Meta)
  25405. if !ok {
  25406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25407. }
  25408. m.SetMeta(v)
  25409. return nil
  25410. case messagerecords.FieldErrorDetail:
  25411. v, ok := value.(string)
  25412. if !ok {
  25413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25414. }
  25415. m.SetErrorDetail(v)
  25416. return nil
  25417. case messagerecords.FieldSendTime:
  25418. v, ok := value.(time.Time)
  25419. if !ok {
  25420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25421. }
  25422. m.SetSendTime(v)
  25423. return nil
  25424. case messagerecords.FieldSourceType:
  25425. v, ok := value.(int)
  25426. if !ok {
  25427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25428. }
  25429. m.SetSourceType(v)
  25430. return nil
  25431. case messagerecords.FieldSourceID:
  25432. v, ok := value.(uint64)
  25433. if !ok {
  25434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25435. }
  25436. m.SetSourceID(v)
  25437. return nil
  25438. case messagerecords.FieldSubSourceID:
  25439. v, ok := value.(uint64)
  25440. if !ok {
  25441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25442. }
  25443. m.SetSubSourceID(v)
  25444. return nil
  25445. case messagerecords.FieldOrganizationID:
  25446. v, ok := value.(uint64)
  25447. if !ok {
  25448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25449. }
  25450. m.SetOrganizationID(v)
  25451. return nil
  25452. }
  25453. return fmt.Errorf("unknown MessageRecords field %s", name)
  25454. }
  25455. // AddedFields returns all numeric fields that were incremented/decremented during
  25456. // this mutation.
  25457. func (m *MessageRecordsMutation) AddedFields() []string {
  25458. var fields []string
  25459. if m.addstatus != nil {
  25460. fields = append(fields, messagerecords.FieldStatus)
  25461. }
  25462. if m.addcontact_type != nil {
  25463. fields = append(fields, messagerecords.FieldContactType)
  25464. }
  25465. if m.addcontent_type != nil {
  25466. fields = append(fields, messagerecords.FieldContentType)
  25467. }
  25468. if m.addsource_type != nil {
  25469. fields = append(fields, messagerecords.FieldSourceType)
  25470. }
  25471. if m.addorganization_id != nil {
  25472. fields = append(fields, messagerecords.FieldOrganizationID)
  25473. }
  25474. return fields
  25475. }
  25476. // AddedField returns the numeric value that was incremented/decremented on a field
  25477. // with the given name. The second boolean return value indicates that this field
  25478. // was not set, or was not defined in the schema.
  25479. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  25480. switch name {
  25481. case messagerecords.FieldStatus:
  25482. return m.AddedStatus()
  25483. case messagerecords.FieldContactType:
  25484. return m.AddedContactType()
  25485. case messagerecords.FieldContentType:
  25486. return m.AddedContentType()
  25487. case messagerecords.FieldSourceType:
  25488. return m.AddedSourceType()
  25489. case messagerecords.FieldOrganizationID:
  25490. return m.AddedOrganizationID()
  25491. }
  25492. return nil, false
  25493. }
  25494. // AddField adds the value to the field with the given name. It returns an error if
  25495. // the field is not defined in the schema, or if the type mismatched the field
  25496. // type.
  25497. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  25498. switch name {
  25499. case messagerecords.FieldStatus:
  25500. v, ok := value.(int8)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.AddStatus(v)
  25505. return nil
  25506. case messagerecords.FieldContactType:
  25507. v, ok := value.(int)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.AddContactType(v)
  25512. return nil
  25513. case messagerecords.FieldContentType:
  25514. v, ok := value.(int)
  25515. if !ok {
  25516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25517. }
  25518. m.AddContentType(v)
  25519. return nil
  25520. case messagerecords.FieldSourceType:
  25521. v, ok := value.(int)
  25522. if !ok {
  25523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25524. }
  25525. m.AddSourceType(v)
  25526. return nil
  25527. case messagerecords.FieldOrganizationID:
  25528. v, ok := value.(int64)
  25529. if !ok {
  25530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25531. }
  25532. m.AddOrganizationID(v)
  25533. return nil
  25534. }
  25535. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  25536. }
  25537. // ClearedFields returns all nullable fields that were cleared during this
  25538. // mutation.
  25539. func (m *MessageRecordsMutation) ClearedFields() []string {
  25540. var fields []string
  25541. if m.FieldCleared(messagerecords.FieldStatus) {
  25542. fields = append(fields, messagerecords.FieldStatus)
  25543. }
  25544. if m.FieldCleared(messagerecords.FieldContactID) {
  25545. fields = append(fields, messagerecords.FieldContactID)
  25546. }
  25547. if m.FieldCleared(messagerecords.FieldMeta) {
  25548. fields = append(fields, messagerecords.FieldMeta)
  25549. }
  25550. if m.FieldCleared(messagerecords.FieldSendTime) {
  25551. fields = append(fields, messagerecords.FieldSendTime)
  25552. }
  25553. if m.FieldCleared(messagerecords.FieldSourceID) {
  25554. fields = append(fields, messagerecords.FieldSourceID)
  25555. }
  25556. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  25557. fields = append(fields, messagerecords.FieldSubSourceID)
  25558. }
  25559. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  25560. fields = append(fields, messagerecords.FieldOrganizationID)
  25561. }
  25562. return fields
  25563. }
  25564. // FieldCleared returns a boolean indicating if a field with the given name was
  25565. // cleared in this mutation.
  25566. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  25567. _, ok := m.clearedFields[name]
  25568. return ok
  25569. }
  25570. // ClearField clears the value of the field with the given name. It returns an
  25571. // error if the field is not defined in the schema.
  25572. func (m *MessageRecordsMutation) ClearField(name string) error {
  25573. switch name {
  25574. case messagerecords.FieldStatus:
  25575. m.ClearStatus()
  25576. return nil
  25577. case messagerecords.FieldContactID:
  25578. m.ClearContactID()
  25579. return nil
  25580. case messagerecords.FieldMeta:
  25581. m.ClearMeta()
  25582. return nil
  25583. case messagerecords.FieldSendTime:
  25584. m.ClearSendTime()
  25585. return nil
  25586. case messagerecords.FieldSourceID:
  25587. m.ClearSourceID()
  25588. return nil
  25589. case messagerecords.FieldSubSourceID:
  25590. m.ClearSubSourceID()
  25591. return nil
  25592. case messagerecords.FieldOrganizationID:
  25593. m.ClearOrganizationID()
  25594. return nil
  25595. }
  25596. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  25597. }
  25598. // ResetField resets all changes in the mutation for the field with the given name.
  25599. // It returns an error if the field is not defined in the schema.
  25600. func (m *MessageRecordsMutation) ResetField(name string) error {
  25601. switch name {
  25602. case messagerecords.FieldCreatedAt:
  25603. m.ResetCreatedAt()
  25604. return nil
  25605. case messagerecords.FieldUpdatedAt:
  25606. m.ResetUpdatedAt()
  25607. return nil
  25608. case messagerecords.FieldStatus:
  25609. m.ResetStatus()
  25610. return nil
  25611. case messagerecords.FieldBotWxid:
  25612. m.ResetBotWxid()
  25613. return nil
  25614. case messagerecords.FieldContactID:
  25615. m.ResetContactID()
  25616. return nil
  25617. case messagerecords.FieldContactType:
  25618. m.ResetContactType()
  25619. return nil
  25620. case messagerecords.FieldContactWxid:
  25621. m.ResetContactWxid()
  25622. return nil
  25623. case messagerecords.FieldContentType:
  25624. m.ResetContentType()
  25625. return nil
  25626. case messagerecords.FieldContent:
  25627. m.ResetContent()
  25628. return nil
  25629. case messagerecords.FieldMeta:
  25630. m.ResetMeta()
  25631. return nil
  25632. case messagerecords.FieldErrorDetail:
  25633. m.ResetErrorDetail()
  25634. return nil
  25635. case messagerecords.FieldSendTime:
  25636. m.ResetSendTime()
  25637. return nil
  25638. case messagerecords.FieldSourceType:
  25639. m.ResetSourceType()
  25640. return nil
  25641. case messagerecords.FieldSourceID:
  25642. m.ResetSourceID()
  25643. return nil
  25644. case messagerecords.FieldSubSourceID:
  25645. m.ResetSubSourceID()
  25646. return nil
  25647. case messagerecords.FieldOrganizationID:
  25648. m.ResetOrganizationID()
  25649. return nil
  25650. }
  25651. return fmt.Errorf("unknown MessageRecords field %s", name)
  25652. }
  25653. // AddedEdges returns all edge names that were set/added in this mutation.
  25654. func (m *MessageRecordsMutation) AddedEdges() []string {
  25655. edges := make([]string, 0, 3)
  25656. if m.sop_stage != nil {
  25657. edges = append(edges, messagerecords.EdgeSopStage)
  25658. }
  25659. if m.sop_node != nil {
  25660. edges = append(edges, messagerecords.EdgeSopNode)
  25661. }
  25662. if m.message_contact != nil {
  25663. edges = append(edges, messagerecords.EdgeMessageContact)
  25664. }
  25665. return edges
  25666. }
  25667. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25668. // name in this mutation.
  25669. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  25670. switch name {
  25671. case messagerecords.EdgeSopStage:
  25672. if id := m.sop_stage; id != nil {
  25673. return []ent.Value{*id}
  25674. }
  25675. case messagerecords.EdgeSopNode:
  25676. if id := m.sop_node; id != nil {
  25677. return []ent.Value{*id}
  25678. }
  25679. case messagerecords.EdgeMessageContact:
  25680. if id := m.message_contact; id != nil {
  25681. return []ent.Value{*id}
  25682. }
  25683. }
  25684. return nil
  25685. }
  25686. // RemovedEdges returns all edge names that were removed in this mutation.
  25687. func (m *MessageRecordsMutation) RemovedEdges() []string {
  25688. edges := make([]string, 0, 3)
  25689. return edges
  25690. }
  25691. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25692. // the given name in this mutation.
  25693. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  25694. return nil
  25695. }
  25696. // ClearedEdges returns all edge names that were cleared in this mutation.
  25697. func (m *MessageRecordsMutation) ClearedEdges() []string {
  25698. edges := make([]string, 0, 3)
  25699. if m.clearedsop_stage {
  25700. edges = append(edges, messagerecords.EdgeSopStage)
  25701. }
  25702. if m.clearedsop_node {
  25703. edges = append(edges, messagerecords.EdgeSopNode)
  25704. }
  25705. if m.clearedmessage_contact {
  25706. edges = append(edges, messagerecords.EdgeMessageContact)
  25707. }
  25708. return edges
  25709. }
  25710. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25711. // was cleared in this mutation.
  25712. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  25713. switch name {
  25714. case messagerecords.EdgeSopStage:
  25715. return m.clearedsop_stage
  25716. case messagerecords.EdgeSopNode:
  25717. return m.clearedsop_node
  25718. case messagerecords.EdgeMessageContact:
  25719. return m.clearedmessage_contact
  25720. }
  25721. return false
  25722. }
  25723. // ClearEdge clears the value of the edge with the given name. It returns an error
  25724. // if that edge is not defined in the schema.
  25725. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  25726. switch name {
  25727. case messagerecords.EdgeSopStage:
  25728. m.ClearSopStage()
  25729. return nil
  25730. case messagerecords.EdgeSopNode:
  25731. m.ClearSopNode()
  25732. return nil
  25733. case messagerecords.EdgeMessageContact:
  25734. m.ClearMessageContact()
  25735. return nil
  25736. }
  25737. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  25738. }
  25739. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25740. // It returns an error if the edge is not defined in the schema.
  25741. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  25742. switch name {
  25743. case messagerecords.EdgeSopStage:
  25744. m.ResetSopStage()
  25745. return nil
  25746. case messagerecords.EdgeSopNode:
  25747. m.ResetSopNode()
  25748. return nil
  25749. case messagerecords.EdgeMessageContact:
  25750. m.ResetMessageContact()
  25751. return nil
  25752. }
  25753. return fmt.Errorf("unknown MessageRecords edge %s", name)
  25754. }
  25755. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  25756. type MsgMutation struct {
  25757. config
  25758. op Op
  25759. typ string
  25760. id *uint64
  25761. created_at *time.Time
  25762. updated_at *time.Time
  25763. deleted_at *time.Time
  25764. status *uint8
  25765. addstatus *int8
  25766. fromwxid *string
  25767. toid *string
  25768. msgtype *int32
  25769. addmsgtype *int32
  25770. msg *string
  25771. batch_no *string
  25772. cc *string
  25773. phone *string
  25774. clearedFields map[string]struct{}
  25775. done bool
  25776. oldValue func(context.Context) (*Msg, error)
  25777. predicates []predicate.Msg
  25778. }
  25779. var _ ent.Mutation = (*MsgMutation)(nil)
  25780. // msgOption allows management of the mutation configuration using functional options.
  25781. type msgOption func(*MsgMutation)
  25782. // newMsgMutation creates new mutation for the Msg entity.
  25783. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  25784. m := &MsgMutation{
  25785. config: c,
  25786. op: op,
  25787. typ: TypeMsg,
  25788. clearedFields: make(map[string]struct{}),
  25789. }
  25790. for _, opt := range opts {
  25791. opt(m)
  25792. }
  25793. return m
  25794. }
  25795. // withMsgID sets the ID field of the mutation.
  25796. func withMsgID(id uint64) msgOption {
  25797. return func(m *MsgMutation) {
  25798. var (
  25799. err error
  25800. once sync.Once
  25801. value *Msg
  25802. )
  25803. m.oldValue = func(ctx context.Context) (*Msg, error) {
  25804. once.Do(func() {
  25805. if m.done {
  25806. err = errors.New("querying old values post mutation is not allowed")
  25807. } else {
  25808. value, err = m.Client().Msg.Get(ctx, id)
  25809. }
  25810. })
  25811. return value, err
  25812. }
  25813. m.id = &id
  25814. }
  25815. }
  25816. // withMsg sets the old Msg of the mutation.
  25817. func withMsg(node *Msg) msgOption {
  25818. return func(m *MsgMutation) {
  25819. m.oldValue = func(context.Context) (*Msg, error) {
  25820. return node, nil
  25821. }
  25822. m.id = &node.ID
  25823. }
  25824. }
  25825. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25826. // executed in a transaction (ent.Tx), a transactional client is returned.
  25827. func (m MsgMutation) Client() *Client {
  25828. client := &Client{config: m.config}
  25829. client.init()
  25830. return client
  25831. }
  25832. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25833. // it returns an error otherwise.
  25834. func (m MsgMutation) Tx() (*Tx, error) {
  25835. if _, ok := m.driver.(*txDriver); !ok {
  25836. return nil, errors.New("ent: mutation is not running in a transaction")
  25837. }
  25838. tx := &Tx{config: m.config}
  25839. tx.init()
  25840. return tx, nil
  25841. }
  25842. // SetID sets the value of the id field. Note that this
  25843. // operation is only accepted on creation of Msg entities.
  25844. func (m *MsgMutation) SetID(id uint64) {
  25845. m.id = &id
  25846. }
  25847. // ID returns the ID value in the mutation. Note that the ID is only available
  25848. // if it was provided to the builder or after it was returned from the database.
  25849. func (m *MsgMutation) ID() (id uint64, exists bool) {
  25850. if m.id == nil {
  25851. return
  25852. }
  25853. return *m.id, true
  25854. }
  25855. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25856. // That means, if the mutation is applied within a transaction with an isolation level such
  25857. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25858. // or updated by the mutation.
  25859. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  25860. switch {
  25861. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25862. id, exists := m.ID()
  25863. if exists {
  25864. return []uint64{id}, nil
  25865. }
  25866. fallthrough
  25867. case m.op.Is(OpUpdate | OpDelete):
  25868. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  25869. default:
  25870. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25871. }
  25872. }
  25873. // SetCreatedAt sets the "created_at" field.
  25874. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  25875. m.created_at = &t
  25876. }
  25877. // CreatedAt returns the value of the "created_at" field in the mutation.
  25878. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  25879. v := m.created_at
  25880. if v == nil {
  25881. return
  25882. }
  25883. return *v, true
  25884. }
  25885. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  25886. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25888. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25889. if !m.op.Is(OpUpdateOne) {
  25890. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25891. }
  25892. if m.id == nil || m.oldValue == nil {
  25893. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25894. }
  25895. oldValue, err := m.oldValue(ctx)
  25896. if err != nil {
  25897. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25898. }
  25899. return oldValue.CreatedAt, nil
  25900. }
  25901. // ResetCreatedAt resets all changes to the "created_at" field.
  25902. func (m *MsgMutation) ResetCreatedAt() {
  25903. m.created_at = nil
  25904. }
  25905. // SetUpdatedAt sets the "updated_at" field.
  25906. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  25907. m.updated_at = &t
  25908. }
  25909. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25910. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  25911. v := m.updated_at
  25912. if v == nil {
  25913. return
  25914. }
  25915. return *v, true
  25916. }
  25917. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  25918. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25920. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25921. if !m.op.Is(OpUpdateOne) {
  25922. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25923. }
  25924. if m.id == nil || m.oldValue == nil {
  25925. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25926. }
  25927. oldValue, err := m.oldValue(ctx)
  25928. if err != nil {
  25929. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25930. }
  25931. return oldValue.UpdatedAt, nil
  25932. }
  25933. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25934. func (m *MsgMutation) ResetUpdatedAt() {
  25935. m.updated_at = nil
  25936. }
  25937. // SetDeletedAt sets the "deleted_at" field.
  25938. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  25939. m.deleted_at = &t
  25940. }
  25941. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25942. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  25943. v := m.deleted_at
  25944. if v == nil {
  25945. return
  25946. }
  25947. return *v, true
  25948. }
  25949. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  25950. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25952. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25953. if !m.op.Is(OpUpdateOne) {
  25954. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25955. }
  25956. if m.id == nil || m.oldValue == nil {
  25957. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25958. }
  25959. oldValue, err := m.oldValue(ctx)
  25960. if err != nil {
  25961. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25962. }
  25963. return oldValue.DeletedAt, nil
  25964. }
  25965. // ClearDeletedAt clears the value of the "deleted_at" field.
  25966. func (m *MsgMutation) ClearDeletedAt() {
  25967. m.deleted_at = nil
  25968. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  25969. }
  25970. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25971. func (m *MsgMutation) DeletedAtCleared() bool {
  25972. _, ok := m.clearedFields[msg.FieldDeletedAt]
  25973. return ok
  25974. }
  25975. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25976. func (m *MsgMutation) ResetDeletedAt() {
  25977. m.deleted_at = nil
  25978. delete(m.clearedFields, msg.FieldDeletedAt)
  25979. }
  25980. // SetStatus sets the "status" field.
  25981. func (m *MsgMutation) SetStatus(u uint8) {
  25982. m.status = &u
  25983. m.addstatus = nil
  25984. }
  25985. // Status returns the value of the "status" field in the mutation.
  25986. func (m *MsgMutation) Status() (r uint8, exists bool) {
  25987. v := m.status
  25988. if v == nil {
  25989. return
  25990. }
  25991. return *v, true
  25992. }
  25993. // OldStatus returns the old "status" field's value of the Msg entity.
  25994. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25996. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25997. if !m.op.Is(OpUpdateOne) {
  25998. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25999. }
  26000. if m.id == nil || m.oldValue == nil {
  26001. return v, errors.New("OldStatus requires an ID field in the mutation")
  26002. }
  26003. oldValue, err := m.oldValue(ctx)
  26004. if err != nil {
  26005. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26006. }
  26007. return oldValue.Status, nil
  26008. }
  26009. // AddStatus adds u to the "status" field.
  26010. func (m *MsgMutation) AddStatus(u int8) {
  26011. if m.addstatus != nil {
  26012. *m.addstatus += u
  26013. } else {
  26014. m.addstatus = &u
  26015. }
  26016. }
  26017. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26018. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  26019. v := m.addstatus
  26020. if v == nil {
  26021. return
  26022. }
  26023. return *v, true
  26024. }
  26025. // ClearStatus clears the value of the "status" field.
  26026. func (m *MsgMutation) ClearStatus() {
  26027. m.status = nil
  26028. m.addstatus = nil
  26029. m.clearedFields[msg.FieldStatus] = struct{}{}
  26030. }
  26031. // StatusCleared returns if the "status" field was cleared in this mutation.
  26032. func (m *MsgMutation) StatusCleared() bool {
  26033. _, ok := m.clearedFields[msg.FieldStatus]
  26034. return ok
  26035. }
  26036. // ResetStatus resets all changes to the "status" field.
  26037. func (m *MsgMutation) ResetStatus() {
  26038. m.status = nil
  26039. m.addstatus = nil
  26040. delete(m.clearedFields, msg.FieldStatus)
  26041. }
  26042. // SetFromwxid sets the "fromwxid" field.
  26043. func (m *MsgMutation) SetFromwxid(s string) {
  26044. m.fromwxid = &s
  26045. }
  26046. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  26047. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  26048. v := m.fromwxid
  26049. if v == nil {
  26050. return
  26051. }
  26052. return *v, true
  26053. }
  26054. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  26055. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26057. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  26058. if !m.op.Is(OpUpdateOne) {
  26059. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  26060. }
  26061. if m.id == nil || m.oldValue == nil {
  26062. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  26063. }
  26064. oldValue, err := m.oldValue(ctx)
  26065. if err != nil {
  26066. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  26067. }
  26068. return oldValue.Fromwxid, nil
  26069. }
  26070. // ClearFromwxid clears the value of the "fromwxid" field.
  26071. func (m *MsgMutation) ClearFromwxid() {
  26072. m.fromwxid = nil
  26073. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  26074. }
  26075. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  26076. func (m *MsgMutation) FromwxidCleared() bool {
  26077. _, ok := m.clearedFields[msg.FieldFromwxid]
  26078. return ok
  26079. }
  26080. // ResetFromwxid resets all changes to the "fromwxid" field.
  26081. func (m *MsgMutation) ResetFromwxid() {
  26082. m.fromwxid = nil
  26083. delete(m.clearedFields, msg.FieldFromwxid)
  26084. }
  26085. // SetToid sets the "toid" field.
  26086. func (m *MsgMutation) SetToid(s string) {
  26087. m.toid = &s
  26088. }
  26089. // Toid returns the value of the "toid" field in the mutation.
  26090. func (m *MsgMutation) Toid() (r string, exists bool) {
  26091. v := m.toid
  26092. if v == nil {
  26093. return
  26094. }
  26095. return *v, true
  26096. }
  26097. // OldToid returns the old "toid" field's value of the Msg entity.
  26098. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26100. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  26101. if !m.op.Is(OpUpdateOne) {
  26102. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  26103. }
  26104. if m.id == nil || m.oldValue == nil {
  26105. return v, errors.New("OldToid requires an ID field in the mutation")
  26106. }
  26107. oldValue, err := m.oldValue(ctx)
  26108. if err != nil {
  26109. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  26110. }
  26111. return oldValue.Toid, nil
  26112. }
  26113. // ClearToid clears the value of the "toid" field.
  26114. func (m *MsgMutation) ClearToid() {
  26115. m.toid = nil
  26116. m.clearedFields[msg.FieldToid] = struct{}{}
  26117. }
  26118. // ToidCleared returns if the "toid" field was cleared in this mutation.
  26119. func (m *MsgMutation) ToidCleared() bool {
  26120. _, ok := m.clearedFields[msg.FieldToid]
  26121. return ok
  26122. }
  26123. // ResetToid resets all changes to the "toid" field.
  26124. func (m *MsgMutation) ResetToid() {
  26125. m.toid = nil
  26126. delete(m.clearedFields, msg.FieldToid)
  26127. }
  26128. // SetMsgtype sets the "msgtype" field.
  26129. func (m *MsgMutation) SetMsgtype(i int32) {
  26130. m.msgtype = &i
  26131. m.addmsgtype = nil
  26132. }
  26133. // Msgtype returns the value of the "msgtype" field in the mutation.
  26134. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  26135. v := m.msgtype
  26136. if v == nil {
  26137. return
  26138. }
  26139. return *v, true
  26140. }
  26141. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  26142. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26144. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  26145. if !m.op.Is(OpUpdateOne) {
  26146. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  26147. }
  26148. if m.id == nil || m.oldValue == nil {
  26149. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  26150. }
  26151. oldValue, err := m.oldValue(ctx)
  26152. if err != nil {
  26153. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  26154. }
  26155. return oldValue.Msgtype, nil
  26156. }
  26157. // AddMsgtype adds i to the "msgtype" field.
  26158. func (m *MsgMutation) AddMsgtype(i int32) {
  26159. if m.addmsgtype != nil {
  26160. *m.addmsgtype += i
  26161. } else {
  26162. m.addmsgtype = &i
  26163. }
  26164. }
  26165. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  26166. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  26167. v := m.addmsgtype
  26168. if v == nil {
  26169. return
  26170. }
  26171. return *v, true
  26172. }
  26173. // ClearMsgtype clears the value of the "msgtype" field.
  26174. func (m *MsgMutation) ClearMsgtype() {
  26175. m.msgtype = nil
  26176. m.addmsgtype = nil
  26177. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  26178. }
  26179. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  26180. func (m *MsgMutation) MsgtypeCleared() bool {
  26181. _, ok := m.clearedFields[msg.FieldMsgtype]
  26182. return ok
  26183. }
  26184. // ResetMsgtype resets all changes to the "msgtype" field.
  26185. func (m *MsgMutation) ResetMsgtype() {
  26186. m.msgtype = nil
  26187. m.addmsgtype = nil
  26188. delete(m.clearedFields, msg.FieldMsgtype)
  26189. }
  26190. // SetMsg sets the "msg" field.
  26191. func (m *MsgMutation) SetMsg(s string) {
  26192. m.msg = &s
  26193. }
  26194. // Msg returns the value of the "msg" field in the mutation.
  26195. func (m *MsgMutation) Msg() (r string, exists bool) {
  26196. v := m.msg
  26197. if v == nil {
  26198. return
  26199. }
  26200. return *v, true
  26201. }
  26202. // OldMsg returns the old "msg" field's value of the Msg entity.
  26203. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26205. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  26206. if !m.op.Is(OpUpdateOne) {
  26207. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  26208. }
  26209. if m.id == nil || m.oldValue == nil {
  26210. return v, errors.New("OldMsg requires an ID field in the mutation")
  26211. }
  26212. oldValue, err := m.oldValue(ctx)
  26213. if err != nil {
  26214. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  26215. }
  26216. return oldValue.Msg, nil
  26217. }
  26218. // ClearMsg clears the value of the "msg" field.
  26219. func (m *MsgMutation) ClearMsg() {
  26220. m.msg = nil
  26221. m.clearedFields[msg.FieldMsg] = struct{}{}
  26222. }
  26223. // MsgCleared returns if the "msg" field was cleared in this mutation.
  26224. func (m *MsgMutation) MsgCleared() bool {
  26225. _, ok := m.clearedFields[msg.FieldMsg]
  26226. return ok
  26227. }
  26228. // ResetMsg resets all changes to the "msg" field.
  26229. func (m *MsgMutation) ResetMsg() {
  26230. m.msg = nil
  26231. delete(m.clearedFields, msg.FieldMsg)
  26232. }
  26233. // SetBatchNo sets the "batch_no" field.
  26234. func (m *MsgMutation) SetBatchNo(s string) {
  26235. m.batch_no = &s
  26236. }
  26237. // BatchNo returns the value of the "batch_no" field in the mutation.
  26238. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  26239. v := m.batch_no
  26240. if v == nil {
  26241. return
  26242. }
  26243. return *v, true
  26244. }
  26245. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  26246. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26248. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  26249. if !m.op.Is(OpUpdateOne) {
  26250. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  26251. }
  26252. if m.id == nil || m.oldValue == nil {
  26253. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  26254. }
  26255. oldValue, err := m.oldValue(ctx)
  26256. if err != nil {
  26257. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  26258. }
  26259. return oldValue.BatchNo, nil
  26260. }
  26261. // ClearBatchNo clears the value of the "batch_no" field.
  26262. func (m *MsgMutation) ClearBatchNo() {
  26263. m.batch_no = nil
  26264. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  26265. }
  26266. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  26267. func (m *MsgMutation) BatchNoCleared() bool {
  26268. _, ok := m.clearedFields[msg.FieldBatchNo]
  26269. return ok
  26270. }
  26271. // ResetBatchNo resets all changes to the "batch_no" field.
  26272. func (m *MsgMutation) ResetBatchNo() {
  26273. m.batch_no = nil
  26274. delete(m.clearedFields, msg.FieldBatchNo)
  26275. }
  26276. // SetCc sets the "cc" field.
  26277. func (m *MsgMutation) SetCc(s string) {
  26278. m.cc = &s
  26279. }
  26280. // Cc returns the value of the "cc" field in the mutation.
  26281. func (m *MsgMutation) Cc() (r string, exists bool) {
  26282. v := m.cc
  26283. if v == nil {
  26284. return
  26285. }
  26286. return *v, true
  26287. }
  26288. // OldCc returns the old "cc" field's value of the Msg entity.
  26289. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26291. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  26292. if !m.op.Is(OpUpdateOne) {
  26293. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  26294. }
  26295. if m.id == nil || m.oldValue == nil {
  26296. return v, errors.New("OldCc requires an ID field in the mutation")
  26297. }
  26298. oldValue, err := m.oldValue(ctx)
  26299. if err != nil {
  26300. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  26301. }
  26302. return oldValue.Cc, nil
  26303. }
  26304. // ResetCc resets all changes to the "cc" field.
  26305. func (m *MsgMutation) ResetCc() {
  26306. m.cc = nil
  26307. }
  26308. // SetPhone sets the "phone" field.
  26309. func (m *MsgMutation) SetPhone(s string) {
  26310. m.phone = &s
  26311. }
  26312. // Phone returns the value of the "phone" field in the mutation.
  26313. func (m *MsgMutation) Phone() (r string, exists bool) {
  26314. v := m.phone
  26315. if v == nil {
  26316. return
  26317. }
  26318. return *v, true
  26319. }
  26320. // OldPhone returns the old "phone" field's value of the Msg entity.
  26321. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26323. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  26324. if !m.op.Is(OpUpdateOne) {
  26325. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26326. }
  26327. if m.id == nil || m.oldValue == nil {
  26328. return v, errors.New("OldPhone requires an ID field in the mutation")
  26329. }
  26330. oldValue, err := m.oldValue(ctx)
  26331. if err != nil {
  26332. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26333. }
  26334. return oldValue.Phone, nil
  26335. }
  26336. // ResetPhone resets all changes to the "phone" field.
  26337. func (m *MsgMutation) ResetPhone() {
  26338. m.phone = nil
  26339. }
  26340. // Where appends a list predicates to the MsgMutation builder.
  26341. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  26342. m.predicates = append(m.predicates, ps...)
  26343. }
  26344. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  26345. // users can use type-assertion to append predicates that do not depend on any generated package.
  26346. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  26347. p := make([]predicate.Msg, len(ps))
  26348. for i := range ps {
  26349. p[i] = ps[i]
  26350. }
  26351. m.Where(p...)
  26352. }
  26353. // Op returns the operation name.
  26354. func (m *MsgMutation) Op() Op {
  26355. return m.op
  26356. }
  26357. // SetOp allows setting the mutation operation.
  26358. func (m *MsgMutation) SetOp(op Op) {
  26359. m.op = op
  26360. }
  26361. // Type returns the node type of this mutation (Msg).
  26362. func (m *MsgMutation) Type() string {
  26363. return m.typ
  26364. }
  26365. // Fields returns all fields that were changed during this mutation. Note that in
  26366. // order to get all numeric fields that were incremented/decremented, call
  26367. // AddedFields().
  26368. func (m *MsgMutation) Fields() []string {
  26369. fields := make([]string, 0, 11)
  26370. if m.created_at != nil {
  26371. fields = append(fields, msg.FieldCreatedAt)
  26372. }
  26373. if m.updated_at != nil {
  26374. fields = append(fields, msg.FieldUpdatedAt)
  26375. }
  26376. if m.deleted_at != nil {
  26377. fields = append(fields, msg.FieldDeletedAt)
  26378. }
  26379. if m.status != nil {
  26380. fields = append(fields, msg.FieldStatus)
  26381. }
  26382. if m.fromwxid != nil {
  26383. fields = append(fields, msg.FieldFromwxid)
  26384. }
  26385. if m.toid != nil {
  26386. fields = append(fields, msg.FieldToid)
  26387. }
  26388. if m.msgtype != nil {
  26389. fields = append(fields, msg.FieldMsgtype)
  26390. }
  26391. if m.msg != nil {
  26392. fields = append(fields, msg.FieldMsg)
  26393. }
  26394. if m.batch_no != nil {
  26395. fields = append(fields, msg.FieldBatchNo)
  26396. }
  26397. if m.cc != nil {
  26398. fields = append(fields, msg.FieldCc)
  26399. }
  26400. if m.phone != nil {
  26401. fields = append(fields, msg.FieldPhone)
  26402. }
  26403. return fields
  26404. }
  26405. // Field returns the value of a field with the given name. The second boolean
  26406. // return value indicates that this field was not set, or was not defined in the
  26407. // schema.
  26408. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  26409. switch name {
  26410. case msg.FieldCreatedAt:
  26411. return m.CreatedAt()
  26412. case msg.FieldUpdatedAt:
  26413. return m.UpdatedAt()
  26414. case msg.FieldDeletedAt:
  26415. return m.DeletedAt()
  26416. case msg.FieldStatus:
  26417. return m.Status()
  26418. case msg.FieldFromwxid:
  26419. return m.Fromwxid()
  26420. case msg.FieldToid:
  26421. return m.Toid()
  26422. case msg.FieldMsgtype:
  26423. return m.Msgtype()
  26424. case msg.FieldMsg:
  26425. return m.Msg()
  26426. case msg.FieldBatchNo:
  26427. return m.BatchNo()
  26428. case msg.FieldCc:
  26429. return m.Cc()
  26430. case msg.FieldPhone:
  26431. return m.Phone()
  26432. }
  26433. return nil, false
  26434. }
  26435. // OldField returns the old value of the field from the database. An error is
  26436. // returned if the mutation operation is not UpdateOne, or the query to the
  26437. // database failed.
  26438. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26439. switch name {
  26440. case msg.FieldCreatedAt:
  26441. return m.OldCreatedAt(ctx)
  26442. case msg.FieldUpdatedAt:
  26443. return m.OldUpdatedAt(ctx)
  26444. case msg.FieldDeletedAt:
  26445. return m.OldDeletedAt(ctx)
  26446. case msg.FieldStatus:
  26447. return m.OldStatus(ctx)
  26448. case msg.FieldFromwxid:
  26449. return m.OldFromwxid(ctx)
  26450. case msg.FieldToid:
  26451. return m.OldToid(ctx)
  26452. case msg.FieldMsgtype:
  26453. return m.OldMsgtype(ctx)
  26454. case msg.FieldMsg:
  26455. return m.OldMsg(ctx)
  26456. case msg.FieldBatchNo:
  26457. return m.OldBatchNo(ctx)
  26458. case msg.FieldCc:
  26459. return m.OldCc(ctx)
  26460. case msg.FieldPhone:
  26461. return m.OldPhone(ctx)
  26462. }
  26463. return nil, fmt.Errorf("unknown Msg field %s", name)
  26464. }
  26465. // SetField sets the value of a field with the given name. It returns an error if
  26466. // the field is not defined in the schema, or if the type mismatched the field
  26467. // type.
  26468. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  26469. switch name {
  26470. case msg.FieldCreatedAt:
  26471. v, ok := value.(time.Time)
  26472. if !ok {
  26473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26474. }
  26475. m.SetCreatedAt(v)
  26476. return nil
  26477. case msg.FieldUpdatedAt:
  26478. v, ok := value.(time.Time)
  26479. if !ok {
  26480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26481. }
  26482. m.SetUpdatedAt(v)
  26483. return nil
  26484. case msg.FieldDeletedAt:
  26485. v, ok := value.(time.Time)
  26486. if !ok {
  26487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26488. }
  26489. m.SetDeletedAt(v)
  26490. return nil
  26491. case msg.FieldStatus:
  26492. v, ok := value.(uint8)
  26493. if !ok {
  26494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26495. }
  26496. m.SetStatus(v)
  26497. return nil
  26498. case msg.FieldFromwxid:
  26499. v, ok := value.(string)
  26500. if !ok {
  26501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26502. }
  26503. m.SetFromwxid(v)
  26504. return nil
  26505. case msg.FieldToid:
  26506. v, ok := value.(string)
  26507. if !ok {
  26508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26509. }
  26510. m.SetToid(v)
  26511. return nil
  26512. case msg.FieldMsgtype:
  26513. v, ok := value.(int32)
  26514. if !ok {
  26515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26516. }
  26517. m.SetMsgtype(v)
  26518. return nil
  26519. case msg.FieldMsg:
  26520. v, ok := value.(string)
  26521. if !ok {
  26522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26523. }
  26524. m.SetMsg(v)
  26525. return nil
  26526. case msg.FieldBatchNo:
  26527. v, ok := value.(string)
  26528. if !ok {
  26529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26530. }
  26531. m.SetBatchNo(v)
  26532. return nil
  26533. case msg.FieldCc:
  26534. v, ok := value.(string)
  26535. if !ok {
  26536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26537. }
  26538. m.SetCc(v)
  26539. return nil
  26540. case msg.FieldPhone:
  26541. v, ok := value.(string)
  26542. if !ok {
  26543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26544. }
  26545. m.SetPhone(v)
  26546. return nil
  26547. }
  26548. return fmt.Errorf("unknown Msg field %s", name)
  26549. }
  26550. // AddedFields returns all numeric fields that were incremented/decremented during
  26551. // this mutation.
  26552. func (m *MsgMutation) AddedFields() []string {
  26553. var fields []string
  26554. if m.addstatus != nil {
  26555. fields = append(fields, msg.FieldStatus)
  26556. }
  26557. if m.addmsgtype != nil {
  26558. fields = append(fields, msg.FieldMsgtype)
  26559. }
  26560. return fields
  26561. }
  26562. // AddedField returns the numeric value that was incremented/decremented on a field
  26563. // with the given name. The second boolean return value indicates that this field
  26564. // was not set, or was not defined in the schema.
  26565. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  26566. switch name {
  26567. case msg.FieldStatus:
  26568. return m.AddedStatus()
  26569. case msg.FieldMsgtype:
  26570. return m.AddedMsgtype()
  26571. }
  26572. return nil, false
  26573. }
  26574. // AddField adds the value to the field with the given name. It returns an error if
  26575. // the field is not defined in the schema, or if the type mismatched the field
  26576. // type.
  26577. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  26578. switch name {
  26579. case msg.FieldStatus:
  26580. v, ok := value.(int8)
  26581. if !ok {
  26582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26583. }
  26584. m.AddStatus(v)
  26585. return nil
  26586. case msg.FieldMsgtype:
  26587. v, ok := value.(int32)
  26588. if !ok {
  26589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26590. }
  26591. m.AddMsgtype(v)
  26592. return nil
  26593. }
  26594. return fmt.Errorf("unknown Msg numeric field %s", name)
  26595. }
  26596. // ClearedFields returns all nullable fields that were cleared during this
  26597. // mutation.
  26598. func (m *MsgMutation) ClearedFields() []string {
  26599. var fields []string
  26600. if m.FieldCleared(msg.FieldDeletedAt) {
  26601. fields = append(fields, msg.FieldDeletedAt)
  26602. }
  26603. if m.FieldCleared(msg.FieldStatus) {
  26604. fields = append(fields, msg.FieldStatus)
  26605. }
  26606. if m.FieldCleared(msg.FieldFromwxid) {
  26607. fields = append(fields, msg.FieldFromwxid)
  26608. }
  26609. if m.FieldCleared(msg.FieldToid) {
  26610. fields = append(fields, msg.FieldToid)
  26611. }
  26612. if m.FieldCleared(msg.FieldMsgtype) {
  26613. fields = append(fields, msg.FieldMsgtype)
  26614. }
  26615. if m.FieldCleared(msg.FieldMsg) {
  26616. fields = append(fields, msg.FieldMsg)
  26617. }
  26618. if m.FieldCleared(msg.FieldBatchNo) {
  26619. fields = append(fields, msg.FieldBatchNo)
  26620. }
  26621. return fields
  26622. }
  26623. // FieldCleared returns a boolean indicating if a field with the given name was
  26624. // cleared in this mutation.
  26625. func (m *MsgMutation) FieldCleared(name string) bool {
  26626. _, ok := m.clearedFields[name]
  26627. return ok
  26628. }
  26629. // ClearField clears the value of the field with the given name. It returns an
  26630. // error if the field is not defined in the schema.
  26631. func (m *MsgMutation) ClearField(name string) error {
  26632. switch name {
  26633. case msg.FieldDeletedAt:
  26634. m.ClearDeletedAt()
  26635. return nil
  26636. case msg.FieldStatus:
  26637. m.ClearStatus()
  26638. return nil
  26639. case msg.FieldFromwxid:
  26640. m.ClearFromwxid()
  26641. return nil
  26642. case msg.FieldToid:
  26643. m.ClearToid()
  26644. return nil
  26645. case msg.FieldMsgtype:
  26646. m.ClearMsgtype()
  26647. return nil
  26648. case msg.FieldMsg:
  26649. m.ClearMsg()
  26650. return nil
  26651. case msg.FieldBatchNo:
  26652. m.ClearBatchNo()
  26653. return nil
  26654. }
  26655. return fmt.Errorf("unknown Msg nullable field %s", name)
  26656. }
  26657. // ResetField resets all changes in the mutation for the field with the given name.
  26658. // It returns an error if the field is not defined in the schema.
  26659. func (m *MsgMutation) ResetField(name string) error {
  26660. switch name {
  26661. case msg.FieldCreatedAt:
  26662. m.ResetCreatedAt()
  26663. return nil
  26664. case msg.FieldUpdatedAt:
  26665. m.ResetUpdatedAt()
  26666. return nil
  26667. case msg.FieldDeletedAt:
  26668. m.ResetDeletedAt()
  26669. return nil
  26670. case msg.FieldStatus:
  26671. m.ResetStatus()
  26672. return nil
  26673. case msg.FieldFromwxid:
  26674. m.ResetFromwxid()
  26675. return nil
  26676. case msg.FieldToid:
  26677. m.ResetToid()
  26678. return nil
  26679. case msg.FieldMsgtype:
  26680. m.ResetMsgtype()
  26681. return nil
  26682. case msg.FieldMsg:
  26683. m.ResetMsg()
  26684. return nil
  26685. case msg.FieldBatchNo:
  26686. m.ResetBatchNo()
  26687. return nil
  26688. case msg.FieldCc:
  26689. m.ResetCc()
  26690. return nil
  26691. case msg.FieldPhone:
  26692. m.ResetPhone()
  26693. return nil
  26694. }
  26695. return fmt.Errorf("unknown Msg field %s", name)
  26696. }
  26697. // AddedEdges returns all edge names that were set/added in this mutation.
  26698. func (m *MsgMutation) AddedEdges() []string {
  26699. edges := make([]string, 0, 0)
  26700. return edges
  26701. }
  26702. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26703. // name in this mutation.
  26704. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  26705. return nil
  26706. }
  26707. // RemovedEdges returns all edge names that were removed in this mutation.
  26708. func (m *MsgMutation) RemovedEdges() []string {
  26709. edges := make([]string, 0, 0)
  26710. return edges
  26711. }
  26712. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26713. // the given name in this mutation.
  26714. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  26715. return nil
  26716. }
  26717. // ClearedEdges returns all edge names that were cleared in this mutation.
  26718. func (m *MsgMutation) ClearedEdges() []string {
  26719. edges := make([]string, 0, 0)
  26720. return edges
  26721. }
  26722. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26723. // was cleared in this mutation.
  26724. func (m *MsgMutation) EdgeCleared(name string) bool {
  26725. return false
  26726. }
  26727. // ClearEdge clears the value of the edge with the given name. It returns an error
  26728. // if that edge is not defined in the schema.
  26729. func (m *MsgMutation) ClearEdge(name string) error {
  26730. return fmt.Errorf("unknown Msg unique edge %s", name)
  26731. }
  26732. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26733. // It returns an error if the edge is not defined in the schema.
  26734. func (m *MsgMutation) ResetEdge(name string) error {
  26735. return fmt.Errorf("unknown Msg edge %s", name)
  26736. }
  26737. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  26738. type PayRechargeMutation struct {
  26739. config
  26740. op Op
  26741. typ string
  26742. id *uint64
  26743. created_at *time.Time
  26744. updated_at *time.Time
  26745. deleted_at *time.Time
  26746. user_id *string
  26747. number *float32
  26748. addnumber *float32
  26749. status *int
  26750. addstatus *int
  26751. money *float32
  26752. addmoney *float32
  26753. out_trade_no *string
  26754. organization_id *uint64
  26755. addorganization_id *int64
  26756. clearedFields map[string]struct{}
  26757. done bool
  26758. oldValue func(context.Context) (*PayRecharge, error)
  26759. predicates []predicate.PayRecharge
  26760. }
  26761. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  26762. // payrechargeOption allows management of the mutation configuration using functional options.
  26763. type payrechargeOption func(*PayRechargeMutation)
  26764. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  26765. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  26766. m := &PayRechargeMutation{
  26767. config: c,
  26768. op: op,
  26769. typ: TypePayRecharge,
  26770. clearedFields: make(map[string]struct{}),
  26771. }
  26772. for _, opt := range opts {
  26773. opt(m)
  26774. }
  26775. return m
  26776. }
  26777. // withPayRechargeID sets the ID field of the mutation.
  26778. func withPayRechargeID(id uint64) payrechargeOption {
  26779. return func(m *PayRechargeMutation) {
  26780. var (
  26781. err error
  26782. once sync.Once
  26783. value *PayRecharge
  26784. )
  26785. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  26786. once.Do(func() {
  26787. if m.done {
  26788. err = errors.New("querying old values post mutation is not allowed")
  26789. } else {
  26790. value, err = m.Client().PayRecharge.Get(ctx, id)
  26791. }
  26792. })
  26793. return value, err
  26794. }
  26795. m.id = &id
  26796. }
  26797. }
  26798. // withPayRecharge sets the old PayRecharge of the mutation.
  26799. func withPayRecharge(node *PayRecharge) payrechargeOption {
  26800. return func(m *PayRechargeMutation) {
  26801. m.oldValue = func(context.Context) (*PayRecharge, error) {
  26802. return node, nil
  26803. }
  26804. m.id = &node.ID
  26805. }
  26806. }
  26807. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26808. // executed in a transaction (ent.Tx), a transactional client is returned.
  26809. func (m PayRechargeMutation) Client() *Client {
  26810. client := &Client{config: m.config}
  26811. client.init()
  26812. return client
  26813. }
  26814. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26815. // it returns an error otherwise.
  26816. func (m PayRechargeMutation) Tx() (*Tx, error) {
  26817. if _, ok := m.driver.(*txDriver); !ok {
  26818. return nil, errors.New("ent: mutation is not running in a transaction")
  26819. }
  26820. tx := &Tx{config: m.config}
  26821. tx.init()
  26822. return tx, nil
  26823. }
  26824. // SetID sets the value of the id field. Note that this
  26825. // operation is only accepted on creation of PayRecharge entities.
  26826. func (m *PayRechargeMutation) SetID(id uint64) {
  26827. m.id = &id
  26828. }
  26829. // ID returns the ID value in the mutation. Note that the ID is only available
  26830. // if it was provided to the builder or after it was returned from the database.
  26831. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  26832. if m.id == nil {
  26833. return
  26834. }
  26835. return *m.id, true
  26836. }
  26837. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26838. // That means, if the mutation is applied within a transaction with an isolation level such
  26839. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26840. // or updated by the mutation.
  26841. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26842. switch {
  26843. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26844. id, exists := m.ID()
  26845. if exists {
  26846. return []uint64{id}, nil
  26847. }
  26848. fallthrough
  26849. case m.op.Is(OpUpdate | OpDelete):
  26850. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  26851. default:
  26852. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26853. }
  26854. }
  26855. // SetCreatedAt sets the "created_at" field.
  26856. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  26857. m.created_at = &t
  26858. }
  26859. // CreatedAt returns the value of the "created_at" field in the mutation.
  26860. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  26861. v := m.created_at
  26862. if v == nil {
  26863. return
  26864. }
  26865. return *v, true
  26866. }
  26867. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  26868. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26870. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26871. if !m.op.Is(OpUpdateOne) {
  26872. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26873. }
  26874. if m.id == nil || m.oldValue == nil {
  26875. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26876. }
  26877. oldValue, err := m.oldValue(ctx)
  26878. if err != nil {
  26879. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26880. }
  26881. return oldValue.CreatedAt, nil
  26882. }
  26883. // ResetCreatedAt resets all changes to the "created_at" field.
  26884. func (m *PayRechargeMutation) ResetCreatedAt() {
  26885. m.created_at = nil
  26886. }
  26887. // SetUpdatedAt sets the "updated_at" field.
  26888. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  26889. m.updated_at = &t
  26890. }
  26891. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26892. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  26893. v := m.updated_at
  26894. if v == nil {
  26895. return
  26896. }
  26897. return *v, true
  26898. }
  26899. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  26900. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26902. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26903. if !m.op.Is(OpUpdateOne) {
  26904. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26905. }
  26906. if m.id == nil || m.oldValue == nil {
  26907. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26908. }
  26909. oldValue, err := m.oldValue(ctx)
  26910. if err != nil {
  26911. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26912. }
  26913. return oldValue.UpdatedAt, nil
  26914. }
  26915. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26916. func (m *PayRechargeMutation) ResetUpdatedAt() {
  26917. m.updated_at = nil
  26918. }
  26919. // SetDeletedAt sets the "deleted_at" field.
  26920. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  26921. m.deleted_at = &t
  26922. }
  26923. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26924. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  26925. v := m.deleted_at
  26926. if v == nil {
  26927. return
  26928. }
  26929. return *v, true
  26930. }
  26931. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  26932. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26934. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26935. if !m.op.Is(OpUpdateOne) {
  26936. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26937. }
  26938. if m.id == nil || m.oldValue == nil {
  26939. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26940. }
  26941. oldValue, err := m.oldValue(ctx)
  26942. if err != nil {
  26943. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26944. }
  26945. return oldValue.DeletedAt, nil
  26946. }
  26947. // ClearDeletedAt clears the value of the "deleted_at" field.
  26948. func (m *PayRechargeMutation) ClearDeletedAt() {
  26949. m.deleted_at = nil
  26950. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  26951. }
  26952. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26953. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  26954. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  26955. return ok
  26956. }
  26957. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26958. func (m *PayRechargeMutation) ResetDeletedAt() {
  26959. m.deleted_at = nil
  26960. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  26961. }
  26962. // SetUserID sets the "user_id" field.
  26963. func (m *PayRechargeMutation) SetUserID(s string) {
  26964. m.user_id = &s
  26965. }
  26966. // UserID returns the value of the "user_id" field in the mutation.
  26967. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  26968. v := m.user_id
  26969. if v == nil {
  26970. return
  26971. }
  26972. return *v, true
  26973. }
  26974. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  26975. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26977. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  26978. if !m.op.Is(OpUpdateOne) {
  26979. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  26980. }
  26981. if m.id == nil || m.oldValue == nil {
  26982. return v, errors.New("OldUserID requires an ID field in the mutation")
  26983. }
  26984. oldValue, err := m.oldValue(ctx)
  26985. if err != nil {
  26986. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  26987. }
  26988. return oldValue.UserID, nil
  26989. }
  26990. // ResetUserID resets all changes to the "user_id" field.
  26991. func (m *PayRechargeMutation) ResetUserID() {
  26992. m.user_id = nil
  26993. }
  26994. // SetNumber sets the "number" field.
  26995. func (m *PayRechargeMutation) SetNumber(f float32) {
  26996. m.number = &f
  26997. m.addnumber = nil
  26998. }
  26999. // Number returns the value of the "number" field in the mutation.
  27000. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  27001. v := m.number
  27002. if v == nil {
  27003. return
  27004. }
  27005. return *v, true
  27006. }
  27007. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  27008. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27010. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  27011. if !m.op.Is(OpUpdateOne) {
  27012. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  27013. }
  27014. if m.id == nil || m.oldValue == nil {
  27015. return v, errors.New("OldNumber requires an ID field in the mutation")
  27016. }
  27017. oldValue, err := m.oldValue(ctx)
  27018. if err != nil {
  27019. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  27020. }
  27021. return oldValue.Number, nil
  27022. }
  27023. // AddNumber adds f to the "number" field.
  27024. func (m *PayRechargeMutation) AddNumber(f float32) {
  27025. if m.addnumber != nil {
  27026. *m.addnumber += f
  27027. } else {
  27028. m.addnumber = &f
  27029. }
  27030. }
  27031. // AddedNumber returns the value that was added to the "number" field in this mutation.
  27032. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  27033. v := m.addnumber
  27034. if v == nil {
  27035. return
  27036. }
  27037. return *v, true
  27038. }
  27039. // ResetNumber resets all changes to the "number" field.
  27040. func (m *PayRechargeMutation) ResetNumber() {
  27041. m.number = nil
  27042. m.addnumber = nil
  27043. }
  27044. // SetStatus sets the "status" field.
  27045. func (m *PayRechargeMutation) SetStatus(i int) {
  27046. m.status = &i
  27047. m.addstatus = nil
  27048. }
  27049. // Status returns the value of the "status" field in the mutation.
  27050. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  27051. v := m.status
  27052. if v == nil {
  27053. return
  27054. }
  27055. return *v, true
  27056. }
  27057. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  27058. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27060. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  27061. if !m.op.Is(OpUpdateOne) {
  27062. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27063. }
  27064. if m.id == nil || m.oldValue == nil {
  27065. return v, errors.New("OldStatus requires an ID field in the mutation")
  27066. }
  27067. oldValue, err := m.oldValue(ctx)
  27068. if err != nil {
  27069. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27070. }
  27071. return oldValue.Status, nil
  27072. }
  27073. // AddStatus adds i to the "status" field.
  27074. func (m *PayRechargeMutation) AddStatus(i int) {
  27075. if m.addstatus != nil {
  27076. *m.addstatus += i
  27077. } else {
  27078. m.addstatus = &i
  27079. }
  27080. }
  27081. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27082. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  27083. v := m.addstatus
  27084. if v == nil {
  27085. return
  27086. }
  27087. return *v, true
  27088. }
  27089. // ClearStatus clears the value of the "status" field.
  27090. func (m *PayRechargeMutation) ClearStatus() {
  27091. m.status = nil
  27092. m.addstatus = nil
  27093. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  27094. }
  27095. // StatusCleared returns if the "status" field was cleared in this mutation.
  27096. func (m *PayRechargeMutation) StatusCleared() bool {
  27097. _, ok := m.clearedFields[payrecharge.FieldStatus]
  27098. return ok
  27099. }
  27100. // ResetStatus resets all changes to the "status" field.
  27101. func (m *PayRechargeMutation) ResetStatus() {
  27102. m.status = nil
  27103. m.addstatus = nil
  27104. delete(m.clearedFields, payrecharge.FieldStatus)
  27105. }
  27106. // SetMoney sets the "money" field.
  27107. func (m *PayRechargeMutation) SetMoney(f float32) {
  27108. m.money = &f
  27109. m.addmoney = nil
  27110. }
  27111. // Money returns the value of the "money" field in the mutation.
  27112. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  27113. v := m.money
  27114. if v == nil {
  27115. return
  27116. }
  27117. return *v, true
  27118. }
  27119. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  27120. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27122. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  27123. if !m.op.Is(OpUpdateOne) {
  27124. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  27125. }
  27126. if m.id == nil || m.oldValue == nil {
  27127. return v, errors.New("OldMoney requires an ID field in the mutation")
  27128. }
  27129. oldValue, err := m.oldValue(ctx)
  27130. if err != nil {
  27131. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  27132. }
  27133. return oldValue.Money, nil
  27134. }
  27135. // AddMoney adds f to the "money" field.
  27136. func (m *PayRechargeMutation) AddMoney(f float32) {
  27137. if m.addmoney != nil {
  27138. *m.addmoney += f
  27139. } else {
  27140. m.addmoney = &f
  27141. }
  27142. }
  27143. // AddedMoney returns the value that was added to the "money" field in this mutation.
  27144. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  27145. v := m.addmoney
  27146. if v == nil {
  27147. return
  27148. }
  27149. return *v, true
  27150. }
  27151. // ClearMoney clears the value of the "money" field.
  27152. func (m *PayRechargeMutation) ClearMoney() {
  27153. m.money = nil
  27154. m.addmoney = nil
  27155. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  27156. }
  27157. // MoneyCleared returns if the "money" field was cleared in this mutation.
  27158. func (m *PayRechargeMutation) MoneyCleared() bool {
  27159. _, ok := m.clearedFields[payrecharge.FieldMoney]
  27160. return ok
  27161. }
  27162. // ResetMoney resets all changes to the "money" field.
  27163. func (m *PayRechargeMutation) ResetMoney() {
  27164. m.money = nil
  27165. m.addmoney = nil
  27166. delete(m.clearedFields, payrecharge.FieldMoney)
  27167. }
  27168. // SetOutTradeNo sets the "out_trade_no" field.
  27169. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  27170. m.out_trade_no = &s
  27171. }
  27172. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  27173. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  27174. v := m.out_trade_no
  27175. if v == nil {
  27176. return
  27177. }
  27178. return *v, true
  27179. }
  27180. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  27181. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27183. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  27184. if !m.op.Is(OpUpdateOne) {
  27185. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  27186. }
  27187. if m.id == nil || m.oldValue == nil {
  27188. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  27189. }
  27190. oldValue, err := m.oldValue(ctx)
  27191. if err != nil {
  27192. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  27193. }
  27194. return oldValue.OutTradeNo, nil
  27195. }
  27196. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  27197. func (m *PayRechargeMutation) ClearOutTradeNo() {
  27198. m.out_trade_no = nil
  27199. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  27200. }
  27201. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  27202. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  27203. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  27204. return ok
  27205. }
  27206. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  27207. func (m *PayRechargeMutation) ResetOutTradeNo() {
  27208. m.out_trade_no = nil
  27209. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  27210. }
  27211. // SetOrganizationID sets the "organization_id" field.
  27212. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  27213. m.organization_id = &u
  27214. m.addorganization_id = nil
  27215. }
  27216. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27217. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  27218. v := m.organization_id
  27219. if v == nil {
  27220. return
  27221. }
  27222. return *v, true
  27223. }
  27224. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  27225. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27227. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27228. if !m.op.Is(OpUpdateOne) {
  27229. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27230. }
  27231. if m.id == nil || m.oldValue == nil {
  27232. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27233. }
  27234. oldValue, err := m.oldValue(ctx)
  27235. if err != nil {
  27236. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27237. }
  27238. return oldValue.OrganizationID, nil
  27239. }
  27240. // AddOrganizationID adds u to the "organization_id" field.
  27241. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  27242. if m.addorganization_id != nil {
  27243. *m.addorganization_id += u
  27244. } else {
  27245. m.addorganization_id = &u
  27246. }
  27247. }
  27248. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27249. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  27250. v := m.addorganization_id
  27251. if v == nil {
  27252. return
  27253. }
  27254. return *v, true
  27255. }
  27256. // ResetOrganizationID resets all changes to the "organization_id" field.
  27257. func (m *PayRechargeMutation) ResetOrganizationID() {
  27258. m.organization_id = nil
  27259. m.addorganization_id = nil
  27260. }
  27261. // Where appends a list predicates to the PayRechargeMutation builder.
  27262. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  27263. m.predicates = append(m.predicates, ps...)
  27264. }
  27265. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  27266. // users can use type-assertion to append predicates that do not depend on any generated package.
  27267. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  27268. p := make([]predicate.PayRecharge, len(ps))
  27269. for i := range ps {
  27270. p[i] = ps[i]
  27271. }
  27272. m.Where(p...)
  27273. }
  27274. // Op returns the operation name.
  27275. func (m *PayRechargeMutation) Op() Op {
  27276. return m.op
  27277. }
  27278. // SetOp allows setting the mutation operation.
  27279. func (m *PayRechargeMutation) SetOp(op Op) {
  27280. m.op = op
  27281. }
  27282. // Type returns the node type of this mutation (PayRecharge).
  27283. func (m *PayRechargeMutation) Type() string {
  27284. return m.typ
  27285. }
  27286. // Fields returns all fields that were changed during this mutation. Note that in
  27287. // order to get all numeric fields that were incremented/decremented, call
  27288. // AddedFields().
  27289. func (m *PayRechargeMutation) Fields() []string {
  27290. fields := make([]string, 0, 9)
  27291. if m.created_at != nil {
  27292. fields = append(fields, payrecharge.FieldCreatedAt)
  27293. }
  27294. if m.updated_at != nil {
  27295. fields = append(fields, payrecharge.FieldUpdatedAt)
  27296. }
  27297. if m.deleted_at != nil {
  27298. fields = append(fields, payrecharge.FieldDeletedAt)
  27299. }
  27300. if m.user_id != nil {
  27301. fields = append(fields, payrecharge.FieldUserID)
  27302. }
  27303. if m.number != nil {
  27304. fields = append(fields, payrecharge.FieldNumber)
  27305. }
  27306. if m.status != nil {
  27307. fields = append(fields, payrecharge.FieldStatus)
  27308. }
  27309. if m.money != nil {
  27310. fields = append(fields, payrecharge.FieldMoney)
  27311. }
  27312. if m.out_trade_no != nil {
  27313. fields = append(fields, payrecharge.FieldOutTradeNo)
  27314. }
  27315. if m.organization_id != nil {
  27316. fields = append(fields, payrecharge.FieldOrganizationID)
  27317. }
  27318. return fields
  27319. }
  27320. // Field returns the value of a field with the given name. The second boolean
  27321. // return value indicates that this field was not set, or was not defined in the
  27322. // schema.
  27323. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  27324. switch name {
  27325. case payrecharge.FieldCreatedAt:
  27326. return m.CreatedAt()
  27327. case payrecharge.FieldUpdatedAt:
  27328. return m.UpdatedAt()
  27329. case payrecharge.FieldDeletedAt:
  27330. return m.DeletedAt()
  27331. case payrecharge.FieldUserID:
  27332. return m.UserID()
  27333. case payrecharge.FieldNumber:
  27334. return m.Number()
  27335. case payrecharge.FieldStatus:
  27336. return m.Status()
  27337. case payrecharge.FieldMoney:
  27338. return m.Money()
  27339. case payrecharge.FieldOutTradeNo:
  27340. return m.OutTradeNo()
  27341. case payrecharge.FieldOrganizationID:
  27342. return m.OrganizationID()
  27343. }
  27344. return nil, false
  27345. }
  27346. // OldField returns the old value of the field from the database. An error is
  27347. // returned if the mutation operation is not UpdateOne, or the query to the
  27348. // database failed.
  27349. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27350. switch name {
  27351. case payrecharge.FieldCreatedAt:
  27352. return m.OldCreatedAt(ctx)
  27353. case payrecharge.FieldUpdatedAt:
  27354. return m.OldUpdatedAt(ctx)
  27355. case payrecharge.FieldDeletedAt:
  27356. return m.OldDeletedAt(ctx)
  27357. case payrecharge.FieldUserID:
  27358. return m.OldUserID(ctx)
  27359. case payrecharge.FieldNumber:
  27360. return m.OldNumber(ctx)
  27361. case payrecharge.FieldStatus:
  27362. return m.OldStatus(ctx)
  27363. case payrecharge.FieldMoney:
  27364. return m.OldMoney(ctx)
  27365. case payrecharge.FieldOutTradeNo:
  27366. return m.OldOutTradeNo(ctx)
  27367. case payrecharge.FieldOrganizationID:
  27368. return m.OldOrganizationID(ctx)
  27369. }
  27370. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  27371. }
  27372. // SetField sets the value of a field with the given name. It returns an error if
  27373. // the field is not defined in the schema, or if the type mismatched the field
  27374. // type.
  27375. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  27376. switch name {
  27377. case payrecharge.FieldCreatedAt:
  27378. v, ok := value.(time.Time)
  27379. if !ok {
  27380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27381. }
  27382. m.SetCreatedAt(v)
  27383. return nil
  27384. case payrecharge.FieldUpdatedAt:
  27385. v, ok := value.(time.Time)
  27386. if !ok {
  27387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27388. }
  27389. m.SetUpdatedAt(v)
  27390. return nil
  27391. case payrecharge.FieldDeletedAt:
  27392. v, ok := value.(time.Time)
  27393. if !ok {
  27394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27395. }
  27396. m.SetDeletedAt(v)
  27397. return nil
  27398. case payrecharge.FieldUserID:
  27399. v, ok := value.(string)
  27400. if !ok {
  27401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27402. }
  27403. m.SetUserID(v)
  27404. return nil
  27405. case payrecharge.FieldNumber:
  27406. v, ok := value.(float32)
  27407. if !ok {
  27408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27409. }
  27410. m.SetNumber(v)
  27411. return nil
  27412. case payrecharge.FieldStatus:
  27413. v, ok := value.(int)
  27414. if !ok {
  27415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27416. }
  27417. m.SetStatus(v)
  27418. return nil
  27419. case payrecharge.FieldMoney:
  27420. v, ok := value.(float32)
  27421. if !ok {
  27422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27423. }
  27424. m.SetMoney(v)
  27425. return nil
  27426. case payrecharge.FieldOutTradeNo:
  27427. v, ok := value.(string)
  27428. if !ok {
  27429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27430. }
  27431. m.SetOutTradeNo(v)
  27432. return nil
  27433. case payrecharge.FieldOrganizationID:
  27434. v, ok := value.(uint64)
  27435. if !ok {
  27436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27437. }
  27438. m.SetOrganizationID(v)
  27439. return nil
  27440. }
  27441. return fmt.Errorf("unknown PayRecharge field %s", name)
  27442. }
  27443. // AddedFields returns all numeric fields that were incremented/decremented during
  27444. // this mutation.
  27445. func (m *PayRechargeMutation) AddedFields() []string {
  27446. var fields []string
  27447. if m.addnumber != nil {
  27448. fields = append(fields, payrecharge.FieldNumber)
  27449. }
  27450. if m.addstatus != nil {
  27451. fields = append(fields, payrecharge.FieldStatus)
  27452. }
  27453. if m.addmoney != nil {
  27454. fields = append(fields, payrecharge.FieldMoney)
  27455. }
  27456. if m.addorganization_id != nil {
  27457. fields = append(fields, payrecharge.FieldOrganizationID)
  27458. }
  27459. return fields
  27460. }
  27461. // AddedField returns the numeric value that was incremented/decremented on a field
  27462. // with the given name. The second boolean return value indicates that this field
  27463. // was not set, or was not defined in the schema.
  27464. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  27465. switch name {
  27466. case payrecharge.FieldNumber:
  27467. return m.AddedNumber()
  27468. case payrecharge.FieldStatus:
  27469. return m.AddedStatus()
  27470. case payrecharge.FieldMoney:
  27471. return m.AddedMoney()
  27472. case payrecharge.FieldOrganizationID:
  27473. return m.AddedOrganizationID()
  27474. }
  27475. return nil, false
  27476. }
  27477. // AddField adds the value to the field with the given name. It returns an error if
  27478. // the field is not defined in the schema, or if the type mismatched the field
  27479. // type.
  27480. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  27481. switch name {
  27482. case payrecharge.FieldNumber:
  27483. v, ok := value.(float32)
  27484. if !ok {
  27485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27486. }
  27487. m.AddNumber(v)
  27488. return nil
  27489. case payrecharge.FieldStatus:
  27490. v, ok := value.(int)
  27491. if !ok {
  27492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27493. }
  27494. m.AddStatus(v)
  27495. return nil
  27496. case payrecharge.FieldMoney:
  27497. v, ok := value.(float32)
  27498. if !ok {
  27499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27500. }
  27501. m.AddMoney(v)
  27502. return nil
  27503. case payrecharge.FieldOrganizationID:
  27504. v, ok := value.(int64)
  27505. if !ok {
  27506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27507. }
  27508. m.AddOrganizationID(v)
  27509. return nil
  27510. }
  27511. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  27512. }
  27513. // ClearedFields returns all nullable fields that were cleared during this
  27514. // mutation.
  27515. func (m *PayRechargeMutation) ClearedFields() []string {
  27516. var fields []string
  27517. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  27518. fields = append(fields, payrecharge.FieldDeletedAt)
  27519. }
  27520. if m.FieldCleared(payrecharge.FieldStatus) {
  27521. fields = append(fields, payrecharge.FieldStatus)
  27522. }
  27523. if m.FieldCleared(payrecharge.FieldMoney) {
  27524. fields = append(fields, payrecharge.FieldMoney)
  27525. }
  27526. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  27527. fields = append(fields, payrecharge.FieldOutTradeNo)
  27528. }
  27529. return fields
  27530. }
  27531. // FieldCleared returns a boolean indicating if a field with the given name was
  27532. // cleared in this mutation.
  27533. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  27534. _, ok := m.clearedFields[name]
  27535. return ok
  27536. }
  27537. // ClearField clears the value of the field with the given name. It returns an
  27538. // error if the field is not defined in the schema.
  27539. func (m *PayRechargeMutation) ClearField(name string) error {
  27540. switch name {
  27541. case payrecharge.FieldDeletedAt:
  27542. m.ClearDeletedAt()
  27543. return nil
  27544. case payrecharge.FieldStatus:
  27545. m.ClearStatus()
  27546. return nil
  27547. case payrecharge.FieldMoney:
  27548. m.ClearMoney()
  27549. return nil
  27550. case payrecharge.FieldOutTradeNo:
  27551. m.ClearOutTradeNo()
  27552. return nil
  27553. }
  27554. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  27555. }
  27556. // ResetField resets all changes in the mutation for the field with the given name.
  27557. // It returns an error if the field is not defined in the schema.
  27558. func (m *PayRechargeMutation) ResetField(name string) error {
  27559. switch name {
  27560. case payrecharge.FieldCreatedAt:
  27561. m.ResetCreatedAt()
  27562. return nil
  27563. case payrecharge.FieldUpdatedAt:
  27564. m.ResetUpdatedAt()
  27565. return nil
  27566. case payrecharge.FieldDeletedAt:
  27567. m.ResetDeletedAt()
  27568. return nil
  27569. case payrecharge.FieldUserID:
  27570. m.ResetUserID()
  27571. return nil
  27572. case payrecharge.FieldNumber:
  27573. m.ResetNumber()
  27574. return nil
  27575. case payrecharge.FieldStatus:
  27576. m.ResetStatus()
  27577. return nil
  27578. case payrecharge.FieldMoney:
  27579. m.ResetMoney()
  27580. return nil
  27581. case payrecharge.FieldOutTradeNo:
  27582. m.ResetOutTradeNo()
  27583. return nil
  27584. case payrecharge.FieldOrganizationID:
  27585. m.ResetOrganizationID()
  27586. return nil
  27587. }
  27588. return fmt.Errorf("unknown PayRecharge field %s", name)
  27589. }
  27590. // AddedEdges returns all edge names that were set/added in this mutation.
  27591. func (m *PayRechargeMutation) AddedEdges() []string {
  27592. edges := make([]string, 0, 0)
  27593. return edges
  27594. }
  27595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27596. // name in this mutation.
  27597. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  27598. return nil
  27599. }
  27600. // RemovedEdges returns all edge names that were removed in this mutation.
  27601. func (m *PayRechargeMutation) RemovedEdges() []string {
  27602. edges := make([]string, 0, 0)
  27603. return edges
  27604. }
  27605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27606. // the given name in this mutation.
  27607. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  27608. return nil
  27609. }
  27610. // ClearedEdges returns all edge names that were cleared in this mutation.
  27611. func (m *PayRechargeMutation) ClearedEdges() []string {
  27612. edges := make([]string, 0, 0)
  27613. return edges
  27614. }
  27615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27616. // was cleared in this mutation.
  27617. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  27618. return false
  27619. }
  27620. // ClearEdge clears the value of the edge with the given name. It returns an error
  27621. // if that edge is not defined in the schema.
  27622. func (m *PayRechargeMutation) ClearEdge(name string) error {
  27623. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  27624. }
  27625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27626. // It returns an error if the edge is not defined in the schema.
  27627. func (m *PayRechargeMutation) ResetEdge(name string) error {
  27628. return fmt.Errorf("unknown PayRecharge edge %s", name)
  27629. }
  27630. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  27631. type ServerMutation struct {
  27632. config
  27633. op Op
  27634. typ string
  27635. id *uint64
  27636. created_at *time.Time
  27637. updated_at *time.Time
  27638. status *uint8
  27639. addstatus *int8
  27640. deleted_at *time.Time
  27641. name *string
  27642. public_ip *string
  27643. private_ip *string
  27644. admin_port *string
  27645. clearedFields map[string]struct{}
  27646. wxs map[uint64]struct{}
  27647. removedwxs map[uint64]struct{}
  27648. clearedwxs bool
  27649. done bool
  27650. oldValue func(context.Context) (*Server, error)
  27651. predicates []predicate.Server
  27652. }
  27653. var _ ent.Mutation = (*ServerMutation)(nil)
  27654. // serverOption allows management of the mutation configuration using functional options.
  27655. type serverOption func(*ServerMutation)
  27656. // newServerMutation creates new mutation for the Server entity.
  27657. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  27658. m := &ServerMutation{
  27659. config: c,
  27660. op: op,
  27661. typ: TypeServer,
  27662. clearedFields: make(map[string]struct{}),
  27663. }
  27664. for _, opt := range opts {
  27665. opt(m)
  27666. }
  27667. return m
  27668. }
  27669. // withServerID sets the ID field of the mutation.
  27670. func withServerID(id uint64) serverOption {
  27671. return func(m *ServerMutation) {
  27672. var (
  27673. err error
  27674. once sync.Once
  27675. value *Server
  27676. )
  27677. m.oldValue = func(ctx context.Context) (*Server, error) {
  27678. once.Do(func() {
  27679. if m.done {
  27680. err = errors.New("querying old values post mutation is not allowed")
  27681. } else {
  27682. value, err = m.Client().Server.Get(ctx, id)
  27683. }
  27684. })
  27685. return value, err
  27686. }
  27687. m.id = &id
  27688. }
  27689. }
  27690. // withServer sets the old Server of the mutation.
  27691. func withServer(node *Server) serverOption {
  27692. return func(m *ServerMutation) {
  27693. m.oldValue = func(context.Context) (*Server, error) {
  27694. return node, nil
  27695. }
  27696. m.id = &node.ID
  27697. }
  27698. }
  27699. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27700. // executed in a transaction (ent.Tx), a transactional client is returned.
  27701. func (m ServerMutation) Client() *Client {
  27702. client := &Client{config: m.config}
  27703. client.init()
  27704. return client
  27705. }
  27706. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27707. // it returns an error otherwise.
  27708. func (m ServerMutation) Tx() (*Tx, error) {
  27709. if _, ok := m.driver.(*txDriver); !ok {
  27710. return nil, errors.New("ent: mutation is not running in a transaction")
  27711. }
  27712. tx := &Tx{config: m.config}
  27713. tx.init()
  27714. return tx, nil
  27715. }
  27716. // SetID sets the value of the id field. Note that this
  27717. // operation is only accepted on creation of Server entities.
  27718. func (m *ServerMutation) SetID(id uint64) {
  27719. m.id = &id
  27720. }
  27721. // ID returns the ID value in the mutation. Note that the ID is only available
  27722. // if it was provided to the builder or after it was returned from the database.
  27723. func (m *ServerMutation) ID() (id uint64, exists bool) {
  27724. if m.id == nil {
  27725. return
  27726. }
  27727. return *m.id, true
  27728. }
  27729. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27730. // That means, if the mutation is applied within a transaction with an isolation level such
  27731. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27732. // or updated by the mutation.
  27733. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  27734. switch {
  27735. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27736. id, exists := m.ID()
  27737. if exists {
  27738. return []uint64{id}, nil
  27739. }
  27740. fallthrough
  27741. case m.op.Is(OpUpdate | OpDelete):
  27742. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  27743. default:
  27744. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27745. }
  27746. }
  27747. // SetCreatedAt sets the "created_at" field.
  27748. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  27749. m.created_at = &t
  27750. }
  27751. // CreatedAt returns the value of the "created_at" field in the mutation.
  27752. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  27753. v := m.created_at
  27754. if v == nil {
  27755. return
  27756. }
  27757. return *v, true
  27758. }
  27759. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  27760. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27762. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27763. if !m.op.Is(OpUpdateOne) {
  27764. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27765. }
  27766. if m.id == nil || m.oldValue == nil {
  27767. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27768. }
  27769. oldValue, err := m.oldValue(ctx)
  27770. if err != nil {
  27771. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27772. }
  27773. return oldValue.CreatedAt, nil
  27774. }
  27775. // ResetCreatedAt resets all changes to the "created_at" field.
  27776. func (m *ServerMutation) ResetCreatedAt() {
  27777. m.created_at = nil
  27778. }
  27779. // SetUpdatedAt sets the "updated_at" field.
  27780. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  27781. m.updated_at = &t
  27782. }
  27783. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27784. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  27785. v := m.updated_at
  27786. if v == nil {
  27787. return
  27788. }
  27789. return *v, true
  27790. }
  27791. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  27792. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27794. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27795. if !m.op.Is(OpUpdateOne) {
  27796. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27797. }
  27798. if m.id == nil || m.oldValue == nil {
  27799. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27800. }
  27801. oldValue, err := m.oldValue(ctx)
  27802. if err != nil {
  27803. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27804. }
  27805. return oldValue.UpdatedAt, nil
  27806. }
  27807. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27808. func (m *ServerMutation) ResetUpdatedAt() {
  27809. m.updated_at = nil
  27810. }
  27811. // SetStatus sets the "status" field.
  27812. func (m *ServerMutation) SetStatus(u uint8) {
  27813. m.status = &u
  27814. m.addstatus = nil
  27815. }
  27816. // Status returns the value of the "status" field in the mutation.
  27817. func (m *ServerMutation) Status() (r uint8, exists bool) {
  27818. v := m.status
  27819. if v == nil {
  27820. return
  27821. }
  27822. return *v, true
  27823. }
  27824. // OldStatus returns the old "status" field's value of the Server entity.
  27825. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27827. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27828. if !m.op.Is(OpUpdateOne) {
  27829. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27830. }
  27831. if m.id == nil || m.oldValue == nil {
  27832. return v, errors.New("OldStatus requires an ID field in the mutation")
  27833. }
  27834. oldValue, err := m.oldValue(ctx)
  27835. if err != nil {
  27836. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27837. }
  27838. return oldValue.Status, nil
  27839. }
  27840. // AddStatus adds u to the "status" field.
  27841. func (m *ServerMutation) AddStatus(u int8) {
  27842. if m.addstatus != nil {
  27843. *m.addstatus += u
  27844. } else {
  27845. m.addstatus = &u
  27846. }
  27847. }
  27848. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27849. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  27850. v := m.addstatus
  27851. if v == nil {
  27852. return
  27853. }
  27854. return *v, true
  27855. }
  27856. // ClearStatus clears the value of the "status" field.
  27857. func (m *ServerMutation) ClearStatus() {
  27858. m.status = nil
  27859. m.addstatus = nil
  27860. m.clearedFields[server.FieldStatus] = struct{}{}
  27861. }
  27862. // StatusCleared returns if the "status" field was cleared in this mutation.
  27863. func (m *ServerMutation) StatusCleared() bool {
  27864. _, ok := m.clearedFields[server.FieldStatus]
  27865. return ok
  27866. }
  27867. // ResetStatus resets all changes to the "status" field.
  27868. func (m *ServerMutation) ResetStatus() {
  27869. m.status = nil
  27870. m.addstatus = nil
  27871. delete(m.clearedFields, server.FieldStatus)
  27872. }
  27873. // SetDeletedAt sets the "deleted_at" field.
  27874. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  27875. m.deleted_at = &t
  27876. }
  27877. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27878. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  27879. v := m.deleted_at
  27880. if v == nil {
  27881. return
  27882. }
  27883. return *v, true
  27884. }
  27885. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  27886. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27888. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27889. if !m.op.Is(OpUpdateOne) {
  27890. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27891. }
  27892. if m.id == nil || m.oldValue == nil {
  27893. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27894. }
  27895. oldValue, err := m.oldValue(ctx)
  27896. if err != nil {
  27897. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27898. }
  27899. return oldValue.DeletedAt, nil
  27900. }
  27901. // ClearDeletedAt clears the value of the "deleted_at" field.
  27902. func (m *ServerMutation) ClearDeletedAt() {
  27903. m.deleted_at = nil
  27904. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  27905. }
  27906. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27907. func (m *ServerMutation) DeletedAtCleared() bool {
  27908. _, ok := m.clearedFields[server.FieldDeletedAt]
  27909. return ok
  27910. }
  27911. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27912. func (m *ServerMutation) ResetDeletedAt() {
  27913. m.deleted_at = nil
  27914. delete(m.clearedFields, server.FieldDeletedAt)
  27915. }
  27916. // SetName sets the "name" field.
  27917. func (m *ServerMutation) SetName(s string) {
  27918. m.name = &s
  27919. }
  27920. // Name returns the value of the "name" field in the mutation.
  27921. func (m *ServerMutation) Name() (r string, exists bool) {
  27922. v := m.name
  27923. if v == nil {
  27924. return
  27925. }
  27926. return *v, true
  27927. }
  27928. // OldName returns the old "name" field's value of the Server entity.
  27929. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27931. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  27932. if !m.op.Is(OpUpdateOne) {
  27933. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27934. }
  27935. if m.id == nil || m.oldValue == nil {
  27936. return v, errors.New("OldName requires an ID field in the mutation")
  27937. }
  27938. oldValue, err := m.oldValue(ctx)
  27939. if err != nil {
  27940. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27941. }
  27942. return oldValue.Name, nil
  27943. }
  27944. // ResetName resets all changes to the "name" field.
  27945. func (m *ServerMutation) ResetName() {
  27946. m.name = nil
  27947. }
  27948. // SetPublicIP sets the "public_ip" field.
  27949. func (m *ServerMutation) SetPublicIP(s string) {
  27950. m.public_ip = &s
  27951. }
  27952. // PublicIP returns the value of the "public_ip" field in the mutation.
  27953. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  27954. v := m.public_ip
  27955. if v == nil {
  27956. return
  27957. }
  27958. return *v, true
  27959. }
  27960. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  27961. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27963. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  27964. if !m.op.Is(OpUpdateOne) {
  27965. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  27966. }
  27967. if m.id == nil || m.oldValue == nil {
  27968. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  27969. }
  27970. oldValue, err := m.oldValue(ctx)
  27971. if err != nil {
  27972. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  27973. }
  27974. return oldValue.PublicIP, nil
  27975. }
  27976. // ResetPublicIP resets all changes to the "public_ip" field.
  27977. func (m *ServerMutation) ResetPublicIP() {
  27978. m.public_ip = nil
  27979. }
  27980. // SetPrivateIP sets the "private_ip" field.
  27981. func (m *ServerMutation) SetPrivateIP(s string) {
  27982. m.private_ip = &s
  27983. }
  27984. // PrivateIP returns the value of the "private_ip" field in the mutation.
  27985. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  27986. v := m.private_ip
  27987. if v == nil {
  27988. return
  27989. }
  27990. return *v, true
  27991. }
  27992. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  27993. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27995. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  27996. if !m.op.Is(OpUpdateOne) {
  27997. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  27998. }
  27999. if m.id == nil || m.oldValue == nil {
  28000. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  28001. }
  28002. oldValue, err := m.oldValue(ctx)
  28003. if err != nil {
  28004. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  28005. }
  28006. return oldValue.PrivateIP, nil
  28007. }
  28008. // ResetPrivateIP resets all changes to the "private_ip" field.
  28009. func (m *ServerMutation) ResetPrivateIP() {
  28010. m.private_ip = nil
  28011. }
  28012. // SetAdminPort sets the "admin_port" field.
  28013. func (m *ServerMutation) SetAdminPort(s string) {
  28014. m.admin_port = &s
  28015. }
  28016. // AdminPort returns the value of the "admin_port" field in the mutation.
  28017. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  28018. v := m.admin_port
  28019. if v == nil {
  28020. return
  28021. }
  28022. return *v, true
  28023. }
  28024. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  28025. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  28026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28027. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  28028. if !m.op.Is(OpUpdateOne) {
  28029. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  28030. }
  28031. if m.id == nil || m.oldValue == nil {
  28032. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  28033. }
  28034. oldValue, err := m.oldValue(ctx)
  28035. if err != nil {
  28036. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  28037. }
  28038. return oldValue.AdminPort, nil
  28039. }
  28040. // ResetAdminPort resets all changes to the "admin_port" field.
  28041. func (m *ServerMutation) ResetAdminPort() {
  28042. m.admin_port = nil
  28043. }
  28044. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  28045. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  28046. if m.wxs == nil {
  28047. m.wxs = make(map[uint64]struct{})
  28048. }
  28049. for i := range ids {
  28050. m.wxs[ids[i]] = struct{}{}
  28051. }
  28052. }
  28053. // ClearWxs clears the "wxs" edge to the Wx entity.
  28054. func (m *ServerMutation) ClearWxs() {
  28055. m.clearedwxs = true
  28056. }
  28057. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  28058. func (m *ServerMutation) WxsCleared() bool {
  28059. return m.clearedwxs
  28060. }
  28061. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  28062. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  28063. if m.removedwxs == nil {
  28064. m.removedwxs = make(map[uint64]struct{})
  28065. }
  28066. for i := range ids {
  28067. delete(m.wxs, ids[i])
  28068. m.removedwxs[ids[i]] = struct{}{}
  28069. }
  28070. }
  28071. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  28072. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  28073. for id := range m.removedwxs {
  28074. ids = append(ids, id)
  28075. }
  28076. return
  28077. }
  28078. // WxsIDs returns the "wxs" edge IDs in the mutation.
  28079. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  28080. for id := range m.wxs {
  28081. ids = append(ids, id)
  28082. }
  28083. return
  28084. }
  28085. // ResetWxs resets all changes to the "wxs" edge.
  28086. func (m *ServerMutation) ResetWxs() {
  28087. m.wxs = nil
  28088. m.clearedwxs = false
  28089. m.removedwxs = nil
  28090. }
  28091. // Where appends a list predicates to the ServerMutation builder.
  28092. func (m *ServerMutation) Where(ps ...predicate.Server) {
  28093. m.predicates = append(m.predicates, ps...)
  28094. }
  28095. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  28096. // users can use type-assertion to append predicates that do not depend on any generated package.
  28097. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  28098. p := make([]predicate.Server, len(ps))
  28099. for i := range ps {
  28100. p[i] = ps[i]
  28101. }
  28102. m.Where(p...)
  28103. }
  28104. // Op returns the operation name.
  28105. func (m *ServerMutation) Op() Op {
  28106. return m.op
  28107. }
  28108. // SetOp allows setting the mutation operation.
  28109. func (m *ServerMutation) SetOp(op Op) {
  28110. m.op = op
  28111. }
  28112. // Type returns the node type of this mutation (Server).
  28113. func (m *ServerMutation) Type() string {
  28114. return m.typ
  28115. }
  28116. // Fields returns all fields that were changed during this mutation. Note that in
  28117. // order to get all numeric fields that were incremented/decremented, call
  28118. // AddedFields().
  28119. func (m *ServerMutation) Fields() []string {
  28120. fields := make([]string, 0, 8)
  28121. if m.created_at != nil {
  28122. fields = append(fields, server.FieldCreatedAt)
  28123. }
  28124. if m.updated_at != nil {
  28125. fields = append(fields, server.FieldUpdatedAt)
  28126. }
  28127. if m.status != nil {
  28128. fields = append(fields, server.FieldStatus)
  28129. }
  28130. if m.deleted_at != nil {
  28131. fields = append(fields, server.FieldDeletedAt)
  28132. }
  28133. if m.name != nil {
  28134. fields = append(fields, server.FieldName)
  28135. }
  28136. if m.public_ip != nil {
  28137. fields = append(fields, server.FieldPublicIP)
  28138. }
  28139. if m.private_ip != nil {
  28140. fields = append(fields, server.FieldPrivateIP)
  28141. }
  28142. if m.admin_port != nil {
  28143. fields = append(fields, server.FieldAdminPort)
  28144. }
  28145. return fields
  28146. }
  28147. // Field returns the value of a field with the given name. The second boolean
  28148. // return value indicates that this field was not set, or was not defined in the
  28149. // schema.
  28150. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  28151. switch name {
  28152. case server.FieldCreatedAt:
  28153. return m.CreatedAt()
  28154. case server.FieldUpdatedAt:
  28155. return m.UpdatedAt()
  28156. case server.FieldStatus:
  28157. return m.Status()
  28158. case server.FieldDeletedAt:
  28159. return m.DeletedAt()
  28160. case server.FieldName:
  28161. return m.Name()
  28162. case server.FieldPublicIP:
  28163. return m.PublicIP()
  28164. case server.FieldPrivateIP:
  28165. return m.PrivateIP()
  28166. case server.FieldAdminPort:
  28167. return m.AdminPort()
  28168. }
  28169. return nil, false
  28170. }
  28171. // OldField returns the old value of the field from the database. An error is
  28172. // returned if the mutation operation is not UpdateOne, or the query to the
  28173. // database failed.
  28174. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28175. switch name {
  28176. case server.FieldCreatedAt:
  28177. return m.OldCreatedAt(ctx)
  28178. case server.FieldUpdatedAt:
  28179. return m.OldUpdatedAt(ctx)
  28180. case server.FieldStatus:
  28181. return m.OldStatus(ctx)
  28182. case server.FieldDeletedAt:
  28183. return m.OldDeletedAt(ctx)
  28184. case server.FieldName:
  28185. return m.OldName(ctx)
  28186. case server.FieldPublicIP:
  28187. return m.OldPublicIP(ctx)
  28188. case server.FieldPrivateIP:
  28189. return m.OldPrivateIP(ctx)
  28190. case server.FieldAdminPort:
  28191. return m.OldAdminPort(ctx)
  28192. }
  28193. return nil, fmt.Errorf("unknown Server field %s", name)
  28194. }
  28195. // SetField sets the value of a field with the given name. It returns an error if
  28196. // the field is not defined in the schema, or if the type mismatched the field
  28197. // type.
  28198. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  28199. switch name {
  28200. case server.FieldCreatedAt:
  28201. v, ok := value.(time.Time)
  28202. if !ok {
  28203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28204. }
  28205. m.SetCreatedAt(v)
  28206. return nil
  28207. case server.FieldUpdatedAt:
  28208. v, ok := value.(time.Time)
  28209. if !ok {
  28210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28211. }
  28212. m.SetUpdatedAt(v)
  28213. return nil
  28214. case server.FieldStatus:
  28215. v, ok := value.(uint8)
  28216. if !ok {
  28217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28218. }
  28219. m.SetStatus(v)
  28220. return nil
  28221. case server.FieldDeletedAt:
  28222. v, ok := value.(time.Time)
  28223. if !ok {
  28224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28225. }
  28226. m.SetDeletedAt(v)
  28227. return nil
  28228. case server.FieldName:
  28229. v, ok := value.(string)
  28230. if !ok {
  28231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28232. }
  28233. m.SetName(v)
  28234. return nil
  28235. case server.FieldPublicIP:
  28236. v, ok := value.(string)
  28237. if !ok {
  28238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28239. }
  28240. m.SetPublicIP(v)
  28241. return nil
  28242. case server.FieldPrivateIP:
  28243. v, ok := value.(string)
  28244. if !ok {
  28245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28246. }
  28247. m.SetPrivateIP(v)
  28248. return nil
  28249. case server.FieldAdminPort:
  28250. v, ok := value.(string)
  28251. if !ok {
  28252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28253. }
  28254. m.SetAdminPort(v)
  28255. return nil
  28256. }
  28257. return fmt.Errorf("unknown Server field %s", name)
  28258. }
  28259. // AddedFields returns all numeric fields that were incremented/decremented during
  28260. // this mutation.
  28261. func (m *ServerMutation) AddedFields() []string {
  28262. var fields []string
  28263. if m.addstatus != nil {
  28264. fields = append(fields, server.FieldStatus)
  28265. }
  28266. return fields
  28267. }
  28268. // AddedField returns the numeric value that was incremented/decremented on a field
  28269. // with the given name. The second boolean return value indicates that this field
  28270. // was not set, or was not defined in the schema.
  28271. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  28272. switch name {
  28273. case server.FieldStatus:
  28274. return m.AddedStatus()
  28275. }
  28276. return nil, false
  28277. }
  28278. // AddField adds the value to the field with the given name. It returns an error if
  28279. // the field is not defined in the schema, or if the type mismatched the field
  28280. // type.
  28281. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  28282. switch name {
  28283. case server.FieldStatus:
  28284. v, ok := value.(int8)
  28285. if !ok {
  28286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28287. }
  28288. m.AddStatus(v)
  28289. return nil
  28290. }
  28291. return fmt.Errorf("unknown Server numeric field %s", name)
  28292. }
  28293. // ClearedFields returns all nullable fields that were cleared during this
  28294. // mutation.
  28295. func (m *ServerMutation) ClearedFields() []string {
  28296. var fields []string
  28297. if m.FieldCleared(server.FieldStatus) {
  28298. fields = append(fields, server.FieldStatus)
  28299. }
  28300. if m.FieldCleared(server.FieldDeletedAt) {
  28301. fields = append(fields, server.FieldDeletedAt)
  28302. }
  28303. return fields
  28304. }
  28305. // FieldCleared returns a boolean indicating if a field with the given name was
  28306. // cleared in this mutation.
  28307. func (m *ServerMutation) FieldCleared(name string) bool {
  28308. _, ok := m.clearedFields[name]
  28309. return ok
  28310. }
  28311. // ClearField clears the value of the field with the given name. It returns an
  28312. // error if the field is not defined in the schema.
  28313. func (m *ServerMutation) ClearField(name string) error {
  28314. switch name {
  28315. case server.FieldStatus:
  28316. m.ClearStatus()
  28317. return nil
  28318. case server.FieldDeletedAt:
  28319. m.ClearDeletedAt()
  28320. return nil
  28321. }
  28322. return fmt.Errorf("unknown Server nullable field %s", name)
  28323. }
  28324. // ResetField resets all changes in the mutation for the field with the given name.
  28325. // It returns an error if the field is not defined in the schema.
  28326. func (m *ServerMutation) ResetField(name string) error {
  28327. switch name {
  28328. case server.FieldCreatedAt:
  28329. m.ResetCreatedAt()
  28330. return nil
  28331. case server.FieldUpdatedAt:
  28332. m.ResetUpdatedAt()
  28333. return nil
  28334. case server.FieldStatus:
  28335. m.ResetStatus()
  28336. return nil
  28337. case server.FieldDeletedAt:
  28338. m.ResetDeletedAt()
  28339. return nil
  28340. case server.FieldName:
  28341. m.ResetName()
  28342. return nil
  28343. case server.FieldPublicIP:
  28344. m.ResetPublicIP()
  28345. return nil
  28346. case server.FieldPrivateIP:
  28347. m.ResetPrivateIP()
  28348. return nil
  28349. case server.FieldAdminPort:
  28350. m.ResetAdminPort()
  28351. return nil
  28352. }
  28353. return fmt.Errorf("unknown Server field %s", name)
  28354. }
  28355. // AddedEdges returns all edge names that were set/added in this mutation.
  28356. func (m *ServerMutation) AddedEdges() []string {
  28357. edges := make([]string, 0, 1)
  28358. if m.wxs != nil {
  28359. edges = append(edges, server.EdgeWxs)
  28360. }
  28361. return edges
  28362. }
  28363. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28364. // name in this mutation.
  28365. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  28366. switch name {
  28367. case server.EdgeWxs:
  28368. ids := make([]ent.Value, 0, len(m.wxs))
  28369. for id := range m.wxs {
  28370. ids = append(ids, id)
  28371. }
  28372. return ids
  28373. }
  28374. return nil
  28375. }
  28376. // RemovedEdges returns all edge names that were removed in this mutation.
  28377. func (m *ServerMutation) RemovedEdges() []string {
  28378. edges := make([]string, 0, 1)
  28379. if m.removedwxs != nil {
  28380. edges = append(edges, server.EdgeWxs)
  28381. }
  28382. return edges
  28383. }
  28384. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28385. // the given name in this mutation.
  28386. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  28387. switch name {
  28388. case server.EdgeWxs:
  28389. ids := make([]ent.Value, 0, len(m.removedwxs))
  28390. for id := range m.removedwxs {
  28391. ids = append(ids, id)
  28392. }
  28393. return ids
  28394. }
  28395. return nil
  28396. }
  28397. // ClearedEdges returns all edge names that were cleared in this mutation.
  28398. func (m *ServerMutation) ClearedEdges() []string {
  28399. edges := make([]string, 0, 1)
  28400. if m.clearedwxs {
  28401. edges = append(edges, server.EdgeWxs)
  28402. }
  28403. return edges
  28404. }
  28405. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28406. // was cleared in this mutation.
  28407. func (m *ServerMutation) EdgeCleared(name string) bool {
  28408. switch name {
  28409. case server.EdgeWxs:
  28410. return m.clearedwxs
  28411. }
  28412. return false
  28413. }
  28414. // ClearEdge clears the value of the edge with the given name. It returns an error
  28415. // if that edge is not defined in the schema.
  28416. func (m *ServerMutation) ClearEdge(name string) error {
  28417. switch name {
  28418. }
  28419. return fmt.Errorf("unknown Server unique edge %s", name)
  28420. }
  28421. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28422. // It returns an error if the edge is not defined in the schema.
  28423. func (m *ServerMutation) ResetEdge(name string) error {
  28424. switch name {
  28425. case server.EdgeWxs:
  28426. m.ResetWxs()
  28427. return nil
  28428. }
  28429. return fmt.Errorf("unknown Server edge %s", name)
  28430. }
  28431. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  28432. type SopNodeMutation struct {
  28433. config
  28434. op Op
  28435. typ string
  28436. id *uint64
  28437. created_at *time.Time
  28438. updated_at *time.Time
  28439. status *uint8
  28440. addstatus *int8
  28441. deleted_at *time.Time
  28442. parent_id *uint64
  28443. addparent_id *int64
  28444. name *string
  28445. condition_type *int
  28446. addcondition_type *int
  28447. condition_list *[]string
  28448. appendcondition_list []string
  28449. no_reply_condition *uint64
  28450. addno_reply_condition *int64
  28451. no_reply_unit *string
  28452. action_message *[]custom_types.Action
  28453. appendaction_message []custom_types.Action
  28454. action_label_add *[]uint64
  28455. appendaction_label_add []uint64
  28456. action_label_del *[]uint64
  28457. appendaction_label_del []uint64
  28458. action_forward **custom_types.ActionForward
  28459. clearedFields map[string]struct{}
  28460. sop_stage *uint64
  28461. clearedsop_stage bool
  28462. node_messages map[uint64]struct{}
  28463. removednode_messages map[uint64]struct{}
  28464. clearednode_messages bool
  28465. done bool
  28466. oldValue func(context.Context) (*SopNode, error)
  28467. predicates []predicate.SopNode
  28468. }
  28469. var _ ent.Mutation = (*SopNodeMutation)(nil)
  28470. // sopnodeOption allows management of the mutation configuration using functional options.
  28471. type sopnodeOption func(*SopNodeMutation)
  28472. // newSopNodeMutation creates new mutation for the SopNode entity.
  28473. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  28474. m := &SopNodeMutation{
  28475. config: c,
  28476. op: op,
  28477. typ: TypeSopNode,
  28478. clearedFields: make(map[string]struct{}),
  28479. }
  28480. for _, opt := range opts {
  28481. opt(m)
  28482. }
  28483. return m
  28484. }
  28485. // withSopNodeID sets the ID field of the mutation.
  28486. func withSopNodeID(id uint64) sopnodeOption {
  28487. return func(m *SopNodeMutation) {
  28488. var (
  28489. err error
  28490. once sync.Once
  28491. value *SopNode
  28492. )
  28493. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  28494. once.Do(func() {
  28495. if m.done {
  28496. err = errors.New("querying old values post mutation is not allowed")
  28497. } else {
  28498. value, err = m.Client().SopNode.Get(ctx, id)
  28499. }
  28500. })
  28501. return value, err
  28502. }
  28503. m.id = &id
  28504. }
  28505. }
  28506. // withSopNode sets the old SopNode of the mutation.
  28507. func withSopNode(node *SopNode) sopnodeOption {
  28508. return func(m *SopNodeMutation) {
  28509. m.oldValue = func(context.Context) (*SopNode, error) {
  28510. return node, nil
  28511. }
  28512. m.id = &node.ID
  28513. }
  28514. }
  28515. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28516. // executed in a transaction (ent.Tx), a transactional client is returned.
  28517. func (m SopNodeMutation) Client() *Client {
  28518. client := &Client{config: m.config}
  28519. client.init()
  28520. return client
  28521. }
  28522. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28523. // it returns an error otherwise.
  28524. func (m SopNodeMutation) Tx() (*Tx, error) {
  28525. if _, ok := m.driver.(*txDriver); !ok {
  28526. return nil, errors.New("ent: mutation is not running in a transaction")
  28527. }
  28528. tx := &Tx{config: m.config}
  28529. tx.init()
  28530. return tx, nil
  28531. }
  28532. // SetID sets the value of the id field. Note that this
  28533. // operation is only accepted on creation of SopNode entities.
  28534. func (m *SopNodeMutation) SetID(id uint64) {
  28535. m.id = &id
  28536. }
  28537. // ID returns the ID value in the mutation. Note that the ID is only available
  28538. // if it was provided to the builder or after it was returned from the database.
  28539. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  28540. if m.id == nil {
  28541. return
  28542. }
  28543. return *m.id, true
  28544. }
  28545. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28546. // That means, if the mutation is applied within a transaction with an isolation level such
  28547. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28548. // or updated by the mutation.
  28549. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  28550. switch {
  28551. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28552. id, exists := m.ID()
  28553. if exists {
  28554. return []uint64{id}, nil
  28555. }
  28556. fallthrough
  28557. case m.op.Is(OpUpdate | OpDelete):
  28558. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  28559. default:
  28560. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28561. }
  28562. }
  28563. // SetCreatedAt sets the "created_at" field.
  28564. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  28565. m.created_at = &t
  28566. }
  28567. // CreatedAt returns the value of the "created_at" field in the mutation.
  28568. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  28569. v := m.created_at
  28570. if v == nil {
  28571. return
  28572. }
  28573. return *v, true
  28574. }
  28575. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  28576. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28578. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28579. if !m.op.Is(OpUpdateOne) {
  28580. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28581. }
  28582. if m.id == nil || m.oldValue == nil {
  28583. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28584. }
  28585. oldValue, err := m.oldValue(ctx)
  28586. if err != nil {
  28587. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28588. }
  28589. return oldValue.CreatedAt, nil
  28590. }
  28591. // ResetCreatedAt resets all changes to the "created_at" field.
  28592. func (m *SopNodeMutation) ResetCreatedAt() {
  28593. m.created_at = nil
  28594. }
  28595. // SetUpdatedAt sets the "updated_at" field.
  28596. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  28597. m.updated_at = &t
  28598. }
  28599. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28600. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  28601. v := m.updated_at
  28602. if v == nil {
  28603. return
  28604. }
  28605. return *v, true
  28606. }
  28607. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  28608. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28610. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28611. if !m.op.Is(OpUpdateOne) {
  28612. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28613. }
  28614. if m.id == nil || m.oldValue == nil {
  28615. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28616. }
  28617. oldValue, err := m.oldValue(ctx)
  28618. if err != nil {
  28619. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28620. }
  28621. return oldValue.UpdatedAt, nil
  28622. }
  28623. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28624. func (m *SopNodeMutation) ResetUpdatedAt() {
  28625. m.updated_at = nil
  28626. }
  28627. // SetStatus sets the "status" field.
  28628. func (m *SopNodeMutation) SetStatus(u uint8) {
  28629. m.status = &u
  28630. m.addstatus = nil
  28631. }
  28632. // Status returns the value of the "status" field in the mutation.
  28633. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  28634. v := m.status
  28635. if v == nil {
  28636. return
  28637. }
  28638. return *v, true
  28639. }
  28640. // OldStatus returns the old "status" field's value of the SopNode entity.
  28641. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28643. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28644. if !m.op.Is(OpUpdateOne) {
  28645. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28646. }
  28647. if m.id == nil || m.oldValue == nil {
  28648. return v, errors.New("OldStatus requires an ID field in the mutation")
  28649. }
  28650. oldValue, err := m.oldValue(ctx)
  28651. if err != nil {
  28652. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28653. }
  28654. return oldValue.Status, nil
  28655. }
  28656. // AddStatus adds u to the "status" field.
  28657. func (m *SopNodeMutation) AddStatus(u int8) {
  28658. if m.addstatus != nil {
  28659. *m.addstatus += u
  28660. } else {
  28661. m.addstatus = &u
  28662. }
  28663. }
  28664. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28665. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  28666. v := m.addstatus
  28667. if v == nil {
  28668. return
  28669. }
  28670. return *v, true
  28671. }
  28672. // ClearStatus clears the value of the "status" field.
  28673. func (m *SopNodeMutation) ClearStatus() {
  28674. m.status = nil
  28675. m.addstatus = nil
  28676. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  28677. }
  28678. // StatusCleared returns if the "status" field was cleared in this mutation.
  28679. func (m *SopNodeMutation) StatusCleared() bool {
  28680. _, ok := m.clearedFields[sopnode.FieldStatus]
  28681. return ok
  28682. }
  28683. // ResetStatus resets all changes to the "status" field.
  28684. func (m *SopNodeMutation) ResetStatus() {
  28685. m.status = nil
  28686. m.addstatus = nil
  28687. delete(m.clearedFields, sopnode.FieldStatus)
  28688. }
  28689. // SetDeletedAt sets the "deleted_at" field.
  28690. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  28691. m.deleted_at = &t
  28692. }
  28693. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28694. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  28695. v := m.deleted_at
  28696. if v == nil {
  28697. return
  28698. }
  28699. return *v, true
  28700. }
  28701. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  28702. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28704. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28705. if !m.op.Is(OpUpdateOne) {
  28706. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28707. }
  28708. if m.id == nil || m.oldValue == nil {
  28709. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28710. }
  28711. oldValue, err := m.oldValue(ctx)
  28712. if err != nil {
  28713. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28714. }
  28715. return oldValue.DeletedAt, nil
  28716. }
  28717. // ClearDeletedAt clears the value of the "deleted_at" field.
  28718. func (m *SopNodeMutation) ClearDeletedAt() {
  28719. m.deleted_at = nil
  28720. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  28721. }
  28722. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28723. func (m *SopNodeMutation) DeletedAtCleared() bool {
  28724. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  28725. return ok
  28726. }
  28727. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28728. func (m *SopNodeMutation) ResetDeletedAt() {
  28729. m.deleted_at = nil
  28730. delete(m.clearedFields, sopnode.FieldDeletedAt)
  28731. }
  28732. // SetStageID sets the "stage_id" field.
  28733. func (m *SopNodeMutation) SetStageID(u uint64) {
  28734. m.sop_stage = &u
  28735. }
  28736. // StageID returns the value of the "stage_id" field in the mutation.
  28737. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  28738. v := m.sop_stage
  28739. if v == nil {
  28740. return
  28741. }
  28742. return *v, true
  28743. }
  28744. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  28745. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28747. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  28748. if !m.op.Is(OpUpdateOne) {
  28749. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  28750. }
  28751. if m.id == nil || m.oldValue == nil {
  28752. return v, errors.New("OldStageID requires an ID field in the mutation")
  28753. }
  28754. oldValue, err := m.oldValue(ctx)
  28755. if err != nil {
  28756. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  28757. }
  28758. return oldValue.StageID, nil
  28759. }
  28760. // ResetStageID resets all changes to the "stage_id" field.
  28761. func (m *SopNodeMutation) ResetStageID() {
  28762. m.sop_stage = nil
  28763. }
  28764. // SetParentID sets the "parent_id" field.
  28765. func (m *SopNodeMutation) SetParentID(u uint64) {
  28766. m.parent_id = &u
  28767. m.addparent_id = nil
  28768. }
  28769. // ParentID returns the value of the "parent_id" field in the mutation.
  28770. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  28771. v := m.parent_id
  28772. if v == nil {
  28773. return
  28774. }
  28775. return *v, true
  28776. }
  28777. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  28778. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28780. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  28781. if !m.op.Is(OpUpdateOne) {
  28782. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  28783. }
  28784. if m.id == nil || m.oldValue == nil {
  28785. return v, errors.New("OldParentID requires an ID field in the mutation")
  28786. }
  28787. oldValue, err := m.oldValue(ctx)
  28788. if err != nil {
  28789. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  28790. }
  28791. return oldValue.ParentID, nil
  28792. }
  28793. // AddParentID adds u to the "parent_id" field.
  28794. func (m *SopNodeMutation) AddParentID(u int64) {
  28795. if m.addparent_id != nil {
  28796. *m.addparent_id += u
  28797. } else {
  28798. m.addparent_id = &u
  28799. }
  28800. }
  28801. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  28802. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  28803. v := m.addparent_id
  28804. if v == nil {
  28805. return
  28806. }
  28807. return *v, true
  28808. }
  28809. // ResetParentID resets all changes to the "parent_id" field.
  28810. func (m *SopNodeMutation) ResetParentID() {
  28811. m.parent_id = nil
  28812. m.addparent_id = nil
  28813. }
  28814. // SetName sets the "name" field.
  28815. func (m *SopNodeMutation) SetName(s string) {
  28816. m.name = &s
  28817. }
  28818. // Name returns the value of the "name" field in the mutation.
  28819. func (m *SopNodeMutation) Name() (r string, exists bool) {
  28820. v := m.name
  28821. if v == nil {
  28822. return
  28823. }
  28824. return *v, true
  28825. }
  28826. // OldName returns the old "name" field's value of the SopNode entity.
  28827. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28829. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  28830. if !m.op.Is(OpUpdateOne) {
  28831. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28832. }
  28833. if m.id == nil || m.oldValue == nil {
  28834. return v, errors.New("OldName requires an ID field in the mutation")
  28835. }
  28836. oldValue, err := m.oldValue(ctx)
  28837. if err != nil {
  28838. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28839. }
  28840. return oldValue.Name, nil
  28841. }
  28842. // ResetName resets all changes to the "name" field.
  28843. func (m *SopNodeMutation) ResetName() {
  28844. m.name = nil
  28845. }
  28846. // SetConditionType sets the "condition_type" field.
  28847. func (m *SopNodeMutation) SetConditionType(i int) {
  28848. m.condition_type = &i
  28849. m.addcondition_type = nil
  28850. }
  28851. // ConditionType returns the value of the "condition_type" field in the mutation.
  28852. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  28853. v := m.condition_type
  28854. if v == nil {
  28855. return
  28856. }
  28857. return *v, true
  28858. }
  28859. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  28860. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28862. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28863. if !m.op.Is(OpUpdateOne) {
  28864. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28865. }
  28866. if m.id == nil || m.oldValue == nil {
  28867. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28868. }
  28869. oldValue, err := m.oldValue(ctx)
  28870. if err != nil {
  28871. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28872. }
  28873. return oldValue.ConditionType, nil
  28874. }
  28875. // AddConditionType adds i to the "condition_type" field.
  28876. func (m *SopNodeMutation) AddConditionType(i int) {
  28877. if m.addcondition_type != nil {
  28878. *m.addcondition_type += i
  28879. } else {
  28880. m.addcondition_type = &i
  28881. }
  28882. }
  28883. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28884. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  28885. v := m.addcondition_type
  28886. if v == nil {
  28887. return
  28888. }
  28889. return *v, true
  28890. }
  28891. // ResetConditionType resets all changes to the "condition_type" field.
  28892. func (m *SopNodeMutation) ResetConditionType() {
  28893. m.condition_type = nil
  28894. m.addcondition_type = nil
  28895. }
  28896. // SetConditionList sets the "condition_list" field.
  28897. func (m *SopNodeMutation) SetConditionList(s []string) {
  28898. m.condition_list = &s
  28899. m.appendcondition_list = nil
  28900. }
  28901. // ConditionList returns the value of the "condition_list" field in the mutation.
  28902. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  28903. v := m.condition_list
  28904. if v == nil {
  28905. return
  28906. }
  28907. return *v, true
  28908. }
  28909. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  28910. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28912. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  28913. if !m.op.Is(OpUpdateOne) {
  28914. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28915. }
  28916. if m.id == nil || m.oldValue == nil {
  28917. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28918. }
  28919. oldValue, err := m.oldValue(ctx)
  28920. if err != nil {
  28921. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28922. }
  28923. return oldValue.ConditionList, nil
  28924. }
  28925. // AppendConditionList adds s to the "condition_list" field.
  28926. func (m *SopNodeMutation) AppendConditionList(s []string) {
  28927. m.appendcondition_list = append(m.appendcondition_list, s...)
  28928. }
  28929. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28930. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  28931. if len(m.appendcondition_list) == 0 {
  28932. return nil, false
  28933. }
  28934. return m.appendcondition_list, true
  28935. }
  28936. // ClearConditionList clears the value of the "condition_list" field.
  28937. func (m *SopNodeMutation) ClearConditionList() {
  28938. m.condition_list = nil
  28939. m.appendcondition_list = nil
  28940. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  28941. }
  28942. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  28943. func (m *SopNodeMutation) ConditionListCleared() bool {
  28944. _, ok := m.clearedFields[sopnode.FieldConditionList]
  28945. return ok
  28946. }
  28947. // ResetConditionList resets all changes to the "condition_list" field.
  28948. func (m *SopNodeMutation) ResetConditionList() {
  28949. m.condition_list = nil
  28950. m.appendcondition_list = nil
  28951. delete(m.clearedFields, sopnode.FieldConditionList)
  28952. }
  28953. // SetNoReplyCondition sets the "no_reply_condition" field.
  28954. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  28955. m.no_reply_condition = &u
  28956. m.addno_reply_condition = nil
  28957. }
  28958. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  28959. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  28960. v := m.no_reply_condition
  28961. if v == nil {
  28962. return
  28963. }
  28964. return *v, true
  28965. }
  28966. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  28967. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28969. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  28970. if !m.op.Is(OpUpdateOne) {
  28971. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  28972. }
  28973. if m.id == nil || m.oldValue == nil {
  28974. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  28975. }
  28976. oldValue, err := m.oldValue(ctx)
  28977. if err != nil {
  28978. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  28979. }
  28980. return oldValue.NoReplyCondition, nil
  28981. }
  28982. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  28983. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  28984. if m.addno_reply_condition != nil {
  28985. *m.addno_reply_condition += u
  28986. } else {
  28987. m.addno_reply_condition = &u
  28988. }
  28989. }
  28990. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  28991. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  28992. v := m.addno_reply_condition
  28993. if v == nil {
  28994. return
  28995. }
  28996. return *v, true
  28997. }
  28998. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  28999. func (m *SopNodeMutation) ResetNoReplyCondition() {
  29000. m.no_reply_condition = nil
  29001. m.addno_reply_condition = nil
  29002. }
  29003. // SetNoReplyUnit sets the "no_reply_unit" field.
  29004. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  29005. m.no_reply_unit = &s
  29006. }
  29007. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  29008. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  29009. v := m.no_reply_unit
  29010. if v == nil {
  29011. return
  29012. }
  29013. return *v, true
  29014. }
  29015. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  29016. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29018. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  29019. if !m.op.Is(OpUpdateOne) {
  29020. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  29021. }
  29022. if m.id == nil || m.oldValue == nil {
  29023. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  29024. }
  29025. oldValue, err := m.oldValue(ctx)
  29026. if err != nil {
  29027. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  29028. }
  29029. return oldValue.NoReplyUnit, nil
  29030. }
  29031. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  29032. func (m *SopNodeMutation) ResetNoReplyUnit() {
  29033. m.no_reply_unit = nil
  29034. }
  29035. // SetActionMessage sets the "action_message" field.
  29036. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  29037. m.action_message = &ct
  29038. m.appendaction_message = nil
  29039. }
  29040. // ActionMessage returns the value of the "action_message" field in the mutation.
  29041. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  29042. v := m.action_message
  29043. if v == nil {
  29044. return
  29045. }
  29046. return *v, true
  29047. }
  29048. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  29049. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29051. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  29052. if !m.op.Is(OpUpdateOne) {
  29053. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  29054. }
  29055. if m.id == nil || m.oldValue == nil {
  29056. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  29057. }
  29058. oldValue, err := m.oldValue(ctx)
  29059. if err != nil {
  29060. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  29061. }
  29062. return oldValue.ActionMessage, nil
  29063. }
  29064. // AppendActionMessage adds ct to the "action_message" field.
  29065. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  29066. m.appendaction_message = append(m.appendaction_message, ct...)
  29067. }
  29068. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  29069. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  29070. if len(m.appendaction_message) == 0 {
  29071. return nil, false
  29072. }
  29073. return m.appendaction_message, true
  29074. }
  29075. // ClearActionMessage clears the value of the "action_message" field.
  29076. func (m *SopNodeMutation) ClearActionMessage() {
  29077. m.action_message = nil
  29078. m.appendaction_message = nil
  29079. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  29080. }
  29081. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  29082. func (m *SopNodeMutation) ActionMessageCleared() bool {
  29083. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  29084. return ok
  29085. }
  29086. // ResetActionMessage resets all changes to the "action_message" field.
  29087. func (m *SopNodeMutation) ResetActionMessage() {
  29088. m.action_message = nil
  29089. m.appendaction_message = nil
  29090. delete(m.clearedFields, sopnode.FieldActionMessage)
  29091. }
  29092. // SetActionLabelAdd sets the "action_label_add" field.
  29093. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  29094. m.action_label_add = &u
  29095. m.appendaction_label_add = nil
  29096. }
  29097. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  29098. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  29099. v := m.action_label_add
  29100. if v == nil {
  29101. return
  29102. }
  29103. return *v, true
  29104. }
  29105. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  29106. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29108. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  29109. if !m.op.Is(OpUpdateOne) {
  29110. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  29111. }
  29112. if m.id == nil || m.oldValue == nil {
  29113. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  29114. }
  29115. oldValue, err := m.oldValue(ctx)
  29116. if err != nil {
  29117. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  29118. }
  29119. return oldValue.ActionLabelAdd, nil
  29120. }
  29121. // AppendActionLabelAdd adds u to the "action_label_add" field.
  29122. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  29123. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  29124. }
  29125. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  29126. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  29127. if len(m.appendaction_label_add) == 0 {
  29128. return nil, false
  29129. }
  29130. return m.appendaction_label_add, true
  29131. }
  29132. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  29133. func (m *SopNodeMutation) ClearActionLabelAdd() {
  29134. m.action_label_add = nil
  29135. m.appendaction_label_add = nil
  29136. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  29137. }
  29138. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  29139. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  29140. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  29141. return ok
  29142. }
  29143. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  29144. func (m *SopNodeMutation) ResetActionLabelAdd() {
  29145. m.action_label_add = nil
  29146. m.appendaction_label_add = nil
  29147. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  29148. }
  29149. // SetActionLabelDel sets the "action_label_del" field.
  29150. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  29151. m.action_label_del = &u
  29152. m.appendaction_label_del = nil
  29153. }
  29154. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  29155. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  29156. v := m.action_label_del
  29157. if v == nil {
  29158. return
  29159. }
  29160. return *v, true
  29161. }
  29162. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  29163. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29165. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  29166. if !m.op.Is(OpUpdateOne) {
  29167. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  29168. }
  29169. if m.id == nil || m.oldValue == nil {
  29170. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  29171. }
  29172. oldValue, err := m.oldValue(ctx)
  29173. if err != nil {
  29174. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  29175. }
  29176. return oldValue.ActionLabelDel, nil
  29177. }
  29178. // AppendActionLabelDel adds u to the "action_label_del" field.
  29179. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  29180. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  29181. }
  29182. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  29183. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  29184. if len(m.appendaction_label_del) == 0 {
  29185. return nil, false
  29186. }
  29187. return m.appendaction_label_del, true
  29188. }
  29189. // ClearActionLabelDel clears the value of the "action_label_del" field.
  29190. func (m *SopNodeMutation) ClearActionLabelDel() {
  29191. m.action_label_del = nil
  29192. m.appendaction_label_del = nil
  29193. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  29194. }
  29195. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  29196. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  29197. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  29198. return ok
  29199. }
  29200. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  29201. func (m *SopNodeMutation) ResetActionLabelDel() {
  29202. m.action_label_del = nil
  29203. m.appendaction_label_del = nil
  29204. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  29205. }
  29206. // SetActionForward sets the "action_forward" field.
  29207. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  29208. m.action_forward = &ctf
  29209. }
  29210. // ActionForward returns the value of the "action_forward" field in the mutation.
  29211. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  29212. v := m.action_forward
  29213. if v == nil {
  29214. return
  29215. }
  29216. return *v, true
  29217. }
  29218. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  29219. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29221. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  29222. if !m.op.Is(OpUpdateOne) {
  29223. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  29224. }
  29225. if m.id == nil || m.oldValue == nil {
  29226. return v, errors.New("OldActionForward requires an ID field in the mutation")
  29227. }
  29228. oldValue, err := m.oldValue(ctx)
  29229. if err != nil {
  29230. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  29231. }
  29232. return oldValue.ActionForward, nil
  29233. }
  29234. // ClearActionForward clears the value of the "action_forward" field.
  29235. func (m *SopNodeMutation) ClearActionForward() {
  29236. m.action_forward = nil
  29237. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  29238. }
  29239. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  29240. func (m *SopNodeMutation) ActionForwardCleared() bool {
  29241. _, ok := m.clearedFields[sopnode.FieldActionForward]
  29242. return ok
  29243. }
  29244. // ResetActionForward resets all changes to the "action_forward" field.
  29245. func (m *SopNodeMutation) ResetActionForward() {
  29246. m.action_forward = nil
  29247. delete(m.clearedFields, sopnode.FieldActionForward)
  29248. }
  29249. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  29250. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  29251. m.sop_stage = &id
  29252. }
  29253. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  29254. func (m *SopNodeMutation) ClearSopStage() {
  29255. m.clearedsop_stage = true
  29256. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  29257. }
  29258. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  29259. func (m *SopNodeMutation) SopStageCleared() bool {
  29260. return m.clearedsop_stage
  29261. }
  29262. // SopStageID returns the "sop_stage" edge ID in the mutation.
  29263. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  29264. if m.sop_stage != nil {
  29265. return *m.sop_stage, true
  29266. }
  29267. return
  29268. }
  29269. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  29270. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29271. // SopStageID instead. It exists only for internal usage by the builders.
  29272. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  29273. if id := m.sop_stage; id != nil {
  29274. ids = append(ids, *id)
  29275. }
  29276. return
  29277. }
  29278. // ResetSopStage resets all changes to the "sop_stage" edge.
  29279. func (m *SopNodeMutation) ResetSopStage() {
  29280. m.sop_stage = nil
  29281. m.clearedsop_stage = false
  29282. }
  29283. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  29284. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  29285. if m.node_messages == nil {
  29286. m.node_messages = make(map[uint64]struct{})
  29287. }
  29288. for i := range ids {
  29289. m.node_messages[ids[i]] = struct{}{}
  29290. }
  29291. }
  29292. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  29293. func (m *SopNodeMutation) ClearNodeMessages() {
  29294. m.clearednode_messages = true
  29295. }
  29296. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  29297. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  29298. return m.clearednode_messages
  29299. }
  29300. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  29301. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  29302. if m.removednode_messages == nil {
  29303. m.removednode_messages = make(map[uint64]struct{})
  29304. }
  29305. for i := range ids {
  29306. delete(m.node_messages, ids[i])
  29307. m.removednode_messages[ids[i]] = struct{}{}
  29308. }
  29309. }
  29310. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  29311. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  29312. for id := range m.removednode_messages {
  29313. ids = append(ids, id)
  29314. }
  29315. return
  29316. }
  29317. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  29318. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  29319. for id := range m.node_messages {
  29320. ids = append(ids, id)
  29321. }
  29322. return
  29323. }
  29324. // ResetNodeMessages resets all changes to the "node_messages" edge.
  29325. func (m *SopNodeMutation) ResetNodeMessages() {
  29326. m.node_messages = nil
  29327. m.clearednode_messages = false
  29328. m.removednode_messages = nil
  29329. }
  29330. // Where appends a list predicates to the SopNodeMutation builder.
  29331. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  29332. m.predicates = append(m.predicates, ps...)
  29333. }
  29334. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  29335. // users can use type-assertion to append predicates that do not depend on any generated package.
  29336. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  29337. p := make([]predicate.SopNode, len(ps))
  29338. for i := range ps {
  29339. p[i] = ps[i]
  29340. }
  29341. m.Where(p...)
  29342. }
  29343. // Op returns the operation name.
  29344. func (m *SopNodeMutation) Op() Op {
  29345. return m.op
  29346. }
  29347. // SetOp allows setting the mutation operation.
  29348. func (m *SopNodeMutation) SetOp(op Op) {
  29349. m.op = op
  29350. }
  29351. // Type returns the node type of this mutation (SopNode).
  29352. func (m *SopNodeMutation) Type() string {
  29353. return m.typ
  29354. }
  29355. // Fields returns all fields that were changed during this mutation. Note that in
  29356. // order to get all numeric fields that were incremented/decremented, call
  29357. // AddedFields().
  29358. func (m *SopNodeMutation) Fields() []string {
  29359. fields := make([]string, 0, 15)
  29360. if m.created_at != nil {
  29361. fields = append(fields, sopnode.FieldCreatedAt)
  29362. }
  29363. if m.updated_at != nil {
  29364. fields = append(fields, sopnode.FieldUpdatedAt)
  29365. }
  29366. if m.status != nil {
  29367. fields = append(fields, sopnode.FieldStatus)
  29368. }
  29369. if m.deleted_at != nil {
  29370. fields = append(fields, sopnode.FieldDeletedAt)
  29371. }
  29372. if m.sop_stage != nil {
  29373. fields = append(fields, sopnode.FieldStageID)
  29374. }
  29375. if m.parent_id != nil {
  29376. fields = append(fields, sopnode.FieldParentID)
  29377. }
  29378. if m.name != nil {
  29379. fields = append(fields, sopnode.FieldName)
  29380. }
  29381. if m.condition_type != nil {
  29382. fields = append(fields, sopnode.FieldConditionType)
  29383. }
  29384. if m.condition_list != nil {
  29385. fields = append(fields, sopnode.FieldConditionList)
  29386. }
  29387. if m.no_reply_condition != nil {
  29388. fields = append(fields, sopnode.FieldNoReplyCondition)
  29389. }
  29390. if m.no_reply_unit != nil {
  29391. fields = append(fields, sopnode.FieldNoReplyUnit)
  29392. }
  29393. if m.action_message != nil {
  29394. fields = append(fields, sopnode.FieldActionMessage)
  29395. }
  29396. if m.action_label_add != nil {
  29397. fields = append(fields, sopnode.FieldActionLabelAdd)
  29398. }
  29399. if m.action_label_del != nil {
  29400. fields = append(fields, sopnode.FieldActionLabelDel)
  29401. }
  29402. if m.action_forward != nil {
  29403. fields = append(fields, sopnode.FieldActionForward)
  29404. }
  29405. return fields
  29406. }
  29407. // Field returns the value of a field with the given name. The second boolean
  29408. // return value indicates that this field was not set, or was not defined in the
  29409. // schema.
  29410. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  29411. switch name {
  29412. case sopnode.FieldCreatedAt:
  29413. return m.CreatedAt()
  29414. case sopnode.FieldUpdatedAt:
  29415. return m.UpdatedAt()
  29416. case sopnode.FieldStatus:
  29417. return m.Status()
  29418. case sopnode.FieldDeletedAt:
  29419. return m.DeletedAt()
  29420. case sopnode.FieldStageID:
  29421. return m.StageID()
  29422. case sopnode.FieldParentID:
  29423. return m.ParentID()
  29424. case sopnode.FieldName:
  29425. return m.Name()
  29426. case sopnode.FieldConditionType:
  29427. return m.ConditionType()
  29428. case sopnode.FieldConditionList:
  29429. return m.ConditionList()
  29430. case sopnode.FieldNoReplyCondition:
  29431. return m.NoReplyCondition()
  29432. case sopnode.FieldNoReplyUnit:
  29433. return m.NoReplyUnit()
  29434. case sopnode.FieldActionMessage:
  29435. return m.ActionMessage()
  29436. case sopnode.FieldActionLabelAdd:
  29437. return m.ActionLabelAdd()
  29438. case sopnode.FieldActionLabelDel:
  29439. return m.ActionLabelDel()
  29440. case sopnode.FieldActionForward:
  29441. return m.ActionForward()
  29442. }
  29443. return nil, false
  29444. }
  29445. // OldField returns the old value of the field from the database. An error is
  29446. // returned if the mutation operation is not UpdateOne, or the query to the
  29447. // database failed.
  29448. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29449. switch name {
  29450. case sopnode.FieldCreatedAt:
  29451. return m.OldCreatedAt(ctx)
  29452. case sopnode.FieldUpdatedAt:
  29453. return m.OldUpdatedAt(ctx)
  29454. case sopnode.FieldStatus:
  29455. return m.OldStatus(ctx)
  29456. case sopnode.FieldDeletedAt:
  29457. return m.OldDeletedAt(ctx)
  29458. case sopnode.FieldStageID:
  29459. return m.OldStageID(ctx)
  29460. case sopnode.FieldParentID:
  29461. return m.OldParentID(ctx)
  29462. case sopnode.FieldName:
  29463. return m.OldName(ctx)
  29464. case sopnode.FieldConditionType:
  29465. return m.OldConditionType(ctx)
  29466. case sopnode.FieldConditionList:
  29467. return m.OldConditionList(ctx)
  29468. case sopnode.FieldNoReplyCondition:
  29469. return m.OldNoReplyCondition(ctx)
  29470. case sopnode.FieldNoReplyUnit:
  29471. return m.OldNoReplyUnit(ctx)
  29472. case sopnode.FieldActionMessage:
  29473. return m.OldActionMessage(ctx)
  29474. case sopnode.FieldActionLabelAdd:
  29475. return m.OldActionLabelAdd(ctx)
  29476. case sopnode.FieldActionLabelDel:
  29477. return m.OldActionLabelDel(ctx)
  29478. case sopnode.FieldActionForward:
  29479. return m.OldActionForward(ctx)
  29480. }
  29481. return nil, fmt.Errorf("unknown SopNode field %s", name)
  29482. }
  29483. // SetField sets the value of a field with the given name. It returns an error if
  29484. // the field is not defined in the schema, or if the type mismatched the field
  29485. // type.
  29486. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  29487. switch name {
  29488. case sopnode.FieldCreatedAt:
  29489. v, ok := value.(time.Time)
  29490. if !ok {
  29491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29492. }
  29493. m.SetCreatedAt(v)
  29494. return nil
  29495. case sopnode.FieldUpdatedAt:
  29496. v, ok := value.(time.Time)
  29497. if !ok {
  29498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29499. }
  29500. m.SetUpdatedAt(v)
  29501. return nil
  29502. case sopnode.FieldStatus:
  29503. v, ok := value.(uint8)
  29504. if !ok {
  29505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29506. }
  29507. m.SetStatus(v)
  29508. return nil
  29509. case sopnode.FieldDeletedAt:
  29510. v, ok := value.(time.Time)
  29511. if !ok {
  29512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29513. }
  29514. m.SetDeletedAt(v)
  29515. return nil
  29516. case sopnode.FieldStageID:
  29517. v, ok := value.(uint64)
  29518. if !ok {
  29519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29520. }
  29521. m.SetStageID(v)
  29522. return nil
  29523. case sopnode.FieldParentID:
  29524. v, ok := value.(uint64)
  29525. if !ok {
  29526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29527. }
  29528. m.SetParentID(v)
  29529. return nil
  29530. case sopnode.FieldName:
  29531. v, ok := value.(string)
  29532. if !ok {
  29533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29534. }
  29535. m.SetName(v)
  29536. return nil
  29537. case sopnode.FieldConditionType:
  29538. v, ok := value.(int)
  29539. if !ok {
  29540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29541. }
  29542. m.SetConditionType(v)
  29543. return nil
  29544. case sopnode.FieldConditionList:
  29545. v, ok := value.([]string)
  29546. if !ok {
  29547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29548. }
  29549. m.SetConditionList(v)
  29550. return nil
  29551. case sopnode.FieldNoReplyCondition:
  29552. v, ok := value.(uint64)
  29553. if !ok {
  29554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29555. }
  29556. m.SetNoReplyCondition(v)
  29557. return nil
  29558. case sopnode.FieldNoReplyUnit:
  29559. v, ok := value.(string)
  29560. if !ok {
  29561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29562. }
  29563. m.SetNoReplyUnit(v)
  29564. return nil
  29565. case sopnode.FieldActionMessage:
  29566. v, ok := value.([]custom_types.Action)
  29567. if !ok {
  29568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29569. }
  29570. m.SetActionMessage(v)
  29571. return nil
  29572. case sopnode.FieldActionLabelAdd:
  29573. v, ok := value.([]uint64)
  29574. if !ok {
  29575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29576. }
  29577. m.SetActionLabelAdd(v)
  29578. return nil
  29579. case sopnode.FieldActionLabelDel:
  29580. v, ok := value.([]uint64)
  29581. if !ok {
  29582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29583. }
  29584. m.SetActionLabelDel(v)
  29585. return nil
  29586. case sopnode.FieldActionForward:
  29587. v, ok := value.(*custom_types.ActionForward)
  29588. if !ok {
  29589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29590. }
  29591. m.SetActionForward(v)
  29592. return nil
  29593. }
  29594. return fmt.Errorf("unknown SopNode field %s", name)
  29595. }
  29596. // AddedFields returns all numeric fields that were incremented/decremented during
  29597. // this mutation.
  29598. func (m *SopNodeMutation) AddedFields() []string {
  29599. var fields []string
  29600. if m.addstatus != nil {
  29601. fields = append(fields, sopnode.FieldStatus)
  29602. }
  29603. if m.addparent_id != nil {
  29604. fields = append(fields, sopnode.FieldParentID)
  29605. }
  29606. if m.addcondition_type != nil {
  29607. fields = append(fields, sopnode.FieldConditionType)
  29608. }
  29609. if m.addno_reply_condition != nil {
  29610. fields = append(fields, sopnode.FieldNoReplyCondition)
  29611. }
  29612. return fields
  29613. }
  29614. // AddedField returns the numeric value that was incremented/decremented on a field
  29615. // with the given name. The second boolean return value indicates that this field
  29616. // was not set, or was not defined in the schema.
  29617. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  29618. switch name {
  29619. case sopnode.FieldStatus:
  29620. return m.AddedStatus()
  29621. case sopnode.FieldParentID:
  29622. return m.AddedParentID()
  29623. case sopnode.FieldConditionType:
  29624. return m.AddedConditionType()
  29625. case sopnode.FieldNoReplyCondition:
  29626. return m.AddedNoReplyCondition()
  29627. }
  29628. return nil, false
  29629. }
  29630. // AddField adds the value to the field with the given name. It returns an error if
  29631. // the field is not defined in the schema, or if the type mismatched the field
  29632. // type.
  29633. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  29634. switch name {
  29635. case sopnode.FieldStatus:
  29636. v, ok := value.(int8)
  29637. if !ok {
  29638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29639. }
  29640. m.AddStatus(v)
  29641. return nil
  29642. case sopnode.FieldParentID:
  29643. v, ok := value.(int64)
  29644. if !ok {
  29645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29646. }
  29647. m.AddParentID(v)
  29648. return nil
  29649. case sopnode.FieldConditionType:
  29650. v, ok := value.(int)
  29651. if !ok {
  29652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29653. }
  29654. m.AddConditionType(v)
  29655. return nil
  29656. case sopnode.FieldNoReplyCondition:
  29657. v, ok := value.(int64)
  29658. if !ok {
  29659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29660. }
  29661. m.AddNoReplyCondition(v)
  29662. return nil
  29663. }
  29664. return fmt.Errorf("unknown SopNode numeric field %s", name)
  29665. }
  29666. // ClearedFields returns all nullable fields that were cleared during this
  29667. // mutation.
  29668. func (m *SopNodeMutation) ClearedFields() []string {
  29669. var fields []string
  29670. if m.FieldCleared(sopnode.FieldStatus) {
  29671. fields = append(fields, sopnode.FieldStatus)
  29672. }
  29673. if m.FieldCleared(sopnode.FieldDeletedAt) {
  29674. fields = append(fields, sopnode.FieldDeletedAt)
  29675. }
  29676. if m.FieldCleared(sopnode.FieldConditionList) {
  29677. fields = append(fields, sopnode.FieldConditionList)
  29678. }
  29679. if m.FieldCleared(sopnode.FieldActionMessage) {
  29680. fields = append(fields, sopnode.FieldActionMessage)
  29681. }
  29682. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  29683. fields = append(fields, sopnode.FieldActionLabelAdd)
  29684. }
  29685. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  29686. fields = append(fields, sopnode.FieldActionLabelDel)
  29687. }
  29688. if m.FieldCleared(sopnode.FieldActionForward) {
  29689. fields = append(fields, sopnode.FieldActionForward)
  29690. }
  29691. return fields
  29692. }
  29693. // FieldCleared returns a boolean indicating if a field with the given name was
  29694. // cleared in this mutation.
  29695. func (m *SopNodeMutation) FieldCleared(name string) bool {
  29696. _, ok := m.clearedFields[name]
  29697. return ok
  29698. }
  29699. // ClearField clears the value of the field with the given name. It returns an
  29700. // error if the field is not defined in the schema.
  29701. func (m *SopNodeMutation) ClearField(name string) error {
  29702. switch name {
  29703. case sopnode.FieldStatus:
  29704. m.ClearStatus()
  29705. return nil
  29706. case sopnode.FieldDeletedAt:
  29707. m.ClearDeletedAt()
  29708. return nil
  29709. case sopnode.FieldConditionList:
  29710. m.ClearConditionList()
  29711. return nil
  29712. case sopnode.FieldActionMessage:
  29713. m.ClearActionMessage()
  29714. return nil
  29715. case sopnode.FieldActionLabelAdd:
  29716. m.ClearActionLabelAdd()
  29717. return nil
  29718. case sopnode.FieldActionLabelDel:
  29719. m.ClearActionLabelDel()
  29720. return nil
  29721. case sopnode.FieldActionForward:
  29722. m.ClearActionForward()
  29723. return nil
  29724. }
  29725. return fmt.Errorf("unknown SopNode nullable field %s", name)
  29726. }
  29727. // ResetField resets all changes in the mutation for the field with the given name.
  29728. // It returns an error if the field is not defined in the schema.
  29729. func (m *SopNodeMutation) ResetField(name string) error {
  29730. switch name {
  29731. case sopnode.FieldCreatedAt:
  29732. m.ResetCreatedAt()
  29733. return nil
  29734. case sopnode.FieldUpdatedAt:
  29735. m.ResetUpdatedAt()
  29736. return nil
  29737. case sopnode.FieldStatus:
  29738. m.ResetStatus()
  29739. return nil
  29740. case sopnode.FieldDeletedAt:
  29741. m.ResetDeletedAt()
  29742. return nil
  29743. case sopnode.FieldStageID:
  29744. m.ResetStageID()
  29745. return nil
  29746. case sopnode.FieldParentID:
  29747. m.ResetParentID()
  29748. return nil
  29749. case sopnode.FieldName:
  29750. m.ResetName()
  29751. return nil
  29752. case sopnode.FieldConditionType:
  29753. m.ResetConditionType()
  29754. return nil
  29755. case sopnode.FieldConditionList:
  29756. m.ResetConditionList()
  29757. return nil
  29758. case sopnode.FieldNoReplyCondition:
  29759. m.ResetNoReplyCondition()
  29760. return nil
  29761. case sopnode.FieldNoReplyUnit:
  29762. m.ResetNoReplyUnit()
  29763. return nil
  29764. case sopnode.FieldActionMessage:
  29765. m.ResetActionMessage()
  29766. return nil
  29767. case sopnode.FieldActionLabelAdd:
  29768. m.ResetActionLabelAdd()
  29769. return nil
  29770. case sopnode.FieldActionLabelDel:
  29771. m.ResetActionLabelDel()
  29772. return nil
  29773. case sopnode.FieldActionForward:
  29774. m.ResetActionForward()
  29775. return nil
  29776. }
  29777. return fmt.Errorf("unknown SopNode field %s", name)
  29778. }
  29779. // AddedEdges returns all edge names that were set/added in this mutation.
  29780. func (m *SopNodeMutation) AddedEdges() []string {
  29781. edges := make([]string, 0, 2)
  29782. if m.sop_stage != nil {
  29783. edges = append(edges, sopnode.EdgeSopStage)
  29784. }
  29785. if m.node_messages != nil {
  29786. edges = append(edges, sopnode.EdgeNodeMessages)
  29787. }
  29788. return edges
  29789. }
  29790. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29791. // name in this mutation.
  29792. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  29793. switch name {
  29794. case sopnode.EdgeSopStage:
  29795. if id := m.sop_stage; id != nil {
  29796. return []ent.Value{*id}
  29797. }
  29798. case sopnode.EdgeNodeMessages:
  29799. ids := make([]ent.Value, 0, len(m.node_messages))
  29800. for id := range m.node_messages {
  29801. ids = append(ids, id)
  29802. }
  29803. return ids
  29804. }
  29805. return nil
  29806. }
  29807. // RemovedEdges returns all edge names that were removed in this mutation.
  29808. func (m *SopNodeMutation) RemovedEdges() []string {
  29809. edges := make([]string, 0, 2)
  29810. if m.removednode_messages != nil {
  29811. edges = append(edges, sopnode.EdgeNodeMessages)
  29812. }
  29813. return edges
  29814. }
  29815. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29816. // the given name in this mutation.
  29817. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  29818. switch name {
  29819. case sopnode.EdgeNodeMessages:
  29820. ids := make([]ent.Value, 0, len(m.removednode_messages))
  29821. for id := range m.removednode_messages {
  29822. ids = append(ids, id)
  29823. }
  29824. return ids
  29825. }
  29826. return nil
  29827. }
  29828. // ClearedEdges returns all edge names that were cleared in this mutation.
  29829. func (m *SopNodeMutation) ClearedEdges() []string {
  29830. edges := make([]string, 0, 2)
  29831. if m.clearedsop_stage {
  29832. edges = append(edges, sopnode.EdgeSopStage)
  29833. }
  29834. if m.clearednode_messages {
  29835. edges = append(edges, sopnode.EdgeNodeMessages)
  29836. }
  29837. return edges
  29838. }
  29839. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29840. // was cleared in this mutation.
  29841. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  29842. switch name {
  29843. case sopnode.EdgeSopStage:
  29844. return m.clearedsop_stage
  29845. case sopnode.EdgeNodeMessages:
  29846. return m.clearednode_messages
  29847. }
  29848. return false
  29849. }
  29850. // ClearEdge clears the value of the edge with the given name. It returns an error
  29851. // if that edge is not defined in the schema.
  29852. func (m *SopNodeMutation) ClearEdge(name string) error {
  29853. switch name {
  29854. case sopnode.EdgeSopStage:
  29855. m.ClearSopStage()
  29856. return nil
  29857. }
  29858. return fmt.Errorf("unknown SopNode unique edge %s", name)
  29859. }
  29860. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29861. // It returns an error if the edge is not defined in the schema.
  29862. func (m *SopNodeMutation) ResetEdge(name string) error {
  29863. switch name {
  29864. case sopnode.EdgeSopStage:
  29865. m.ResetSopStage()
  29866. return nil
  29867. case sopnode.EdgeNodeMessages:
  29868. m.ResetNodeMessages()
  29869. return nil
  29870. }
  29871. return fmt.Errorf("unknown SopNode edge %s", name)
  29872. }
  29873. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  29874. type SopStageMutation struct {
  29875. config
  29876. op Op
  29877. typ string
  29878. id *uint64
  29879. created_at *time.Time
  29880. updated_at *time.Time
  29881. status *uint8
  29882. addstatus *int8
  29883. deleted_at *time.Time
  29884. name *string
  29885. condition_type *int
  29886. addcondition_type *int
  29887. condition_operator *int
  29888. addcondition_operator *int
  29889. condition_list *[]custom_types.Condition
  29890. appendcondition_list []custom_types.Condition
  29891. action_message *[]custom_types.Action
  29892. appendaction_message []custom_types.Action
  29893. action_label_add *[]uint64
  29894. appendaction_label_add []uint64
  29895. action_label_del *[]uint64
  29896. appendaction_label_del []uint64
  29897. action_forward **custom_types.ActionForward
  29898. index_sort *int
  29899. addindex_sort *int
  29900. clearedFields map[string]struct{}
  29901. sop_task *uint64
  29902. clearedsop_task bool
  29903. stage_nodes map[uint64]struct{}
  29904. removedstage_nodes map[uint64]struct{}
  29905. clearedstage_nodes bool
  29906. stage_messages map[uint64]struct{}
  29907. removedstage_messages map[uint64]struct{}
  29908. clearedstage_messages bool
  29909. done bool
  29910. oldValue func(context.Context) (*SopStage, error)
  29911. predicates []predicate.SopStage
  29912. }
  29913. var _ ent.Mutation = (*SopStageMutation)(nil)
  29914. // sopstageOption allows management of the mutation configuration using functional options.
  29915. type sopstageOption func(*SopStageMutation)
  29916. // newSopStageMutation creates new mutation for the SopStage entity.
  29917. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  29918. m := &SopStageMutation{
  29919. config: c,
  29920. op: op,
  29921. typ: TypeSopStage,
  29922. clearedFields: make(map[string]struct{}),
  29923. }
  29924. for _, opt := range opts {
  29925. opt(m)
  29926. }
  29927. return m
  29928. }
  29929. // withSopStageID sets the ID field of the mutation.
  29930. func withSopStageID(id uint64) sopstageOption {
  29931. return func(m *SopStageMutation) {
  29932. var (
  29933. err error
  29934. once sync.Once
  29935. value *SopStage
  29936. )
  29937. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  29938. once.Do(func() {
  29939. if m.done {
  29940. err = errors.New("querying old values post mutation is not allowed")
  29941. } else {
  29942. value, err = m.Client().SopStage.Get(ctx, id)
  29943. }
  29944. })
  29945. return value, err
  29946. }
  29947. m.id = &id
  29948. }
  29949. }
  29950. // withSopStage sets the old SopStage of the mutation.
  29951. func withSopStage(node *SopStage) sopstageOption {
  29952. return func(m *SopStageMutation) {
  29953. m.oldValue = func(context.Context) (*SopStage, error) {
  29954. return node, nil
  29955. }
  29956. m.id = &node.ID
  29957. }
  29958. }
  29959. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29960. // executed in a transaction (ent.Tx), a transactional client is returned.
  29961. func (m SopStageMutation) Client() *Client {
  29962. client := &Client{config: m.config}
  29963. client.init()
  29964. return client
  29965. }
  29966. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29967. // it returns an error otherwise.
  29968. func (m SopStageMutation) Tx() (*Tx, error) {
  29969. if _, ok := m.driver.(*txDriver); !ok {
  29970. return nil, errors.New("ent: mutation is not running in a transaction")
  29971. }
  29972. tx := &Tx{config: m.config}
  29973. tx.init()
  29974. return tx, nil
  29975. }
  29976. // SetID sets the value of the id field. Note that this
  29977. // operation is only accepted on creation of SopStage entities.
  29978. func (m *SopStageMutation) SetID(id uint64) {
  29979. m.id = &id
  29980. }
  29981. // ID returns the ID value in the mutation. Note that the ID is only available
  29982. // if it was provided to the builder or after it was returned from the database.
  29983. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  29984. if m.id == nil {
  29985. return
  29986. }
  29987. return *m.id, true
  29988. }
  29989. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29990. // That means, if the mutation is applied within a transaction with an isolation level such
  29991. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29992. // or updated by the mutation.
  29993. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  29994. switch {
  29995. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29996. id, exists := m.ID()
  29997. if exists {
  29998. return []uint64{id}, nil
  29999. }
  30000. fallthrough
  30001. case m.op.Is(OpUpdate | OpDelete):
  30002. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  30003. default:
  30004. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30005. }
  30006. }
  30007. // SetCreatedAt sets the "created_at" field.
  30008. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  30009. m.created_at = &t
  30010. }
  30011. // CreatedAt returns the value of the "created_at" field in the mutation.
  30012. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  30013. v := m.created_at
  30014. if v == nil {
  30015. return
  30016. }
  30017. return *v, true
  30018. }
  30019. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  30020. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30022. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30023. if !m.op.Is(OpUpdateOne) {
  30024. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30025. }
  30026. if m.id == nil || m.oldValue == nil {
  30027. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30028. }
  30029. oldValue, err := m.oldValue(ctx)
  30030. if err != nil {
  30031. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30032. }
  30033. return oldValue.CreatedAt, nil
  30034. }
  30035. // ResetCreatedAt resets all changes to the "created_at" field.
  30036. func (m *SopStageMutation) ResetCreatedAt() {
  30037. m.created_at = nil
  30038. }
  30039. // SetUpdatedAt sets the "updated_at" field.
  30040. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  30041. m.updated_at = &t
  30042. }
  30043. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30044. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  30045. v := m.updated_at
  30046. if v == nil {
  30047. return
  30048. }
  30049. return *v, true
  30050. }
  30051. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  30052. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30054. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30055. if !m.op.Is(OpUpdateOne) {
  30056. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30057. }
  30058. if m.id == nil || m.oldValue == nil {
  30059. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30060. }
  30061. oldValue, err := m.oldValue(ctx)
  30062. if err != nil {
  30063. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30064. }
  30065. return oldValue.UpdatedAt, nil
  30066. }
  30067. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30068. func (m *SopStageMutation) ResetUpdatedAt() {
  30069. m.updated_at = nil
  30070. }
  30071. // SetStatus sets the "status" field.
  30072. func (m *SopStageMutation) SetStatus(u uint8) {
  30073. m.status = &u
  30074. m.addstatus = nil
  30075. }
  30076. // Status returns the value of the "status" field in the mutation.
  30077. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  30078. v := m.status
  30079. if v == nil {
  30080. return
  30081. }
  30082. return *v, true
  30083. }
  30084. // OldStatus returns the old "status" field's value of the SopStage entity.
  30085. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30087. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30088. if !m.op.Is(OpUpdateOne) {
  30089. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30090. }
  30091. if m.id == nil || m.oldValue == nil {
  30092. return v, errors.New("OldStatus requires an ID field in the mutation")
  30093. }
  30094. oldValue, err := m.oldValue(ctx)
  30095. if err != nil {
  30096. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30097. }
  30098. return oldValue.Status, nil
  30099. }
  30100. // AddStatus adds u to the "status" field.
  30101. func (m *SopStageMutation) AddStatus(u int8) {
  30102. if m.addstatus != nil {
  30103. *m.addstatus += u
  30104. } else {
  30105. m.addstatus = &u
  30106. }
  30107. }
  30108. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30109. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  30110. v := m.addstatus
  30111. if v == nil {
  30112. return
  30113. }
  30114. return *v, true
  30115. }
  30116. // ClearStatus clears the value of the "status" field.
  30117. func (m *SopStageMutation) ClearStatus() {
  30118. m.status = nil
  30119. m.addstatus = nil
  30120. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  30121. }
  30122. // StatusCleared returns if the "status" field was cleared in this mutation.
  30123. func (m *SopStageMutation) StatusCleared() bool {
  30124. _, ok := m.clearedFields[sopstage.FieldStatus]
  30125. return ok
  30126. }
  30127. // ResetStatus resets all changes to the "status" field.
  30128. func (m *SopStageMutation) ResetStatus() {
  30129. m.status = nil
  30130. m.addstatus = nil
  30131. delete(m.clearedFields, sopstage.FieldStatus)
  30132. }
  30133. // SetDeletedAt sets the "deleted_at" field.
  30134. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  30135. m.deleted_at = &t
  30136. }
  30137. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30138. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  30139. v := m.deleted_at
  30140. if v == nil {
  30141. return
  30142. }
  30143. return *v, true
  30144. }
  30145. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  30146. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30148. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30149. if !m.op.Is(OpUpdateOne) {
  30150. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30151. }
  30152. if m.id == nil || m.oldValue == nil {
  30153. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30154. }
  30155. oldValue, err := m.oldValue(ctx)
  30156. if err != nil {
  30157. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30158. }
  30159. return oldValue.DeletedAt, nil
  30160. }
  30161. // ClearDeletedAt clears the value of the "deleted_at" field.
  30162. func (m *SopStageMutation) ClearDeletedAt() {
  30163. m.deleted_at = nil
  30164. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  30165. }
  30166. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30167. func (m *SopStageMutation) DeletedAtCleared() bool {
  30168. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  30169. return ok
  30170. }
  30171. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30172. func (m *SopStageMutation) ResetDeletedAt() {
  30173. m.deleted_at = nil
  30174. delete(m.clearedFields, sopstage.FieldDeletedAt)
  30175. }
  30176. // SetTaskID sets the "task_id" field.
  30177. func (m *SopStageMutation) SetTaskID(u uint64) {
  30178. m.sop_task = &u
  30179. }
  30180. // TaskID returns the value of the "task_id" field in the mutation.
  30181. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  30182. v := m.sop_task
  30183. if v == nil {
  30184. return
  30185. }
  30186. return *v, true
  30187. }
  30188. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  30189. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30191. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  30192. if !m.op.Is(OpUpdateOne) {
  30193. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  30194. }
  30195. if m.id == nil || m.oldValue == nil {
  30196. return v, errors.New("OldTaskID requires an ID field in the mutation")
  30197. }
  30198. oldValue, err := m.oldValue(ctx)
  30199. if err != nil {
  30200. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  30201. }
  30202. return oldValue.TaskID, nil
  30203. }
  30204. // ResetTaskID resets all changes to the "task_id" field.
  30205. func (m *SopStageMutation) ResetTaskID() {
  30206. m.sop_task = nil
  30207. }
  30208. // SetName sets the "name" field.
  30209. func (m *SopStageMutation) SetName(s string) {
  30210. m.name = &s
  30211. }
  30212. // Name returns the value of the "name" field in the mutation.
  30213. func (m *SopStageMutation) Name() (r string, exists bool) {
  30214. v := m.name
  30215. if v == nil {
  30216. return
  30217. }
  30218. return *v, true
  30219. }
  30220. // OldName returns the old "name" field's value of the SopStage entity.
  30221. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30223. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  30224. if !m.op.Is(OpUpdateOne) {
  30225. return v, errors.New("OldName is only allowed on UpdateOne operations")
  30226. }
  30227. if m.id == nil || m.oldValue == nil {
  30228. return v, errors.New("OldName requires an ID field in the mutation")
  30229. }
  30230. oldValue, err := m.oldValue(ctx)
  30231. if err != nil {
  30232. return v, fmt.Errorf("querying old value for OldName: %w", err)
  30233. }
  30234. return oldValue.Name, nil
  30235. }
  30236. // ResetName resets all changes to the "name" field.
  30237. func (m *SopStageMutation) ResetName() {
  30238. m.name = nil
  30239. }
  30240. // SetConditionType sets the "condition_type" field.
  30241. func (m *SopStageMutation) SetConditionType(i int) {
  30242. m.condition_type = &i
  30243. m.addcondition_type = nil
  30244. }
  30245. // ConditionType returns the value of the "condition_type" field in the mutation.
  30246. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  30247. v := m.condition_type
  30248. if v == nil {
  30249. return
  30250. }
  30251. return *v, true
  30252. }
  30253. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  30254. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30256. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  30257. if !m.op.Is(OpUpdateOne) {
  30258. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  30259. }
  30260. if m.id == nil || m.oldValue == nil {
  30261. return v, errors.New("OldConditionType requires an ID field in the mutation")
  30262. }
  30263. oldValue, err := m.oldValue(ctx)
  30264. if err != nil {
  30265. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  30266. }
  30267. return oldValue.ConditionType, nil
  30268. }
  30269. // AddConditionType adds i to the "condition_type" field.
  30270. func (m *SopStageMutation) AddConditionType(i int) {
  30271. if m.addcondition_type != nil {
  30272. *m.addcondition_type += i
  30273. } else {
  30274. m.addcondition_type = &i
  30275. }
  30276. }
  30277. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  30278. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  30279. v := m.addcondition_type
  30280. if v == nil {
  30281. return
  30282. }
  30283. return *v, true
  30284. }
  30285. // ResetConditionType resets all changes to the "condition_type" field.
  30286. func (m *SopStageMutation) ResetConditionType() {
  30287. m.condition_type = nil
  30288. m.addcondition_type = nil
  30289. }
  30290. // SetConditionOperator sets the "condition_operator" field.
  30291. func (m *SopStageMutation) SetConditionOperator(i int) {
  30292. m.condition_operator = &i
  30293. m.addcondition_operator = nil
  30294. }
  30295. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  30296. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  30297. v := m.condition_operator
  30298. if v == nil {
  30299. return
  30300. }
  30301. return *v, true
  30302. }
  30303. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  30304. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30306. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  30307. if !m.op.Is(OpUpdateOne) {
  30308. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  30309. }
  30310. if m.id == nil || m.oldValue == nil {
  30311. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  30312. }
  30313. oldValue, err := m.oldValue(ctx)
  30314. if err != nil {
  30315. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  30316. }
  30317. return oldValue.ConditionOperator, nil
  30318. }
  30319. // AddConditionOperator adds i to the "condition_operator" field.
  30320. func (m *SopStageMutation) AddConditionOperator(i int) {
  30321. if m.addcondition_operator != nil {
  30322. *m.addcondition_operator += i
  30323. } else {
  30324. m.addcondition_operator = &i
  30325. }
  30326. }
  30327. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  30328. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  30329. v := m.addcondition_operator
  30330. if v == nil {
  30331. return
  30332. }
  30333. return *v, true
  30334. }
  30335. // ResetConditionOperator resets all changes to the "condition_operator" field.
  30336. func (m *SopStageMutation) ResetConditionOperator() {
  30337. m.condition_operator = nil
  30338. m.addcondition_operator = nil
  30339. }
  30340. // SetConditionList sets the "condition_list" field.
  30341. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  30342. m.condition_list = &ct
  30343. m.appendcondition_list = nil
  30344. }
  30345. // ConditionList returns the value of the "condition_list" field in the mutation.
  30346. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  30347. v := m.condition_list
  30348. if v == nil {
  30349. return
  30350. }
  30351. return *v, true
  30352. }
  30353. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  30354. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30356. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  30357. if !m.op.Is(OpUpdateOne) {
  30358. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  30359. }
  30360. if m.id == nil || m.oldValue == nil {
  30361. return v, errors.New("OldConditionList requires an ID field in the mutation")
  30362. }
  30363. oldValue, err := m.oldValue(ctx)
  30364. if err != nil {
  30365. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  30366. }
  30367. return oldValue.ConditionList, nil
  30368. }
  30369. // AppendConditionList adds ct to the "condition_list" field.
  30370. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  30371. m.appendcondition_list = append(m.appendcondition_list, ct...)
  30372. }
  30373. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  30374. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  30375. if len(m.appendcondition_list) == 0 {
  30376. return nil, false
  30377. }
  30378. return m.appendcondition_list, true
  30379. }
  30380. // ResetConditionList resets all changes to the "condition_list" field.
  30381. func (m *SopStageMutation) ResetConditionList() {
  30382. m.condition_list = nil
  30383. m.appendcondition_list = nil
  30384. }
  30385. // SetActionMessage sets the "action_message" field.
  30386. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  30387. m.action_message = &ct
  30388. m.appendaction_message = nil
  30389. }
  30390. // ActionMessage returns the value of the "action_message" field in the mutation.
  30391. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  30392. v := m.action_message
  30393. if v == nil {
  30394. return
  30395. }
  30396. return *v, true
  30397. }
  30398. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  30399. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30401. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  30402. if !m.op.Is(OpUpdateOne) {
  30403. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  30404. }
  30405. if m.id == nil || m.oldValue == nil {
  30406. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  30407. }
  30408. oldValue, err := m.oldValue(ctx)
  30409. if err != nil {
  30410. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  30411. }
  30412. return oldValue.ActionMessage, nil
  30413. }
  30414. // AppendActionMessage adds ct to the "action_message" field.
  30415. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  30416. m.appendaction_message = append(m.appendaction_message, ct...)
  30417. }
  30418. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  30419. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  30420. if len(m.appendaction_message) == 0 {
  30421. return nil, false
  30422. }
  30423. return m.appendaction_message, true
  30424. }
  30425. // ClearActionMessage clears the value of the "action_message" field.
  30426. func (m *SopStageMutation) ClearActionMessage() {
  30427. m.action_message = nil
  30428. m.appendaction_message = nil
  30429. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  30430. }
  30431. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  30432. func (m *SopStageMutation) ActionMessageCleared() bool {
  30433. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  30434. return ok
  30435. }
  30436. // ResetActionMessage resets all changes to the "action_message" field.
  30437. func (m *SopStageMutation) ResetActionMessage() {
  30438. m.action_message = nil
  30439. m.appendaction_message = nil
  30440. delete(m.clearedFields, sopstage.FieldActionMessage)
  30441. }
  30442. // SetActionLabelAdd sets the "action_label_add" field.
  30443. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  30444. m.action_label_add = &u
  30445. m.appendaction_label_add = nil
  30446. }
  30447. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  30448. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  30449. v := m.action_label_add
  30450. if v == nil {
  30451. return
  30452. }
  30453. return *v, true
  30454. }
  30455. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  30456. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30458. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  30459. if !m.op.Is(OpUpdateOne) {
  30460. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  30461. }
  30462. if m.id == nil || m.oldValue == nil {
  30463. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  30464. }
  30465. oldValue, err := m.oldValue(ctx)
  30466. if err != nil {
  30467. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  30468. }
  30469. return oldValue.ActionLabelAdd, nil
  30470. }
  30471. // AppendActionLabelAdd adds u to the "action_label_add" field.
  30472. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  30473. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  30474. }
  30475. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  30476. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  30477. if len(m.appendaction_label_add) == 0 {
  30478. return nil, false
  30479. }
  30480. return m.appendaction_label_add, true
  30481. }
  30482. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  30483. func (m *SopStageMutation) ClearActionLabelAdd() {
  30484. m.action_label_add = nil
  30485. m.appendaction_label_add = nil
  30486. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  30487. }
  30488. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  30489. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  30490. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  30491. return ok
  30492. }
  30493. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  30494. func (m *SopStageMutation) ResetActionLabelAdd() {
  30495. m.action_label_add = nil
  30496. m.appendaction_label_add = nil
  30497. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  30498. }
  30499. // SetActionLabelDel sets the "action_label_del" field.
  30500. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  30501. m.action_label_del = &u
  30502. m.appendaction_label_del = nil
  30503. }
  30504. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  30505. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  30506. v := m.action_label_del
  30507. if v == nil {
  30508. return
  30509. }
  30510. return *v, true
  30511. }
  30512. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  30513. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30515. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  30516. if !m.op.Is(OpUpdateOne) {
  30517. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  30518. }
  30519. if m.id == nil || m.oldValue == nil {
  30520. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  30521. }
  30522. oldValue, err := m.oldValue(ctx)
  30523. if err != nil {
  30524. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  30525. }
  30526. return oldValue.ActionLabelDel, nil
  30527. }
  30528. // AppendActionLabelDel adds u to the "action_label_del" field.
  30529. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  30530. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  30531. }
  30532. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  30533. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  30534. if len(m.appendaction_label_del) == 0 {
  30535. return nil, false
  30536. }
  30537. return m.appendaction_label_del, true
  30538. }
  30539. // ClearActionLabelDel clears the value of the "action_label_del" field.
  30540. func (m *SopStageMutation) ClearActionLabelDel() {
  30541. m.action_label_del = nil
  30542. m.appendaction_label_del = nil
  30543. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  30544. }
  30545. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  30546. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  30547. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  30548. return ok
  30549. }
  30550. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  30551. func (m *SopStageMutation) ResetActionLabelDel() {
  30552. m.action_label_del = nil
  30553. m.appendaction_label_del = nil
  30554. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  30555. }
  30556. // SetActionForward sets the "action_forward" field.
  30557. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  30558. m.action_forward = &ctf
  30559. }
  30560. // ActionForward returns the value of the "action_forward" field in the mutation.
  30561. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  30562. v := m.action_forward
  30563. if v == nil {
  30564. return
  30565. }
  30566. return *v, true
  30567. }
  30568. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  30569. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30571. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  30572. if !m.op.Is(OpUpdateOne) {
  30573. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  30574. }
  30575. if m.id == nil || m.oldValue == nil {
  30576. return v, errors.New("OldActionForward requires an ID field in the mutation")
  30577. }
  30578. oldValue, err := m.oldValue(ctx)
  30579. if err != nil {
  30580. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  30581. }
  30582. return oldValue.ActionForward, nil
  30583. }
  30584. // ClearActionForward clears the value of the "action_forward" field.
  30585. func (m *SopStageMutation) ClearActionForward() {
  30586. m.action_forward = nil
  30587. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  30588. }
  30589. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  30590. func (m *SopStageMutation) ActionForwardCleared() bool {
  30591. _, ok := m.clearedFields[sopstage.FieldActionForward]
  30592. return ok
  30593. }
  30594. // ResetActionForward resets all changes to the "action_forward" field.
  30595. func (m *SopStageMutation) ResetActionForward() {
  30596. m.action_forward = nil
  30597. delete(m.clearedFields, sopstage.FieldActionForward)
  30598. }
  30599. // SetIndexSort sets the "index_sort" field.
  30600. func (m *SopStageMutation) SetIndexSort(i int) {
  30601. m.index_sort = &i
  30602. m.addindex_sort = nil
  30603. }
  30604. // IndexSort returns the value of the "index_sort" field in the mutation.
  30605. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  30606. v := m.index_sort
  30607. if v == nil {
  30608. return
  30609. }
  30610. return *v, true
  30611. }
  30612. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  30613. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30615. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  30616. if !m.op.Is(OpUpdateOne) {
  30617. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  30618. }
  30619. if m.id == nil || m.oldValue == nil {
  30620. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  30621. }
  30622. oldValue, err := m.oldValue(ctx)
  30623. if err != nil {
  30624. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  30625. }
  30626. return oldValue.IndexSort, nil
  30627. }
  30628. // AddIndexSort adds i to the "index_sort" field.
  30629. func (m *SopStageMutation) AddIndexSort(i int) {
  30630. if m.addindex_sort != nil {
  30631. *m.addindex_sort += i
  30632. } else {
  30633. m.addindex_sort = &i
  30634. }
  30635. }
  30636. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  30637. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  30638. v := m.addindex_sort
  30639. if v == nil {
  30640. return
  30641. }
  30642. return *v, true
  30643. }
  30644. // ClearIndexSort clears the value of the "index_sort" field.
  30645. func (m *SopStageMutation) ClearIndexSort() {
  30646. m.index_sort = nil
  30647. m.addindex_sort = nil
  30648. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  30649. }
  30650. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  30651. func (m *SopStageMutation) IndexSortCleared() bool {
  30652. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  30653. return ok
  30654. }
  30655. // ResetIndexSort resets all changes to the "index_sort" field.
  30656. func (m *SopStageMutation) ResetIndexSort() {
  30657. m.index_sort = nil
  30658. m.addindex_sort = nil
  30659. delete(m.clearedFields, sopstage.FieldIndexSort)
  30660. }
  30661. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  30662. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  30663. m.sop_task = &id
  30664. }
  30665. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  30666. func (m *SopStageMutation) ClearSopTask() {
  30667. m.clearedsop_task = true
  30668. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  30669. }
  30670. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  30671. func (m *SopStageMutation) SopTaskCleared() bool {
  30672. return m.clearedsop_task
  30673. }
  30674. // SopTaskID returns the "sop_task" edge ID in the mutation.
  30675. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  30676. if m.sop_task != nil {
  30677. return *m.sop_task, true
  30678. }
  30679. return
  30680. }
  30681. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  30682. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30683. // SopTaskID instead. It exists only for internal usage by the builders.
  30684. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  30685. if id := m.sop_task; id != nil {
  30686. ids = append(ids, *id)
  30687. }
  30688. return
  30689. }
  30690. // ResetSopTask resets all changes to the "sop_task" edge.
  30691. func (m *SopStageMutation) ResetSopTask() {
  30692. m.sop_task = nil
  30693. m.clearedsop_task = false
  30694. }
  30695. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  30696. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  30697. if m.stage_nodes == nil {
  30698. m.stage_nodes = make(map[uint64]struct{})
  30699. }
  30700. for i := range ids {
  30701. m.stage_nodes[ids[i]] = struct{}{}
  30702. }
  30703. }
  30704. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  30705. func (m *SopStageMutation) ClearStageNodes() {
  30706. m.clearedstage_nodes = true
  30707. }
  30708. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  30709. func (m *SopStageMutation) StageNodesCleared() bool {
  30710. return m.clearedstage_nodes
  30711. }
  30712. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  30713. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  30714. if m.removedstage_nodes == nil {
  30715. m.removedstage_nodes = make(map[uint64]struct{})
  30716. }
  30717. for i := range ids {
  30718. delete(m.stage_nodes, ids[i])
  30719. m.removedstage_nodes[ids[i]] = struct{}{}
  30720. }
  30721. }
  30722. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  30723. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  30724. for id := range m.removedstage_nodes {
  30725. ids = append(ids, id)
  30726. }
  30727. return
  30728. }
  30729. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  30730. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  30731. for id := range m.stage_nodes {
  30732. ids = append(ids, id)
  30733. }
  30734. return
  30735. }
  30736. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  30737. func (m *SopStageMutation) ResetStageNodes() {
  30738. m.stage_nodes = nil
  30739. m.clearedstage_nodes = false
  30740. m.removedstage_nodes = nil
  30741. }
  30742. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  30743. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  30744. if m.stage_messages == nil {
  30745. m.stage_messages = make(map[uint64]struct{})
  30746. }
  30747. for i := range ids {
  30748. m.stage_messages[ids[i]] = struct{}{}
  30749. }
  30750. }
  30751. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  30752. func (m *SopStageMutation) ClearStageMessages() {
  30753. m.clearedstage_messages = true
  30754. }
  30755. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  30756. func (m *SopStageMutation) StageMessagesCleared() bool {
  30757. return m.clearedstage_messages
  30758. }
  30759. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  30760. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  30761. if m.removedstage_messages == nil {
  30762. m.removedstage_messages = make(map[uint64]struct{})
  30763. }
  30764. for i := range ids {
  30765. delete(m.stage_messages, ids[i])
  30766. m.removedstage_messages[ids[i]] = struct{}{}
  30767. }
  30768. }
  30769. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  30770. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  30771. for id := range m.removedstage_messages {
  30772. ids = append(ids, id)
  30773. }
  30774. return
  30775. }
  30776. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  30777. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  30778. for id := range m.stage_messages {
  30779. ids = append(ids, id)
  30780. }
  30781. return
  30782. }
  30783. // ResetStageMessages resets all changes to the "stage_messages" edge.
  30784. func (m *SopStageMutation) ResetStageMessages() {
  30785. m.stage_messages = nil
  30786. m.clearedstage_messages = false
  30787. m.removedstage_messages = nil
  30788. }
  30789. // Where appends a list predicates to the SopStageMutation builder.
  30790. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  30791. m.predicates = append(m.predicates, ps...)
  30792. }
  30793. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  30794. // users can use type-assertion to append predicates that do not depend on any generated package.
  30795. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  30796. p := make([]predicate.SopStage, len(ps))
  30797. for i := range ps {
  30798. p[i] = ps[i]
  30799. }
  30800. m.Where(p...)
  30801. }
  30802. // Op returns the operation name.
  30803. func (m *SopStageMutation) Op() Op {
  30804. return m.op
  30805. }
  30806. // SetOp allows setting the mutation operation.
  30807. func (m *SopStageMutation) SetOp(op Op) {
  30808. m.op = op
  30809. }
  30810. // Type returns the node type of this mutation (SopStage).
  30811. func (m *SopStageMutation) Type() string {
  30812. return m.typ
  30813. }
  30814. // Fields returns all fields that were changed during this mutation. Note that in
  30815. // order to get all numeric fields that were incremented/decremented, call
  30816. // AddedFields().
  30817. func (m *SopStageMutation) Fields() []string {
  30818. fields := make([]string, 0, 14)
  30819. if m.created_at != nil {
  30820. fields = append(fields, sopstage.FieldCreatedAt)
  30821. }
  30822. if m.updated_at != nil {
  30823. fields = append(fields, sopstage.FieldUpdatedAt)
  30824. }
  30825. if m.status != nil {
  30826. fields = append(fields, sopstage.FieldStatus)
  30827. }
  30828. if m.deleted_at != nil {
  30829. fields = append(fields, sopstage.FieldDeletedAt)
  30830. }
  30831. if m.sop_task != nil {
  30832. fields = append(fields, sopstage.FieldTaskID)
  30833. }
  30834. if m.name != nil {
  30835. fields = append(fields, sopstage.FieldName)
  30836. }
  30837. if m.condition_type != nil {
  30838. fields = append(fields, sopstage.FieldConditionType)
  30839. }
  30840. if m.condition_operator != nil {
  30841. fields = append(fields, sopstage.FieldConditionOperator)
  30842. }
  30843. if m.condition_list != nil {
  30844. fields = append(fields, sopstage.FieldConditionList)
  30845. }
  30846. if m.action_message != nil {
  30847. fields = append(fields, sopstage.FieldActionMessage)
  30848. }
  30849. if m.action_label_add != nil {
  30850. fields = append(fields, sopstage.FieldActionLabelAdd)
  30851. }
  30852. if m.action_label_del != nil {
  30853. fields = append(fields, sopstage.FieldActionLabelDel)
  30854. }
  30855. if m.action_forward != nil {
  30856. fields = append(fields, sopstage.FieldActionForward)
  30857. }
  30858. if m.index_sort != nil {
  30859. fields = append(fields, sopstage.FieldIndexSort)
  30860. }
  30861. return fields
  30862. }
  30863. // Field returns the value of a field with the given name. The second boolean
  30864. // return value indicates that this field was not set, or was not defined in the
  30865. // schema.
  30866. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  30867. switch name {
  30868. case sopstage.FieldCreatedAt:
  30869. return m.CreatedAt()
  30870. case sopstage.FieldUpdatedAt:
  30871. return m.UpdatedAt()
  30872. case sopstage.FieldStatus:
  30873. return m.Status()
  30874. case sopstage.FieldDeletedAt:
  30875. return m.DeletedAt()
  30876. case sopstage.FieldTaskID:
  30877. return m.TaskID()
  30878. case sopstage.FieldName:
  30879. return m.Name()
  30880. case sopstage.FieldConditionType:
  30881. return m.ConditionType()
  30882. case sopstage.FieldConditionOperator:
  30883. return m.ConditionOperator()
  30884. case sopstage.FieldConditionList:
  30885. return m.ConditionList()
  30886. case sopstage.FieldActionMessage:
  30887. return m.ActionMessage()
  30888. case sopstage.FieldActionLabelAdd:
  30889. return m.ActionLabelAdd()
  30890. case sopstage.FieldActionLabelDel:
  30891. return m.ActionLabelDel()
  30892. case sopstage.FieldActionForward:
  30893. return m.ActionForward()
  30894. case sopstage.FieldIndexSort:
  30895. return m.IndexSort()
  30896. }
  30897. return nil, false
  30898. }
  30899. // OldField returns the old value of the field from the database. An error is
  30900. // returned if the mutation operation is not UpdateOne, or the query to the
  30901. // database failed.
  30902. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30903. switch name {
  30904. case sopstage.FieldCreatedAt:
  30905. return m.OldCreatedAt(ctx)
  30906. case sopstage.FieldUpdatedAt:
  30907. return m.OldUpdatedAt(ctx)
  30908. case sopstage.FieldStatus:
  30909. return m.OldStatus(ctx)
  30910. case sopstage.FieldDeletedAt:
  30911. return m.OldDeletedAt(ctx)
  30912. case sopstage.FieldTaskID:
  30913. return m.OldTaskID(ctx)
  30914. case sopstage.FieldName:
  30915. return m.OldName(ctx)
  30916. case sopstage.FieldConditionType:
  30917. return m.OldConditionType(ctx)
  30918. case sopstage.FieldConditionOperator:
  30919. return m.OldConditionOperator(ctx)
  30920. case sopstage.FieldConditionList:
  30921. return m.OldConditionList(ctx)
  30922. case sopstage.FieldActionMessage:
  30923. return m.OldActionMessage(ctx)
  30924. case sopstage.FieldActionLabelAdd:
  30925. return m.OldActionLabelAdd(ctx)
  30926. case sopstage.FieldActionLabelDel:
  30927. return m.OldActionLabelDel(ctx)
  30928. case sopstage.FieldActionForward:
  30929. return m.OldActionForward(ctx)
  30930. case sopstage.FieldIndexSort:
  30931. return m.OldIndexSort(ctx)
  30932. }
  30933. return nil, fmt.Errorf("unknown SopStage field %s", name)
  30934. }
  30935. // SetField sets the value of a field with the given name. It returns an error if
  30936. // the field is not defined in the schema, or if the type mismatched the field
  30937. // type.
  30938. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  30939. switch name {
  30940. case sopstage.FieldCreatedAt:
  30941. v, ok := value.(time.Time)
  30942. if !ok {
  30943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30944. }
  30945. m.SetCreatedAt(v)
  30946. return nil
  30947. case sopstage.FieldUpdatedAt:
  30948. v, ok := value.(time.Time)
  30949. if !ok {
  30950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30951. }
  30952. m.SetUpdatedAt(v)
  30953. return nil
  30954. case sopstage.FieldStatus:
  30955. v, ok := value.(uint8)
  30956. if !ok {
  30957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30958. }
  30959. m.SetStatus(v)
  30960. return nil
  30961. case sopstage.FieldDeletedAt:
  30962. v, ok := value.(time.Time)
  30963. if !ok {
  30964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30965. }
  30966. m.SetDeletedAt(v)
  30967. return nil
  30968. case sopstage.FieldTaskID:
  30969. v, ok := value.(uint64)
  30970. if !ok {
  30971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30972. }
  30973. m.SetTaskID(v)
  30974. return nil
  30975. case sopstage.FieldName:
  30976. v, ok := value.(string)
  30977. if !ok {
  30978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30979. }
  30980. m.SetName(v)
  30981. return nil
  30982. case sopstage.FieldConditionType:
  30983. v, ok := value.(int)
  30984. if !ok {
  30985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30986. }
  30987. m.SetConditionType(v)
  30988. return nil
  30989. case sopstage.FieldConditionOperator:
  30990. v, ok := value.(int)
  30991. if !ok {
  30992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30993. }
  30994. m.SetConditionOperator(v)
  30995. return nil
  30996. case sopstage.FieldConditionList:
  30997. v, ok := value.([]custom_types.Condition)
  30998. if !ok {
  30999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31000. }
  31001. m.SetConditionList(v)
  31002. return nil
  31003. case sopstage.FieldActionMessage:
  31004. v, ok := value.([]custom_types.Action)
  31005. if !ok {
  31006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31007. }
  31008. m.SetActionMessage(v)
  31009. return nil
  31010. case sopstage.FieldActionLabelAdd:
  31011. v, ok := value.([]uint64)
  31012. if !ok {
  31013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31014. }
  31015. m.SetActionLabelAdd(v)
  31016. return nil
  31017. case sopstage.FieldActionLabelDel:
  31018. v, ok := value.([]uint64)
  31019. if !ok {
  31020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31021. }
  31022. m.SetActionLabelDel(v)
  31023. return nil
  31024. case sopstage.FieldActionForward:
  31025. v, ok := value.(*custom_types.ActionForward)
  31026. if !ok {
  31027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31028. }
  31029. m.SetActionForward(v)
  31030. return nil
  31031. case sopstage.FieldIndexSort:
  31032. v, ok := value.(int)
  31033. if !ok {
  31034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31035. }
  31036. m.SetIndexSort(v)
  31037. return nil
  31038. }
  31039. return fmt.Errorf("unknown SopStage field %s", name)
  31040. }
  31041. // AddedFields returns all numeric fields that were incremented/decremented during
  31042. // this mutation.
  31043. func (m *SopStageMutation) AddedFields() []string {
  31044. var fields []string
  31045. if m.addstatus != nil {
  31046. fields = append(fields, sopstage.FieldStatus)
  31047. }
  31048. if m.addcondition_type != nil {
  31049. fields = append(fields, sopstage.FieldConditionType)
  31050. }
  31051. if m.addcondition_operator != nil {
  31052. fields = append(fields, sopstage.FieldConditionOperator)
  31053. }
  31054. if m.addindex_sort != nil {
  31055. fields = append(fields, sopstage.FieldIndexSort)
  31056. }
  31057. return fields
  31058. }
  31059. // AddedField returns the numeric value that was incremented/decremented on a field
  31060. // with the given name. The second boolean return value indicates that this field
  31061. // was not set, or was not defined in the schema.
  31062. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  31063. switch name {
  31064. case sopstage.FieldStatus:
  31065. return m.AddedStatus()
  31066. case sopstage.FieldConditionType:
  31067. return m.AddedConditionType()
  31068. case sopstage.FieldConditionOperator:
  31069. return m.AddedConditionOperator()
  31070. case sopstage.FieldIndexSort:
  31071. return m.AddedIndexSort()
  31072. }
  31073. return nil, false
  31074. }
  31075. // AddField adds the value to the field with the given name. It returns an error if
  31076. // the field is not defined in the schema, or if the type mismatched the field
  31077. // type.
  31078. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  31079. switch name {
  31080. case sopstage.FieldStatus:
  31081. v, ok := value.(int8)
  31082. if !ok {
  31083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31084. }
  31085. m.AddStatus(v)
  31086. return nil
  31087. case sopstage.FieldConditionType:
  31088. v, ok := value.(int)
  31089. if !ok {
  31090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31091. }
  31092. m.AddConditionType(v)
  31093. return nil
  31094. case sopstage.FieldConditionOperator:
  31095. v, ok := value.(int)
  31096. if !ok {
  31097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31098. }
  31099. m.AddConditionOperator(v)
  31100. return nil
  31101. case sopstage.FieldIndexSort:
  31102. v, ok := value.(int)
  31103. if !ok {
  31104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31105. }
  31106. m.AddIndexSort(v)
  31107. return nil
  31108. }
  31109. return fmt.Errorf("unknown SopStage numeric field %s", name)
  31110. }
  31111. // ClearedFields returns all nullable fields that were cleared during this
  31112. // mutation.
  31113. func (m *SopStageMutation) ClearedFields() []string {
  31114. var fields []string
  31115. if m.FieldCleared(sopstage.FieldStatus) {
  31116. fields = append(fields, sopstage.FieldStatus)
  31117. }
  31118. if m.FieldCleared(sopstage.FieldDeletedAt) {
  31119. fields = append(fields, sopstage.FieldDeletedAt)
  31120. }
  31121. if m.FieldCleared(sopstage.FieldActionMessage) {
  31122. fields = append(fields, sopstage.FieldActionMessage)
  31123. }
  31124. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  31125. fields = append(fields, sopstage.FieldActionLabelAdd)
  31126. }
  31127. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  31128. fields = append(fields, sopstage.FieldActionLabelDel)
  31129. }
  31130. if m.FieldCleared(sopstage.FieldActionForward) {
  31131. fields = append(fields, sopstage.FieldActionForward)
  31132. }
  31133. if m.FieldCleared(sopstage.FieldIndexSort) {
  31134. fields = append(fields, sopstage.FieldIndexSort)
  31135. }
  31136. return fields
  31137. }
  31138. // FieldCleared returns a boolean indicating if a field with the given name was
  31139. // cleared in this mutation.
  31140. func (m *SopStageMutation) FieldCleared(name string) bool {
  31141. _, ok := m.clearedFields[name]
  31142. return ok
  31143. }
  31144. // ClearField clears the value of the field with the given name. It returns an
  31145. // error if the field is not defined in the schema.
  31146. func (m *SopStageMutation) ClearField(name string) error {
  31147. switch name {
  31148. case sopstage.FieldStatus:
  31149. m.ClearStatus()
  31150. return nil
  31151. case sopstage.FieldDeletedAt:
  31152. m.ClearDeletedAt()
  31153. return nil
  31154. case sopstage.FieldActionMessage:
  31155. m.ClearActionMessage()
  31156. return nil
  31157. case sopstage.FieldActionLabelAdd:
  31158. m.ClearActionLabelAdd()
  31159. return nil
  31160. case sopstage.FieldActionLabelDel:
  31161. m.ClearActionLabelDel()
  31162. return nil
  31163. case sopstage.FieldActionForward:
  31164. m.ClearActionForward()
  31165. return nil
  31166. case sopstage.FieldIndexSort:
  31167. m.ClearIndexSort()
  31168. return nil
  31169. }
  31170. return fmt.Errorf("unknown SopStage nullable field %s", name)
  31171. }
  31172. // ResetField resets all changes in the mutation for the field with the given name.
  31173. // It returns an error if the field is not defined in the schema.
  31174. func (m *SopStageMutation) ResetField(name string) error {
  31175. switch name {
  31176. case sopstage.FieldCreatedAt:
  31177. m.ResetCreatedAt()
  31178. return nil
  31179. case sopstage.FieldUpdatedAt:
  31180. m.ResetUpdatedAt()
  31181. return nil
  31182. case sopstage.FieldStatus:
  31183. m.ResetStatus()
  31184. return nil
  31185. case sopstage.FieldDeletedAt:
  31186. m.ResetDeletedAt()
  31187. return nil
  31188. case sopstage.FieldTaskID:
  31189. m.ResetTaskID()
  31190. return nil
  31191. case sopstage.FieldName:
  31192. m.ResetName()
  31193. return nil
  31194. case sopstage.FieldConditionType:
  31195. m.ResetConditionType()
  31196. return nil
  31197. case sopstage.FieldConditionOperator:
  31198. m.ResetConditionOperator()
  31199. return nil
  31200. case sopstage.FieldConditionList:
  31201. m.ResetConditionList()
  31202. return nil
  31203. case sopstage.FieldActionMessage:
  31204. m.ResetActionMessage()
  31205. return nil
  31206. case sopstage.FieldActionLabelAdd:
  31207. m.ResetActionLabelAdd()
  31208. return nil
  31209. case sopstage.FieldActionLabelDel:
  31210. m.ResetActionLabelDel()
  31211. return nil
  31212. case sopstage.FieldActionForward:
  31213. m.ResetActionForward()
  31214. return nil
  31215. case sopstage.FieldIndexSort:
  31216. m.ResetIndexSort()
  31217. return nil
  31218. }
  31219. return fmt.Errorf("unknown SopStage field %s", name)
  31220. }
  31221. // AddedEdges returns all edge names that were set/added in this mutation.
  31222. func (m *SopStageMutation) AddedEdges() []string {
  31223. edges := make([]string, 0, 3)
  31224. if m.sop_task != nil {
  31225. edges = append(edges, sopstage.EdgeSopTask)
  31226. }
  31227. if m.stage_nodes != nil {
  31228. edges = append(edges, sopstage.EdgeStageNodes)
  31229. }
  31230. if m.stage_messages != nil {
  31231. edges = append(edges, sopstage.EdgeStageMessages)
  31232. }
  31233. return edges
  31234. }
  31235. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31236. // name in this mutation.
  31237. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  31238. switch name {
  31239. case sopstage.EdgeSopTask:
  31240. if id := m.sop_task; id != nil {
  31241. return []ent.Value{*id}
  31242. }
  31243. case sopstage.EdgeStageNodes:
  31244. ids := make([]ent.Value, 0, len(m.stage_nodes))
  31245. for id := range m.stage_nodes {
  31246. ids = append(ids, id)
  31247. }
  31248. return ids
  31249. case sopstage.EdgeStageMessages:
  31250. ids := make([]ent.Value, 0, len(m.stage_messages))
  31251. for id := range m.stage_messages {
  31252. ids = append(ids, id)
  31253. }
  31254. return ids
  31255. }
  31256. return nil
  31257. }
  31258. // RemovedEdges returns all edge names that were removed in this mutation.
  31259. func (m *SopStageMutation) RemovedEdges() []string {
  31260. edges := make([]string, 0, 3)
  31261. if m.removedstage_nodes != nil {
  31262. edges = append(edges, sopstage.EdgeStageNodes)
  31263. }
  31264. if m.removedstage_messages != nil {
  31265. edges = append(edges, sopstage.EdgeStageMessages)
  31266. }
  31267. return edges
  31268. }
  31269. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31270. // the given name in this mutation.
  31271. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  31272. switch name {
  31273. case sopstage.EdgeStageNodes:
  31274. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  31275. for id := range m.removedstage_nodes {
  31276. ids = append(ids, id)
  31277. }
  31278. return ids
  31279. case sopstage.EdgeStageMessages:
  31280. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  31281. for id := range m.removedstage_messages {
  31282. ids = append(ids, id)
  31283. }
  31284. return ids
  31285. }
  31286. return nil
  31287. }
  31288. // ClearedEdges returns all edge names that were cleared in this mutation.
  31289. func (m *SopStageMutation) ClearedEdges() []string {
  31290. edges := make([]string, 0, 3)
  31291. if m.clearedsop_task {
  31292. edges = append(edges, sopstage.EdgeSopTask)
  31293. }
  31294. if m.clearedstage_nodes {
  31295. edges = append(edges, sopstage.EdgeStageNodes)
  31296. }
  31297. if m.clearedstage_messages {
  31298. edges = append(edges, sopstage.EdgeStageMessages)
  31299. }
  31300. return edges
  31301. }
  31302. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31303. // was cleared in this mutation.
  31304. func (m *SopStageMutation) EdgeCleared(name string) bool {
  31305. switch name {
  31306. case sopstage.EdgeSopTask:
  31307. return m.clearedsop_task
  31308. case sopstage.EdgeStageNodes:
  31309. return m.clearedstage_nodes
  31310. case sopstage.EdgeStageMessages:
  31311. return m.clearedstage_messages
  31312. }
  31313. return false
  31314. }
  31315. // ClearEdge clears the value of the edge with the given name. It returns an error
  31316. // if that edge is not defined in the schema.
  31317. func (m *SopStageMutation) ClearEdge(name string) error {
  31318. switch name {
  31319. case sopstage.EdgeSopTask:
  31320. m.ClearSopTask()
  31321. return nil
  31322. }
  31323. return fmt.Errorf("unknown SopStage unique edge %s", name)
  31324. }
  31325. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31326. // It returns an error if the edge is not defined in the schema.
  31327. func (m *SopStageMutation) ResetEdge(name string) error {
  31328. switch name {
  31329. case sopstage.EdgeSopTask:
  31330. m.ResetSopTask()
  31331. return nil
  31332. case sopstage.EdgeStageNodes:
  31333. m.ResetStageNodes()
  31334. return nil
  31335. case sopstage.EdgeStageMessages:
  31336. m.ResetStageMessages()
  31337. return nil
  31338. }
  31339. return fmt.Errorf("unknown SopStage edge %s", name)
  31340. }
  31341. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  31342. type SopTaskMutation struct {
  31343. config
  31344. op Op
  31345. typ string
  31346. id *uint64
  31347. created_at *time.Time
  31348. updated_at *time.Time
  31349. status *uint8
  31350. addstatus *int8
  31351. deleted_at *time.Time
  31352. name *string
  31353. bot_wxid_list *[]string
  31354. appendbot_wxid_list []string
  31355. _type *int
  31356. add_type *int
  31357. plan_start_time *time.Time
  31358. plan_end_time *time.Time
  31359. creator_id *string
  31360. organization_id *uint64
  31361. addorganization_id *int64
  31362. token *[]string
  31363. appendtoken []string
  31364. clearedFields map[string]struct{}
  31365. task_stages map[uint64]struct{}
  31366. removedtask_stages map[uint64]struct{}
  31367. clearedtask_stages bool
  31368. done bool
  31369. oldValue func(context.Context) (*SopTask, error)
  31370. predicates []predicate.SopTask
  31371. }
  31372. var _ ent.Mutation = (*SopTaskMutation)(nil)
  31373. // soptaskOption allows management of the mutation configuration using functional options.
  31374. type soptaskOption func(*SopTaskMutation)
  31375. // newSopTaskMutation creates new mutation for the SopTask entity.
  31376. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  31377. m := &SopTaskMutation{
  31378. config: c,
  31379. op: op,
  31380. typ: TypeSopTask,
  31381. clearedFields: make(map[string]struct{}),
  31382. }
  31383. for _, opt := range opts {
  31384. opt(m)
  31385. }
  31386. return m
  31387. }
  31388. // withSopTaskID sets the ID field of the mutation.
  31389. func withSopTaskID(id uint64) soptaskOption {
  31390. return func(m *SopTaskMutation) {
  31391. var (
  31392. err error
  31393. once sync.Once
  31394. value *SopTask
  31395. )
  31396. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  31397. once.Do(func() {
  31398. if m.done {
  31399. err = errors.New("querying old values post mutation is not allowed")
  31400. } else {
  31401. value, err = m.Client().SopTask.Get(ctx, id)
  31402. }
  31403. })
  31404. return value, err
  31405. }
  31406. m.id = &id
  31407. }
  31408. }
  31409. // withSopTask sets the old SopTask of the mutation.
  31410. func withSopTask(node *SopTask) soptaskOption {
  31411. return func(m *SopTaskMutation) {
  31412. m.oldValue = func(context.Context) (*SopTask, error) {
  31413. return node, nil
  31414. }
  31415. m.id = &node.ID
  31416. }
  31417. }
  31418. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31419. // executed in a transaction (ent.Tx), a transactional client is returned.
  31420. func (m SopTaskMutation) Client() *Client {
  31421. client := &Client{config: m.config}
  31422. client.init()
  31423. return client
  31424. }
  31425. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31426. // it returns an error otherwise.
  31427. func (m SopTaskMutation) Tx() (*Tx, error) {
  31428. if _, ok := m.driver.(*txDriver); !ok {
  31429. return nil, errors.New("ent: mutation is not running in a transaction")
  31430. }
  31431. tx := &Tx{config: m.config}
  31432. tx.init()
  31433. return tx, nil
  31434. }
  31435. // SetID sets the value of the id field. Note that this
  31436. // operation is only accepted on creation of SopTask entities.
  31437. func (m *SopTaskMutation) SetID(id uint64) {
  31438. m.id = &id
  31439. }
  31440. // ID returns the ID value in the mutation. Note that the ID is only available
  31441. // if it was provided to the builder or after it was returned from the database.
  31442. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  31443. if m.id == nil {
  31444. return
  31445. }
  31446. return *m.id, true
  31447. }
  31448. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31449. // That means, if the mutation is applied within a transaction with an isolation level such
  31450. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31451. // or updated by the mutation.
  31452. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  31453. switch {
  31454. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31455. id, exists := m.ID()
  31456. if exists {
  31457. return []uint64{id}, nil
  31458. }
  31459. fallthrough
  31460. case m.op.Is(OpUpdate | OpDelete):
  31461. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  31462. default:
  31463. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31464. }
  31465. }
  31466. // SetCreatedAt sets the "created_at" field.
  31467. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  31468. m.created_at = &t
  31469. }
  31470. // CreatedAt returns the value of the "created_at" field in the mutation.
  31471. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  31472. v := m.created_at
  31473. if v == nil {
  31474. return
  31475. }
  31476. return *v, true
  31477. }
  31478. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  31479. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31481. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31482. if !m.op.Is(OpUpdateOne) {
  31483. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31484. }
  31485. if m.id == nil || m.oldValue == nil {
  31486. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31487. }
  31488. oldValue, err := m.oldValue(ctx)
  31489. if err != nil {
  31490. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31491. }
  31492. return oldValue.CreatedAt, nil
  31493. }
  31494. // ResetCreatedAt resets all changes to the "created_at" field.
  31495. func (m *SopTaskMutation) ResetCreatedAt() {
  31496. m.created_at = nil
  31497. }
  31498. // SetUpdatedAt sets the "updated_at" field.
  31499. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  31500. m.updated_at = &t
  31501. }
  31502. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31503. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  31504. v := m.updated_at
  31505. if v == nil {
  31506. return
  31507. }
  31508. return *v, true
  31509. }
  31510. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  31511. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31513. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31514. if !m.op.Is(OpUpdateOne) {
  31515. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31516. }
  31517. if m.id == nil || m.oldValue == nil {
  31518. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31519. }
  31520. oldValue, err := m.oldValue(ctx)
  31521. if err != nil {
  31522. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31523. }
  31524. return oldValue.UpdatedAt, nil
  31525. }
  31526. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31527. func (m *SopTaskMutation) ResetUpdatedAt() {
  31528. m.updated_at = nil
  31529. }
  31530. // SetStatus sets the "status" field.
  31531. func (m *SopTaskMutation) SetStatus(u uint8) {
  31532. m.status = &u
  31533. m.addstatus = nil
  31534. }
  31535. // Status returns the value of the "status" field in the mutation.
  31536. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  31537. v := m.status
  31538. if v == nil {
  31539. return
  31540. }
  31541. return *v, true
  31542. }
  31543. // OldStatus returns the old "status" field's value of the SopTask entity.
  31544. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31546. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31547. if !m.op.Is(OpUpdateOne) {
  31548. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31549. }
  31550. if m.id == nil || m.oldValue == nil {
  31551. return v, errors.New("OldStatus requires an ID field in the mutation")
  31552. }
  31553. oldValue, err := m.oldValue(ctx)
  31554. if err != nil {
  31555. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31556. }
  31557. return oldValue.Status, nil
  31558. }
  31559. // AddStatus adds u to the "status" field.
  31560. func (m *SopTaskMutation) AddStatus(u int8) {
  31561. if m.addstatus != nil {
  31562. *m.addstatus += u
  31563. } else {
  31564. m.addstatus = &u
  31565. }
  31566. }
  31567. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31568. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  31569. v := m.addstatus
  31570. if v == nil {
  31571. return
  31572. }
  31573. return *v, true
  31574. }
  31575. // ClearStatus clears the value of the "status" field.
  31576. func (m *SopTaskMutation) ClearStatus() {
  31577. m.status = nil
  31578. m.addstatus = nil
  31579. m.clearedFields[soptask.FieldStatus] = struct{}{}
  31580. }
  31581. // StatusCleared returns if the "status" field was cleared in this mutation.
  31582. func (m *SopTaskMutation) StatusCleared() bool {
  31583. _, ok := m.clearedFields[soptask.FieldStatus]
  31584. return ok
  31585. }
  31586. // ResetStatus resets all changes to the "status" field.
  31587. func (m *SopTaskMutation) ResetStatus() {
  31588. m.status = nil
  31589. m.addstatus = nil
  31590. delete(m.clearedFields, soptask.FieldStatus)
  31591. }
  31592. // SetDeletedAt sets the "deleted_at" field.
  31593. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  31594. m.deleted_at = &t
  31595. }
  31596. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31597. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  31598. v := m.deleted_at
  31599. if v == nil {
  31600. return
  31601. }
  31602. return *v, true
  31603. }
  31604. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  31605. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31607. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31608. if !m.op.Is(OpUpdateOne) {
  31609. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31610. }
  31611. if m.id == nil || m.oldValue == nil {
  31612. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31613. }
  31614. oldValue, err := m.oldValue(ctx)
  31615. if err != nil {
  31616. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31617. }
  31618. return oldValue.DeletedAt, nil
  31619. }
  31620. // ClearDeletedAt clears the value of the "deleted_at" field.
  31621. func (m *SopTaskMutation) ClearDeletedAt() {
  31622. m.deleted_at = nil
  31623. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  31624. }
  31625. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31626. func (m *SopTaskMutation) DeletedAtCleared() bool {
  31627. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  31628. return ok
  31629. }
  31630. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31631. func (m *SopTaskMutation) ResetDeletedAt() {
  31632. m.deleted_at = nil
  31633. delete(m.clearedFields, soptask.FieldDeletedAt)
  31634. }
  31635. // SetName sets the "name" field.
  31636. func (m *SopTaskMutation) SetName(s string) {
  31637. m.name = &s
  31638. }
  31639. // Name returns the value of the "name" field in the mutation.
  31640. func (m *SopTaskMutation) Name() (r string, exists bool) {
  31641. v := m.name
  31642. if v == nil {
  31643. return
  31644. }
  31645. return *v, true
  31646. }
  31647. // OldName returns the old "name" field's value of the SopTask entity.
  31648. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31650. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  31651. if !m.op.Is(OpUpdateOne) {
  31652. return v, errors.New("OldName is only allowed on UpdateOne operations")
  31653. }
  31654. if m.id == nil || m.oldValue == nil {
  31655. return v, errors.New("OldName requires an ID field in the mutation")
  31656. }
  31657. oldValue, err := m.oldValue(ctx)
  31658. if err != nil {
  31659. return v, fmt.Errorf("querying old value for OldName: %w", err)
  31660. }
  31661. return oldValue.Name, nil
  31662. }
  31663. // ResetName resets all changes to the "name" field.
  31664. func (m *SopTaskMutation) ResetName() {
  31665. m.name = nil
  31666. }
  31667. // SetBotWxidList sets the "bot_wxid_list" field.
  31668. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  31669. m.bot_wxid_list = &s
  31670. m.appendbot_wxid_list = nil
  31671. }
  31672. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  31673. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  31674. v := m.bot_wxid_list
  31675. if v == nil {
  31676. return
  31677. }
  31678. return *v, true
  31679. }
  31680. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  31681. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31683. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  31684. if !m.op.Is(OpUpdateOne) {
  31685. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  31686. }
  31687. if m.id == nil || m.oldValue == nil {
  31688. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  31689. }
  31690. oldValue, err := m.oldValue(ctx)
  31691. if err != nil {
  31692. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  31693. }
  31694. return oldValue.BotWxidList, nil
  31695. }
  31696. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  31697. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  31698. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  31699. }
  31700. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  31701. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  31702. if len(m.appendbot_wxid_list) == 0 {
  31703. return nil, false
  31704. }
  31705. return m.appendbot_wxid_list, true
  31706. }
  31707. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  31708. func (m *SopTaskMutation) ClearBotWxidList() {
  31709. m.bot_wxid_list = nil
  31710. m.appendbot_wxid_list = nil
  31711. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  31712. }
  31713. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  31714. func (m *SopTaskMutation) BotWxidListCleared() bool {
  31715. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  31716. return ok
  31717. }
  31718. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  31719. func (m *SopTaskMutation) ResetBotWxidList() {
  31720. m.bot_wxid_list = nil
  31721. m.appendbot_wxid_list = nil
  31722. delete(m.clearedFields, soptask.FieldBotWxidList)
  31723. }
  31724. // SetType sets the "type" field.
  31725. func (m *SopTaskMutation) SetType(i int) {
  31726. m._type = &i
  31727. m.add_type = nil
  31728. }
  31729. // GetType returns the value of the "type" field in the mutation.
  31730. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  31731. v := m._type
  31732. if v == nil {
  31733. return
  31734. }
  31735. return *v, true
  31736. }
  31737. // OldType returns the old "type" field's value of the SopTask entity.
  31738. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31740. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  31741. if !m.op.Is(OpUpdateOne) {
  31742. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31743. }
  31744. if m.id == nil || m.oldValue == nil {
  31745. return v, errors.New("OldType requires an ID field in the mutation")
  31746. }
  31747. oldValue, err := m.oldValue(ctx)
  31748. if err != nil {
  31749. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31750. }
  31751. return oldValue.Type, nil
  31752. }
  31753. // AddType adds i to the "type" field.
  31754. func (m *SopTaskMutation) AddType(i int) {
  31755. if m.add_type != nil {
  31756. *m.add_type += i
  31757. } else {
  31758. m.add_type = &i
  31759. }
  31760. }
  31761. // AddedType returns the value that was added to the "type" field in this mutation.
  31762. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  31763. v := m.add_type
  31764. if v == nil {
  31765. return
  31766. }
  31767. return *v, true
  31768. }
  31769. // ResetType resets all changes to the "type" field.
  31770. func (m *SopTaskMutation) ResetType() {
  31771. m._type = nil
  31772. m.add_type = nil
  31773. }
  31774. // SetPlanStartTime sets the "plan_start_time" field.
  31775. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  31776. m.plan_start_time = &t
  31777. }
  31778. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  31779. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  31780. v := m.plan_start_time
  31781. if v == nil {
  31782. return
  31783. }
  31784. return *v, true
  31785. }
  31786. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  31787. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31789. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  31790. if !m.op.Is(OpUpdateOne) {
  31791. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  31792. }
  31793. if m.id == nil || m.oldValue == nil {
  31794. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  31795. }
  31796. oldValue, err := m.oldValue(ctx)
  31797. if err != nil {
  31798. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  31799. }
  31800. return oldValue.PlanStartTime, nil
  31801. }
  31802. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  31803. func (m *SopTaskMutation) ClearPlanStartTime() {
  31804. m.plan_start_time = nil
  31805. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  31806. }
  31807. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  31808. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  31809. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  31810. return ok
  31811. }
  31812. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  31813. func (m *SopTaskMutation) ResetPlanStartTime() {
  31814. m.plan_start_time = nil
  31815. delete(m.clearedFields, soptask.FieldPlanStartTime)
  31816. }
  31817. // SetPlanEndTime sets the "plan_end_time" field.
  31818. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  31819. m.plan_end_time = &t
  31820. }
  31821. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  31822. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  31823. v := m.plan_end_time
  31824. if v == nil {
  31825. return
  31826. }
  31827. return *v, true
  31828. }
  31829. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  31830. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31832. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  31833. if !m.op.Is(OpUpdateOne) {
  31834. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  31835. }
  31836. if m.id == nil || m.oldValue == nil {
  31837. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  31838. }
  31839. oldValue, err := m.oldValue(ctx)
  31840. if err != nil {
  31841. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  31842. }
  31843. return oldValue.PlanEndTime, nil
  31844. }
  31845. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  31846. func (m *SopTaskMutation) ClearPlanEndTime() {
  31847. m.plan_end_time = nil
  31848. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  31849. }
  31850. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  31851. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  31852. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  31853. return ok
  31854. }
  31855. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  31856. func (m *SopTaskMutation) ResetPlanEndTime() {
  31857. m.plan_end_time = nil
  31858. delete(m.clearedFields, soptask.FieldPlanEndTime)
  31859. }
  31860. // SetCreatorID sets the "creator_id" field.
  31861. func (m *SopTaskMutation) SetCreatorID(s string) {
  31862. m.creator_id = &s
  31863. }
  31864. // CreatorID returns the value of the "creator_id" field in the mutation.
  31865. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  31866. v := m.creator_id
  31867. if v == nil {
  31868. return
  31869. }
  31870. return *v, true
  31871. }
  31872. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  31873. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31875. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  31876. if !m.op.Is(OpUpdateOne) {
  31877. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  31878. }
  31879. if m.id == nil || m.oldValue == nil {
  31880. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  31881. }
  31882. oldValue, err := m.oldValue(ctx)
  31883. if err != nil {
  31884. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  31885. }
  31886. return oldValue.CreatorID, nil
  31887. }
  31888. // ClearCreatorID clears the value of the "creator_id" field.
  31889. func (m *SopTaskMutation) ClearCreatorID() {
  31890. m.creator_id = nil
  31891. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  31892. }
  31893. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  31894. func (m *SopTaskMutation) CreatorIDCleared() bool {
  31895. _, ok := m.clearedFields[soptask.FieldCreatorID]
  31896. return ok
  31897. }
  31898. // ResetCreatorID resets all changes to the "creator_id" field.
  31899. func (m *SopTaskMutation) ResetCreatorID() {
  31900. m.creator_id = nil
  31901. delete(m.clearedFields, soptask.FieldCreatorID)
  31902. }
  31903. // SetOrganizationID sets the "organization_id" field.
  31904. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  31905. m.organization_id = &u
  31906. m.addorganization_id = nil
  31907. }
  31908. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31909. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  31910. v := m.organization_id
  31911. if v == nil {
  31912. return
  31913. }
  31914. return *v, true
  31915. }
  31916. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  31917. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31919. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31920. if !m.op.Is(OpUpdateOne) {
  31921. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31922. }
  31923. if m.id == nil || m.oldValue == nil {
  31924. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31925. }
  31926. oldValue, err := m.oldValue(ctx)
  31927. if err != nil {
  31928. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31929. }
  31930. return oldValue.OrganizationID, nil
  31931. }
  31932. // AddOrganizationID adds u to the "organization_id" field.
  31933. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  31934. if m.addorganization_id != nil {
  31935. *m.addorganization_id += u
  31936. } else {
  31937. m.addorganization_id = &u
  31938. }
  31939. }
  31940. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31941. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  31942. v := m.addorganization_id
  31943. if v == nil {
  31944. return
  31945. }
  31946. return *v, true
  31947. }
  31948. // ClearOrganizationID clears the value of the "organization_id" field.
  31949. func (m *SopTaskMutation) ClearOrganizationID() {
  31950. m.organization_id = nil
  31951. m.addorganization_id = nil
  31952. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  31953. }
  31954. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31955. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  31956. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  31957. return ok
  31958. }
  31959. // ResetOrganizationID resets all changes to the "organization_id" field.
  31960. func (m *SopTaskMutation) ResetOrganizationID() {
  31961. m.organization_id = nil
  31962. m.addorganization_id = nil
  31963. delete(m.clearedFields, soptask.FieldOrganizationID)
  31964. }
  31965. // SetToken sets the "token" field.
  31966. func (m *SopTaskMutation) SetToken(s []string) {
  31967. m.token = &s
  31968. m.appendtoken = nil
  31969. }
  31970. // Token returns the value of the "token" field in the mutation.
  31971. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  31972. v := m.token
  31973. if v == nil {
  31974. return
  31975. }
  31976. return *v, true
  31977. }
  31978. // OldToken returns the old "token" field's value of the SopTask entity.
  31979. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31981. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  31982. if !m.op.Is(OpUpdateOne) {
  31983. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31984. }
  31985. if m.id == nil || m.oldValue == nil {
  31986. return v, errors.New("OldToken requires an ID field in the mutation")
  31987. }
  31988. oldValue, err := m.oldValue(ctx)
  31989. if err != nil {
  31990. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31991. }
  31992. return oldValue.Token, nil
  31993. }
  31994. // AppendToken adds s to the "token" field.
  31995. func (m *SopTaskMutation) AppendToken(s []string) {
  31996. m.appendtoken = append(m.appendtoken, s...)
  31997. }
  31998. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  31999. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  32000. if len(m.appendtoken) == 0 {
  32001. return nil, false
  32002. }
  32003. return m.appendtoken, true
  32004. }
  32005. // ClearToken clears the value of the "token" field.
  32006. func (m *SopTaskMutation) ClearToken() {
  32007. m.token = nil
  32008. m.appendtoken = nil
  32009. m.clearedFields[soptask.FieldToken] = struct{}{}
  32010. }
  32011. // TokenCleared returns if the "token" field was cleared in this mutation.
  32012. func (m *SopTaskMutation) TokenCleared() bool {
  32013. _, ok := m.clearedFields[soptask.FieldToken]
  32014. return ok
  32015. }
  32016. // ResetToken resets all changes to the "token" field.
  32017. func (m *SopTaskMutation) ResetToken() {
  32018. m.token = nil
  32019. m.appendtoken = nil
  32020. delete(m.clearedFields, soptask.FieldToken)
  32021. }
  32022. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  32023. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  32024. if m.task_stages == nil {
  32025. m.task_stages = make(map[uint64]struct{})
  32026. }
  32027. for i := range ids {
  32028. m.task_stages[ids[i]] = struct{}{}
  32029. }
  32030. }
  32031. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  32032. func (m *SopTaskMutation) ClearTaskStages() {
  32033. m.clearedtask_stages = true
  32034. }
  32035. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  32036. func (m *SopTaskMutation) TaskStagesCleared() bool {
  32037. return m.clearedtask_stages
  32038. }
  32039. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  32040. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  32041. if m.removedtask_stages == nil {
  32042. m.removedtask_stages = make(map[uint64]struct{})
  32043. }
  32044. for i := range ids {
  32045. delete(m.task_stages, ids[i])
  32046. m.removedtask_stages[ids[i]] = struct{}{}
  32047. }
  32048. }
  32049. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  32050. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  32051. for id := range m.removedtask_stages {
  32052. ids = append(ids, id)
  32053. }
  32054. return
  32055. }
  32056. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  32057. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  32058. for id := range m.task_stages {
  32059. ids = append(ids, id)
  32060. }
  32061. return
  32062. }
  32063. // ResetTaskStages resets all changes to the "task_stages" edge.
  32064. func (m *SopTaskMutation) ResetTaskStages() {
  32065. m.task_stages = nil
  32066. m.clearedtask_stages = false
  32067. m.removedtask_stages = nil
  32068. }
  32069. // Where appends a list predicates to the SopTaskMutation builder.
  32070. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  32071. m.predicates = append(m.predicates, ps...)
  32072. }
  32073. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  32074. // users can use type-assertion to append predicates that do not depend on any generated package.
  32075. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  32076. p := make([]predicate.SopTask, len(ps))
  32077. for i := range ps {
  32078. p[i] = ps[i]
  32079. }
  32080. m.Where(p...)
  32081. }
  32082. // Op returns the operation name.
  32083. func (m *SopTaskMutation) Op() Op {
  32084. return m.op
  32085. }
  32086. // SetOp allows setting the mutation operation.
  32087. func (m *SopTaskMutation) SetOp(op Op) {
  32088. m.op = op
  32089. }
  32090. // Type returns the node type of this mutation (SopTask).
  32091. func (m *SopTaskMutation) Type() string {
  32092. return m.typ
  32093. }
  32094. // Fields returns all fields that were changed during this mutation. Note that in
  32095. // order to get all numeric fields that were incremented/decremented, call
  32096. // AddedFields().
  32097. func (m *SopTaskMutation) Fields() []string {
  32098. fields := make([]string, 0, 12)
  32099. if m.created_at != nil {
  32100. fields = append(fields, soptask.FieldCreatedAt)
  32101. }
  32102. if m.updated_at != nil {
  32103. fields = append(fields, soptask.FieldUpdatedAt)
  32104. }
  32105. if m.status != nil {
  32106. fields = append(fields, soptask.FieldStatus)
  32107. }
  32108. if m.deleted_at != nil {
  32109. fields = append(fields, soptask.FieldDeletedAt)
  32110. }
  32111. if m.name != nil {
  32112. fields = append(fields, soptask.FieldName)
  32113. }
  32114. if m.bot_wxid_list != nil {
  32115. fields = append(fields, soptask.FieldBotWxidList)
  32116. }
  32117. if m._type != nil {
  32118. fields = append(fields, soptask.FieldType)
  32119. }
  32120. if m.plan_start_time != nil {
  32121. fields = append(fields, soptask.FieldPlanStartTime)
  32122. }
  32123. if m.plan_end_time != nil {
  32124. fields = append(fields, soptask.FieldPlanEndTime)
  32125. }
  32126. if m.creator_id != nil {
  32127. fields = append(fields, soptask.FieldCreatorID)
  32128. }
  32129. if m.organization_id != nil {
  32130. fields = append(fields, soptask.FieldOrganizationID)
  32131. }
  32132. if m.token != nil {
  32133. fields = append(fields, soptask.FieldToken)
  32134. }
  32135. return fields
  32136. }
  32137. // Field returns the value of a field with the given name. The second boolean
  32138. // return value indicates that this field was not set, or was not defined in the
  32139. // schema.
  32140. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  32141. switch name {
  32142. case soptask.FieldCreatedAt:
  32143. return m.CreatedAt()
  32144. case soptask.FieldUpdatedAt:
  32145. return m.UpdatedAt()
  32146. case soptask.FieldStatus:
  32147. return m.Status()
  32148. case soptask.FieldDeletedAt:
  32149. return m.DeletedAt()
  32150. case soptask.FieldName:
  32151. return m.Name()
  32152. case soptask.FieldBotWxidList:
  32153. return m.BotWxidList()
  32154. case soptask.FieldType:
  32155. return m.GetType()
  32156. case soptask.FieldPlanStartTime:
  32157. return m.PlanStartTime()
  32158. case soptask.FieldPlanEndTime:
  32159. return m.PlanEndTime()
  32160. case soptask.FieldCreatorID:
  32161. return m.CreatorID()
  32162. case soptask.FieldOrganizationID:
  32163. return m.OrganizationID()
  32164. case soptask.FieldToken:
  32165. return m.Token()
  32166. }
  32167. return nil, false
  32168. }
  32169. // OldField returns the old value of the field from the database. An error is
  32170. // returned if the mutation operation is not UpdateOne, or the query to the
  32171. // database failed.
  32172. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32173. switch name {
  32174. case soptask.FieldCreatedAt:
  32175. return m.OldCreatedAt(ctx)
  32176. case soptask.FieldUpdatedAt:
  32177. return m.OldUpdatedAt(ctx)
  32178. case soptask.FieldStatus:
  32179. return m.OldStatus(ctx)
  32180. case soptask.FieldDeletedAt:
  32181. return m.OldDeletedAt(ctx)
  32182. case soptask.FieldName:
  32183. return m.OldName(ctx)
  32184. case soptask.FieldBotWxidList:
  32185. return m.OldBotWxidList(ctx)
  32186. case soptask.FieldType:
  32187. return m.OldType(ctx)
  32188. case soptask.FieldPlanStartTime:
  32189. return m.OldPlanStartTime(ctx)
  32190. case soptask.FieldPlanEndTime:
  32191. return m.OldPlanEndTime(ctx)
  32192. case soptask.FieldCreatorID:
  32193. return m.OldCreatorID(ctx)
  32194. case soptask.FieldOrganizationID:
  32195. return m.OldOrganizationID(ctx)
  32196. case soptask.FieldToken:
  32197. return m.OldToken(ctx)
  32198. }
  32199. return nil, fmt.Errorf("unknown SopTask field %s", name)
  32200. }
  32201. // SetField sets the value of a field with the given name. It returns an error if
  32202. // the field is not defined in the schema, or if the type mismatched the field
  32203. // type.
  32204. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  32205. switch name {
  32206. case soptask.FieldCreatedAt:
  32207. v, ok := value.(time.Time)
  32208. if !ok {
  32209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32210. }
  32211. m.SetCreatedAt(v)
  32212. return nil
  32213. case soptask.FieldUpdatedAt:
  32214. v, ok := value.(time.Time)
  32215. if !ok {
  32216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32217. }
  32218. m.SetUpdatedAt(v)
  32219. return nil
  32220. case soptask.FieldStatus:
  32221. v, ok := value.(uint8)
  32222. if !ok {
  32223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32224. }
  32225. m.SetStatus(v)
  32226. return nil
  32227. case soptask.FieldDeletedAt:
  32228. v, ok := value.(time.Time)
  32229. if !ok {
  32230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32231. }
  32232. m.SetDeletedAt(v)
  32233. return nil
  32234. case soptask.FieldName:
  32235. v, ok := value.(string)
  32236. if !ok {
  32237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32238. }
  32239. m.SetName(v)
  32240. return nil
  32241. case soptask.FieldBotWxidList:
  32242. v, ok := value.([]string)
  32243. if !ok {
  32244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32245. }
  32246. m.SetBotWxidList(v)
  32247. return nil
  32248. case soptask.FieldType:
  32249. v, ok := value.(int)
  32250. if !ok {
  32251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32252. }
  32253. m.SetType(v)
  32254. return nil
  32255. case soptask.FieldPlanStartTime:
  32256. v, ok := value.(time.Time)
  32257. if !ok {
  32258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32259. }
  32260. m.SetPlanStartTime(v)
  32261. return nil
  32262. case soptask.FieldPlanEndTime:
  32263. v, ok := value.(time.Time)
  32264. if !ok {
  32265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32266. }
  32267. m.SetPlanEndTime(v)
  32268. return nil
  32269. case soptask.FieldCreatorID:
  32270. v, ok := value.(string)
  32271. if !ok {
  32272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32273. }
  32274. m.SetCreatorID(v)
  32275. return nil
  32276. case soptask.FieldOrganizationID:
  32277. v, ok := value.(uint64)
  32278. if !ok {
  32279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32280. }
  32281. m.SetOrganizationID(v)
  32282. return nil
  32283. case soptask.FieldToken:
  32284. v, ok := value.([]string)
  32285. if !ok {
  32286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32287. }
  32288. m.SetToken(v)
  32289. return nil
  32290. }
  32291. return fmt.Errorf("unknown SopTask field %s", name)
  32292. }
  32293. // AddedFields returns all numeric fields that were incremented/decremented during
  32294. // this mutation.
  32295. func (m *SopTaskMutation) AddedFields() []string {
  32296. var fields []string
  32297. if m.addstatus != nil {
  32298. fields = append(fields, soptask.FieldStatus)
  32299. }
  32300. if m.add_type != nil {
  32301. fields = append(fields, soptask.FieldType)
  32302. }
  32303. if m.addorganization_id != nil {
  32304. fields = append(fields, soptask.FieldOrganizationID)
  32305. }
  32306. return fields
  32307. }
  32308. // AddedField returns the numeric value that was incremented/decremented on a field
  32309. // with the given name. The second boolean return value indicates that this field
  32310. // was not set, or was not defined in the schema.
  32311. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  32312. switch name {
  32313. case soptask.FieldStatus:
  32314. return m.AddedStatus()
  32315. case soptask.FieldType:
  32316. return m.AddedType()
  32317. case soptask.FieldOrganizationID:
  32318. return m.AddedOrganizationID()
  32319. }
  32320. return nil, false
  32321. }
  32322. // AddField adds the value to the field with the given name. It returns an error if
  32323. // the field is not defined in the schema, or if the type mismatched the field
  32324. // type.
  32325. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  32326. switch name {
  32327. case soptask.FieldStatus:
  32328. v, ok := value.(int8)
  32329. if !ok {
  32330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32331. }
  32332. m.AddStatus(v)
  32333. return nil
  32334. case soptask.FieldType:
  32335. v, ok := value.(int)
  32336. if !ok {
  32337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32338. }
  32339. m.AddType(v)
  32340. return nil
  32341. case soptask.FieldOrganizationID:
  32342. v, ok := value.(int64)
  32343. if !ok {
  32344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32345. }
  32346. m.AddOrganizationID(v)
  32347. return nil
  32348. }
  32349. return fmt.Errorf("unknown SopTask numeric field %s", name)
  32350. }
  32351. // ClearedFields returns all nullable fields that were cleared during this
  32352. // mutation.
  32353. func (m *SopTaskMutation) ClearedFields() []string {
  32354. var fields []string
  32355. if m.FieldCleared(soptask.FieldStatus) {
  32356. fields = append(fields, soptask.FieldStatus)
  32357. }
  32358. if m.FieldCleared(soptask.FieldDeletedAt) {
  32359. fields = append(fields, soptask.FieldDeletedAt)
  32360. }
  32361. if m.FieldCleared(soptask.FieldBotWxidList) {
  32362. fields = append(fields, soptask.FieldBotWxidList)
  32363. }
  32364. if m.FieldCleared(soptask.FieldPlanStartTime) {
  32365. fields = append(fields, soptask.FieldPlanStartTime)
  32366. }
  32367. if m.FieldCleared(soptask.FieldPlanEndTime) {
  32368. fields = append(fields, soptask.FieldPlanEndTime)
  32369. }
  32370. if m.FieldCleared(soptask.FieldCreatorID) {
  32371. fields = append(fields, soptask.FieldCreatorID)
  32372. }
  32373. if m.FieldCleared(soptask.FieldOrganizationID) {
  32374. fields = append(fields, soptask.FieldOrganizationID)
  32375. }
  32376. if m.FieldCleared(soptask.FieldToken) {
  32377. fields = append(fields, soptask.FieldToken)
  32378. }
  32379. return fields
  32380. }
  32381. // FieldCleared returns a boolean indicating if a field with the given name was
  32382. // cleared in this mutation.
  32383. func (m *SopTaskMutation) FieldCleared(name string) bool {
  32384. _, ok := m.clearedFields[name]
  32385. return ok
  32386. }
  32387. // ClearField clears the value of the field with the given name. It returns an
  32388. // error if the field is not defined in the schema.
  32389. func (m *SopTaskMutation) ClearField(name string) error {
  32390. switch name {
  32391. case soptask.FieldStatus:
  32392. m.ClearStatus()
  32393. return nil
  32394. case soptask.FieldDeletedAt:
  32395. m.ClearDeletedAt()
  32396. return nil
  32397. case soptask.FieldBotWxidList:
  32398. m.ClearBotWxidList()
  32399. return nil
  32400. case soptask.FieldPlanStartTime:
  32401. m.ClearPlanStartTime()
  32402. return nil
  32403. case soptask.FieldPlanEndTime:
  32404. m.ClearPlanEndTime()
  32405. return nil
  32406. case soptask.FieldCreatorID:
  32407. m.ClearCreatorID()
  32408. return nil
  32409. case soptask.FieldOrganizationID:
  32410. m.ClearOrganizationID()
  32411. return nil
  32412. case soptask.FieldToken:
  32413. m.ClearToken()
  32414. return nil
  32415. }
  32416. return fmt.Errorf("unknown SopTask nullable field %s", name)
  32417. }
  32418. // ResetField resets all changes in the mutation for the field with the given name.
  32419. // It returns an error if the field is not defined in the schema.
  32420. func (m *SopTaskMutation) ResetField(name string) error {
  32421. switch name {
  32422. case soptask.FieldCreatedAt:
  32423. m.ResetCreatedAt()
  32424. return nil
  32425. case soptask.FieldUpdatedAt:
  32426. m.ResetUpdatedAt()
  32427. return nil
  32428. case soptask.FieldStatus:
  32429. m.ResetStatus()
  32430. return nil
  32431. case soptask.FieldDeletedAt:
  32432. m.ResetDeletedAt()
  32433. return nil
  32434. case soptask.FieldName:
  32435. m.ResetName()
  32436. return nil
  32437. case soptask.FieldBotWxidList:
  32438. m.ResetBotWxidList()
  32439. return nil
  32440. case soptask.FieldType:
  32441. m.ResetType()
  32442. return nil
  32443. case soptask.FieldPlanStartTime:
  32444. m.ResetPlanStartTime()
  32445. return nil
  32446. case soptask.FieldPlanEndTime:
  32447. m.ResetPlanEndTime()
  32448. return nil
  32449. case soptask.FieldCreatorID:
  32450. m.ResetCreatorID()
  32451. return nil
  32452. case soptask.FieldOrganizationID:
  32453. m.ResetOrganizationID()
  32454. return nil
  32455. case soptask.FieldToken:
  32456. m.ResetToken()
  32457. return nil
  32458. }
  32459. return fmt.Errorf("unknown SopTask field %s", name)
  32460. }
  32461. // AddedEdges returns all edge names that were set/added in this mutation.
  32462. func (m *SopTaskMutation) AddedEdges() []string {
  32463. edges := make([]string, 0, 1)
  32464. if m.task_stages != nil {
  32465. edges = append(edges, soptask.EdgeTaskStages)
  32466. }
  32467. return edges
  32468. }
  32469. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32470. // name in this mutation.
  32471. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  32472. switch name {
  32473. case soptask.EdgeTaskStages:
  32474. ids := make([]ent.Value, 0, len(m.task_stages))
  32475. for id := range m.task_stages {
  32476. ids = append(ids, id)
  32477. }
  32478. return ids
  32479. }
  32480. return nil
  32481. }
  32482. // RemovedEdges returns all edge names that were removed in this mutation.
  32483. func (m *SopTaskMutation) RemovedEdges() []string {
  32484. edges := make([]string, 0, 1)
  32485. if m.removedtask_stages != nil {
  32486. edges = append(edges, soptask.EdgeTaskStages)
  32487. }
  32488. return edges
  32489. }
  32490. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32491. // the given name in this mutation.
  32492. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  32493. switch name {
  32494. case soptask.EdgeTaskStages:
  32495. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  32496. for id := range m.removedtask_stages {
  32497. ids = append(ids, id)
  32498. }
  32499. return ids
  32500. }
  32501. return nil
  32502. }
  32503. // ClearedEdges returns all edge names that were cleared in this mutation.
  32504. func (m *SopTaskMutation) ClearedEdges() []string {
  32505. edges := make([]string, 0, 1)
  32506. if m.clearedtask_stages {
  32507. edges = append(edges, soptask.EdgeTaskStages)
  32508. }
  32509. return edges
  32510. }
  32511. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32512. // was cleared in this mutation.
  32513. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  32514. switch name {
  32515. case soptask.EdgeTaskStages:
  32516. return m.clearedtask_stages
  32517. }
  32518. return false
  32519. }
  32520. // ClearEdge clears the value of the edge with the given name. It returns an error
  32521. // if that edge is not defined in the schema.
  32522. func (m *SopTaskMutation) ClearEdge(name string) error {
  32523. switch name {
  32524. }
  32525. return fmt.Errorf("unknown SopTask unique edge %s", name)
  32526. }
  32527. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32528. // It returns an error if the edge is not defined in the schema.
  32529. func (m *SopTaskMutation) ResetEdge(name string) error {
  32530. switch name {
  32531. case soptask.EdgeTaskStages:
  32532. m.ResetTaskStages()
  32533. return nil
  32534. }
  32535. return fmt.Errorf("unknown SopTask edge %s", name)
  32536. }
  32537. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  32538. type TokenMutation struct {
  32539. config
  32540. op Op
  32541. typ string
  32542. id *uint64
  32543. created_at *time.Time
  32544. updated_at *time.Time
  32545. deleted_at *time.Time
  32546. expire_at *time.Time
  32547. token *string
  32548. mac *string
  32549. organization_id *uint64
  32550. addorganization_id *int64
  32551. custom_agent_base *string
  32552. custom_agent_key *string
  32553. openai_base *string
  32554. openai_key *string
  32555. clearedFields map[string]struct{}
  32556. agent *uint64
  32557. clearedagent bool
  32558. done bool
  32559. oldValue func(context.Context) (*Token, error)
  32560. predicates []predicate.Token
  32561. }
  32562. var _ ent.Mutation = (*TokenMutation)(nil)
  32563. // tokenOption allows management of the mutation configuration using functional options.
  32564. type tokenOption func(*TokenMutation)
  32565. // newTokenMutation creates new mutation for the Token entity.
  32566. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  32567. m := &TokenMutation{
  32568. config: c,
  32569. op: op,
  32570. typ: TypeToken,
  32571. clearedFields: make(map[string]struct{}),
  32572. }
  32573. for _, opt := range opts {
  32574. opt(m)
  32575. }
  32576. return m
  32577. }
  32578. // withTokenID sets the ID field of the mutation.
  32579. func withTokenID(id uint64) tokenOption {
  32580. return func(m *TokenMutation) {
  32581. var (
  32582. err error
  32583. once sync.Once
  32584. value *Token
  32585. )
  32586. m.oldValue = func(ctx context.Context) (*Token, error) {
  32587. once.Do(func() {
  32588. if m.done {
  32589. err = errors.New("querying old values post mutation is not allowed")
  32590. } else {
  32591. value, err = m.Client().Token.Get(ctx, id)
  32592. }
  32593. })
  32594. return value, err
  32595. }
  32596. m.id = &id
  32597. }
  32598. }
  32599. // withToken sets the old Token of the mutation.
  32600. func withToken(node *Token) tokenOption {
  32601. return func(m *TokenMutation) {
  32602. m.oldValue = func(context.Context) (*Token, error) {
  32603. return node, nil
  32604. }
  32605. m.id = &node.ID
  32606. }
  32607. }
  32608. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32609. // executed in a transaction (ent.Tx), a transactional client is returned.
  32610. func (m TokenMutation) Client() *Client {
  32611. client := &Client{config: m.config}
  32612. client.init()
  32613. return client
  32614. }
  32615. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32616. // it returns an error otherwise.
  32617. func (m TokenMutation) Tx() (*Tx, error) {
  32618. if _, ok := m.driver.(*txDriver); !ok {
  32619. return nil, errors.New("ent: mutation is not running in a transaction")
  32620. }
  32621. tx := &Tx{config: m.config}
  32622. tx.init()
  32623. return tx, nil
  32624. }
  32625. // SetID sets the value of the id field. Note that this
  32626. // operation is only accepted on creation of Token entities.
  32627. func (m *TokenMutation) SetID(id uint64) {
  32628. m.id = &id
  32629. }
  32630. // ID returns the ID value in the mutation. Note that the ID is only available
  32631. // if it was provided to the builder or after it was returned from the database.
  32632. func (m *TokenMutation) ID() (id uint64, exists bool) {
  32633. if m.id == nil {
  32634. return
  32635. }
  32636. return *m.id, true
  32637. }
  32638. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32639. // That means, if the mutation is applied within a transaction with an isolation level such
  32640. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32641. // or updated by the mutation.
  32642. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  32643. switch {
  32644. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32645. id, exists := m.ID()
  32646. if exists {
  32647. return []uint64{id}, nil
  32648. }
  32649. fallthrough
  32650. case m.op.Is(OpUpdate | OpDelete):
  32651. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  32652. default:
  32653. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32654. }
  32655. }
  32656. // SetCreatedAt sets the "created_at" field.
  32657. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  32658. m.created_at = &t
  32659. }
  32660. // CreatedAt returns the value of the "created_at" field in the mutation.
  32661. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  32662. v := m.created_at
  32663. if v == nil {
  32664. return
  32665. }
  32666. return *v, true
  32667. }
  32668. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  32669. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32671. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32672. if !m.op.Is(OpUpdateOne) {
  32673. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32674. }
  32675. if m.id == nil || m.oldValue == nil {
  32676. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32677. }
  32678. oldValue, err := m.oldValue(ctx)
  32679. if err != nil {
  32680. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32681. }
  32682. return oldValue.CreatedAt, nil
  32683. }
  32684. // ResetCreatedAt resets all changes to the "created_at" field.
  32685. func (m *TokenMutation) ResetCreatedAt() {
  32686. m.created_at = nil
  32687. }
  32688. // SetUpdatedAt sets the "updated_at" field.
  32689. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  32690. m.updated_at = &t
  32691. }
  32692. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32693. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  32694. v := m.updated_at
  32695. if v == nil {
  32696. return
  32697. }
  32698. return *v, true
  32699. }
  32700. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  32701. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32703. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32704. if !m.op.Is(OpUpdateOne) {
  32705. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32706. }
  32707. if m.id == nil || m.oldValue == nil {
  32708. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32709. }
  32710. oldValue, err := m.oldValue(ctx)
  32711. if err != nil {
  32712. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32713. }
  32714. return oldValue.UpdatedAt, nil
  32715. }
  32716. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32717. func (m *TokenMutation) ResetUpdatedAt() {
  32718. m.updated_at = nil
  32719. }
  32720. // SetDeletedAt sets the "deleted_at" field.
  32721. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  32722. m.deleted_at = &t
  32723. }
  32724. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32725. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  32726. v := m.deleted_at
  32727. if v == nil {
  32728. return
  32729. }
  32730. return *v, true
  32731. }
  32732. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  32733. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32735. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32736. if !m.op.Is(OpUpdateOne) {
  32737. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32738. }
  32739. if m.id == nil || m.oldValue == nil {
  32740. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32741. }
  32742. oldValue, err := m.oldValue(ctx)
  32743. if err != nil {
  32744. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32745. }
  32746. return oldValue.DeletedAt, nil
  32747. }
  32748. // ClearDeletedAt clears the value of the "deleted_at" field.
  32749. func (m *TokenMutation) ClearDeletedAt() {
  32750. m.deleted_at = nil
  32751. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  32752. }
  32753. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32754. func (m *TokenMutation) DeletedAtCleared() bool {
  32755. _, ok := m.clearedFields[token.FieldDeletedAt]
  32756. return ok
  32757. }
  32758. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32759. func (m *TokenMutation) ResetDeletedAt() {
  32760. m.deleted_at = nil
  32761. delete(m.clearedFields, token.FieldDeletedAt)
  32762. }
  32763. // SetExpireAt sets the "expire_at" field.
  32764. func (m *TokenMutation) SetExpireAt(t time.Time) {
  32765. m.expire_at = &t
  32766. }
  32767. // ExpireAt returns the value of the "expire_at" field in the mutation.
  32768. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  32769. v := m.expire_at
  32770. if v == nil {
  32771. return
  32772. }
  32773. return *v, true
  32774. }
  32775. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  32776. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32778. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  32779. if !m.op.Is(OpUpdateOne) {
  32780. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  32781. }
  32782. if m.id == nil || m.oldValue == nil {
  32783. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  32784. }
  32785. oldValue, err := m.oldValue(ctx)
  32786. if err != nil {
  32787. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  32788. }
  32789. return oldValue.ExpireAt, nil
  32790. }
  32791. // ClearExpireAt clears the value of the "expire_at" field.
  32792. func (m *TokenMutation) ClearExpireAt() {
  32793. m.expire_at = nil
  32794. m.clearedFields[token.FieldExpireAt] = struct{}{}
  32795. }
  32796. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  32797. func (m *TokenMutation) ExpireAtCleared() bool {
  32798. _, ok := m.clearedFields[token.FieldExpireAt]
  32799. return ok
  32800. }
  32801. // ResetExpireAt resets all changes to the "expire_at" field.
  32802. func (m *TokenMutation) ResetExpireAt() {
  32803. m.expire_at = nil
  32804. delete(m.clearedFields, token.FieldExpireAt)
  32805. }
  32806. // SetToken sets the "token" field.
  32807. func (m *TokenMutation) SetToken(s string) {
  32808. m.token = &s
  32809. }
  32810. // Token returns the value of the "token" field in the mutation.
  32811. func (m *TokenMutation) Token() (r string, exists bool) {
  32812. v := m.token
  32813. if v == nil {
  32814. return
  32815. }
  32816. return *v, true
  32817. }
  32818. // OldToken returns the old "token" field's value of the Token entity.
  32819. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32821. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  32822. if !m.op.Is(OpUpdateOne) {
  32823. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  32824. }
  32825. if m.id == nil || m.oldValue == nil {
  32826. return v, errors.New("OldToken requires an ID field in the mutation")
  32827. }
  32828. oldValue, err := m.oldValue(ctx)
  32829. if err != nil {
  32830. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  32831. }
  32832. return oldValue.Token, nil
  32833. }
  32834. // ClearToken clears the value of the "token" field.
  32835. func (m *TokenMutation) ClearToken() {
  32836. m.token = nil
  32837. m.clearedFields[token.FieldToken] = struct{}{}
  32838. }
  32839. // TokenCleared returns if the "token" field was cleared in this mutation.
  32840. func (m *TokenMutation) TokenCleared() bool {
  32841. _, ok := m.clearedFields[token.FieldToken]
  32842. return ok
  32843. }
  32844. // ResetToken resets all changes to the "token" field.
  32845. func (m *TokenMutation) ResetToken() {
  32846. m.token = nil
  32847. delete(m.clearedFields, token.FieldToken)
  32848. }
  32849. // SetMAC sets the "mac" field.
  32850. func (m *TokenMutation) SetMAC(s string) {
  32851. m.mac = &s
  32852. }
  32853. // MAC returns the value of the "mac" field in the mutation.
  32854. func (m *TokenMutation) MAC() (r string, exists bool) {
  32855. v := m.mac
  32856. if v == nil {
  32857. return
  32858. }
  32859. return *v, true
  32860. }
  32861. // OldMAC returns the old "mac" field's value of the Token entity.
  32862. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32864. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  32865. if !m.op.Is(OpUpdateOne) {
  32866. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  32867. }
  32868. if m.id == nil || m.oldValue == nil {
  32869. return v, errors.New("OldMAC requires an ID field in the mutation")
  32870. }
  32871. oldValue, err := m.oldValue(ctx)
  32872. if err != nil {
  32873. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  32874. }
  32875. return oldValue.MAC, nil
  32876. }
  32877. // ClearMAC clears the value of the "mac" field.
  32878. func (m *TokenMutation) ClearMAC() {
  32879. m.mac = nil
  32880. m.clearedFields[token.FieldMAC] = struct{}{}
  32881. }
  32882. // MACCleared returns if the "mac" field was cleared in this mutation.
  32883. func (m *TokenMutation) MACCleared() bool {
  32884. _, ok := m.clearedFields[token.FieldMAC]
  32885. return ok
  32886. }
  32887. // ResetMAC resets all changes to the "mac" field.
  32888. func (m *TokenMutation) ResetMAC() {
  32889. m.mac = nil
  32890. delete(m.clearedFields, token.FieldMAC)
  32891. }
  32892. // SetOrganizationID sets the "organization_id" field.
  32893. func (m *TokenMutation) SetOrganizationID(u uint64) {
  32894. m.organization_id = &u
  32895. m.addorganization_id = nil
  32896. }
  32897. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32898. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  32899. v := m.organization_id
  32900. if v == nil {
  32901. return
  32902. }
  32903. return *v, true
  32904. }
  32905. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  32906. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32908. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32909. if !m.op.Is(OpUpdateOne) {
  32910. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32911. }
  32912. if m.id == nil || m.oldValue == nil {
  32913. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32914. }
  32915. oldValue, err := m.oldValue(ctx)
  32916. if err != nil {
  32917. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32918. }
  32919. return oldValue.OrganizationID, nil
  32920. }
  32921. // AddOrganizationID adds u to the "organization_id" field.
  32922. func (m *TokenMutation) AddOrganizationID(u int64) {
  32923. if m.addorganization_id != nil {
  32924. *m.addorganization_id += u
  32925. } else {
  32926. m.addorganization_id = &u
  32927. }
  32928. }
  32929. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32930. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  32931. v := m.addorganization_id
  32932. if v == nil {
  32933. return
  32934. }
  32935. return *v, true
  32936. }
  32937. // ResetOrganizationID resets all changes to the "organization_id" field.
  32938. func (m *TokenMutation) ResetOrganizationID() {
  32939. m.organization_id = nil
  32940. m.addorganization_id = nil
  32941. }
  32942. // SetAgentID sets the "agent_id" field.
  32943. func (m *TokenMutation) SetAgentID(u uint64) {
  32944. m.agent = &u
  32945. }
  32946. // AgentID returns the value of the "agent_id" field in the mutation.
  32947. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  32948. v := m.agent
  32949. if v == nil {
  32950. return
  32951. }
  32952. return *v, true
  32953. }
  32954. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  32955. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32957. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32958. if !m.op.Is(OpUpdateOne) {
  32959. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32960. }
  32961. if m.id == nil || m.oldValue == nil {
  32962. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32963. }
  32964. oldValue, err := m.oldValue(ctx)
  32965. if err != nil {
  32966. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32967. }
  32968. return oldValue.AgentID, nil
  32969. }
  32970. // ResetAgentID resets all changes to the "agent_id" field.
  32971. func (m *TokenMutation) ResetAgentID() {
  32972. m.agent = nil
  32973. }
  32974. // SetCustomAgentBase sets the "custom_agent_base" field.
  32975. func (m *TokenMutation) SetCustomAgentBase(s string) {
  32976. m.custom_agent_base = &s
  32977. }
  32978. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  32979. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  32980. v := m.custom_agent_base
  32981. if v == nil {
  32982. return
  32983. }
  32984. return *v, true
  32985. }
  32986. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  32987. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32989. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  32990. if !m.op.Is(OpUpdateOne) {
  32991. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  32992. }
  32993. if m.id == nil || m.oldValue == nil {
  32994. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  32995. }
  32996. oldValue, err := m.oldValue(ctx)
  32997. if err != nil {
  32998. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  32999. }
  33000. return oldValue.CustomAgentBase, nil
  33001. }
  33002. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  33003. func (m *TokenMutation) ClearCustomAgentBase() {
  33004. m.custom_agent_base = nil
  33005. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  33006. }
  33007. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  33008. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  33009. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  33010. return ok
  33011. }
  33012. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  33013. func (m *TokenMutation) ResetCustomAgentBase() {
  33014. m.custom_agent_base = nil
  33015. delete(m.clearedFields, token.FieldCustomAgentBase)
  33016. }
  33017. // SetCustomAgentKey sets the "custom_agent_key" field.
  33018. func (m *TokenMutation) SetCustomAgentKey(s string) {
  33019. m.custom_agent_key = &s
  33020. }
  33021. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  33022. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  33023. v := m.custom_agent_key
  33024. if v == nil {
  33025. return
  33026. }
  33027. return *v, true
  33028. }
  33029. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  33030. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  33031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33032. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  33033. if !m.op.Is(OpUpdateOne) {
  33034. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  33035. }
  33036. if m.id == nil || m.oldValue == nil {
  33037. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  33038. }
  33039. oldValue, err := m.oldValue(ctx)
  33040. if err != nil {
  33041. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  33042. }
  33043. return oldValue.CustomAgentKey, nil
  33044. }
  33045. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  33046. func (m *TokenMutation) ClearCustomAgentKey() {
  33047. m.custom_agent_key = nil
  33048. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  33049. }
  33050. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  33051. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  33052. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  33053. return ok
  33054. }
  33055. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  33056. func (m *TokenMutation) ResetCustomAgentKey() {
  33057. m.custom_agent_key = nil
  33058. delete(m.clearedFields, token.FieldCustomAgentKey)
  33059. }
  33060. // SetOpenaiBase sets the "openai_base" field.
  33061. func (m *TokenMutation) SetOpenaiBase(s string) {
  33062. m.openai_base = &s
  33063. }
  33064. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  33065. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  33066. v := m.openai_base
  33067. if v == nil {
  33068. return
  33069. }
  33070. return *v, true
  33071. }
  33072. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  33073. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  33074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33075. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  33076. if !m.op.Is(OpUpdateOne) {
  33077. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  33078. }
  33079. if m.id == nil || m.oldValue == nil {
  33080. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  33081. }
  33082. oldValue, err := m.oldValue(ctx)
  33083. if err != nil {
  33084. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  33085. }
  33086. return oldValue.OpenaiBase, nil
  33087. }
  33088. // ClearOpenaiBase clears the value of the "openai_base" field.
  33089. func (m *TokenMutation) ClearOpenaiBase() {
  33090. m.openai_base = nil
  33091. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  33092. }
  33093. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  33094. func (m *TokenMutation) OpenaiBaseCleared() bool {
  33095. _, ok := m.clearedFields[token.FieldOpenaiBase]
  33096. return ok
  33097. }
  33098. // ResetOpenaiBase resets all changes to the "openai_base" field.
  33099. func (m *TokenMutation) ResetOpenaiBase() {
  33100. m.openai_base = nil
  33101. delete(m.clearedFields, token.FieldOpenaiBase)
  33102. }
  33103. // SetOpenaiKey sets the "openai_key" field.
  33104. func (m *TokenMutation) SetOpenaiKey(s string) {
  33105. m.openai_key = &s
  33106. }
  33107. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  33108. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  33109. v := m.openai_key
  33110. if v == nil {
  33111. return
  33112. }
  33113. return *v, true
  33114. }
  33115. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  33116. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  33117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33118. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  33119. if !m.op.Is(OpUpdateOne) {
  33120. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  33121. }
  33122. if m.id == nil || m.oldValue == nil {
  33123. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  33124. }
  33125. oldValue, err := m.oldValue(ctx)
  33126. if err != nil {
  33127. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  33128. }
  33129. return oldValue.OpenaiKey, nil
  33130. }
  33131. // ClearOpenaiKey clears the value of the "openai_key" field.
  33132. func (m *TokenMutation) ClearOpenaiKey() {
  33133. m.openai_key = nil
  33134. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  33135. }
  33136. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  33137. func (m *TokenMutation) OpenaiKeyCleared() bool {
  33138. _, ok := m.clearedFields[token.FieldOpenaiKey]
  33139. return ok
  33140. }
  33141. // ResetOpenaiKey resets all changes to the "openai_key" field.
  33142. func (m *TokenMutation) ResetOpenaiKey() {
  33143. m.openai_key = nil
  33144. delete(m.clearedFields, token.FieldOpenaiKey)
  33145. }
  33146. // ClearAgent clears the "agent" edge to the Agent entity.
  33147. func (m *TokenMutation) ClearAgent() {
  33148. m.clearedagent = true
  33149. m.clearedFields[token.FieldAgentID] = struct{}{}
  33150. }
  33151. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  33152. func (m *TokenMutation) AgentCleared() bool {
  33153. return m.clearedagent
  33154. }
  33155. // AgentIDs returns the "agent" edge IDs in the mutation.
  33156. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33157. // AgentID instead. It exists only for internal usage by the builders.
  33158. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  33159. if id := m.agent; id != nil {
  33160. ids = append(ids, *id)
  33161. }
  33162. return
  33163. }
  33164. // ResetAgent resets all changes to the "agent" edge.
  33165. func (m *TokenMutation) ResetAgent() {
  33166. m.agent = nil
  33167. m.clearedagent = false
  33168. }
  33169. // Where appends a list predicates to the TokenMutation builder.
  33170. func (m *TokenMutation) Where(ps ...predicate.Token) {
  33171. m.predicates = append(m.predicates, ps...)
  33172. }
  33173. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  33174. // users can use type-assertion to append predicates that do not depend on any generated package.
  33175. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  33176. p := make([]predicate.Token, len(ps))
  33177. for i := range ps {
  33178. p[i] = ps[i]
  33179. }
  33180. m.Where(p...)
  33181. }
  33182. // Op returns the operation name.
  33183. func (m *TokenMutation) Op() Op {
  33184. return m.op
  33185. }
  33186. // SetOp allows setting the mutation operation.
  33187. func (m *TokenMutation) SetOp(op Op) {
  33188. m.op = op
  33189. }
  33190. // Type returns the node type of this mutation (Token).
  33191. func (m *TokenMutation) Type() string {
  33192. return m.typ
  33193. }
  33194. // Fields returns all fields that were changed during this mutation. Note that in
  33195. // order to get all numeric fields that were incremented/decremented, call
  33196. // AddedFields().
  33197. func (m *TokenMutation) Fields() []string {
  33198. fields := make([]string, 0, 12)
  33199. if m.created_at != nil {
  33200. fields = append(fields, token.FieldCreatedAt)
  33201. }
  33202. if m.updated_at != nil {
  33203. fields = append(fields, token.FieldUpdatedAt)
  33204. }
  33205. if m.deleted_at != nil {
  33206. fields = append(fields, token.FieldDeletedAt)
  33207. }
  33208. if m.expire_at != nil {
  33209. fields = append(fields, token.FieldExpireAt)
  33210. }
  33211. if m.token != nil {
  33212. fields = append(fields, token.FieldToken)
  33213. }
  33214. if m.mac != nil {
  33215. fields = append(fields, token.FieldMAC)
  33216. }
  33217. if m.organization_id != nil {
  33218. fields = append(fields, token.FieldOrganizationID)
  33219. }
  33220. if m.agent != nil {
  33221. fields = append(fields, token.FieldAgentID)
  33222. }
  33223. if m.custom_agent_base != nil {
  33224. fields = append(fields, token.FieldCustomAgentBase)
  33225. }
  33226. if m.custom_agent_key != nil {
  33227. fields = append(fields, token.FieldCustomAgentKey)
  33228. }
  33229. if m.openai_base != nil {
  33230. fields = append(fields, token.FieldOpenaiBase)
  33231. }
  33232. if m.openai_key != nil {
  33233. fields = append(fields, token.FieldOpenaiKey)
  33234. }
  33235. return fields
  33236. }
  33237. // Field returns the value of a field with the given name. The second boolean
  33238. // return value indicates that this field was not set, or was not defined in the
  33239. // schema.
  33240. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  33241. switch name {
  33242. case token.FieldCreatedAt:
  33243. return m.CreatedAt()
  33244. case token.FieldUpdatedAt:
  33245. return m.UpdatedAt()
  33246. case token.FieldDeletedAt:
  33247. return m.DeletedAt()
  33248. case token.FieldExpireAt:
  33249. return m.ExpireAt()
  33250. case token.FieldToken:
  33251. return m.Token()
  33252. case token.FieldMAC:
  33253. return m.MAC()
  33254. case token.FieldOrganizationID:
  33255. return m.OrganizationID()
  33256. case token.FieldAgentID:
  33257. return m.AgentID()
  33258. case token.FieldCustomAgentBase:
  33259. return m.CustomAgentBase()
  33260. case token.FieldCustomAgentKey:
  33261. return m.CustomAgentKey()
  33262. case token.FieldOpenaiBase:
  33263. return m.OpenaiBase()
  33264. case token.FieldOpenaiKey:
  33265. return m.OpenaiKey()
  33266. }
  33267. return nil, false
  33268. }
  33269. // OldField returns the old value of the field from the database. An error is
  33270. // returned if the mutation operation is not UpdateOne, or the query to the
  33271. // database failed.
  33272. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33273. switch name {
  33274. case token.FieldCreatedAt:
  33275. return m.OldCreatedAt(ctx)
  33276. case token.FieldUpdatedAt:
  33277. return m.OldUpdatedAt(ctx)
  33278. case token.FieldDeletedAt:
  33279. return m.OldDeletedAt(ctx)
  33280. case token.FieldExpireAt:
  33281. return m.OldExpireAt(ctx)
  33282. case token.FieldToken:
  33283. return m.OldToken(ctx)
  33284. case token.FieldMAC:
  33285. return m.OldMAC(ctx)
  33286. case token.FieldOrganizationID:
  33287. return m.OldOrganizationID(ctx)
  33288. case token.FieldAgentID:
  33289. return m.OldAgentID(ctx)
  33290. case token.FieldCustomAgentBase:
  33291. return m.OldCustomAgentBase(ctx)
  33292. case token.FieldCustomAgentKey:
  33293. return m.OldCustomAgentKey(ctx)
  33294. case token.FieldOpenaiBase:
  33295. return m.OldOpenaiBase(ctx)
  33296. case token.FieldOpenaiKey:
  33297. return m.OldOpenaiKey(ctx)
  33298. }
  33299. return nil, fmt.Errorf("unknown Token field %s", name)
  33300. }
  33301. // SetField sets the value of a field with the given name. It returns an error if
  33302. // the field is not defined in the schema, or if the type mismatched the field
  33303. // type.
  33304. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  33305. switch name {
  33306. case token.FieldCreatedAt:
  33307. v, ok := value.(time.Time)
  33308. if !ok {
  33309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33310. }
  33311. m.SetCreatedAt(v)
  33312. return nil
  33313. case token.FieldUpdatedAt:
  33314. v, ok := value.(time.Time)
  33315. if !ok {
  33316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33317. }
  33318. m.SetUpdatedAt(v)
  33319. return nil
  33320. case token.FieldDeletedAt:
  33321. v, ok := value.(time.Time)
  33322. if !ok {
  33323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33324. }
  33325. m.SetDeletedAt(v)
  33326. return nil
  33327. case token.FieldExpireAt:
  33328. v, ok := value.(time.Time)
  33329. if !ok {
  33330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33331. }
  33332. m.SetExpireAt(v)
  33333. return nil
  33334. case token.FieldToken:
  33335. v, ok := value.(string)
  33336. if !ok {
  33337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33338. }
  33339. m.SetToken(v)
  33340. return nil
  33341. case token.FieldMAC:
  33342. v, ok := value.(string)
  33343. if !ok {
  33344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33345. }
  33346. m.SetMAC(v)
  33347. return nil
  33348. case token.FieldOrganizationID:
  33349. v, ok := value.(uint64)
  33350. if !ok {
  33351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33352. }
  33353. m.SetOrganizationID(v)
  33354. return nil
  33355. case token.FieldAgentID:
  33356. v, ok := value.(uint64)
  33357. if !ok {
  33358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33359. }
  33360. m.SetAgentID(v)
  33361. return nil
  33362. case token.FieldCustomAgentBase:
  33363. v, ok := value.(string)
  33364. if !ok {
  33365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33366. }
  33367. m.SetCustomAgentBase(v)
  33368. return nil
  33369. case token.FieldCustomAgentKey:
  33370. v, ok := value.(string)
  33371. if !ok {
  33372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33373. }
  33374. m.SetCustomAgentKey(v)
  33375. return nil
  33376. case token.FieldOpenaiBase:
  33377. v, ok := value.(string)
  33378. if !ok {
  33379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33380. }
  33381. m.SetOpenaiBase(v)
  33382. return nil
  33383. case token.FieldOpenaiKey:
  33384. v, ok := value.(string)
  33385. if !ok {
  33386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33387. }
  33388. m.SetOpenaiKey(v)
  33389. return nil
  33390. }
  33391. return fmt.Errorf("unknown Token field %s", name)
  33392. }
  33393. // AddedFields returns all numeric fields that were incremented/decremented during
  33394. // this mutation.
  33395. func (m *TokenMutation) AddedFields() []string {
  33396. var fields []string
  33397. if m.addorganization_id != nil {
  33398. fields = append(fields, token.FieldOrganizationID)
  33399. }
  33400. return fields
  33401. }
  33402. // AddedField returns the numeric value that was incremented/decremented on a field
  33403. // with the given name. The second boolean return value indicates that this field
  33404. // was not set, or was not defined in the schema.
  33405. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  33406. switch name {
  33407. case token.FieldOrganizationID:
  33408. return m.AddedOrganizationID()
  33409. }
  33410. return nil, false
  33411. }
  33412. // AddField adds the value to the field with the given name. It returns an error if
  33413. // the field is not defined in the schema, or if the type mismatched the field
  33414. // type.
  33415. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  33416. switch name {
  33417. case token.FieldOrganizationID:
  33418. v, ok := value.(int64)
  33419. if !ok {
  33420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33421. }
  33422. m.AddOrganizationID(v)
  33423. return nil
  33424. }
  33425. return fmt.Errorf("unknown Token numeric field %s", name)
  33426. }
  33427. // ClearedFields returns all nullable fields that were cleared during this
  33428. // mutation.
  33429. func (m *TokenMutation) ClearedFields() []string {
  33430. var fields []string
  33431. if m.FieldCleared(token.FieldDeletedAt) {
  33432. fields = append(fields, token.FieldDeletedAt)
  33433. }
  33434. if m.FieldCleared(token.FieldExpireAt) {
  33435. fields = append(fields, token.FieldExpireAt)
  33436. }
  33437. if m.FieldCleared(token.FieldToken) {
  33438. fields = append(fields, token.FieldToken)
  33439. }
  33440. if m.FieldCleared(token.FieldMAC) {
  33441. fields = append(fields, token.FieldMAC)
  33442. }
  33443. if m.FieldCleared(token.FieldCustomAgentBase) {
  33444. fields = append(fields, token.FieldCustomAgentBase)
  33445. }
  33446. if m.FieldCleared(token.FieldCustomAgentKey) {
  33447. fields = append(fields, token.FieldCustomAgentKey)
  33448. }
  33449. if m.FieldCleared(token.FieldOpenaiBase) {
  33450. fields = append(fields, token.FieldOpenaiBase)
  33451. }
  33452. if m.FieldCleared(token.FieldOpenaiKey) {
  33453. fields = append(fields, token.FieldOpenaiKey)
  33454. }
  33455. return fields
  33456. }
  33457. // FieldCleared returns a boolean indicating if a field with the given name was
  33458. // cleared in this mutation.
  33459. func (m *TokenMutation) FieldCleared(name string) bool {
  33460. _, ok := m.clearedFields[name]
  33461. return ok
  33462. }
  33463. // ClearField clears the value of the field with the given name. It returns an
  33464. // error if the field is not defined in the schema.
  33465. func (m *TokenMutation) ClearField(name string) error {
  33466. switch name {
  33467. case token.FieldDeletedAt:
  33468. m.ClearDeletedAt()
  33469. return nil
  33470. case token.FieldExpireAt:
  33471. m.ClearExpireAt()
  33472. return nil
  33473. case token.FieldToken:
  33474. m.ClearToken()
  33475. return nil
  33476. case token.FieldMAC:
  33477. m.ClearMAC()
  33478. return nil
  33479. case token.FieldCustomAgentBase:
  33480. m.ClearCustomAgentBase()
  33481. return nil
  33482. case token.FieldCustomAgentKey:
  33483. m.ClearCustomAgentKey()
  33484. return nil
  33485. case token.FieldOpenaiBase:
  33486. m.ClearOpenaiBase()
  33487. return nil
  33488. case token.FieldOpenaiKey:
  33489. m.ClearOpenaiKey()
  33490. return nil
  33491. }
  33492. return fmt.Errorf("unknown Token nullable field %s", name)
  33493. }
  33494. // ResetField resets all changes in the mutation for the field with the given name.
  33495. // It returns an error if the field is not defined in the schema.
  33496. func (m *TokenMutation) ResetField(name string) error {
  33497. switch name {
  33498. case token.FieldCreatedAt:
  33499. m.ResetCreatedAt()
  33500. return nil
  33501. case token.FieldUpdatedAt:
  33502. m.ResetUpdatedAt()
  33503. return nil
  33504. case token.FieldDeletedAt:
  33505. m.ResetDeletedAt()
  33506. return nil
  33507. case token.FieldExpireAt:
  33508. m.ResetExpireAt()
  33509. return nil
  33510. case token.FieldToken:
  33511. m.ResetToken()
  33512. return nil
  33513. case token.FieldMAC:
  33514. m.ResetMAC()
  33515. return nil
  33516. case token.FieldOrganizationID:
  33517. m.ResetOrganizationID()
  33518. return nil
  33519. case token.FieldAgentID:
  33520. m.ResetAgentID()
  33521. return nil
  33522. case token.FieldCustomAgentBase:
  33523. m.ResetCustomAgentBase()
  33524. return nil
  33525. case token.FieldCustomAgentKey:
  33526. m.ResetCustomAgentKey()
  33527. return nil
  33528. case token.FieldOpenaiBase:
  33529. m.ResetOpenaiBase()
  33530. return nil
  33531. case token.FieldOpenaiKey:
  33532. m.ResetOpenaiKey()
  33533. return nil
  33534. }
  33535. return fmt.Errorf("unknown Token field %s", name)
  33536. }
  33537. // AddedEdges returns all edge names that were set/added in this mutation.
  33538. func (m *TokenMutation) AddedEdges() []string {
  33539. edges := make([]string, 0, 1)
  33540. if m.agent != nil {
  33541. edges = append(edges, token.EdgeAgent)
  33542. }
  33543. return edges
  33544. }
  33545. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33546. // name in this mutation.
  33547. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  33548. switch name {
  33549. case token.EdgeAgent:
  33550. if id := m.agent; id != nil {
  33551. return []ent.Value{*id}
  33552. }
  33553. }
  33554. return nil
  33555. }
  33556. // RemovedEdges returns all edge names that were removed in this mutation.
  33557. func (m *TokenMutation) RemovedEdges() []string {
  33558. edges := make([]string, 0, 1)
  33559. return edges
  33560. }
  33561. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33562. // the given name in this mutation.
  33563. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  33564. return nil
  33565. }
  33566. // ClearedEdges returns all edge names that were cleared in this mutation.
  33567. func (m *TokenMutation) ClearedEdges() []string {
  33568. edges := make([]string, 0, 1)
  33569. if m.clearedagent {
  33570. edges = append(edges, token.EdgeAgent)
  33571. }
  33572. return edges
  33573. }
  33574. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33575. // was cleared in this mutation.
  33576. func (m *TokenMutation) EdgeCleared(name string) bool {
  33577. switch name {
  33578. case token.EdgeAgent:
  33579. return m.clearedagent
  33580. }
  33581. return false
  33582. }
  33583. // ClearEdge clears the value of the edge with the given name. It returns an error
  33584. // if that edge is not defined in the schema.
  33585. func (m *TokenMutation) ClearEdge(name string) error {
  33586. switch name {
  33587. case token.EdgeAgent:
  33588. m.ClearAgent()
  33589. return nil
  33590. }
  33591. return fmt.Errorf("unknown Token unique edge %s", name)
  33592. }
  33593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33594. // It returns an error if the edge is not defined in the schema.
  33595. func (m *TokenMutation) ResetEdge(name string) error {
  33596. switch name {
  33597. case token.EdgeAgent:
  33598. m.ResetAgent()
  33599. return nil
  33600. }
  33601. return fmt.Errorf("unknown Token edge %s", name)
  33602. }
  33603. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  33604. type TutorialMutation struct {
  33605. config
  33606. op Op
  33607. typ string
  33608. id *uint64
  33609. created_at *time.Time
  33610. updated_at *time.Time
  33611. deleted_at *time.Time
  33612. index *int
  33613. addindex *int
  33614. title *string
  33615. content *string
  33616. organization_id *uint64
  33617. addorganization_id *int64
  33618. clearedFields map[string]struct{}
  33619. employee *uint64
  33620. clearedemployee bool
  33621. done bool
  33622. oldValue func(context.Context) (*Tutorial, error)
  33623. predicates []predicate.Tutorial
  33624. }
  33625. var _ ent.Mutation = (*TutorialMutation)(nil)
  33626. // tutorialOption allows management of the mutation configuration using functional options.
  33627. type tutorialOption func(*TutorialMutation)
  33628. // newTutorialMutation creates new mutation for the Tutorial entity.
  33629. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  33630. m := &TutorialMutation{
  33631. config: c,
  33632. op: op,
  33633. typ: TypeTutorial,
  33634. clearedFields: make(map[string]struct{}),
  33635. }
  33636. for _, opt := range opts {
  33637. opt(m)
  33638. }
  33639. return m
  33640. }
  33641. // withTutorialID sets the ID field of the mutation.
  33642. func withTutorialID(id uint64) tutorialOption {
  33643. return func(m *TutorialMutation) {
  33644. var (
  33645. err error
  33646. once sync.Once
  33647. value *Tutorial
  33648. )
  33649. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  33650. once.Do(func() {
  33651. if m.done {
  33652. err = errors.New("querying old values post mutation is not allowed")
  33653. } else {
  33654. value, err = m.Client().Tutorial.Get(ctx, id)
  33655. }
  33656. })
  33657. return value, err
  33658. }
  33659. m.id = &id
  33660. }
  33661. }
  33662. // withTutorial sets the old Tutorial of the mutation.
  33663. func withTutorial(node *Tutorial) tutorialOption {
  33664. return func(m *TutorialMutation) {
  33665. m.oldValue = func(context.Context) (*Tutorial, error) {
  33666. return node, nil
  33667. }
  33668. m.id = &node.ID
  33669. }
  33670. }
  33671. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33672. // executed in a transaction (ent.Tx), a transactional client is returned.
  33673. func (m TutorialMutation) Client() *Client {
  33674. client := &Client{config: m.config}
  33675. client.init()
  33676. return client
  33677. }
  33678. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33679. // it returns an error otherwise.
  33680. func (m TutorialMutation) Tx() (*Tx, error) {
  33681. if _, ok := m.driver.(*txDriver); !ok {
  33682. return nil, errors.New("ent: mutation is not running in a transaction")
  33683. }
  33684. tx := &Tx{config: m.config}
  33685. tx.init()
  33686. return tx, nil
  33687. }
  33688. // SetID sets the value of the id field. Note that this
  33689. // operation is only accepted on creation of Tutorial entities.
  33690. func (m *TutorialMutation) SetID(id uint64) {
  33691. m.id = &id
  33692. }
  33693. // ID returns the ID value in the mutation. Note that the ID is only available
  33694. // if it was provided to the builder or after it was returned from the database.
  33695. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  33696. if m.id == nil {
  33697. return
  33698. }
  33699. return *m.id, true
  33700. }
  33701. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33702. // That means, if the mutation is applied within a transaction with an isolation level such
  33703. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33704. // or updated by the mutation.
  33705. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  33706. switch {
  33707. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33708. id, exists := m.ID()
  33709. if exists {
  33710. return []uint64{id}, nil
  33711. }
  33712. fallthrough
  33713. case m.op.Is(OpUpdate | OpDelete):
  33714. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  33715. default:
  33716. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33717. }
  33718. }
  33719. // SetCreatedAt sets the "created_at" field.
  33720. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  33721. m.created_at = &t
  33722. }
  33723. // CreatedAt returns the value of the "created_at" field in the mutation.
  33724. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  33725. v := m.created_at
  33726. if v == nil {
  33727. return
  33728. }
  33729. return *v, true
  33730. }
  33731. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  33732. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33734. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33735. if !m.op.Is(OpUpdateOne) {
  33736. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33737. }
  33738. if m.id == nil || m.oldValue == nil {
  33739. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33740. }
  33741. oldValue, err := m.oldValue(ctx)
  33742. if err != nil {
  33743. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33744. }
  33745. return oldValue.CreatedAt, nil
  33746. }
  33747. // ResetCreatedAt resets all changes to the "created_at" field.
  33748. func (m *TutorialMutation) ResetCreatedAt() {
  33749. m.created_at = nil
  33750. }
  33751. // SetUpdatedAt sets the "updated_at" field.
  33752. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  33753. m.updated_at = &t
  33754. }
  33755. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33756. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  33757. v := m.updated_at
  33758. if v == nil {
  33759. return
  33760. }
  33761. return *v, true
  33762. }
  33763. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  33764. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33766. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33767. if !m.op.Is(OpUpdateOne) {
  33768. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33769. }
  33770. if m.id == nil || m.oldValue == nil {
  33771. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33772. }
  33773. oldValue, err := m.oldValue(ctx)
  33774. if err != nil {
  33775. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33776. }
  33777. return oldValue.UpdatedAt, nil
  33778. }
  33779. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33780. func (m *TutorialMutation) ResetUpdatedAt() {
  33781. m.updated_at = nil
  33782. }
  33783. // SetDeletedAt sets the "deleted_at" field.
  33784. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  33785. m.deleted_at = &t
  33786. }
  33787. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33788. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  33789. v := m.deleted_at
  33790. if v == nil {
  33791. return
  33792. }
  33793. return *v, true
  33794. }
  33795. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  33796. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33798. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33799. if !m.op.Is(OpUpdateOne) {
  33800. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33801. }
  33802. if m.id == nil || m.oldValue == nil {
  33803. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33804. }
  33805. oldValue, err := m.oldValue(ctx)
  33806. if err != nil {
  33807. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33808. }
  33809. return oldValue.DeletedAt, nil
  33810. }
  33811. // ClearDeletedAt clears the value of the "deleted_at" field.
  33812. func (m *TutorialMutation) ClearDeletedAt() {
  33813. m.deleted_at = nil
  33814. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  33815. }
  33816. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33817. func (m *TutorialMutation) DeletedAtCleared() bool {
  33818. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  33819. return ok
  33820. }
  33821. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33822. func (m *TutorialMutation) ResetDeletedAt() {
  33823. m.deleted_at = nil
  33824. delete(m.clearedFields, tutorial.FieldDeletedAt)
  33825. }
  33826. // SetEmployeeID sets the "employee_id" field.
  33827. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  33828. m.employee = &u
  33829. }
  33830. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33831. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  33832. v := m.employee
  33833. if v == nil {
  33834. return
  33835. }
  33836. return *v, true
  33837. }
  33838. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  33839. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33841. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33842. if !m.op.Is(OpUpdateOne) {
  33843. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33844. }
  33845. if m.id == nil || m.oldValue == nil {
  33846. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33847. }
  33848. oldValue, err := m.oldValue(ctx)
  33849. if err != nil {
  33850. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33851. }
  33852. return oldValue.EmployeeID, nil
  33853. }
  33854. // ResetEmployeeID resets all changes to the "employee_id" field.
  33855. func (m *TutorialMutation) ResetEmployeeID() {
  33856. m.employee = nil
  33857. }
  33858. // SetIndex sets the "index" field.
  33859. func (m *TutorialMutation) SetIndex(i int) {
  33860. m.index = &i
  33861. m.addindex = nil
  33862. }
  33863. // Index returns the value of the "index" field in the mutation.
  33864. func (m *TutorialMutation) Index() (r int, exists bool) {
  33865. v := m.index
  33866. if v == nil {
  33867. return
  33868. }
  33869. return *v, true
  33870. }
  33871. // OldIndex returns the old "index" field's value of the Tutorial entity.
  33872. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33874. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  33875. if !m.op.Is(OpUpdateOne) {
  33876. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  33877. }
  33878. if m.id == nil || m.oldValue == nil {
  33879. return v, errors.New("OldIndex requires an ID field in the mutation")
  33880. }
  33881. oldValue, err := m.oldValue(ctx)
  33882. if err != nil {
  33883. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  33884. }
  33885. return oldValue.Index, nil
  33886. }
  33887. // AddIndex adds i to the "index" field.
  33888. func (m *TutorialMutation) AddIndex(i int) {
  33889. if m.addindex != nil {
  33890. *m.addindex += i
  33891. } else {
  33892. m.addindex = &i
  33893. }
  33894. }
  33895. // AddedIndex returns the value that was added to the "index" field in this mutation.
  33896. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  33897. v := m.addindex
  33898. if v == nil {
  33899. return
  33900. }
  33901. return *v, true
  33902. }
  33903. // ResetIndex resets all changes to the "index" field.
  33904. func (m *TutorialMutation) ResetIndex() {
  33905. m.index = nil
  33906. m.addindex = nil
  33907. }
  33908. // SetTitle sets the "title" field.
  33909. func (m *TutorialMutation) SetTitle(s string) {
  33910. m.title = &s
  33911. }
  33912. // Title returns the value of the "title" field in the mutation.
  33913. func (m *TutorialMutation) Title() (r string, exists bool) {
  33914. v := m.title
  33915. if v == nil {
  33916. return
  33917. }
  33918. return *v, true
  33919. }
  33920. // OldTitle returns the old "title" field's value of the Tutorial entity.
  33921. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33923. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  33924. if !m.op.Is(OpUpdateOne) {
  33925. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  33926. }
  33927. if m.id == nil || m.oldValue == nil {
  33928. return v, errors.New("OldTitle requires an ID field in the mutation")
  33929. }
  33930. oldValue, err := m.oldValue(ctx)
  33931. if err != nil {
  33932. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  33933. }
  33934. return oldValue.Title, nil
  33935. }
  33936. // ResetTitle resets all changes to the "title" field.
  33937. func (m *TutorialMutation) ResetTitle() {
  33938. m.title = nil
  33939. }
  33940. // SetContent sets the "content" field.
  33941. func (m *TutorialMutation) SetContent(s string) {
  33942. m.content = &s
  33943. }
  33944. // Content returns the value of the "content" field in the mutation.
  33945. func (m *TutorialMutation) Content() (r string, exists bool) {
  33946. v := m.content
  33947. if v == nil {
  33948. return
  33949. }
  33950. return *v, true
  33951. }
  33952. // OldContent returns the old "content" field's value of the Tutorial entity.
  33953. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33955. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  33956. if !m.op.Is(OpUpdateOne) {
  33957. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  33958. }
  33959. if m.id == nil || m.oldValue == nil {
  33960. return v, errors.New("OldContent requires an ID field in the mutation")
  33961. }
  33962. oldValue, err := m.oldValue(ctx)
  33963. if err != nil {
  33964. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  33965. }
  33966. return oldValue.Content, nil
  33967. }
  33968. // ResetContent resets all changes to the "content" field.
  33969. func (m *TutorialMutation) ResetContent() {
  33970. m.content = nil
  33971. }
  33972. // SetOrganizationID sets the "organization_id" field.
  33973. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  33974. m.organization_id = &u
  33975. m.addorganization_id = nil
  33976. }
  33977. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33978. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  33979. v := m.organization_id
  33980. if v == nil {
  33981. return
  33982. }
  33983. return *v, true
  33984. }
  33985. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  33986. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33988. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33989. if !m.op.Is(OpUpdateOne) {
  33990. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33991. }
  33992. if m.id == nil || m.oldValue == nil {
  33993. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33994. }
  33995. oldValue, err := m.oldValue(ctx)
  33996. if err != nil {
  33997. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33998. }
  33999. return oldValue.OrganizationID, nil
  34000. }
  34001. // AddOrganizationID adds u to the "organization_id" field.
  34002. func (m *TutorialMutation) AddOrganizationID(u int64) {
  34003. if m.addorganization_id != nil {
  34004. *m.addorganization_id += u
  34005. } else {
  34006. m.addorganization_id = &u
  34007. }
  34008. }
  34009. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34010. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  34011. v := m.addorganization_id
  34012. if v == nil {
  34013. return
  34014. }
  34015. return *v, true
  34016. }
  34017. // ResetOrganizationID resets all changes to the "organization_id" field.
  34018. func (m *TutorialMutation) ResetOrganizationID() {
  34019. m.organization_id = nil
  34020. m.addorganization_id = nil
  34021. }
  34022. // ClearEmployee clears the "employee" edge to the Employee entity.
  34023. func (m *TutorialMutation) ClearEmployee() {
  34024. m.clearedemployee = true
  34025. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  34026. }
  34027. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  34028. func (m *TutorialMutation) EmployeeCleared() bool {
  34029. return m.clearedemployee
  34030. }
  34031. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  34032. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34033. // EmployeeID instead. It exists only for internal usage by the builders.
  34034. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  34035. if id := m.employee; id != nil {
  34036. ids = append(ids, *id)
  34037. }
  34038. return
  34039. }
  34040. // ResetEmployee resets all changes to the "employee" edge.
  34041. func (m *TutorialMutation) ResetEmployee() {
  34042. m.employee = nil
  34043. m.clearedemployee = false
  34044. }
  34045. // Where appends a list predicates to the TutorialMutation builder.
  34046. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  34047. m.predicates = append(m.predicates, ps...)
  34048. }
  34049. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  34050. // users can use type-assertion to append predicates that do not depend on any generated package.
  34051. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  34052. p := make([]predicate.Tutorial, len(ps))
  34053. for i := range ps {
  34054. p[i] = ps[i]
  34055. }
  34056. m.Where(p...)
  34057. }
  34058. // Op returns the operation name.
  34059. func (m *TutorialMutation) Op() Op {
  34060. return m.op
  34061. }
  34062. // SetOp allows setting the mutation operation.
  34063. func (m *TutorialMutation) SetOp(op Op) {
  34064. m.op = op
  34065. }
  34066. // Type returns the node type of this mutation (Tutorial).
  34067. func (m *TutorialMutation) Type() string {
  34068. return m.typ
  34069. }
  34070. // Fields returns all fields that were changed during this mutation. Note that in
  34071. // order to get all numeric fields that were incremented/decremented, call
  34072. // AddedFields().
  34073. func (m *TutorialMutation) Fields() []string {
  34074. fields := make([]string, 0, 8)
  34075. if m.created_at != nil {
  34076. fields = append(fields, tutorial.FieldCreatedAt)
  34077. }
  34078. if m.updated_at != nil {
  34079. fields = append(fields, tutorial.FieldUpdatedAt)
  34080. }
  34081. if m.deleted_at != nil {
  34082. fields = append(fields, tutorial.FieldDeletedAt)
  34083. }
  34084. if m.employee != nil {
  34085. fields = append(fields, tutorial.FieldEmployeeID)
  34086. }
  34087. if m.index != nil {
  34088. fields = append(fields, tutorial.FieldIndex)
  34089. }
  34090. if m.title != nil {
  34091. fields = append(fields, tutorial.FieldTitle)
  34092. }
  34093. if m.content != nil {
  34094. fields = append(fields, tutorial.FieldContent)
  34095. }
  34096. if m.organization_id != nil {
  34097. fields = append(fields, tutorial.FieldOrganizationID)
  34098. }
  34099. return fields
  34100. }
  34101. // Field returns the value of a field with the given name. The second boolean
  34102. // return value indicates that this field was not set, or was not defined in the
  34103. // schema.
  34104. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  34105. switch name {
  34106. case tutorial.FieldCreatedAt:
  34107. return m.CreatedAt()
  34108. case tutorial.FieldUpdatedAt:
  34109. return m.UpdatedAt()
  34110. case tutorial.FieldDeletedAt:
  34111. return m.DeletedAt()
  34112. case tutorial.FieldEmployeeID:
  34113. return m.EmployeeID()
  34114. case tutorial.FieldIndex:
  34115. return m.Index()
  34116. case tutorial.FieldTitle:
  34117. return m.Title()
  34118. case tutorial.FieldContent:
  34119. return m.Content()
  34120. case tutorial.FieldOrganizationID:
  34121. return m.OrganizationID()
  34122. }
  34123. return nil, false
  34124. }
  34125. // OldField returns the old value of the field from the database. An error is
  34126. // returned if the mutation operation is not UpdateOne, or the query to the
  34127. // database failed.
  34128. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34129. switch name {
  34130. case tutorial.FieldCreatedAt:
  34131. return m.OldCreatedAt(ctx)
  34132. case tutorial.FieldUpdatedAt:
  34133. return m.OldUpdatedAt(ctx)
  34134. case tutorial.FieldDeletedAt:
  34135. return m.OldDeletedAt(ctx)
  34136. case tutorial.FieldEmployeeID:
  34137. return m.OldEmployeeID(ctx)
  34138. case tutorial.FieldIndex:
  34139. return m.OldIndex(ctx)
  34140. case tutorial.FieldTitle:
  34141. return m.OldTitle(ctx)
  34142. case tutorial.FieldContent:
  34143. return m.OldContent(ctx)
  34144. case tutorial.FieldOrganizationID:
  34145. return m.OldOrganizationID(ctx)
  34146. }
  34147. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  34148. }
  34149. // SetField sets the value of a field with the given name. It returns an error if
  34150. // the field is not defined in the schema, or if the type mismatched the field
  34151. // type.
  34152. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  34153. switch name {
  34154. case tutorial.FieldCreatedAt:
  34155. v, ok := value.(time.Time)
  34156. if !ok {
  34157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34158. }
  34159. m.SetCreatedAt(v)
  34160. return nil
  34161. case tutorial.FieldUpdatedAt:
  34162. v, ok := value.(time.Time)
  34163. if !ok {
  34164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34165. }
  34166. m.SetUpdatedAt(v)
  34167. return nil
  34168. case tutorial.FieldDeletedAt:
  34169. v, ok := value.(time.Time)
  34170. if !ok {
  34171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34172. }
  34173. m.SetDeletedAt(v)
  34174. return nil
  34175. case tutorial.FieldEmployeeID:
  34176. v, ok := value.(uint64)
  34177. if !ok {
  34178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34179. }
  34180. m.SetEmployeeID(v)
  34181. return nil
  34182. case tutorial.FieldIndex:
  34183. v, ok := value.(int)
  34184. if !ok {
  34185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34186. }
  34187. m.SetIndex(v)
  34188. return nil
  34189. case tutorial.FieldTitle:
  34190. v, ok := value.(string)
  34191. if !ok {
  34192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34193. }
  34194. m.SetTitle(v)
  34195. return nil
  34196. case tutorial.FieldContent:
  34197. v, ok := value.(string)
  34198. if !ok {
  34199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34200. }
  34201. m.SetContent(v)
  34202. return nil
  34203. case tutorial.FieldOrganizationID:
  34204. v, ok := value.(uint64)
  34205. if !ok {
  34206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34207. }
  34208. m.SetOrganizationID(v)
  34209. return nil
  34210. }
  34211. return fmt.Errorf("unknown Tutorial field %s", name)
  34212. }
  34213. // AddedFields returns all numeric fields that were incremented/decremented during
  34214. // this mutation.
  34215. func (m *TutorialMutation) AddedFields() []string {
  34216. var fields []string
  34217. if m.addindex != nil {
  34218. fields = append(fields, tutorial.FieldIndex)
  34219. }
  34220. if m.addorganization_id != nil {
  34221. fields = append(fields, tutorial.FieldOrganizationID)
  34222. }
  34223. return fields
  34224. }
  34225. // AddedField returns the numeric value that was incremented/decremented on a field
  34226. // with the given name. The second boolean return value indicates that this field
  34227. // was not set, or was not defined in the schema.
  34228. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  34229. switch name {
  34230. case tutorial.FieldIndex:
  34231. return m.AddedIndex()
  34232. case tutorial.FieldOrganizationID:
  34233. return m.AddedOrganizationID()
  34234. }
  34235. return nil, false
  34236. }
  34237. // AddField adds the value to the field with the given name. It returns an error if
  34238. // the field is not defined in the schema, or if the type mismatched the field
  34239. // type.
  34240. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  34241. switch name {
  34242. case tutorial.FieldIndex:
  34243. v, ok := value.(int)
  34244. if !ok {
  34245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34246. }
  34247. m.AddIndex(v)
  34248. return nil
  34249. case tutorial.FieldOrganizationID:
  34250. v, ok := value.(int64)
  34251. if !ok {
  34252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34253. }
  34254. m.AddOrganizationID(v)
  34255. return nil
  34256. }
  34257. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  34258. }
  34259. // ClearedFields returns all nullable fields that were cleared during this
  34260. // mutation.
  34261. func (m *TutorialMutation) ClearedFields() []string {
  34262. var fields []string
  34263. if m.FieldCleared(tutorial.FieldDeletedAt) {
  34264. fields = append(fields, tutorial.FieldDeletedAt)
  34265. }
  34266. return fields
  34267. }
  34268. // FieldCleared returns a boolean indicating if a field with the given name was
  34269. // cleared in this mutation.
  34270. func (m *TutorialMutation) FieldCleared(name string) bool {
  34271. _, ok := m.clearedFields[name]
  34272. return ok
  34273. }
  34274. // ClearField clears the value of the field with the given name. It returns an
  34275. // error if the field is not defined in the schema.
  34276. func (m *TutorialMutation) ClearField(name string) error {
  34277. switch name {
  34278. case tutorial.FieldDeletedAt:
  34279. m.ClearDeletedAt()
  34280. return nil
  34281. }
  34282. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  34283. }
  34284. // ResetField resets all changes in the mutation for the field with the given name.
  34285. // It returns an error if the field is not defined in the schema.
  34286. func (m *TutorialMutation) ResetField(name string) error {
  34287. switch name {
  34288. case tutorial.FieldCreatedAt:
  34289. m.ResetCreatedAt()
  34290. return nil
  34291. case tutorial.FieldUpdatedAt:
  34292. m.ResetUpdatedAt()
  34293. return nil
  34294. case tutorial.FieldDeletedAt:
  34295. m.ResetDeletedAt()
  34296. return nil
  34297. case tutorial.FieldEmployeeID:
  34298. m.ResetEmployeeID()
  34299. return nil
  34300. case tutorial.FieldIndex:
  34301. m.ResetIndex()
  34302. return nil
  34303. case tutorial.FieldTitle:
  34304. m.ResetTitle()
  34305. return nil
  34306. case tutorial.FieldContent:
  34307. m.ResetContent()
  34308. return nil
  34309. case tutorial.FieldOrganizationID:
  34310. m.ResetOrganizationID()
  34311. return nil
  34312. }
  34313. return fmt.Errorf("unknown Tutorial field %s", name)
  34314. }
  34315. // AddedEdges returns all edge names that were set/added in this mutation.
  34316. func (m *TutorialMutation) AddedEdges() []string {
  34317. edges := make([]string, 0, 1)
  34318. if m.employee != nil {
  34319. edges = append(edges, tutorial.EdgeEmployee)
  34320. }
  34321. return edges
  34322. }
  34323. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34324. // name in this mutation.
  34325. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  34326. switch name {
  34327. case tutorial.EdgeEmployee:
  34328. if id := m.employee; id != nil {
  34329. return []ent.Value{*id}
  34330. }
  34331. }
  34332. return nil
  34333. }
  34334. // RemovedEdges returns all edge names that were removed in this mutation.
  34335. func (m *TutorialMutation) RemovedEdges() []string {
  34336. edges := make([]string, 0, 1)
  34337. return edges
  34338. }
  34339. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34340. // the given name in this mutation.
  34341. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  34342. return nil
  34343. }
  34344. // ClearedEdges returns all edge names that were cleared in this mutation.
  34345. func (m *TutorialMutation) ClearedEdges() []string {
  34346. edges := make([]string, 0, 1)
  34347. if m.clearedemployee {
  34348. edges = append(edges, tutorial.EdgeEmployee)
  34349. }
  34350. return edges
  34351. }
  34352. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34353. // was cleared in this mutation.
  34354. func (m *TutorialMutation) EdgeCleared(name string) bool {
  34355. switch name {
  34356. case tutorial.EdgeEmployee:
  34357. return m.clearedemployee
  34358. }
  34359. return false
  34360. }
  34361. // ClearEdge clears the value of the edge with the given name. It returns an error
  34362. // if that edge is not defined in the schema.
  34363. func (m *TutorialMutation) ClearEdge(name string) error {
  34364. switch name {
  34365. case tutorial.EdgeEmployee:
  34366. m.ClearEmployee()
  34367. return nil
  34368. }
  34369. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  34370. }
  34371. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34372. // It returns an error if the edge is not defined in the schema.
  34373. func (m *TutorialMutation) ResetEdge(name string) error {
  34374. switch name {
  34375. case tutorial.EdgeEmployee:
  34376. m.ResetEmployee()
  34377. return nil
  34378. }
  34379. return fmt.Errorf("unknown Tutorial edge %s", name)
  34380. }
  34381. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  34382. type UsageDetailMutation struct {
  34383. config
  34384. op Op
  34385. typ string
  34386. id *uint64
  34387. created_at *time.Time
  34388. updated_at *time.Time
  34389. status *uint8
  34390. addstatus *int8
  34391. _type *int
  34392. add_type *int
  34393. bot_id *string
  34394. receiver_id *string
  34395. app *int
  34396. addapp *int
  34397. session_id *uint64
  34398. addsession_id *int64
  34399. request *string
  34400. response *string
  34401. original_data *custom_types.OriginalData
  34402. total_tokens *uint64
  34403. addtotal_tokens *int64
  34404. prompt_tokens *uint64
  34405. addprompt_tokens *int64
  34406. completion_tokens *uint64
  34407. addcompletion_tokens *int64
  34408. organization_id *uint64
  34409. addorganization_id *int64
  34410. model *string
  34411. credits *float64
  34412. addcredits *float64
  34413. clearedFields map[string]struct{}
  34414. done bool
  34415. oldValue func(context.Context) (*UsageDetail, error)
  34416. predicates []predicate.UsageDetail
  34417. }
  34418. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  34419. // usagedetailOption allows management of the mutation configuration using functional options.
  34420. type usagedetailOption func(*UsageDetailMutation)
  34421. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  34422. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  34423. m := &UsageDetailMutation{
  34424. config: c,
  34425. op: op,
  34426. typ: TypeUsageDetail,
  34427. clearedFields: make(map[string]struct{}),
  34428. }
  34429. for _, opt := range opts {
  34430. opt(m)
  34431. }
  34432. return m
  34433. }
  34434. // withUsageDetailID sets the ID field of the mutation.
  34435. func withUsageDetailID(id uint64) usagedetailOption {
  34436. return func(m *UsageDetailMutation) {
  34437. var (
  34438. err error
  34439. once sync.Once
  34440. value *UsageDetail
  34441. )
  34442. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  34443. once.Do(func() {
  34444. if m.done {
  34445. err = errors.New("querying old values post mutation is not allowed")
  34446. } else {
  34447. value, err = m.Client().UsageDetail.Get(ctx, id)
  34448. }
  34449. })
  34450. return value, err
  34451. }
  34452. m.id = &id
  34453. }
  34454. }
  34455. // withUsageDetail sets the old UsageDetail of the mutation.
  34456. func withUsageDetail(node *UsageDetail) usagedetailOption {
  34457. return func(m *UsageDetailMutation) {
  34458. m.oldValue = func(context.Context) (*UsageDetail, error) {
  34459. return node, nil
  34460. }
  34461. m.id = &node.ID
  34462. }
  34463. }
  34464. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34465. // executed in a transaction (ent.Tx), a transactional client is returned.
  34466. func (m UsageDetailMutation) Client() *Client {
  34467. client := &Client{config: m.config}
  34468. client.init()
  34469. return client
  34470. }
  34471. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34472. // it returns an error otherwise.
  34473. func (m UsageDetailMutation) Tx() (*Tx, error) {
  34474. if _, ok := m.driver.(*txDriver); !ok {
  34475. return nil, errors.New("ent: mutation is not running in a transaction")
  34476. }
  34477. tx := &Tx{config: m.config}
  34478. tx.init()
  34479. return tx, nil
  34480. }
  34481. // SetID sets the value of the id field. Note that this
  34482. // operation is only accepted on creation of UsageDetail entities.
  34483. func (m *UsageDetailMutation) SetID(id uint64) {
  34484. m.id = &id
  34485. }
  34486. // ID returns the ID value in the mutation. Note that the ID is only available
  34487. // if it was provided to the builder or after it was returned from the database.
  34488. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  34489. if m.id == nil {
  34490. return
  34491. }
  34492. return *m.id, true
  34493. }
  34494. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34495. // That means, if the mutation is applied within a transaction with an isolation level such
  34496. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34497. // or updated by the mutation.
  34498. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  34499. switch {
  34500. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34501. id, exists := m.ID()
  34502. if exists {
  34503. return []uint64{id}, nil
  34504. }
  34505. fallthrough
  34506. case m.op.Is(OpUpdate | OpDelete):
  34507. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  34508. default:
  34509. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34510. }
  34511. }
  34512. // SetCreatedAt sets the "created_at" field.
  34513. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  34514. m.created_at = &t
  34515. }
  34516. // CreatedAt returns the value of the "created_at" field in the mutation.
  34517. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  34518. v := m.created_at
  34519. if v == nil {
  34520. return
  34521. }
  34522. return *v, true
  34523. }
  34524. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  34525. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34527. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34528. if !m.op.Is(OpUpdateOne) {
  34529. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34530. }
  34531. if m.id == nil || m.oldValue == nil {
  34532. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34533. }
  34534. oldValue, err := m.oldValue(ctx)
  34535. if err != nil {
  34536. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34537. }
  34538. return oldValue.CreatedAt, nil
  34539. }
  34540. // ResetCreatedAt resets all changes to the "created_at" field.
  34541. func (m *UsageDetailMutation) ResetCreatedAt() {
  34542. m.created_at = nil
  34543. }
  34544. // SetUpdatedAt sets the "updated_at" field.
  34545. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  34546. m.updated_at = &t
  34547. }
  34548. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34549. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  34550. v := m.updated_at
  34551. if v == nil {
  34552. return
  34553. }
  34554. return *v, true
  34555. }
  34556. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  34557. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34559. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34560. if !m.op.Is(OpUpdateOne) {
  34561. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34562. }
  34563. if m.id == nil || m.oldValue == nil {
  34564. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34565. }
  34566. oldValue, err := m.oldValue(ctx)
  34567. if err != nil {
  34568. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34569. }
  34570. return oldValue.UpdatedAt, nil
  34571. }
  34572. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34573. func (m *UsageDetailMutation) ResetUpdatedAt() {
  34574. m.updated_at = nil
  34575. }
  34576. // SetStatus sets the "status" field.
  34577. func (m *UsageDetailMutation) SetStatus(u uint8) {
  34578. m.status = &u
  34579. m.addstatus = nil
  34580. }
  34581. // Status returns the value of the "status" field in the mutation.
  34582. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  34583. v := m.status
  34584. if v == nil {
  34585. return
  34586. }
  34587. return *v, true
  34588. }
  34589. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  34590. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34592. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34593. if !m.op.Is(OpUpdateOne) {
  34594. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34595. }
  34596. if m.id == nil || m.oldValue == nil {
  34597. return v, errors.New("OldStatus requires an ID field in the mutation")
  34598. }
  34599. oldValue, err := m.oldValue(ctx)
  34600. if err != nil {
  34601. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34602. }
  34603. return oldValue.Status, nil
  34604. }
  34605. // AddStatus adds u to the "status" field.
  34606. func (m *UsageDetailMutation) AddStatus(u int8) {
  34607. if m.addstatus != nil {
  34608. *m.addstatus += u
  34609. } else {
  34610. m.addstatus = &u
  34611. }
  34612. }
  34613. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34614. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  34615. v := m.addstatus
  34616. if v == nil {
  34617. return
  34618. }
  34619. return *v, true
  34620. }
  34621. // ClearStatus clears the value of the "status" field.
  34622. func (m *UsageDetailMutation) ClearStatus() {
  34623. m.status = nil
  34624. m.addstatus = nil
  34625. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  34626. }
  34627. // StatusCleared returns if the "status" field was cleared in this mutation.
  34628. func (m *UsageDetailMutation) StatusCleared() bool {
  34629. _, ok := m.clearedFields[usagedetail.FieldStatus]
  34630. return ok
  34631. }
  34632. // ResetStatus resets all changes to the "status" field.
  34633. func (m *UsageDetailMutation) ResetStatus() {
  34634. m.status = nil
  34635. m.addstatus = nil
  34636. delete(m.clearedFields, usagedetail.FieldStatus)
  34637. }
  34638. // SetType sets the "type" field.
  34639. func (m *UsageDetailMutation) SetType(i int) {
  34640. m._type = &i
  34641. m.add_type = nil
  34642. }
  34643. // GetType returns the value of the "type" field in the mutation.
  34644. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  34645. v := m._type
  34646. if v == nil {
  34647. return
  34648. }
  34649. return *v, true
  34650. }
  34651. // OldType returns the old "type" field's value of the UsageDetail entity.
  34652. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34654. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  34655. if !m.op.Is(OpUpdateOne) {
  34656. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34657. }
  34658. if m.id == nil || m.oldValue == nil {
  34659. return v, errors.New("OldType requires an ID field in the mutation")
  34660. }
  34661. oldValue, err := m.oldValue(ctx)
  34662. if err != nil {
  34663. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34664. }
  34665. return oldValue.Type, nil
  34666. }
  34667. // AddType adds i to the "type" field.
  34668. func (m *UsageDetailMutation) AddType(i int) {
  34669. if m.add_type != nil {
  34670. *m.add_type += i
  34671. } else {
  34672. m.add_type = &i
  34673. }
  34674. }
  34675. // AddedType returns the value that was added to the "type" field in this mutation.
  34676. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  34677. v := m.add_type
  34678. if v == nil {
  34679. return
  34680. }
  34681. return *v, true
  34682. }
  34683. // ClearType clears the value of the "type" field.
  34684. func (m *UsageDetailMutation) ClearType() {
  34685. m._type = nil
  34686. m.add_type = nil
  34687. m.clearedFields[usagedetail.FieldType] = struct{}{}
  34688. }
  34689. // TypeCleared returns if the "type" field was cleared in this mutation.
  34690. func (m *UsageDetailMutation) TypeCleared() bool {
  34691. _, ok := m.clearedFields[usagedetail.FieldType]
  34692. return ok
  34693. }
  34694. // ResetType resets all changes to the "type" field.
  34695. func (m *UsageDetailMutation) ResetType() {
  34696. m._type = nil
  34697. m.add_type = nil
  34698. delete(m.clearedFields, usagedetail.FieldType)
  34699. }
  34700. // SetBotID sets the "bot_id" field.
  34701. func (m *UsageDetailMutation) SetBotID(s string) {
  34702. m.bot_id = &s
  34703. }
  34704. // BotID returns the value of the "bot_id" field in the mutation.
  34705. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  34706. v := m.bot_id
  34707. if v == nil {
  34708. return
  34709. }
  34710. return *v, true
  34711. }
  34712. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  34713. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34715. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  34716. if !m.op.Is(OpUpdateOne) {
  34717. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34718. }
  34719. if m.id == nil || m.oldValue == nil {
  34720. return v, errors.New("OldBotID requires an ID field in the mutation")
  34721. }
  34722. oldValue, err := m.oldValue(ctx)
  34723. if err != nil {
  34724. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34725. }
  34726. return oldValue.BotID, nil
  34727. }
  34728. // ResetBotID resets all changes to the "bot_id" field.
  34729. func (m *UsageDetailMutation) ResetBotID() {
  34730. m.bot_id = nil
  34731. }
  34732. // SetReceiverID sets the "receiver_id" field.
  34733. func (m *UsageDetailMutation) SetReceiverID(s string) {
  34734. m.receiver_id = &s
  34735. }
  34736. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  34737. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  34738. v := m.receiver_id
  34739. if v == nil {
  34740. return
  34741. }
  34742. return *v, true
  34743. }
  34744. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  34745. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34747. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  34748. if !m.op.Is(OpUpdateOne) {
  34749. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  34750. }
  34751. if m.id == nil || m.oldValue == nil {
  34752. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  34753. }
  34754. oldValue, err := m.oldValue(ctx)
  34755. if err != nil {
  34756. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  34757. }
  34758. return oldValue.ReceiverID, nil
  34759. }
  34760. // ResetReceiverID resets all changes to the "receiver_id" field.
  34761. func (m *UsageDetailMutation) ResetReceiverID() {
  34762. m.receiver_id = nil
  34763. }
  34764. // SetApp sets the "app" field.
  34765. func (m *UsageDetailMutation) SetApp(i int) {
  34766. m.app = &i
  34767. m.addapp = nil
  34768. }
  34769. // App returns the value of the "app" field in the mutation.
  34770. func (m *UsageDetailMutation) App() (r int, exists bool) {
  34771. v := m.app
  34772. if v == nil {
  34773. return
  34774. }
  34775. return *v, true
  34776. }
  34777. // OldApp returns the old "app" field's value of the UsageDetail entity.
  34778. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34780. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  34781. if !m.op.Is(OpUpdateOne) {
  34782. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  34783. }
  34784. if m.id == nil || m.oldValue == nil {
  34785. return v, errors.New("OldApp requires an ID field in the mutation")
  34786. }
  34787. oldValue, err := m.oldValue(ctx)
  34788. if err != nil {
  34789. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  34790. }
  34791. return oldValue.App, nil
  34792. }
  34793. // AddApp adds i to the "app" field.
  34794. func (m *UsageDetailMutation) AddApp(i int) {
  34795. if m.addapp != nil {
  34796. *m.addapp += i
  34797. } else {
  34798. m.addapp = &i
  34799. }
  34800. }
  34801. // AddedApp returns the value that was added to the "app" field in this mutation.
  34802. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  34803. v := m.addapp
  34804. if v == nil {
  34805. return
  34806. }
  34807. return *v, true
  34808. }
  34809. // ClearApp clears the value of the "app" field.
  34810. func (m *UsageDetailMutation) ClearApp() {
  34811. m.app = nil
  34812. m.addapp = nil
  34813. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  34814. }
  34815. // AppCleared returns if the "app" field was cleared in this mutation.
  34816. func (m *UsageDetailMutation) AppCleared() bool {
  34817. _, ok := m.clearedFields[usagedetail.FieldApp]
  34818. return ok
  34819. }
  34820. // ResetApp resets all changes to the "app" field.
  34821. func (m *UsageDetailMutation) ResetApp() {
  34822. m.app = nil
  34823. m.addapp = nil
  34824. delete(m.clearedFields, usagedetail.FieldApp)
  34825. }
  34826. // SetSessionID sets the "session_id" field.
  34827. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  34828. m.session_id = &u
  34829. m.addsession_id = nil
  34830. }
  34831. // SessionID returns the value of the "session_id" field in the mutation.
  34832. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  34833. v := m.session_id
  34834. if v == nil {
  34835. return
  34836. }
  34837. return *v, true
  34838. }
  34839. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  34840. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34842. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  34843. if !m.op.Is(OpUpdateOne) {
  34844. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  34845. }
  34846. if m.id == nil || m.oldValue == nil {
  34847. return v, errors.New("OldSessionID requires an ID field in the mutation")
  34848. }
  34849. oldValue, err := m.oldValue(ctx)
  34850. if err != nil {
  34851. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  34852. }
  34853. return oldValue.SessionID, nil
  34854. }
  34855. // AddSessionID adds u to the "session_id" field.
  34856. func (m *UsageDetailMutation) AddSessionID(u int64) {
  34857. if m.addsession_id != nil {
  34858. *m.addsession_id += u
  34859. } else {
  34860. m.addsession_id = &u
  34861. }
  34862. }
  34863. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  34864. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  34865. v := m.addsession_id
  34866. if v == nil {
  34867. return
  34868. }
  34869. return *v, true
  34870. }
  34871. // ClearSessionID clears the value of the "session_id" field.
  34872. func (m *UsageDetailMutation) ClearSessionID() {
  34873. m.session_id = nil
  34874. m.addsession_id = nil
  34875. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  34876. }
  34877. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  34878. func (m *UsageDetailMutation) SessionIDCleared() bool {
  34879. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  34880. return ok
  34881. }
  34882. // ResetSessionID resets all changes to the "session_id" field.
  34883. func (m *UsageDetailMutation) ResetSessionID() {
  34884. m.session_id = nil
  34885. m.addsession_id = nil
  34886. delete(m.clearedFields, usagedetail.FieldSessionID)
  34887. }
  34888. // SetRequest sets the "request" field.
  34889. func (m *UsageDetailMutation) SetRequest(s string) {
  34890. m.request = &s
  34891. }
  34892. // Request returns the value of the "request" field in the mutation.
  34893. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  34894. v := m.request
  34895. if v == nil {
  34896. return
  34897. }
  34898. return *v, true
  34899. }
  34900. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  34901. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34903. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  34904. if !m.op.Is(OpUpdateOne) {
  34905. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  34906. }
  34907. if m.id == nil || m.oldValue == nil {
  34908. return v, errors.New("OldRequest requires an ID field in the mutation")
  34909. }
  34910. oldValue, err := m.oldValue(ctx)
  34911. if err != nil {
  34912. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  34913. }
  34914. return oldValue.Request, nil
  34915. }
  34916. // ResetRequest resets all changes to the "request" field.
  34917. func (m *UsageDetailMutation) ResetRequest() {
  34918. m.request = nil
  34919. }
  34920. // SetResponse sets the "response" field.
  34921. func (m *UsageDetailMutation) SetResponse(s string) {
  34922. m.response = &s
  34923. }
  34924. // Response returns the value of the "response" field in the mutation.
  34925. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  34926. v := m.response
  34927. if v == nil {
  34928. return
  34929. }
  34930. return *v, true
  34931. }
  34932. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  34933. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34935. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  34936. if !m.op.Is(OpUpdateOne) {
  34937. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  34938. }
  34939. if m.id == nil || m.oldValue == nil {
  34940. return v, errors.New("OldResponse requires an ID field in the mutation")
  34941. }
  34942. oldValue, err := m.oldValue(ctx)
  34943. if err != nil {
  34944. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  34945. }
  34946. return oldValue.Response, nil
  34947. }
  34948. // ResetResponse resets all changes to the "response" field.
  34949. func (m *UsageDetailMutation) ResetResponse() {
  34950. m.response = nil
  34951. }
  34952. // SetOriginalData sets the "original_data" field.
  34953. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  34954. m.original_data = &ctd
  34955. }
  34956. // OriginalData returns the value of the "original_data" field in the mutation.
  34957. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  34958. v := m.original_data
  34959. if v == nil {
  34960. return
  34961. }
  34962. return *v, true
  34963. }
  34964. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  34965. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34967. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  34968. if !m.op.Is(OpUpdateOne) {
  34969. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  34970. }
  34971. if m.id == nil || m.oldValue == nil {
  34972. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  34973. }
  34974. oldValue, err := m.oldValue(ctx)
  34975. if err != nil {
  34976. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  34977. }
  34978. return oldValue.OriginalData, nil
  34979. }
  34980. // ResetOriginalData resets all changes to the "original_data" field.
  34981. func (m *UsageDetailMutation) ResetOriginalData() {
  34982. m.original_data = nil
  34983. }
  34984. // SetTotalTokens sets the "total_tokens" field.
  34985. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  34986. m.total_tokens = &u
  34987. m.addtotal_tokens = nil
  34988. }
  34989. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34990. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  34991. v := m.total_tokens
  34992. if v == nil {
  34993. return
  34994. }
  34995. return *v, true
  34996. }
  34997. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  34998. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35000. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35001. if !m.op.Is(OpUpdateOne) {
  35002. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35003. }
  35004. if m.id == nil || m.oldValue == nil {
  35005. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35006. }
  35007. oldValue, err := m.oldValue(ctx)
  35008. if err != nil {
  35009. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35010. }
  35011. return oldValue.TotalTokens, nil
  35012. }
  35013. // AddTotalTokens adds u to the "total_tokens" field.
  35014. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  35015. if m.addtotal_tokens != nil {
  35016. *m.addtotal_tokens += u
  35017. } else {
  35018. m.addtotal_tokens = &u
  35019. }
  35020. }
  35021. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35022. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  35023. v := m.addtotal_tokens
  35024. if v == nil {
  35025. return
  35026. }
  35027. return *v, true
  35028. }
  35029. // ClearTotalTokens clears the value of the "total_tokens" field.
  35030. func (m *UsageDetailMutation) ClearTotalTokens() {
  35031. m.total_tokens = nil
  35032. m.addtotal_tokens = nil
  35033. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  35034. }
  35035. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35036. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  35037. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  35038. return ok
  35039. }
  35040. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35041. func (m *UsageDetailMutation) ResetTotalTokens() {
  35042. m.total_tokens = nil
  35043. m.addtotal_tokens = nil
  35044. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  35045. }
  35046. // SetPromptTokens sets the "prompt_tokens" field.
  35047. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  35048. m.prompt_tokens = &u
  35049. m.addprompt_tokens = nil
  35050. }
  35051. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  35052. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  35053. v := m.prompt_tokens
  35054. if v == nil {
  35055. return
  35056. }
  35057. return *v, true
  35058. }
  35059. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  35060. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35062. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  35063. if !m.op.Is(OpUpdateOne) {
  35064. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  35065. }
  35066. if m.id == nil || m.oldValue == nil {
  35067. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  35068. }
  35069. oldValue, err := m.oldValue(ctx)
  35070. if err != nil {
  35071. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  35072. }
  35073. return oldValue.PromptTokens, nil
  35074. }
  35075. // AddPromptTokens adds u to the "prompt_tokens" field.
  35076. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  35077. if m.addprompt_tokens != nil {
  35078. *m.addprompt_tokens += u
  35079. } else {
  35080. m.addprompt_tokens = &u
  35081. }
  35082. }
  35083. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  35084. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  35085. v := m.addprompt_tokens
  35086. if v == nil {
  35087. return
  35088. }
  35089. return *v, true
  35090. }
  35091. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  35092. func (m *UsageDetailMutation) ClearPromptTokens() {
  35093. m.prompt_tokens = nil
  35094. m.addprompt_tokens = nil
  35095. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  35096. }
  35097. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  35098. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  35099. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  35100. return ok
  35101. }
  35102. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  35103. func (m *UsageDetailMutation) ResetPromptTokens() {
  35104. m.prompt_tokens = nil
  35105. m.addprompt_tokens = nil
  35106. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  35107. }
  35108. // SetCompletionTokens sets the "completion_tokens" field.
  35109. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  35110. m.completion_tokens = &u
  35111. m.addcompletion_tokens = nil
  35112. }
  35113. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  35114. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  35115. v := m.completion_tokens
  35116. if v == nil {
  35117. return
  35118. }
  35119. return *v, true
  35120. }
  35121. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  35122. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35124. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  35125. if !m.op.Is(OpUpdateOne) {
  35126. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  35127. }
  35128. if m.id == nil || m.oldValue == nil {
  35129. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  35130. }
  35131. oldValue, err := m.oldValue(ctx)
  35132. if err != nil {
  35133. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  35134. }
  35135. return oldValue.CompletionTokens, nil
  35136. }
  35137. // AddCompletionTokens adds u to the "completion_tokens" field.
  35138. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  35139. if m.addcompletion_tokens != nil {
  35140. *m.addcompletion_tokens += u
  35141. } else {
  35142. m.addcompletion_tokens = &u
  35143. }
  35144. }
  35145. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  35146. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  35147. v := m.addcompletion_tokens
  35148. if v == nil {
  35149. return
  35150. }
  35151. return *v, true
  35152. }
  35153. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  35154. func (m *UsageDetailMutation) ClearCompletionTokens() {
  35155. m.completion_tokens = nil
  35156. m.addcompletion_tokens = nil
  35157. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  35158. }
  35159. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  35160. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  35161. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  35162. return ok
  35163. }
  35164. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  35165. func (m *UsageDetailMutation) ResetCompletionTokens() {
  35166. m.completion_tokens = nil
  35167. m.addcompletion_tokens = nil
  35168. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  35169. }
  35170. // SetOrganizationID sets the "organization_id" field.
  35171. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  35172. m.organization_id = &u
  35173. m.addorganization_id = nil
  35174. }
  35175. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35176. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  35177. v := m.organization_id
  35178. if v == nil {
  35179. return
  35180. }
  35181. return *v, true
  35182. }
  35183. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  35184. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35186. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35187. if !m.op.Is(OpUpdateOne) {
  35188. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35189. }
  35190. if m.id == nil || m.oldValue == nil {
  35191. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35192. }
  35193. oldValue, err := m.oldValue(ctx)
  35194. if err != nil {
  35195. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35196. }
  35197. return oldValue.OrganizationID, nil
  35198. }
  35199. // AddOrganizationID adds u to the "organization_id" field.
  35200. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  35201. if m.addorganization_id != nil {
  35202. *m.addorganization_id += u
  35203. } else {
  35204. m.addorganization_id = &u
  35205. }
  35206. }
  35207. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35208. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  35209. v := m.addorganization_id
  35210. if v == nil {
  35211. return
  35212. }
  35213. return *v, true
  35214. }
  35215. // ClearOrganizationID clears the value of the "organization_id" field.
  35216. func (m *UsageDetailMutation) ClearOrganizationID() {
  35217. m.organization_id = nil
  35218. m.addorganization_id = nil
  35219. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  35220. }
  35221. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35222. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  35223. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  35224. return ok
  35225. }
  35226. // ResetOrganizationID resets all changes to the "organization_id" field.
  35227. func (m *UsageDetailMutation) ResetOrganizationID() {
  35228. m.organization_id = nil
  35229. m.addorganization_id = nil
  35230. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  35231. }
  35232. // SetModel sets the "model" field.
  35233. func (m *UsageDetailMutation) SetModel(s string) {
  35234. m.model = &s
  35235. }
  35236. // Model returns the value of the "model" field in the mutation.
  35237. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  35238. v := m.model
  35239. if v == nil {
  35240. return
  35241. }
  35242. return *v, true
  35243. }
  35244. // OldModel returns the old "model" field's value of the UsageDetail entity.
  35245. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35247. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  35248. if !m.op.Is(OpUpdateOne) {
  35249. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  35250. }
  35251. if m.id == nil || m.oldValue == nil {
  35252. return v, errors.New("OldModel requires an ID field in the mutation")
  35253. }
  35254. oldValue, err := m.oldValue(ctx)
  35255. if err != nil {
  35256. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  35257. }
  35258. return oldValue.Model, nil
  35259. }
  35260. // ClearModel clears the value of the "model" field.
  35261. func (m *UsageDetailMutation) ClearModel() {
  35262. m.model = nil
  35263. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  35264. }
  35265. // ModelCleared returns if the "model" field was cleared in this mutation.
  35266. func (m *UsageDetailMutation) ModelCleared() bool {
  35267. _, ok := m.clearedFields[usagedetail.FieldModel]
  35268. return ok
  35269. }
  35270. // ResetModel resets all changes to the "model" field.
  35271. func (m *UsageDetailMutation) ResetModel() {
  35272. m.model = nil
  35273. delete(m.clearedFields, usagedetail.FieldModel)
  35274. }
  35275. // SetCredits sets the "credits" field.
  35276. func (m *UsageDetailMutation) SetCredits(f float64) {
  35277. m.credits = &f
  35278. m.addcredits = nil
  35279. }
  35280. // Credits returns the value of the "credits" field in the mutation.
  35281. func (m *UsageDetailMutation) Credits() (r float64, exists bool) {
  35282. v := m.credits
  35283. if v == nil {
  35284. return
  35285. }
  35286. return *v, true
  35287. }
  35288. // OldCredits returns the old "credits" field's value of the UsageDetail entity.
  35289. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35291. func (m *UsageDetailMutation) OldCredits(ctx context.Context) (v float64, err error) {
  35292. if !m.op.Is(OpUpdateOne) {
  35293. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  35294. }
  35295. if m.id == nil || m.oldValue == nil {
  35296. return v, errors.New("OldCredits requires an ID field in the mutation")
  35297. }
  35298. oldValue, err := m.oldValue(ctx)
  35299. if err != nil {
  35300. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  35301. }
  35302. return oldValue.Credits, nil
  35303. }
  35304. // AddCredits adds f to the "credits" field.
  35305. func (m *UsageDetailMutation) AddCredits(f float64) {
  35306. if m.addcredits != nil {
  35307. *m.addcredits += f
  35308. } else {
  35309. m.addcredits = &f
  35310. }
  35311. }
  35312. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  35313. func (m *UsageDetailMutation) AddedCredits() (r float64, exists bool) {
  35314. v := m.addcredits
  35315. if v == nil {
  35316. return
  35317. }
  35318. return *v, true
  35319. }
  35320. // ClearCredits clears the value of the "credits" field.
  35321. func (m *UsageDetailMutation) ClearCredits() {
  35322. m.credits = nil
  35323. m.addcredits = nil
  35324. m.clearedFields[usagedetail.FieldCredits] = struct{}{}
  35325. }
  35326. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  35327. func (m *UsageDetailMutation) CreditsCleared() bool {
  35328. _, ok := m.clearedFields[usagedetail.FieldCredits]
  35329. return ok
  35330. }
  35331. // ResetCredits resets all changes to the "credits" field.
  35332. func (m *UsageDetailMutation) ResetCredits() {
  35333. m.credits = nil
  35334. m.addcredits = nil
  35335. delete(m.clearedFields, usagedetail.FieldCredits)
  35336. }
  35337. // Where appends a list predicates to the UsageDetailMutation builder.
  35338. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  35339. m.predicates = append(m.predicates, ps...)
  35340. }
  35341. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  35342. // users can use type-assertion to append predicates that do not depend on any generated package.
  35343. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  35344. p := make([]predicate.UsageDetail, len(ps))
  35345. for i := range ps {
  35346. p[i] = ps[i]
  35347. }
  35348. m.Where(p...)
  35349. }
  35350. // Op returns the operation name.
  35351. func (m *UsageDetailMutation) Op() Op {
  35352. return m.op
  35353. }
  35354. // SetOp allows setting the mutation operation.
  35355. func (m *UsageDetailMutation) SetOp(op Op) {
  35356. m.op = op
  35357. }
  35358. // Type returns the node type of this mutation (UsageDetail).
  35359. func (m *UsageDetailMutation) Type() string {
  35360. return m.typ
  35361. }
  35362. // Fields returns all fields that were changed during this mutation. Note that in
  35363. // order to get all numeric fields that were incremented/decremented, call
  35364. // AddedFields().
  35365. func (m *UsageDetailMutation) Fields() []string {
  35366. fields := make([]string, 0, 17)
  35367. if m.created_at != nil {
  35368. fields = append(fields, usagedetail.FieldCreatedAt)
  35369. }
  35370. if m.updated_at != nil {
  35371. fields = append(fields, usagedetail.FieldUpdatedAt)
  35372. }
  35373. if m.status != nil {
  35374. fields = append(fields, usagedetail.FieldStatus)
  35375. }
  35376. if m._type != nil {
  35377. fields = append(fields, usagedetail.FieldType)
  35378. }
  35379. if m.bot_id != nil {
  35380. fields = append(fields, usagedetail.FieldBotID)
  35381. }
  35382. if m.receiver_id != nil {
  35383. fields = append(fields, usagedetail.FieldReceiverID)
  35384. }
  35385. if m.app != nil {
  35386. fields = append(fields, usagedetail.FieldApp)
  35387. }
  35388. if m.session_id != nil {
  35389. fields = append(fields, usagedetail.FieldSessionID)
  35390. }
  35391. if m.request != nil {
  35392. fields = append(fields, usagedetail.FieldRequest)
  35393. }
  35394. if m.response != nil {
  35395. fields = append(fields, usagedetail.FieldResponse)
  35396. }
  35397. if m.original_data != nil {
  35398. fields = append(fields, usagedetail.FieldOriginalData)
  35399. }
  35400. if m.total_tokens != nil {
  35401. fields = append(fields, usagedetail.FieldTotalTokens)
  35402. }
  35403. if m.prompt_tokens != nil {
  35404. fields = append(fields, usagedetail.FieldPromptTokens)
  35405. }
  35406. if m.completion_tokens != nil {
  35407. fields = append(fields, usagedetail.FieldCompletionTokens)
  35408. }
  35409. if m.organization_id != nil {
  35410. fields = append(fields, usagedetail.FieldOrganizationID)
  35411. }
  35412. if m.model != nil {
  35413. fields = append(fields, usagedetail.FieldModel)
  35414. }
  35415. if m.credits != nil {
  35416. fields = append(fields, usagedetail.FieldCredits)
  35417. }
  35418. return fields
  35419. }
  35420. // Field returns the value of a field with the given name. The second boolean
  35421. // return value indicates that this field was not set, or was not defined in the
  35422. // schema.
  35423. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  35424. switch name {
  35425. case usagedetail.FieldCreatedAt:
  35426. return m.CreatedAt()
  35427. case usagedetail.FieldUpdatedAt:
  35428. return m.UpdatedAt()
  35429. case usagedetail.FieldStatus:
  35430. return m.Status()
  35431. case usagedetail.FieldType:
  35432. return m.GetType()
  35433. case usagedetail.FieldBotID:
  35434. return m.BotID()
  35435. case usagedetail.FieldReceiverID:
  35436. return m.ReceiverID()
  35437. case usagedetail.FieldApp:
  35438. return m.App()
  35439. case usagedetail.FieldSessionID:
  35440. return m.SessionID()
  35441. case usagedetail.FieldRequest:
  35442. return m.Request()
  35443. case usagedetail.FieldResponse:
  35444. return m.Response()
  35445. case usagedetail.FieldOriginalData:
  35446. return m.OriginalData()
  35447. case usagedetail.FieldTotalTokens:
  35448. return m.TotalTokens()
  35449. case usagedetail.FieldPromptTokens:
  35450. return m.PromptTokens()
  35451. case usagedetail.FieldCompletionTokens:
  35452. return m.CompletionTokens()
  35453. case usagedetail.FieldOrganizationID:
  35454. return m.OrganizationID()
  35455. case usagedetail.FieldModel:
  35456. return m.Model()
  35457. case usagedetail.FieldCredits:
  35458. return m.Credits()
  35459. }
  35460. return nil, false
  35461. }
  35462. // OldField returns the old value of the field from the database. An error is
  35463. // returned if the mutation operation is not UpdateOne, or the query to the
  35464. // database failed.
  35465. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35466. switch name {
  35467. case usagedetail.FieldCreatedAt:
  35468. return m.OldCreatedAt(ctx)
  35469. case usagedetail.FieldUpdatedAt:
  35470. return m.OldUpdatedAt(ctx)
  35471. case usagedetail.FieldStatus:
  35472. return m.OldStatus(ctx)
  35473. case usagedetail.FieldType:
  35474. return m.OldType(ctx)
  35475. case usagedetail.FieldBotID:
  35476. return m.OldBotID(ctx)
  35477. case usagedetail.FieldReceiverID:
  35478. return m.OldReceiverID(ctx)
  35479. case usagedetail.FieldApp:
  35480. return m.OldApp(ctx)
  35481. case usagedetail.FieldSessionID:
  35482. return m.OldSessionID(ctx)
  35483. case usagedetail.FieldRequest:
  35484. return m.OldRequest(ctx)
  35485. case usagedetail.FieldResponse:
  35486. return m.OldResponse(ctx)
  35487. case usagedetail.FieldOriginalData:
  35488. return m.OldOriginalData(ctx)
  35489. case usagedetail.FieldTotalTokens:
  35490. return m.OldTotalTokens(ctx)
  35491. case usagedetail.FieldPromptTokens:
  35492. return m.OldPromptTokens(ctx)
  35493. case usagedetail.FieldCompletionTokens:
  35494. return m.OldCompletionTokens(ctx)
  35495. case usagedetail.FieldOrganizationID:
  35496. return m.OldOrganizationID(ctx)
  35497. case usagedetail.FieldModel:
  35498. return m.OldModel(ctx)
  35499. case usagedetail.FieldCredits:
  35500. return m.OldCredits(ctx)
  35501. }
  35502. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  35503. }
  35504. // SetField sets the value of a field with the given name. It returns an error if
  35505. // the field is not defined in the schema, or if the type mismatched the field
  35506. // type.
  35507. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  35508. switch name {
  35509. case usagedetail.FieldCreatedAt:
  35510. v, ok := value.(time.Time)
  35511. if !ok {
  35512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35513. }
  35514. m.SetCreatedAt(v)
  35515. return nil
  35516. case usagedetail.FieldUpdatedAt:
  35517. v, ok := value.(time.Time)
  35518. if !ok {
  35519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35520. }
  35521. m.SetUpdatedAt(v)
  35522. return nil
  35523. case usagedetail.FieldStatus:
  35524. v, ok := value.(uint8)
  35525. if !ok {
  35526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35527. }
  35528. m.SetStatus(v)
  35529. return nil
  35530. case usagedetail.FieldType:
  35531. v, ok := value.(int)
  35532. if !ok {
  35533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35534. }
  35535. m.SetType(v)
  35536. return nil
  35537. case usagedetail.FieldBotID:
  35538. v, ok := value.(string)
  35539. if !ok {
  35540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35541. }
  35542. m.SetBotID(v)
  35543. return nil
  35544. case usagedetail.FieldReceiverID:
  35545. v, ok := value.(string)
  35546. if !ok {
  35547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35548. }
  35549. m.SetReceiverID(v)
  35550. return nil
  35551. case usagedetail.FieldApp:
  35552. v, ok := value.(int)
  35553. if !ok {
  35554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35555. }
  35556. m.SetApp(v)
  35557. return nil
  35558. case usagedetail.FieldSessionID:
  35559. v, ok := value.(uint64)
  35560. if !ok {
  35561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35562. }
  35563. m.SetSessionID(v)
  35564. return nil
  35565. case usagedetail.FieldRequest:
  35566. v, ok := value.(string)
  35567. if !ok {
  35568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35569. }
  35570. m.SetRequest(v)
  35571. return nil
  35572. case usagedetail.FieldResponse:
  35573. v, ok := value.(string)
  35574. if !ok {
  35575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35576. }
  35577. m.SetResponse(v)
  35578. return nil
  35579. case usagedetail.FieldOriginalData:
  35580. v, ok := value.(custom_types.OriginalData)
  35581. if !ok {
  35582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35583. }
  35584. m.SetOriginalData(v)
  35585. return nil
  35586. case usagedetail.FieldTotalTokens:
  35587. v, ok := value.(uint64)
  35588. if !ok {
  35589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35590. }
  35591. m.SetTotalTokens(v)
  35592. return nil
  35593. case usagedetail.FieldPromptTokens:
  35594. v, ok := value.(uint64)
  35595. if !ok {
  35596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35597. }
  35598. m.SetPromptTokens(v)
  35599. return nil
  35600. case usagedetail.FieldCompletionTokens:
  35601. v, ok := value.(uint64)
  35602. if !ok {
  35603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35604. }
  35605. m.SetCompletionTokens(v)
  35606. return nil
  35607. case usagedetail.FieldOrganizationID:
  35608. v, ok := value.(uint64)
  35609. if !ok {
  35610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35611. }
  35612. m.SetOrganizationID(v)
  35613. return nil
  35614. case usagedetail.FieldModel:
  35615. v, ok := value.(string)
  35616. if !ok {
  35617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35618. }
  35619. m.SetModel(v)
  35620. return nil
  35621. case usagedetail.FieldCredits:
  35622. v, ok := value.(float64)
  35623. if !ok {
  35624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35625. }
  35626. m.SetCredits(v)
  35627. return nil
  35628. }
  35629. return fmt.Errorf("unknown UsageDetail field %s", name)
  35630. }
  35631. // AddedFields returns all numeric fields that were incremented/decremented during
  35632. // this mutation.
  35633. func (m *UsageDetailMutation) AddedFields() []string {
  35634. var fields []string
  35635. if m.addstatus != nil {
  35636. fields = append(fields, usagedetail.FieldStatus)
  35637. }
  35638. if m.add_type != nil {
  35639. fields = append(fields, usagedetail.FieldType)
  35640. }
  35641. if m.addapp != nil {
  35642. fields = append(fields, usagedetail.FieldApp)
  35643. }
  35644. if m.addsession_id != nil {
  35645. fields = append(fields, usagedetail.FieldSessionID)
  35646. }
  35647. if m.addtotal_tokens != nil {
  35648. fields = append(fields, usagedetail.FieldTotalTokens)
  35649. }
  35650. if m.addprompt_tokens != nil {
  35651. fields = append(fields, usagedetail.FieldPromptTokens)
  35652. }
  35653. if m.addcompletion_tokens != nil {
  35654. fields = append(fields, usagedetail.FieldCompletionTokens)
  35655. }
  35656. if m.addorganization_id != nil {
  35657. fields = append(fields, usagedetail.FieldOrganizationID)
  35658. }
  35659. if m.addcredits != nil {
  35660. fields = append(fields, usagedetail.FieldCredits)
  35661. }
  35662. return fields
  35663. }
  35664. // AddedField returns the numeric value that was incremented/decremented on a field
  35665. // with the given name. The second boolean return value indicates that this field
  35666. // was not set, or was not defined in the schema.
  35667. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  35668. switch name {
  35669. case usagedetail.FieldStatus:
  35670. return m.AddedStatus()
  35671. case usagedetail.FieldType:
  35672. return m.AddedType()
  35673. case usagedetail.FieldApp:
  35674. return m.AddedApp()
  35675. case usagedetail.FieldSessionID:
  35676. return m.AddedSessionID()
  35677. case usagedetail.FieldTotalTokens:
  35678. return m.AddedTotalTokens()
  35679. case usagedetail.FieldPromptTokens:
  35680. return m.AddedPromptTokens()
  35681. case usagedetail.FieldCompletionTokens:
  35682. return m.AddedCompletionTokens()
  35683. case usagedetail.FieldOrganizationID:
  35684. return m.AddedOrganizationID()
  35685. case usagedetail.FieldCredits:
  35686. return m.AddedCredits()
  35687. }
  35688. return nil, false
  35689. }
  35690. // AddField adds the value to the field with the given name. It returns an error if
  35691. // the field is not defined in the schema, or if the type mismatched the field
  35692. // type.
  35693. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  35694. switch name {
  35695. case usagedetail.FieldStatus:
  35696. v, ok := value.(int8)
  35697. if !ok {
  35698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35699. }
  35700. m.AddStatus(v)
  35701. return nil
  35702. case usagedetail.FieldType:
  35703. v, ok := value.(int)
  35704. if !ok {
  35705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35706. }
  35707. m.AddType(v)
  35708. return nil
  35709. case usagedetail.FieldApp:
  35710. v, ok := value.(int)
  35711. if !ok {
  35712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35713. }
  35714. m.AddApp(v)
  35715. return nil
  35716. case usagedetail.FieldSessionID:
  35717. v, ok := value.(int64)
  35718. if !ok {
  35719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35720. }
  35721. m.AddSessionID(v)
  35722. return nil
  35723. case usagedetail.FieldTotalTokens:
  35724. v, ok := value.(int64)
  35725. if !ok {
  35726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35727. }
  35728. m.AddTotalTokens(v)
  35729. return nil
  35730. case usagedetail.FieldPromptTokens:
  35731. v, ok := value.(int64)
  35732. if !ok {
  35733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35734. }
  35735. m.AddPromptTokens(v)
  35736. return nil
  35737. case usagedetail.FieldCompletionTokens:
  35738. v, ok := value.(int64)
  35739. if !ok {
  35740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35741. }
  35742. m.AddCompletionTokens(v)
  35743. return nil
  35744. case usagedetail.FieldOrganizationID:
  35745. v, ok := value.(int64)
  35746. if !ok {
  35747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35748. }
  35749. m.AddOrganizationID(v)
  35750. return nil
  35751. case usagedetail.FieldCredits:
  35752. v, ok := value.(float64)
  35753. if !ok {
  35754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35755. }
  35756. m.AddCredits(v)
  35757. return nil
  35758. }
  35759. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  35760. }
  35761. // ClearedFields returns all nullable fields that were cleared during this
  35762. // mutation.
  35763. func (m *UsageDetailMutation) ClearedFields() []string {
  35764. var fields []string
  35765. if m.FieldCleared(usagedetail.FieldStatus) {
  35766. fields = append(fields, usagedetail.FieldStatus)
  35767. }
  35768. if m.FieldCleared(usagedetail.FieldType) {
  35769. fields = append(fields, usagedetail.FieldType)
  35770. }
  35771. if m.FieldCleared(usagedetail.FieldApp) {
  35772. fields = append(fields, usagedetail.FieldApp)
  35773. }
  35774. if m.FieldCleared(usagedetail.FieldSessionID) {
  35775. fields = append(fields, usagedetail.FieldSessionID)
  35776. }
  35777. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  35778. fields = append(fields, usagedetail.FieldTotalTokens)
  35779. }
  35780. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  35781. fields = append(fields, usagedetail.FieldPromptTokens)
  35782. }
  35783. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  35784. fields = append(fields, usagedetail.FieldCompletionTokens)
  35785. }
  35786. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  35787. fields = append(fields, usagedetail.FieldOrganizationID)
  35788. }
  35789. if m.FieldCleared(usagedetail.FieldModel) {
  35790. fields = append(fields, usagedetail.FieldModel)
  35791. }
  35792. if m.FieldCleared(usagedetail.FieldCredits) {
  35793. fields = append(fields, usagedetail.FieldCredits)
  35794. }
  35795. return fields
  35796. }
  35797. // FieldCleared returns a boolean indicating if a field with the given name was
  35798. // cleared in this mutation.
  35799. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  35800. _, ok := m.clearedFields[name]
  35801. return ok
  35802. }
  35803. // ClearField clears the value of the field with the given name. It returns an
  35804. // error if the field is not defined in the schema.
  35805. func (m *UsageDetailMutation) ClearField(name string) error {
  35806. switch name {
  35807. case usagedetail.FieldStatus:
  35808. m.ClearStatus()
  35809. return nil
  35810. case usagedetail.FieldType:
  35811. m.ClearType()
  35812. return nil
  35813. case usagedetail.FieldApp:
  35814. m.ClearApp()
  35815. return nil
  35816. case usagedetail.FieldSessionID:
  35817. m.ClearSessionID()
  35818. return nil
  35819. case usagedetail.FieldTotalTokens:
  35820. m.ClearTotalTokens()
  35821. return nil
  35822. case usagedetail.FieldPromptTokens:
  35823. m.ClearPromptTokens()
  35824. return nil
  35825. case usagedetail.FieldCompletionTokens:
  35826. m.ClearCompletionTokens()
  35827. return nil
  35828. case usagedetail.FieldOrganizationID:
  35829. m.ClearOrganizationID()
  35830. return nil
  35831. case usagedetail.FieldModel:
  35832. m.ClearModel()
  35833. return nil
  35834. case usagedetail.FieldCredits:
  35835. m.ClearCredits()
  35836. return nil
  35837. }
  35838. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  35839. }
  35840. // ResetField resets all changes in the mutation for the field with the given name.
  35841. // It returns an error if the field is not defined in the schema.
  35842. func (m *UsageDetailMutation) ResetField(name string) error {
  35843. switch name {
  35844. case usagedetail.FieldCreatedAt:
  35845. m.ResetCreatedAt()
  35846. return nil
  35847. case usagedetail.FieldUpdatedAt:
  35848. m.ResetUpdatedAt()
  35849. return nil
  35850. case usagedetail.FieldStatus:
  35851. m.ResetStatus()
  35852. return nil
  35853. case usagedetail.FieldType:
  35854. m.ResetType()
  35855. return nil
  35856. case usagedetail.FieldBotID:
  35857. m.ResetBotID()
  35858. return nil
  35859. case usagedetail.FieldReceiverID:
  35860. m.ResetReceiverID()
  35861. return nil
  35862. case usagedetail.FieldApp:
  35863. m.ResetApp()
  35864. return nil
  35865. case usagedetail.FieldSessionID:
  35866. m.ResetSessionID()
  35867. return nil
  35868. case usagedetail.FieldRequest:
  35869. m.ResetRequest()
  35870. return nil
  35871. case usagedetail.FieldResponse:
  35872. m.ResetResponse()
  35873. return nil
  35874. case usagedetail.FieldOriginalData:
  35875. m.ResetOriginalData()
  35876. return nil
  35877. case usagedetail.FieldTotalTokens:
  35878. m.ResetTotalTokens()
  35879. return nil
  35880. case usagedetail.FieldPromptTokens:
  35881. m.ResetPromptTokens()
  35882. return nil
  35883. case usagedetail.FieldCompletionTokens:
  35884. m.ResetCompletionTokens()
  35885. return nil
  35886. case usagedetail.FieldOrganizationID:
  35887. m.ResetOrganizationID()
  35888. return nil
  35889. case usagedetail.FieldModel:
  35890. m.ResetModel()
  35891. return nil
  35892. case usagedetail.FieldCredits:
  35893. m.ResetCredits()
  35894. return nil
  35895. }
  35896. return fmt.Errorf("unknown UsageDetail field %s", name)
  35897. }
  35898. // AddedEdges returns all edge names that were set/added in this mutation.
  35899. func (m *UsageDetailMutation) AddedEdges() []string {
  35900. edges := make([]string, 0, 0)
  35901. return edges
  35902. }
  35903. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35904. // name in this mutation.
  35905. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  35906. return nil
  35907. }
  35908. // RemovedEdges returns all edge names that were removed in this mutation.
  35909. func (m *UsageDetailMutation) RemovedEdges() []string {
  35910. edges := make([]string, 0, 0)
  35911. return edges
  35912. }
  35913. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35914. // the given name in this mutation.
  35915. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  35916. return nil
  35917. }
  35918. // ClearedEdges returns all edge names that were cleared in this mutation.
  35919. func (m *UsageDetailMutation) ClearedEdges() []string {
  35920. edges := make([]string, 0, 0)
  35921. return edges
  35922. }
  35923. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35924. // was cleared in this mutation.
  35925. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  35926. return false
  35927. }
  35928. // ClearEdge clears the value of the edge with the given name. It returns an error
  35929. // if that edge is not defined in the schema.
  35930. func (m *UsageDetailMutation) ClearEdge(name string) error {
  35931. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  35932. }
  35933. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35934. // It returns an error if the edge is not defined in the schema.
  35935. func (m *UsageDetailMutation) ResetEdge(name string) error {
  35936. return fmt.Errorf("unknown UsageDetail edge %s", name)
  35937. }
  35938. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  35939. type UsageStatisticDayMutation struct {
  35940. config
  35941. op Op
  35942. typ string
  35943. id *uint64
  35944. created_at *time.Time
  35945. updated_at *time.Time
  35946. status *uint8
  35947. addstatus *int8
  35948. deleted_at *time.Time
  35949. addtime *uint64
  35950. addaddtime *int64
  35951. _type *int
  35952. add_type *int
  35953. bot_id *string
  35954. organization_id *uint64
  35955. addorganization_id *int64
  35956. ai_response *uint64
  35957. addai_response *int64
  35958. sop_run *uint64
  35959. addsop_run *int64
  35960. total_friend *uint64
  35961. addtotal_friend *int64
  35962. total_group *uint64
  35963. addtotal_group *int64
  35964. account_balance *uint64
  35965. addaccount_balance *int64
  35966. consume_token *uint64
  35967. addconsume_token *int64
  35968. active_user *uint64
  35969. addactive_user *int64
  35970. new_user *int64
  35971. addnew_user *int64
  35972. label_dist *[]custom_types.LabelDist
  35973. appendlabel_dist []custom_types.LabelDist
  35974. consume_coin *float64
  35975. addconsume_coin *float64
  35976. clearedFields map[string]struct{}
  35977. done bool
  35978. oldValue func(context.Context) (*UsageStatisticDay, error)
  35979. predicates []predicate.UsageStatisticDay
  35980. }
  35981. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  35982. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  35983. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  35984. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  35985. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  35986. m := &UsageStatisticDayMutation{
  35987. config: c,
  35988. op: op,
  35989. typ: TypeUsageStatisticDay,
  35990. clearedFields: make(map[string]struct{}),
  35991. }
  35992. for _, opt := range opts {
  35993. opt(m)
  35994. }
  35995. return m
  35996. }
  35997. // withUsageStatisticDayID sets the ID field of the mutation.
  35998. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  35999. return func(m *UsageStatisticDayMutation) {
  36000. var (
  36001. err error
  36002. once sync.Once
  36003. value *UsageStatisticDay
  36004. )
  36005. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  36006. once.Do(func() {
  36007. if m.done {
  36008. err = errors.New("querying old values post mutation is not allowed")
  36009. } else {
  36010. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  36011. }
  36012. })
  36013. return value, err
  36014. }
  36015. m.id = &id
  36016. }
  36017. }
  36018. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  36019. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  36020. return func(m *UsageStatisticDayMutation) {
  36021. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  36022. return node, nil
  36023. }
  36024. m.id = &node.ID
  36025. }
  36026. }
  36027. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36028. // executed in a transaction (ent.Tx), a transactional client is returned.
  36029. func (m UsageStatisticDayMutation) Client() *Client {
  36030. client := &Client{config: m.config}
  36031. client.init()
  36032. return client
  36033. }
  36034. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36035. // it returns an error otherwise.
  36036. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  36037. if _, ok := m.driver.(*txDriver); !ok {
  36038. return nil, errors.New("ent: mutation is not running in a transaction")
  36039. }
  36040. tx := &Tx{config: m.config}
  36041. tx.init()
  36042. return tx, nil
  36043. }
  36044. // SetID sets the value of the id field. Note that this
  36045. // operation is only accepted on creation of UsageStatisticDay entities.
  36046. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  36047. m.id = &id
  36048. }
  36049. // ID returns the ID value in the mutation. Note that the ID is only available
  36050. // if it was provided to the builder or after it was returned from the database.
  36051. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  36052. if m.id == nil {
  36053. return
  36054. }
  36055. return *m.id, true
  36056. }
  36057. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36058. // That means, if the mutation is applied within a transaction with an isolation level such
  36059. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36060. // or updated by the mutation.
  36061. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  36062. switch {
  36063. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36064. id, exists := m.ID()
  36065. if exists {
  36066. return []uint64{id}, nil
  36067. }
  36068. fallthrough
  36069. case m.op.Is(OpUpdate | OpDelete):
  36070. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  36071. default:
  36072. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36073. }
  36074. }
  36075. // SetCreatedAt sets the "created_at" field.
  36076. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  36077. m.created_at = &t
  36078. }
  36079. // CreatedAt returns the value of the "created_at" field in the mutation.
  36080. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  36081. v := m.created_at
  36082. if v == nil {
  36083. return
  36084. }
  36085. return *v, true
  36086. }
  36087. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  36088. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36090. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36091. if !m.op.Is(OpUpdateOne) {
  36092. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36093. }
  36094. if m.id == nil || m.oldValue == nil {
  36095. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36096. }
  36097. oldValue, err := m.oldValue(ctx)
  36098. if err != nil {
  36099. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36100. }
  36101. return oldValue.CreatedAt, nil
  36102. }
  36103. // ResetCreatedAt resets all changes to the "created_at" field.
  36104. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  36105. m.created_at = nil
  36106. }
  36107. // SetUpdatedAt sets the "updated_at" field.
  36108. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  36109. m.updated_at = &t
  36110. }
  36111. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36112. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  36113. v := m.updated_at
  36114. if v == nil {
  36115. return
  36116. }
  36117. return *v, true
  36118. }
  36119. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  36120. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36122. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36123. if !m.op.Is(OpUpdateOne) {
  36124. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36125. }
  36126. if m.id == nil || m.oldValue == nil {
  36127. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36128. }
  36129. oldValue, err := m.oldValue(ctx)
  36130. if err != nil {
  36131. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36132. }
  36133. return oldValue.UpdatedAt, nil
  36134. }
  36135. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36136. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  36137. m.updated_at = nil
  36138. }
  36139. // SetStatus sets the "status" field.
  36140. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  36141. m.status = &u
  36142. m.addstatus = nil
  36143. }
  36144. // Status returns the value of the "status" field in the mutation.
  36145. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  36146. v := m.status
  36147. if v == nil {
  36148. return
  36149. }
  36150. return *v, true
  36151. }
  36152. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  36153. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36155. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36156. if !m.op.Is(OpUpdateOne) {
  36157. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36158. }
  36159. if m.id == nil || m.oldValue == nil {
  36160. return v, errors.New("OldStatus requires an ID field in the mutation")
  36161. }
  36162. oldValue, err := m.oldValue(ctx)
  36163. if err != nil {
  36164. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36165. }
  36166. return oldValue.Status, nil
  36167. }
  36168. // AddStatus adds u to the "status" field.
  36169. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  36170. if m.addstatus != nil {
  36171. *m.addstatus += u
  36172. } else {
  36173. m.addstatus = &u
  36174. }
  36175. }
  36176. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36177. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  36178. v := m.addstatus
  36179. if v == nil {
  36180. return
  36181. }
  36182. return *v, true
  36183. }
  36184. // ClearStatus clears the value of the "status" field.
  36185. func (m *UsageStatisticDayMutation) ClearStatus() {
  36186. m.status = nil
  36187. m.addstatus = nil
  36188. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  36189. }
  36190. // StatusCleared returns if the "status" field was cleared in this mutation.
  36191. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  36192. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  36193. return ok
  36194. }
  36195. // ResetStatus resets all changes to the "status" field.
  36196. func (m *UsageStatisticDayMutation) ResetStatus() {
  36197. m.status = nil
  36198. m.addstatus = nil
  36199. delete(m.clearedFields, usagestatisticday.FieldStatus)
  36200. }
  36201. // SetDeletedAt sets the "deleted_at" field.
  36202. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  36203. m.deleted_at = &t
  36204. }
  36205. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36206. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  36207. v := m.deleted_at
  36208. if v == nil {
  36209. return
  36210. }
  36211. return *v, true
  36212. }
  36213. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  36214. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36216. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36217. if !m.op.Is(OpUpdateOne) {
  36218. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36219. }
  36220. if m.id == nil || m.oldValue == nil {
  36221. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36222. }
  36223. oldValue, err := m.oldValue(ctx)
  36224. if err != nil {
  36225. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36226. }
  36227. return oldValue.DeletedAt, nil
  36228. }
  36229. // ClearDeletedAt clears the value of the "deleted_at" field.
  36230. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  36231. m.deleted_at = nil
  36232. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  36233. }
  36234. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36235. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  36236. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  36237. return ok
  36238. }
  36239. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36240. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  36241. m.deleted_at = nil
  36242. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  36243. }
  36244. // SetAddtime sets the "addtime" field.
  36245. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  36246. m.addtime = &u
  36247. m.addaddtime = nil
  36248. }
  36249. // Addtime returns the value of the "addtime" field in the mutation.
  36250. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  36251. v := m.addtime
  36252. if v == nil {
  36253. return
  36254. }
  36255. return *v, true
  36256. }
  36257. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  36258. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36260. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  36261. if !m.op.Is(OpUpdateOne) {
  36262. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  36263. }
  36264. if m.id == nil || m.oldValue == nil {
  36265. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36266. }
  36267. oldValue, err := m.oldValue(ctx)
  36268. if err != nil {
  36269. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36270. }
  36271. return oldValue.Addtime, nil
  36272. }
  36273. // AddAddtime adds u to the "addtime" field.
  36274. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  36275. if m.addaddtime != nil {
  36276. *m.addaddtime += u
  36277. } else {
  36278. m.addaddtime = &u
  36279. }
  36280. }
  36281. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36282. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  36283. v := m.addaddtime
  36284. if v == nil {
  36285. return
  36286. }
  36287. return *v, true
  36288. }
  36289. // ResetAddtime resets all changes to the "addtime" field.
  36290. func (m *UsageStatisticDayMutation) ResetAddtime() {
  36291. m.addtime = nil
  36292. m.addaddtime = nil
  36293. }
  36294. // SetType sets the "type" field.
  36295. func (m *UsageStatisticDayMutation) SetType(i int) {
  36296. m._type = &i
  36297. m.add_type = nil
  36298. }
  36299. // GetType returns the value of the "type" field in the mutation.
  36300. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  36301. v := m._type
  36302. if v == nil {
  36303. return
  36304. }
  36305. return *v, true
  36306. }
  36307. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  36308. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36310. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  36311. if !m.op.Is(OpUpdateOne) {
  36312. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36313. }
  36314. if m.id == nil || m.oldValue == nil {
  36315. return v, errors.New("OldType requires an ID field in the mutation")
  36316. }
  36317. oldValue, err := m.oldValue(ctx)
  36318. if err != nil {
  36319. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36320. }
  36321. return oldValue.Type, nil
  36322. }
  36323. // AddType adds i to the "type" field.
  36324. func (m *UsageStatisticDayMutation) AddType(i int) {
  36325. if m.add_type != nil {
  36326. *m.add_type += i
  36327. } else {
  36328. m.add_type = &i
  36329. }
  36330. }
  36331. // AddedType returns the value that was added to the "type" field in this mutation.
  36332. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  36333. v := m.add_type
  36334. if v == nil {
  36335. return
  36336. }
  36337. return *v, true
  36338. }
  36339. // ResetType resets all changes to the "type" field.
  36340. func (m *UsageStatisticDayMutation) ResetType() {
  36341. m._type = nil
  36342. m.add_type = nil
  36343. }
  36344. // SetBotID sets the "bot_id" field.
  36345. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  36346. m.bot_id = &s
  36347. }
  36348. // BotID returns the value of the "bot_id" field in the mutation.
  36349. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  36350. v := m.bot_id
  36351. if v == nil {
  36352. return
  36353. }
  36354. return *v, true
  36355. }
  36356. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  36357. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36359. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  36360. if !m.op.Is(OpUpdateOne) {
  36361. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36362. }
  36363. if m.id == nil || m.oldValue == nil {
  36364. return v, errors.New("OldBotID requires an ID field in the mutation")
  36365. }
  36366. oldValue, err := m.oldValue(ctx)
  36367. if err != nil {
  36368. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36369. }
  36370. return oldValue.BotID, nil
  36371. }
  36372. // ClearBotID clears the value of the "bot_id" field.
  36373. func (m *UsageStatisticDayMutation) ClearBotID() {
  36374. m.bot_id = nil
  36375. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  36376. }
  36377. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36378. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  36379. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  36380. return ok
  36381. }
  36382. // ResetBotID resets all changes to the "bot_id" field.
  36383. func (m *UsageStatisticDayMutation) ResetBotID() {
  36384. m.bot_id = nil
  36385. delete(m.clearedFields, usagestatisticday.FieldBotID)
  36386. }
  36387. // SetOrganizationID sets the "organization_id" field.
  36388. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  36389. m.organization_id = &u
  36390. m.addorganization_id = nil
  36391. }
  36392. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36393. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  36394. v := m.organization_id
  36395. if v == nil {
  36396. return
  36397. }
  36398. return *v, true
  36399. }
  36400. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  36401. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36403. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36404. if !m.op.Is(OpUpdateOne) {
  36405. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36406. }
  36407. if m.id == nil || m.oldValue == nil {
  36408. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36409. }
  36410. oldValue, err := m.oldValue(ctx)
  36411. if err != nil {
  36412. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36413. }
  36414. return oldValue.OrganizationID, nil
  36415. }
  36416. // AddOrganizationID adds u to the "organization_id" field.
  36417. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  36418. if m.addorganization_id != nil {
  36419. *m.addorganization_id += u
  36420. } else {
  36421. m.addorganization_id = &u
  36422. }
  36423. }
  36424. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36425. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  36426. v := m.addorganization_id
  36427. if v == nil {
  36428. return
  36429. }
  36430. return *v, true
  36431. }
  36432. // ClearOrganizationID clears the value of the "organization_id" field.
  36433. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  36434. m.organization_id = nil
  36435. m.addorganization_id = nil
  36436. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  36437. }
  36438. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36439. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  36440. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  36441. return ok
  36442. }
  36443. // ResetOrganizationID resets all changes to the "organization_id" field.
  36444. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  36445. m.organization_id = nil
  36446. m.addorganization_id = nil
  36447. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  36448. }
  36449. // SetAiResponse sets the "ai_response" field.
  36450. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  36451. m.ai_response = &u
  36452. m.addai_response = nil
  36453. }
  36454. // AiResponse returns the value of the "ai_response" field in the mutation.
  36455. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  36456. v := m.ai_response
  36457. if v == nil {
  36458. return
  36459. }
  36460. return *v, true
  36461. }
  36462. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  36463. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36465. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36466. if !m.op.Is(OpUpdateOne) {
  36467. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36468. }
  36469. if m.id == nil || m.oldValue == nil {
  36470. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36471. }
  36472. oldValue, err := m.oldValue(ctx)
  36473. if err != nil {
  36474. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36475. }
  36476. return oldValue.AiResponse, nil
  36477. }
  36478. // AddAiResponse adds u to the "ai_response" field.
  36479. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  36480. if m.addai_response != nil {
  36481. *m.addai_response += u
  36482. } else {
  36483. m.addai_response = &u
  36484. }
  36485. }
  36486. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36487. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  36488. v := m.addai_response
  36489. if v == nil {
  36490. return
  36491. }
  36492. return *v, true
  36493. }
  36494. // ResetAiResponse resets all changes to the "ai_response" field.
  36495. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  36496. m.ai_response = nil
  36497. m.addai_response = nil
  36498. }
  36499. // SetSopRun sets the "sop_run" field.
  36500. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  36501. m.sop_run = &u
  36502. m.addsop_run = nil
  36503. }
  36504. // SopRun returns the value of the "sop_run" field in the mutation.
  36505. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  36506. v := m.sop_run
  36507. if v == nil {
  36508. return
  36509. }
  36510. return *v, true
  36511. }
  36512. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  36513. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36515. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36516. if !m.op.Is(OpUpdateOne) {
  36517. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36518. }
  36519. if m.id == nil || m.oldValue == nil {
  36520. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36521. }
  36522. oldValue, err := m.oldValue(ctx)
  36523. if err != nil {
  36524. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36525. }
  36526. return oldValue.SopRun, nil
  36527. }
  36528. // AddSopRun adds u to the "sop_run" field.
  36529. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  36530. if m.addsop_run != nil {
  36531. *m.addsop_run += u
  36532. } else {
  36533. m.addsop_run = &u
  36534. }
  36535. }
  36536. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36537. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  36538. v := m.addsop_run
  36539. if v == nil {
  36540. return
  36541. }
  36542. return *v, true
  36543. }
  36544. // ResetSopRun resets all changes to the "sop_run" field.
  36545. func (m *UsageStatisticDayMutation) ResetSopRun() {
  36546. m.sop_run = nil
  36547. m.addsop_run = nil
  36548. }
  36549. // SetTotalFriend sets the "total_friend" field.
  36550. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  36551. m.total_friend = &u
  36552. m.addtotal_friend = nil
  36553. }
  36554. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36555. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  36556. v := m.total_friend
  36557. if v == nil {
  36558. return
  36559. }
  36560. return *v, true
  36561. }
  36562. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  36563. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36565. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36566. if !m.op.Is(OpUpdateOne) {
  36567. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36568. }
  36569. if m.id == nil || m.oldValue == nil {
  36570. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36571. }
  36572. oldValue, err := m.oldValue(ctx)
  36573. if err != nil {
  36574. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36575. }
  36576. return oldValue.TotalFriend, nil
  36577. }
  36578. // AddTotalFriend adds u to the "total_friend" field.
  36579. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  36580. if m.addtotal_friend != nil {
  36581. *m.addtotal_friend += u
  36582. } else {
  36583. m.addtotal_friend = &u
  36584. }
  36585. }
  36586. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36587. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  36588. v := m.addtotal_friend
  36589. if v == nil {
  36590. return
  36591. }
  36592. return *v, true
  36593. }
  36594. // ResetTotalFriend resets all changes to the "total_friend" field.
  36595. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  36596. m.total_friend = nil
  36597. m.addtotal_friend = nil
  36598. }
  36599. // SetTotalGroup sets the "total_group" field.
  36600. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  36601. m.total_group = &u
  36602. m.addtotal_group = nil
  36603. }
  36604. // TotalGroup returns the value of the "total_group" field in the mutation.
  36605. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  36606. v := m.total_group
  36607. if v == nil {
  36608. return
  36609. }
  36610. return *v, true
  36611. }
  36612. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  36613. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36615. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36616. if !m.op.Is(OpUpdateOne) {
  36617. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36618. }
  36619. if m.id == nil || m.oldValue == nil {
  36620. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36621. }
  36622. oldValue, err := m.oldValue(ctx)
  36623. if err != nil {
  36624. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36625. }
  36626. return oldValue.TotalGroup, nil
  36627. }
  36628. // AddTotalGroup adds u to the "total_group" field.
  36629. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  36630. if m.addtotal_group != nil {
  36631. *m.addtotal_group += u
  36632. } else {
  36633. m.addtotal_group = &u
  36634. }
  36635. }
  36636. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36637. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  36638. v := m.addtotal_group
  36639. if v == nil {
  36640. return
  36641. }
  36642. return *v, true
  36643. }
  36644. // ResetTotalGroup resets all changes to the "total_group" field.
  36645. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  36646. m.total_group = nil
  36647. m.addtotal_group = nil
  36648. }
  36649. // SetAccountBalance sets the "account_balance" field.
  36650. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  36651. m.account_balance = &u
  36652. m.addaccount_balance = nil
  36653. }
  36654. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36655. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  36656. v := m.account_balance
  36657. if v == nil {
  36658. return
  36659. }
  36660. return *v, true
  36661. }
  36662. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  36663. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36665. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36666. if !m.op.Is(OpUpdateOne) {
  36667. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36668. }
  36669. if m.id == nil || m.oldValue == nil {
  36670. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36671. }
  36672. oldValue, err := m.oldValue(ctx)
  36673. if err != nil {
  36674. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36675. }
  36676. return oldValue.AccountBalance, nil
  36677. }
  36678. // AddAccountBalance adds u to the "account_balance" field.
  36679. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  36680. if m.addaccount_balance != nil {
  36681. *m.addaccount_balance += u
  36682. } else {
  36683. m.addaccount_balance = &u
  36684. }
  36685. }
  36686. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36687. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  36688. v := m.addaccount_balance
  36689. if v == nil {
  36690. return
  36691. }
  36692. return *v, true
  36693. }
  36694. // ResetAccountBalance resets all changes to the "account_balance" field.
  36695. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  36696. m.account_balance = nil
  36697. m.addaccount_balance = nil
  36698. }
  36699. // SetConsumeToken sets the "consume_token" field.
  36700. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  36701. m.consume_token = &u
  36702. m.addconsume_token = nil
  36703. }
  36704. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36705. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  36706. v := m.consume_token
  36707. if v == nil {
  36708. return
  36709. }
  36710. return *v, true
  36711. }
  36712. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  36713. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36715. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36716. if !m.op.Is(OpUpdateOne) {
  36717. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36718. }
  36719. if m.id == nil || m.oldValue == nil {
  36720. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36721. }
  36722. oldValue, err := m.oldValue(ctx)
  36723. if err != nil {
  36724. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36725. }
  36726. return oldValue.ConsumeToken, nil
  36727. }
  36728. // AddConsumeToken adds u to the "consume_token" field.
  36729. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  36730. if m.addconsume_token != nil {
  36731. *m.addconsume_token += u
  36732. } else {
  36733. m.addconsume_token = &u
  36734. }
  36735. }
  36736. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36737. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  36738. v := m.addconsume_token
  36739. if v == nil {
  36740. return
  36741. }
  36742. return *v, true
  36743. }
  36744. // ResetConsumeToken resets all changes to the "consume_token" field.
  36745. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  36746. m.consume_token = nil
  36747. m.addconsume_token = nil
  36748. }
  36749. // SetActiveUser sets the "active_user" field.
  36750. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  36751. m.active_user = &u
  36752. m.addactive_user = nil
  36753. }
  36754. // ActiveUser returns the value of the "active_user" field in the mutation.
  36755. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  36756. v := m.active_user
  36757. if v == nil {
  36758. return
  36759. }
  36760. return *v, true
  36761. }
  36762. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  36763. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36765. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36766. if !m.op.Is(OpUpdateOne) {
  36767. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36768. }
  36769. if m.id == nil || m.oldValue == nil {
  36770. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36771. }
  36772. oldValue, err := m.oldValue(ctx)
  36773. if err != nil {
  36774. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36775. }
  36776. return oldValue.ActiveUser, nil
  36777. }
  36778. // AddActiveUser adds u to the "active_user" field.
  36779. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  36780. if m.addactive_user != nil {
  36781. *m.addactive_user += u
  36782. } else {
  36783. m.addactive_user = &u
  36784. }
  36785. }
  36786. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36787. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  36788. v := m.addactive_user
  36789. if v == nil {
  36790. return
  36791. }
  36792. return *v, true
  36793. }
  36794. // ResetActiveUser resets all changes to the "active_user" field.
  36795. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  36796. m.active_user = nil
  36797. m.addactive_user = nil
  36798. }
  36799. // SetNewUser sets the "new_user" field.
  36800. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  36801. m.new_user = &i
  36802. m.addnew_user = nil
  36803. }
  36804. // NewUser returns the value of the "new_user" field in the mutation.
  36805. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  36806. v := m.new_user
  36807. if v == nil {
  36808. return
  36809. }
  36810. return *v, true
  36811. }
  36812. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  36813. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36815. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36816. if !m.op.Is(OpUpdateOne) {
  36817. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36818. }
  36819. if m.id == nil || m.oldValue == nil {
  36820. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36821. }
  36822. oldValue, err := m.oldValue(ctx)
  36823. if err != nil {
  36824. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36825. }
  36826. return oldValue.NewUser, nil
  36827. }
  36828. // AddNewUser adds i to the "new_user" field.
  36829. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  36830. if m.addnew_user != nil {
  36831. *m.addnew_user += i
  36832. } else {
  36833. m.addnew_user = &i
  36834. }
  36835. }
  36836. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36837. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  36838. v := m.addnew_user
  36839. if v == nil {
  36840. return
  36841. }
  36842. return *v, true
  36843. }
  36844. // ResetNewUser resets all changes to the "new_user" field.
  36845. func (m *UsageStatisticDayMutation) ResetNewUser() {
  36846. m.new_user = nil
  36847. m.addnew_user = nil
  36848. }
  36849. // SetLabelDist sets the "label_dist" field.
  36850. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36851. m.label_dist = &ctd
  36852. m.appendlabel_dist = nil
  36853. }
  36854. // LabelDist returns the value of the "label_dist" field in the mutation.
  36855. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36856. v := m.label_dist
  36857. if v == nil {
  36858. return
  36859. }
  36860. return *v, true
  36861. }
  36862. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  36863. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36865. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36866. if !m.op.Is(OpUpdateOne) {
  36867. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36868. }
  36869. if m.id == nil || m.oldValue == nil {
  36870. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36871. }
  36872. oldValue, err := m.oldValue(ctx)
  36873. if err != nil {
  36874. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36875. }
  36876. return oldValue.LabelDist, nil
  36877. }
  36878. // AppendLabelDist adds ctd to the "label_dist" field.
  36879. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36880. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36881. }
  36882. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36883. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36884. if len(m.appendlabel_dist) == 0 {
  36885. return nil, false
  36886. }
  36887. return m.appendlabel_dist, true
  36888. }
  36889. // ResetLabelDist resets all changes to the "label_dist" field.
  36890. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  36891. m.label_dist = nil
  36892. m.appendlabel_dist = nil
  36893. }
  36894. // SetConsumeCoin sets the "consume_coin" field.
  36895. func (m *UsageStatisticDayMutation) SetConsumeCoin(f float64) {
  36896. m.consume_coin = &f
  36897. m.addconsume_coin = nil
  36898. }
  36899. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  36900. func (m *UsageStatisticDayMutation) ConsumeCoin() (r float64, exists bool) {
  36901. v := m.consume_coin
  36902. if v == nil {
  36903. return
  36904. }
  36905. return *v, true
  36906. }
  36907. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  36908. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36910. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  36911. if !m.op.Is(OpUpdateOne) {
  36912. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  36913. }
  36914. if m.id == nil || m.oldValue == nil {
  36915. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  36916. }
  36917. oldValue, err := m.oldValue(ctx)
  36918. if err != nil {
  36919. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  36920. }
  36921. return oldValue.ConsumeCoin, nil
  36922. }
  36923. // AddConsumeCoin adds f to the "consume_coin" field.
  36924. func (m *UsageStatisticDayMutation) AddConsumeCoin(f float64) {
  36925. if m.addconsume_coin != nil {
  36926. *m.addconsume_coin += f
  36927. } else {
  36928. m.addconsume_coin = &f
  36929. }
  36930. }
  36931. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  36932. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r float64, exists bool) {
  36933. v := m.addconsume_coin
  36934. if v == nil {
  36935. return
  36936. }
  36937. return *v, true
  36938. }
  36939. // ClearConsumeCoin clears the value of the "consume_coin" field.
  36940. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  36941. m.consume_coin = nil
  36942. m.addconsume_coin = nil
  36943. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  36944. }
  36945. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  36946. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  36947. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  36948. return ok
  36949. }
  36950. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  36951. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  36952. m.consume_coin = nil
  36953. m.addconsume_coin = nil
  36954. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  36955. }
  36956. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  36957. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  36958. m.predicates = append(m.predicates, ps...)
  36959. }
  36960. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  36961. // users can use type-assertion to append predicates that do not depend on any generated package.
  36962. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  36963. p := make([]predicate.UsageStatisticDay, len(ps))
  36964. for i := range ps {
  36965. p[i] = ps[i]
  36966. }
  36967. m.Where(p...)
  36968. }
  36969. // Op returns the operation name.
  36970. func (m *UsageStatisticDayMutation) Op() Op {
  36971. return m.op
  36972. }
  36973. // SetOp allows setting the mutation operation.
  36974. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  36975. m.op = op
  36976. }
  36977. // Type returns the node type of this mutation (UsageStatisticDay).
  36978. func (m *UsageStatisticDayMutation) Type() string {
  36979. return m.typ
  36980. }
  36981. // Fields returns all fields that were changed during this mutation. Note that in
  36982. // order to get all numeric fields that were incremented/decremented, call
  36983. // AddedFields().
  36984. func (m *UsageStatisticDayMutation) Fields() []string {
  36985. fields := make([]string, 0, 18)
  36986. if m.created_at != nil {
  36987. fields = append(fields, usagestatisticday.FieldCreatedAt)
  36988. }
  36989. if m.updated_at != nil {
  36990. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  36991. }
  36992. if m.status != nil {
  36993. fields = append(fields, usagestatisticday.FieldStatus)
  36994. }
  36995. if m.deleted_at != nil {
  36996. fields = append(fields, usagestatisticday.FieldDeletedAt)
  36997. }
  36998. if m.addtime != nil {
  36999. fields = append(fields, usagestatisticday.FieldAddtime)
  37000. }
  37001. if m._type != nil {
  37002. fields = append(fields, usagestatisticday.FieldType)
  37003. }
  37004. if m.bot_id != nil {
  37005. fields = append(fields, usagestatisticday.FieldBotID)
  37006. }
  37007. if m.organization_id != nil {
  37008. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37009. }
  37010. if m.ai_response != nil {
  37011. fields = append(fields, usagestatisticday.FieldAiResponse)
  37012. }
  37013. if m.sop_run != nil {
  37014. fields = append(fields, usagestatisticday.FieldSopRun)
  37015. }
  37016. if m.total_friend != nil {
  37017. fields = append(fields, usagestatisticday.FieldTotalFriend)
  37018. }
  37019. if m.total_group != nil {
  37020. fields = append(fields, usagestatisticday.FieldTotalGroup)
  37021. }
  37022. if m.account_balance != nil {
  37023. fields = append(fields, usagestatisticday.FieldAccountBalance)
  37024. }
  37025. if m.consume_token != nil {
  37026. fields = append(fields, usagestatisticday.FieldConsumeToken)
  37027. }
  37028. if m.active_user != nil {
  37029. fields = append(fields, usagestatisticday.FieldActiveUser)
  37030. }
  37031. if m.new_user != nil {
  37032. fields = append(fields, usagestatisticday.FieldNewUser)
  37033. }
  37034. if m.label_dist != nil {
  37035. fields = append(fields, usagestatisticday.FieldLabelDist)
  37036. }
  37037. if m.consume_coin != nil {
  37038. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37039. }
  37040. return fields
  37041. }
  37042. // Field returns the value of a field with the given name. The second boolean
  37043. // return value indicates that this field was not set, or was not defined in the
  37044. // schema.
  37045. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  37046. switch name {
  37047. case usagestatisticday.FieldCreatedAt:
  37048. return m.CreatedAt()
  37049. case usagestatisticday.FieldUpdatedAt:
  37050. return m.UpdatedAt()
  37051. case usagestatisticday.FieldStatus:
  37052. return m.Status()
  37053. case usagestatisticday.FieldDeletedAt:
  37054. return m.DeletedAt()
  37055. case usagestatisticday.FieldAddtime:
  37056. return m.Addtime()
  37057. case usagestatisticday.FieldType:
  37058. return m.GetType()
  37059. case usagestatisticday.FieldBotID:
  37060. return m.BotID()
  37061. case usagestatisticday.FieldOrganizationID:
  37062. return m.OrganizationID()
  37063. case usagestatisticday.FieldAiResponse:
  37064. return m.AiResponse()
  37065. case usagestatisticday.FieldSopRun:
  37066. return m.SopRun()
  37067. case usagestatisticday.FieldTotalFriend:
  37068. return m.TotalFriend()
  37069. case usagestatisticday.FieldTotalGroup:
  37070. return m.TotalGroup()
  37071. case usagestatisticday.FieldAccountBalance:
  37072. return m.AccountBalance()
  37073. case usagestatisticday.FieldConsumeToken:
  37074. return m.ConsumeToken()
  37075. case usagestatisticday.FieldActiveUser:
  37076. return m.ActiveUser()
  37077. case usagestatisticday.FieldNewUser:
  37078. return m.NewUser()
  37079. case usagestatisticday.FieldLabelDist:
  37080. return m.LabelDist()
  37081. case usagestatisticday.FieldConsumeCoin:
  37082. return m.ConsumeCoin()
  37083. }
  37084. return nil, false
  37085. }
  37086. // OldField returns the old value of the field from the database. An error is
  37087. // returned if the mutation operation is not UpdateOne, or the query to the
  37088. // database failed.
  37089. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37090. switch name {
  37091. case usagestatisticday.FieldCreatedAt:
  37092. return m.OldCreatedAt(ctx)
  37093. case usagestatisticday.FieldUpdatedAt:
  37094. return m.OldUpdatedAt(ctx)
  37095. case usagestatisticday.FieldStatus:
  37096. return m.OldStatus(ctx)
  37097. case usagestatisticday.FieldDeletedAt:
  37098. return m.OldDeletedAt(ctx)
  37099. case usagestatisticday.FieldAddtime:
  37100. return m.OldAddtime(ctx)
  37101. case usagestatisticday.FieldType:
  37102. return m.OldType(ctx)
  37103. case usagestatisticday.FieldBotID:
  37104. return m.OldBotID(ctx)
  37105. case usagestatisticday.FieldOrganizationID:
  37106. return m.OldOrganizationID(ctx)
  37107. case usagestatisticday.FieldAiResponse:
  37108. return m.OldAiResponse(ctx)
  37109. case usagestatisticday.FieldSopRun:
  37110. return m.OldSopRun(ctx)
  37111. case usagestatisticday.FieldTotalFriend:
  37112. return m.OldTotalFriend(ctx)
  37113. case usagestatisticday.FieldTotalGroup:
  37114. return m.OldTotalGroup(ctx)
  37115. case usagestatisticday.FieldAccountBalance:
  37116. return m.OldAccountBalance(ctx)
  37117. case usagestatisticday.FieldConsumeToken:
  37118. return m.OldConsumeToken(ctx)
  37119. case usagestatisticday.FieldActiveUser:
  37120. return m.OldActiveUser(ctx)
  37121. case usagestatisticday.FieldNewUser:
  37122. return m.OldNewUser(ctx)
  37123. case usagestatisticday.FieldLabelDist:
  37124. return m.OldLabelDist(ctx)
  37125. case usagestatisticday.FieldConsumeCoin:
  37126. return m.OldConsumeCoin(ctx)
  37127. }
  37128. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37129. }
  37130. // SetField sets the value of a field with the given name. It returns an error if
  37131. // the field is not defined in the schema, or if the type mismatched the field
  37132. // type.
  37133. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  37134. switch name {
  37135. case usagestatisticday.FieldCreatedAt:
  37136. v, ok := value.(time.Time)
  37137. if !ok {
  37138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37139. }
  37140. m.SetCreatedAt(v)
  37141. return nil
  37142. case usagestatisticday.FieldUpdatedAt:
  37143. v, ok := value.(time.Time)
  37144. if !ok {
  37145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37146. }
  37147. m.SetUpdatedAt(v)
  37148. return nil
  37149. case usagestatisticday.FieldStatus:
  37150. v, ok := value.(uint8)
  37151. if !ok {
  37152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37153. }
  37154. m.SetStatus(v)
  37155. return nil
  37156. case usagestatisticday.FieldDeletedAt:
  37157. v, ok := value.(time.Time)
  37158. if !ok {
  37159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37160. }
  37161. m.SetDeletedAt(v)
  37162. return nil
  37163. case usagestatisticday.FieldAddtime:
  37164. v, ok := value.(uint64)
  37165. if !ok {
  37166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37167. }
  37168. m.SetAddtime(v)
  37169. return nil
  37170. case usagestatisticday.FieldType:
  37171. v, ok := value.(int)
  37172. if !ok {
  37173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37174. }
  37175. m.SetType(v)
  37176. return nil
  37177. case usagestatisticday.FieldBotID:
  37178. v, ok := value.(string)
  37179. if !ok {
  37180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37181. }
  37182. m.SetBotID(v)
  37183. return nil
  37184. case usagestatisticday.FieldOrganizationID:
  37185. v, ok := value.(uint64)
  37186. if !ok {
  37187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37188. }
  37189. m.SetOrganizationID(v)
  37190. return nil
  37191. case usagestatisticday.FieldAiResponse:
  37192. v, ok := value.(uint64)
  37193. if !ok {
  37194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37195. }
  37196. m.SetAiResponse(v)
  37197. return nil
  37198. case usagestatisticday.FieldSopRun:
  37199. v, ok := value.(uint64)
  37200. if !ok {
  37201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37202. }
  37203. m.SetSopRun(v)
  37204. return nil
  37205. case usagestatisticday.FieldTotalFriend:
  37206. v, ok := value.(uint64)
  37207. if !ok {
  37208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37209. }
  37210. m.SetTotalFriend(v)
  37211. return nil
  37212. case usagestatisticday.FieldTotalGroup:
  37213. v, ok := value.(uint64)
  37214. if !ok {
  37215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37216. }
  37217. m.SetTotalGroup(v)
  37218. return nil
  37219. case usagestatisticday.FieldAccountBalance:
  37220. v, ok := value.(uint64)
  37221. if !ok {
  37222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37223. }
  37224. m.SetAccountBalance(v)
  37225. return nil
  37226. case usagestatisticday.FieldConsumeToken:
  37227. v, ok := value.(uint64)
  37228. if !ok {
  37229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37230. }
  37231. m.SetConsumeToken(v)
  37232. return nil
  37233. case usagestatisticday.FieldActiveUser:
  37234. v, ok := value.(uint64)
  37235. if !ok {
  37236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37237. }
  37238. m.SetActiveUser(v)
  37239. return nil
  37240. case usagestatisticday.FieldNewUser:
  37241. v, ok := value.(int64)
  37242. if !ok {
  37243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37244. }
  37245. m.SetNewUser(v)
  37246. return nil
  37247. case usagestatisticday.FieldLabelDist:
  37248. v, ok := value.([]custom_types.LabelDist)
  37249. if !ok {
  37250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37251. }
  37252. m.SetLabelDist(v)
  37253. return nil
  37254. case usagestatisticday.FieldConsumeCoin:
  37255. v, ok := value.(float64)
  37256. if !ok {
  37257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37258. }
  37259. m.SetConsumeCoin(v)
  37260. return nil
  37261. }
  37262. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37263. }
  37264. // AddedFields returns all numeric fields that were incremented/decremented during
  37265. // this mutation.
  37266. func (m *UsageStatisticDayMutation) AddedFields() []string {
  37267. var fields []string
  37268. if m.addstatus != nil {
  37269. fields = append(fields, usagestatisticday.FieldStatus)
  37270. }
  37271. if m.addaddtime != nil {
  37272. fields = append(fields, usagestatisticday.FieldAddtime)
  37273. }
  37274. if m.add_type != nil {
  37275. fields = append(fields, usagestatisticday.FieldType)
  37276. }
  37277. if m.addorganization_id != nil {
  37278. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37279. }
  37280. if m.addai_response != nil {
  37281. fields = append(fields, usagestatisticday.FieldAiResponse)
  37282. }
  37283. if m.addsop_run != nil {
  37284. fields = append(fields, usagestatisticday.FieldSopRun)
  37285. }
  37286. if m.addtotal_friend != nil {
  37287. fields = append(fields, usagestatisticday.FieldTotalFriend)
  37288. }
  37289. if m.addtotal_group != nil {
  37290. fields = append(fields, usagestatisticday.FieldTotalGroup)
  37291. }
  37292. if m.addaccount_balance != nil {
  37293. fields = append(fields, usagestatisticday.FieldAccountBalance)
  37294. }
  37295. if m.addconsume_token != nil {
  37296. fields = append(fields, usagestatisticday.FieldConsumeToken)
  37297. }
  37298. if m.addactive_user != nil {
  37299. fields = append(fields, usagestatisticday.FieldActiveUser)
  37300. }
  37301. if m.addnew_user != nil {
  37302. fields = append(fields, usagestatisticday.FieldNewUser)
  37303. }
  37304. if m.addconsume_coin != nil {
  37305. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37306. }
  37307. return fields
  37308. }
  37309. // AddedField returns the numeric value that was incremented/decremented on a field
  37310. // with the given name. The second boolean return value indicates that this field
  37311. // was not set, or was not defined in the schema.
  37312. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  37313. switch name {
  37314. case usagestatisticday.FieldStatus:
  37315. return m.AddedStatus()
  37316. case usagestatisticday.FieldAddtime:
  37317. return m.AddedAddtime()
  37318. case usagestatisticday.FieldType:
  37319. return m.AddedType()
  37320. case usagestatisticday.FieldOrganizationID:
  37321. return m.AddedOrganizationID()
  37322. case usagestatisticday.FieldAiResponse:
  37323. return m.AddedAiResponse()
  37324. case usagestatisticday.FieldSopRun:
  37325. return m.AddedSopRun()
  37326. case usagestatisticday.FieldTotalFriend:
  37327. return m.AddedTotalFriend()
  37328. case usagestatisticday.FieldTotalGroup:
  37329. return m.AddedTotalGroup()
  37330. case usagestatisticday.FieldAccountBalance:
  37331. return m.AddedAccountBalance()
  37332. case usagestatisticday.FieldConsumeToken:
  37333. return m.AddedConsumeToken()
  37334. case usagestatisticday.FieldActiveUser:
  37335. return m.AddedActiveUser()
  37336. case usagestatisticday.FieldNewUser:
  37337. return m.AddedNewUser()
  37338. case usagestatisticday.FieldConsumeCoin:
  37339. return m.AddedConsumeCoin()
  37340. }
  37341. return nil, false
  37342. }
  37343. // AddField adds the value to the field with the given name. It returns an error if
  37344. // the field is not defined in the schema, or if the type mismatched the field
  37345. // type.
  37346. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  37347. switch name {
  37348. case usagestatisticday.FieldStatus:
  37349. v, ok := value.(int8)
  37350. if !ok {
  37351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37352. }
  37353. m.AddStatus(v)
  37354. return nil
  37355. case usagestatisticday.FieldAddtime:
  37356. v, ok := value.(int64)
  37357. if !ok {
  37358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37359. }
  37360. m.AddAddtime(v)
  37361. return nil
  37362. case usagestatisticday.FieldType:
  37363. v, ok := value.(int)
  37364. if !ok {
  37365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37366. }
  37367. m.AddType(v)
  37368. return nil
  37369. case usagestatisticday.FieldOrganizationID:
  37370. v, ok := value.(int64)
  37371. if !ok {
  37372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37373. }
  37374. m.AddOrganizationID(v)
  37375. return nil
  37376. case usagestatisticday.FieldAiResponse:
  37377. v, ok := value.(int64)
  37378. if !ok {
  37379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37380. }
  37381. m.AddAiResponse(v)
  37382. return nil
  37383. case usagestatisticday.FieldSopRun:
  37384. v, ok := value.(int64)
  37385. if !ok {
  37386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37387. }
  37388. m.AddSopRun(v)
  37389. return nil
  37390. case usagestatisticday.FieldTotalFriend:
  37391. v, ok := value.(int64)
  37392. if !ok {
  37393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37394. }
  37395. m.AddTotalFriend(v)
  37396. return nil
  37397. case usagestatisticday.FieldTotalGroup:
  37398. v, ok := value.(int64)
  37399. if !ok {
  37400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37401. }
  37402. m.AddTotalGroup(v)
  37403. return nil
  37404. case usagestatisticday.FieldAccountBalance:
  37405. v, ok := value.(int64)
  37406. if !ok {
  37407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37408. }
  37409. m.AddAccountBalance(v)
  37410. return nil
  37411. case usagestatisticday.FieldConsumeToken:
  37412. v, ok := value.(int64)
  37413. if !ok {
  37414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37415. }
  37416. m.AddConsumeToken(v)
  37417. return nil
  37418. case usagestatisticday.FieldActiveUser:
  37419. v, ok := value.(int64)
  37420. if !ok {
  37421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37422. }
  37423. m.AddActiveUser(v)
  37424. return nil
  37425. case usagestatisticday.FieldNewUser:
  37426. v, ok := value.(int64)
  37427. if !ok {
  37428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37429. }
  37430. m.AddNewUser(v)
  37431. return nil
  37432. case usagestatisticday.FieldConsumeCoin:
  37433. v, ok := value.(float64)
  37434. if !ok {
  37435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37436. }
  37437. m.AddConsumeCoin(v)
  37438. return nil
  37439. }
  37440. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  37441. }
  37442. // ClearedFields returns all nullable fields that were cleared during this
  37443. // mutation.
  37444. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  37445. var fields []string
  37446. if m.FieldCleared(usagestatisticday.FieldStatus) {
  37447. fields = append(fields, usagestatisticday.FieldStatus)
  37448. }
  37449. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  37450. fields = append(fields, usagestatisticday.FieldDeletedAt)
  37451. }
  37452. if m.FieldCleared(usagestatisticday.FieldBotID) {
  37453. fields = append(fields, usagestatisticday.FieldBotID)
  37454. }
  37455. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  37456. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37457. }
  37458. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  37459. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37460. }
  37461. return fields
  37462. }
  37463. // FieldCleared returns a boolean indicating if a field with the given name was
  37464. // cleared in this mutation.
  37465. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  37466. _, ok := m.clearedFields[name]
  37467. return ok
  37468. }
  37469. // ClearField clears the value of the field with the given name. It returns an
  37470. // error if the field is not defined in the schema.
  37471. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  37472. switch name {
  37473. case usagestatisticday.FieldStatus:
  37474. m.ClearStatus()
  37475. return nil
  37476. case usagestatisticday.FieldDeletedAt:
  37477. m.ClearDeletedAt()
  37478. return nil
  37479. case usagestatisticday.FieldBotID:
  37480. m.ClearBotID()
  37481. return nil
  37482. case usagestatisticday.FieldOrganizationID:
  37483. m.ClearOrganizationID()
  37484. return nil
  37485. case usagestatisticday.FieldConsumeCoin:
  37486. m.ClearConsumeCoin()
  37487. return nil
  37488. }
  37489. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  37490. }
  37491. // ResetField resets all changes in the mutation for the field with the given name.
  37492. // It returns an error if the field is not defined in the schema.
  37493. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  37494. switch name {
  37495. case usagestatisticday.FieldCreatedAt:
  37496. m.ResetCreatedAt()
  37497. return nil
  37498. case usagestatisticday.FieldUpdatedAt:
  37499. m.ResetUpdatedAt()
  37500. return nil
  37501. case usagestatisticday.FieldStatus:
  37502. m.ResetStatus()
  37503. return nil
  37504. case usagestatisticday.FieldDeletedAt:
  37505. m.ResetDeletedAt()
  37506. return nil
  37507. case usagestatisticday.FieldAddtime:
  37508. m.ResetAddtime()
  37509. return nil
  37510. case usagestatisticday.FieldType:
  37511. m.ResetType()
  37512. return nil
  37513. case usagestatisticday.FieldBotID:
  37514. m.ResetBotID()
  37515. return nil
  37516. case usagestatisticday.FieldOrganizationID:
  37517. m.ResetOrganizationID()
  37518. return nil
  37519. case usagestatisticday.FieldAiResponse:
  37520. m.ResetAiResponse()
  37521. return nil
  37522. case usagestatisticday.FieldSopRun:
  37523. m.ResetSopRun()
  37524. return nil
  37525. case usagestatisticday.FieldTotalFriend:
  37526. m.ResetTotalFriend()
  37527. return nil
  37528. case usagestatisticday.FieldTotalGroup:
  37529. m.ResetTotalGroup()
  37530. return nil
  37531. case usagestatisticday.FieldAccountBalance:
  37532. m.ResetAccountBalance()
  37533. return nil
  37534. case usagestatisticday.FieldConsumeToken:
  37535. m.ResetConsumeToken()
  37536. return nil
  37537. case usagestatisticday.FieldActiveUser:
  37538. m.ResetActiveUser()
  37539. return nil
  37540. case usagestatisticday.FieldNewUser:
  37541. m.ResetNewUser()
  37542. return nil
  37543. case usagestatisticday.FieldLabelDist:
  37544. m.ResetLabelDist()
  37545. return nil
  37546. case usagestatisticday.FieldConsumeCoin:
  37547. m.ResetConsumeCoin()
  37548. return nil
  37549. }
  37550. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37551. }
  37552. // AddedEdges returns all edge names that were set/added in this mutation.
  37553. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  37554. edges := make([]string, 0, 0)
  37555. return edges
  37556. }
  37557. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37558. // name in this mutation.
  37559. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  37560. return nil
  37561. }
  37562. // RemovedEdges returns all edge names that were removed in this mutation.
  37563. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  37564. edges := make([]string, 0, 0)
  37565. return edges
  37566. }
  37567. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37568. // the given name in this mutation.
  37569. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  37570. return nil
  37571. }
  37572. // ClearedEdges returns all edge names that were cleared in this mutation.
  37573. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  37574. edges := make([]string, 0, 0)
  37575. return edges
  37576. }
  37577. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37578. // was cleared in this mutation.
  37579. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  37580. return false
  37581. }
  37582. // ClearEdge clears the value of the edge with the given name. It returns an error
  37583. // if that edge is not defined in the schema.
  37584. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  37585. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  37586. }
  37587. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37588. // It returns an error if the edge is not defined in the schema.
  37589. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  37590. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  37591. }
  37592. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  37593. type UsageStatisticHourMutation struct {
  37594. config
  37595. op Op
  37596. typ string
  37597. id *uint64
  37598. created_at *time.Time
  37599. updated_at *time.Time
  37600. status *uint8
  37601. addstatus *int8
  37602. deleted_at *time.Time
  37603. addtime *uint64
  37604. addaddtime *int64
  37605. _type *int
  37606. add_type *int
  37607. bot_id *string
  37608. organization_id *uint64
  37609. addorganization_id *int64
  37610. ai_response *uint64
  37611. addai_response *int64
  37612. sop_run *uint64
  37613. addsop_run *int64
  37614. total_friend *uint64
  37615. addtotal_friend *int64
  37616. total_group *uint64
  37617. addtotal_group *int64
  37618. account_balance *uint64
  37619. addaccount_balance *int64
  37620. consume_token *uint64
  37621. addconsume_token *int64
  37622. active_user *uint64
  37623. addactive_user *int64
  37624. new_user *int64
  37625. addnew_user *int64
  37626. label_dist *[]custom_types.LabelDist
  37627. appendlabel_dist []custom_types.LabelDist
  37628. consume_coin *float64
  37629. addconsume_coin *float64
  37630. clearedFields map[string]struct{}
  37631. done bool
  37632. oldValue func(context.Context) (*UsageStatisticHour, error)
  37633. predicates []predicate.UsageStatisticHour
  37634. }
  37635. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  37636. // usagestatistichourOption allows management of the mutation configuration using functional options.
  37637. type usagestatistichourOption func(*UsageStatisticHourMutation)
  37638. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  37639. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  37640. m := &UsageStatisticHourMutation{
  37641. config: c,
  37642. op: op,
  37643. typ: TypeUsageStatisticHour,
  37644. clearedFields: make(map[string]struct{}),
  37645. }
  37646. for _, opt := range opts {
  37647. opt(m)
  37648. }
  37649. return m
  37650. }
  37651. // withUsageStatisticHourID sets the ID field of the mutation.
  37652. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  37653. return func(m *UsageStatisticHourMutation) {
  37654. var (
  37655. err error
  37656. once sync.Once
  37657. value *UsageStatisticHour
  37658. )
  37659. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  37660. once.Do(func() {
  37661. if m.done {
  37662. err = errors.New("querying old values post mutation is not allowed")
  37663. } else {
  37664. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  37665. }
  37666. })
  37667. return value, err
  37668. }
  37669. m.id = &id
  37670. }
  37671. }
  37672. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  37673. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  37674. return func(m *UsageStatisticHourMutation) {
  37675. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  37676. return node, nil
  37677. }
  37678. m.id = &node.ID
  37679. }
  37680. }
  37681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37682. // executed in a transaction (ent.Tx), a transactional client is returned.
  37683. func (m UsageStatisticHourMutation) Client() *Client {
  37684. client := &Client{config: m.config}
  37685. client.init()
  37686. return client
  37687. }
  37688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37689. // it returns an error otherwise.
  37690. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  37691. if _, ok := m.driver.(*txDriver); !ok {
  37692. return nil, errors.New("ent: mutation is not running in a transaction")
  37693. }
  37694. tx := &Tx{config: m.config}
  37695. tx.init()
  37696. return tx, nil
  37697. }
  37698. // SetID sets the value of the id field. Note that this
  37699. // operation is only accepted on creation of UsageStatisticHour entities.
  37700. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  37701. m.id = &id
  37702. }
  37703. // ID returns the ID value in the mutation. Note that the ID is only available
  37704. // if it was provided to the builder or after it was returned from the database.
  37705. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  37706. if m.id == nil {
  37707. return
  37708. }
  37709. return *m.id, true
  37710. }
  37711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37712. // That means, if the mutation is applied within a transaction with an isolation level such
  37713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37714. // or updated by the mutation.
  37715. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  37716. switch {
  37717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37718. id, exists := m.ID()
  37719. if exists {
  37720. return []uint64{id}, nil
  37721. }
  37722. fallthrough
  37723. case m.op.Is(OpUpdate | OpDelete):
  37724. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  37725. default:
  37726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37727. }
  37728. }
  37729. // SetCreatedAt sets the "created_at" field.
  37730. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  37731. m.created_at = &t
  37732. }
  37733. // CreatedAt returns the value of the "created_at" field in the mutation.
  37734. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  37735. v := m.created_at
  37736. if v == nil {
  37737. return
  37738. }
  37739. return *v, true
  37740. }
  37741. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  37742. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37744. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37745. if !m.op.Is(OpUpdateOne) {
  37746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37747. }
  37748. if m.id == nil || m.oldValue == nil {
  37749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37750. }
  37751. oldValue, err := m.oldValue(ctx)
  37752. if err != nil {
  37753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37754. }
  37755. return oldValue.CreatedAt, nil
  37756. }
  37757. // ResetCreatedAt resets all changes to the "created_at" field.
  37758. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  37759. m.created_at = nil
  37760. }
  37761. // SetUpdatedAt sets the "updated_at" field.
  37762. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  37763. m.updated_at = &t
  37764. }
  37765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37766. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  37767. v := m.updated_at
  37768. if v == nil {
  37769. return
  37770. }
  37771. return *v, true
  37772. }
  37773. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  37774. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37776. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37777. if !m.op.Is(OpUpdateOne) {
  37778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37779. }
  37780. if m.id == nil || m.oldValue == nil {
  37781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37782. }
  37783. oldValue, err := m.oldValue(ctx)
  37784. if err != nil {
  37785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37786. }
  37787. return oldValue.UpdatedAt, nil
  37788. }
  37789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37790. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  37791. m.updated_at = nil
  37792. }
  37793. // SetStatus sets the "status" field.
  37794. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  37795. m.status = &u
  37796. m.addstatus = nil
  37797. }
  37798. // Status returns the value of the "status" field in the mutation.
  37799. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  37800. v := m.status
  37801. if v == nil {
  37802. return
  37803. }
  37804. return *v, true
  37805. }
  37806. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  37807. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37809. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37810. if !m.op.Is(OpUpdateOne) {
  37811. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37812. }
  37813. if m.id == nil || m.oldValue == nil {
  37814. return v, errors.New("OldStatus requires an ID field in the mutation")
  37815. }
  37816. oldValue, err := m.oldValue(ctx)
  37817. if err != nil {
  37818. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37819. }
  37820. return oldValue.Status, nil
  37821. }
  37822. // AddStatus adds u to the "status" field.
  37823. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  37824. if m.addstatus != nil {
  37825. *m.addstatus += u
  37826. } else {
  37827. m.addstatus = &u
  37828. }
  37829. }
  37830. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37831. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  37832. v := m.addstatus
  37833. if v == nil {
  37834. return
  37835. }
  37836. return *v, true
  37837. }
  37838. // ClearStatus clears the value of the "status" field.
  37839. func (m *UsageStatisticHourMutation) ClearStatus() {
  37840. m.status = nil
  37841. m.addstatus = nil
  37842. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  37843. }
  37844. // StatusCleared returns if the "status" field was cleared in this mutation.
  37845. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  37846. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  37847. return ok
  37848. }
  37849. // ResetStatus resets all changes to the "status" field.
  37850. func (m *UsageStatisticHourMutation) ResetStatus() {
  37851. m.status = nil
  37852. m.addstatus = nil
  37853. delete(m.clearedFields, usagestatistichour.FieldStatus)
  37854. }
  37855. // SetDeletedAt sets the "deleted_at" field.
  37856. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  37857. m.deleted_at = &t
  37858. }
  37859. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37860. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  37861. v := m.deleted_at
  37862. if v == nil {
  37863. return
  37864. }
  37865. return *v, true
  37866. }
  37867. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  37868. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37870. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37871. if !m.op.Is(OpUpdateOne) {
  37872. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37873. }
  37874. if m.id == nil || m.oldValue == nil {
  37875. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37876. }
  37877. oldValue, err := m.oldValue(ctx)
  37878. if err != nil {
  37879. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37880. }
  37881. return oldValue.DeletedAt, nil
  37882. }
  37883. // ClearDeletedAt clears the value of the "deleted_at" field.
  37884. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  37885. m.deleted_at = nil
  37886. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  37887. }
  37888. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37889. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  37890. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  37891. return ok
  37892. }
  37893. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37894. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  37895. m.deleted_at = nil
  37896. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  37897. }
  37898. // SetAddtime sets the "addtime" field.
  37899. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  37900. m.addtime = &u
  37901. m.addaddtime = nil
  37902. }
  37903. // Addtime returns the value of the "addtime" field in the mutation.
  37904. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  37905. v := m.addtime
  37906. if v == nil {
  37907. return
  37908. }
  37909. return *v, true
  37910. }
  37911. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  37912. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37914. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37915. if !m.op.Is(OpUpdateOne) {
  37916. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37917. }
  37918. if m.id == nil || m.oldValue == nil {
  37919. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37920. }
  37921. oldValue, err := m.oldValue(ctx)
  37922. if err != nil {
  37923. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37924. }
  37925. return oldValue.Addtime, nil
  37926. }
  37927. // AddAddtime adds u to the "addtime" field.
  37928. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  37929. if m.addaddtime != nil {
  37930. *m.addaddtime += u
  37931. } else {
  37932. m.addaddtime = &u
  37933. }
  37934. }
  37935. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37936. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  37937. v := m.addaddtime
  37938. if v == nil {
  37939. return
  37940. }
  37941. return *v, true
  37942. }
  37943. // ResetAddtime resets all changes to the "addtime" field.
  37944. func (m *UsageStatisticHourMutation) ResetAddtime() {
  37945. m.addtime = nil
  37946. m.addaddtime = nil
  37947. }
  37948. // SetType sets the "type" field.
  37949. func (m *UsageStatisticHourMutation) SetType(i int) {
  37950. m._type = &i
  37951. m.add_type = nil
  37952. }
  37953. // GetType returns the value of the "type" field in the mutation.
  37954. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  37955. v := m._type
  37956. if v == nil {
  37957. return
  37958. }
  37959. return *v, true
  37960. }
  37961. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  37962. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37964. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  37965. if !m.op.Is(OpUpdateOne) {
  37966. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37967. }
  37968. if m.id == nil || m.oldValue == nil {
  37969. return v, errors.New("OldType requires an ID field in the mutation")
  37970. }
  37971. oldValue, err := m.oldValue(ctx)
  37972. if err != nil {
  37973. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37974. }
  37975. return oldValue.Type, nil
  37976. }
  37977. // AddType adds i to the "type" field.
  37978. func (m *UsageStatisticHourMutation) AddType(i int) {
  37979. if m.add_type != nil {
  37980. *m.add_type += i
  37981. } else {
  37982. m.add_type = &i
  37983. }
  37984. }
  37985. // AddedType returns the value that was added to the "type" field in this mutation.
  37986. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  37987. v := m.add_type
  37988. if v == nil {
  37989. return
  37990. }
  37991. return *v, true
  37992. }
  37993. // ResetType resets all changes to the "type" field.
  37994. func (m *UsageStatisticHourMutation) ResetType() {
  37995. m._type = nil
  37996. m.add_type = nil
  37997. }
  37998. // SetBotID sets the "bot_id" field.
  37999. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  38000. m.bot_id = &s
  38001. }
  38002. // BotID returns the value of the "bot_id" field in the mutation.
  38003. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  38004. v := m.bot_id
  38005. if v == nil {
  38006. return
  38007. }
  38008. return *v, true
  38009. }
  38010. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  38011. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38013. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  38014. if !m.op.Is(OpUpdateOne) {
  38015. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  38016. }
  38017. if m.id == nil || m.oldValue == nil {
  38018. return v, errors.New("OldBotID requires an ID field in the mutation")
  38019. }
  38020. oldValue, err := m.oldValue(ctx)
  38021. if err != nil {
  38022. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  38023. }
  38024. return oldValue.BotID, nil
  38025. }
  38026. // ClearBotID clears the value of the "bot_id" field.
  38027. func (m *UsageStatisticHourMutation) ClearBotID() {
  38028. m.bot_id = nil
  38029. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  38030. }
  38031. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  38032. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  38033. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  38034. return ok
  38035. }
  38036. // ResetBotID resets all changes to the "bot_id" field.
  38037. func (m *UsageStatisticHourMutation) ResetBotID() {
  38038. m.bot_id = nil
  38039. delete(m.clearedFields, usagestatistichour.FieldBotID)
  38040. }
  38041. // SetOrganizationID sets the "organization_id" field.
  38042. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  38043. m.organization_id = &u
  38044. m.addorganization_id = nil
  38045. }
  38046. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38047. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  38048. v := m.organization_id
  38049. if v == nil {
  38050. return
  38051. }
  38052. return *v, true
  38053. }
  38054. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  38055. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38057. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38058. if !m.op.Is(OpUpdateOne) {
  38059. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38060. }
  38061. if m.id == nil || m.oldValue == nil {
  38062. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38063. }
  38064. oldValue, err := m.oldValue(ctx)
  38065. if err != nil {
  38066. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38067. }
  38068. return oldValue.OrganizationID, nil
  38069. }
  38070. // AddOrganizationID adds u to the "organization_id" field.
  38071. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  38072. if m.addorganization_id != nil {
  38073. *m.addorganization_id += u
  38074. } else {
  38075. m.addorganization_id = &u
  38076. }
  38077. }
  38078. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38079. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  38080. v := m.addorganization_id
  38081. if v == nil {
  38082. return
  38083. }
  38084. return *v, true
  38085. }
  38086. // ClearOrganizationID clears the value of the "organization_id" field.
  38087. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  38088. m.organization_id = nil
  38089. m.addorganization_id = nil
  38090. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  38091. }
  38092. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38093. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  38094. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  38095. return ok
  38096. }
  38097. // ResetOrganizationID resets all changes to the "organization_id" field.
  38098. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  38099. m.organization_id = nil
  38100. m.addorganization_id = nil
  38101. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  38102. }
  38103. // SetAiResponse sets the "ai_response" field.
  38104. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  38105. m.ai_response = &u
  38106. m.addai_response = nil
  38107. }
  38108. // AiResponse returns the value of the "ai_response" field in the mutation.
  38109. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  38110. v := m.ai_response
  38111. if v == nil {
  38112. return
  38113. }
  38114. return *v, true
  38115. }
  38116. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  38117. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38119. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  38120. if !m.op.Is(OpUpdateOne) {
  38121. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  38122. }
  38123. if m.id == nil || m.oldValue == nil {
  38124. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  38125. }
  38126. oldValue, err := m.oldValue(ctx)
  38127. if err != nil {
  38128. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  38129. }
  38130. return oldValue.AiResponse, nil
  38131. }
  38132. // AddAiResponse adds u to the "ai_response" field.
  38133. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  38134. if m.addai_response != nil {
  38135. *m.addai_response += u
  38136. } else {
  38137. m.addai_response = &u
  38138. }
  38139. }
  38140. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  38141. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  38142. v := m.addai_response
  38143. if v == nil {
  38144. return
  38145. }
  38146. return *v, true
  38147. }
  38148. // ResetAiResponse resets all changes to the "ai_response" field.
  38149. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  38150. m.ai_response = nil
  38151. m.addai_response = nil
  38152. }
  38153. // SetSopRun sets the "sop_run" field.
  38154. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  38155. m.sop_run = &u
  38156. m.addsop_run = nil
  38157. }
  38158. // SopRun returns the value of the "sop_run" field in the mutation.
  38159. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  38160. v := m.sop_run
  38161. if v == nil {
  38162. return
  38163. }
  38164. return *v, true
  38165. }
  38166. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  38167. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38169. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  38170. if !m.op.Is(OpUpdateOne) {
  38171. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  38172. }
  38173. if m.id == nil || m.oldValue == nil {
  38174. return v, errors.New("OldSopRun requires an ID field in the mutation")
  38175. }
  38176. oldValue, err := m.oldValue(ctx)
  38177. if err != nil {
  38178. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  38179. }
  38180. return oldValue.SopRun, nil
  38181. }
  38182. // AddSopRun adds u to the "sop_run" field.
  38183. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  38184. if m.addsop_run != nil {
  38185. *m.addsop_run += u
  38186. } else {
  38187. m.addsop_run = &u
  38188. }
  38189. }
  38190. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  38191. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  38192. v := m.addsop_run
  38193. if v == nil {
  38194. return
  38195. }
  38196. return *v, true
  38197. }
  38198. // ResetSopRun resets all changes to the "sop_run" field.
  38199. func (m *UsageStatisticHourMutation) ResetSopRun() {
  38200. m.sop_run = nil
  38201. m.addsop_run = nil
  38202. }
  38203. // SetTotalFriend sets the "total_friend" field.
  38204. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  38205. m.total_friend = &u
  38206. m.addtotal_friend = nil
  38207. }
  38208. // TotalFriend returns the value of the "total_friend" field in the mutation.
  38209. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  38210. v := m.total_friend
  38211. if v == nil {
  38212. return
  38213. }
  38214. return *v, true
  38215. }
  38216. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  38217. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38219. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  38220. if !m.op.Is(OpUpdateOne) {
  38221. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  38222. }
  38223. if m.id == nil || m.oldValue == nil {
  38224. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  38225. }
  38226. oldValue, err := m.oldValue(ctx)
  38227. if err != nil {
  38228. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  38229. }
  38230. return oldValue.TotalFriend, nil
  38231. }
  38232. // AddTotalFriend adds u to the "total_friend" field.
  38233. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  38234. if m.addtotal_friend != nil {
  38235. *m.addtotal_friend += u
  38236. } else {
  38237. m.addtotal_friend = &u
  38238. }
  38239. }
  38240. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  38241. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  38242. v := m.addtotal_friend
  38243. if v == nil {
  38244. return
  38245. }
  38246. return *v, true
  38247. }
  38248. // ResetTotalFriend resets all changes to the "total_friend" field.
  38249. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  38250. m.total_friend = nil
  38251. m.addtotal_friend = nil
  38252. }
  38253. // SetTotalGroup sets the "total_group" field.
  38254. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  38255. m.total_group = &u
  38256. m.addtotal_group = nil
  38257. }
  38258. // TotalGroup returns the value of the "total_group" field in the mutation.
  38259. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  38260. v := m.total_group
  38261. if v == nil {
  38262. return
  38263. }
  38264. return *v, true
  38265. }
  38266. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  38267. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38269. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  38270. if !m.op.Is(OpUpdateOne) {
  38271. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  38272. }
  38273. if m.id == nil || m.oldValue == nil {
  38274. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  38275. }
  38276. oldValue, err := m.oldValue(ctx)
  38277. if err != nil {
  38278. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  38279. }
  38280. return oldValue.TotalGroup, nil
  38281. }
  38282. // AddTotalGroup adds u to the "total_group" field.
  38283. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  38284. if m.addtotal_group != nil {
  38285. *m.addtotal_group += u
  38286. } else {
  38287. m.addtotal_group = &u
  38288. }
  38289. }
  38290. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  38291. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  38292. v := m.addtotal_group
  38293. if v == nil {
  38294. return
  38295. }
  38296. return *v, true
  38297. }
  38298. // ResetTotalGroup resets all changes to the "total_group" field.
  38299. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  38300. m.total_group = nil
  38301. m.addtotal_group = nil
  38302. }
  38303. // SetAccountBalance sets the "account_balance" field.
  38304. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  38305. m.account_balance = &u
  38306. m.addaccount_balance = nil
  38307. }
  38308. // AccountBalance returns the value of the "account_balance" field in the mutation.
  38309. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  38310. v := m.account_balance
  38311. if v == nil {
  38312. return
  38313. }
  38314. return *v, true
  38315. }
  38316. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  38317. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38319. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  38320. if !m.op.Is(OpUpdateOne) {
  38321. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  38322. }
  38323. if m.id == nil || m.oldValue == nil {
  38324. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  38325. }
  38326. oldValue, err := m.oldValue(ctx)
  38327. if err != nil {
  38328. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  38329. }
  38330. return oldValue.AccountBalance, nil
  38331. }
  38332. // AddAccountBalance adds u to the "account_balance" field.
  38333. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  38334. if m.addaccount_balance != nil {
  38335. *m.addaccount_balance += u
  38336. } else {
  38337. m.addaccount_balance = &u
  38338. }
  38339. }
  38340. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  38341. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  38342. v := m.addaccount_balance
  38343. if v == nil {
  38344. return
  38345. }
  38346. return *v, true
  38347. }
  38348. // ResetAccountBalance resets all changes to the "account_balance" field.
  38349. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  38350. m.account_balance = nil
  38351. m.addaccount_balance = nil
  38352. }
  38353. // SetConsumeToken sets the "consume_token" field.
  38354. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  38355. m.consume_token = &u
  38356. m.addconsume_token = nil
  38357. }
  38358. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  38359. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  38360. v := m.consume_token
  38361. if v == nil {
  38362. return
  38363. }
  38364. return *v, true
  38365. }
  38366. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  38367. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38369. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38370. if !m.op.Is(OpUpdateOne) {
  38371. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38372. }
  38373. if m.id == nil || m.oldValue == nil {
  38374. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38375. }
  38376. oldValue, err := m.oldValue(ctx)
  38377. if err != nil {
  38378. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38379. }
  38380. return oldValue.ConsumeToken, nil
  38381. }
  38382. // AddConsumeToken adds u to the "consume_token" field.
  38383. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  38384. if m.addconsume_token != nil {
  38385. *m.addconsume_token += u
  38386. } else {
  38387. m.addconsume_token = &u
  38388. }
  38389. }
  38390. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38391. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  38392. v := m.addconsume_token
  38393. if v == nil {
  38394. return
  38395. }
  38396. return *v, true
  38397. }
  38398. // ResetConsumeToken resets all changes to the "consume_token" field.
  38399. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  38400. m.consume_token = nil
  38401. m.addconsume_token = nil
  38402. }
  38403. // SetActiveUser sets the "active_user" field.
  38404. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  38405. m.active_user = &u
  38406. m.addactive_user = nil
  38407. }
  38408. // ActiveUser returns the value of the "active_user" field in the mutation.
  38409. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  38410. v := m.active_user
  38411. if v == nil {
  38412. return
  38413. }
  38414. return *v, true
  38415. }
  38416. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  38417. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38419. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38420. if !m.op.Is(OpUpdateOne) {
  38421. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38422. }
  38423. if m.id == nil || m.oldValue == nil {
  38424. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  38425. }
  38426. oldValue, err := m.oldValue(ctx)
  38427. if err != nil {
  38428. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  38429. }
  38430. return oldValue.ActiveUser, nil
  38431. }
  38432. // AddActiveUser adds u to the "active_user" field.
  38433. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  38434. if m.addactive_user != nil {
  38435. *m.addactive_user += u
  38436. } else {
  38437. m.addactive_user = &u
  38438. }
  38439. }
  38440. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38441. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  38442. v := m.addactive_user
  38443. if v == nil {
  38444. return
  38445. }
  38446. return *v, true
  38447. }
  38448. // ResetActiveUser resets all changes to the "active_user" field.
  38449. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  38450. m.active_user = nil
  38451. m.addactive_user = nil
  38452. }
  38453. // SetNewUser sets the "new_user" field.
  38454. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  38455. m.new_user = &i
  38456. m.addnew_user = nil
  38457. }
  38458. // NewUser returns the value of the "new_user" field in the mutation.
  38459. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  38460. v := m.new_user
  38461. if v == nil {
  38462. return
  38463. }
  38464. return *v, true
  38465. }
  38466. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  38467. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38469. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38470. if !m.op.Is(OpUpdateOne) {
  38471. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38472. }
  38473. if m.id == nil || m.oldValue == nil {
  38474. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38475. }
  38476. oldValue, err := m.oldValue(ctx)
  38477. if err != nil {
  38478. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38479. }
  38480. return oldValue.NewUser, nil
  38481. }
  38482. // AddNewUser adds i to the "new_user" field.
  38483. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  38484. if m.addnew_user != nil {
  38485. *m.addnew_user += i
  38486. } else {
  38487. m.addnew_user = &i
  38488. }
  38489. }
  38490. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38491. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  38492. v := m.addnew_user
  38493. if v == nil {
  38494. return
  38495. }
  38496. return *v, true
  38497. }
  38498. // ResetNewUser resets all changes to the "new_user" field.
  38499. func (m *UsageStatisticHourMutation) ResetNewUser() {
  38500. m.new_user = nil
  38501. m.addnew_user = nil
  38502. }
  38503. // SetLabelDist sets the "label_dist" field.
  38504. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38505. m.label_dist = &ctd
  38506. m.appendlabel_dist = nil
  38507. }
  38508. // LabelDist returns the value of the "label_dist" field in the mutation.
  38509. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38510. v := m.label_dist
  38511. if v == nil {
  38512. return
  38513. }
  38514. return *v, true
  38515. }
  38516. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  38517. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38519. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38520. if !m.op.Is(OpUpdateOne) {
  38521. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38522. }
  38523. if m.id == nil || m.oldValue == nil {
  38524. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38525. }
  38526. oldValue, err := m.oldValue(ctx)
  38527. if err != nil {
  38528. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38529. }
  38530. return oldValue.LabelDist, nil
  38531. }
  38532. // AppendLabelDist adds ctd to the "label_dist" field.
  38533. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38534. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38535. }
  38536. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38537. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38538. if len(m.appendlabel_dist) == 0 {
  38539. return nil, false
  38540. }
  38541. return m.appendlabel_dist, true
  38542. }
  38543. // ResetLabelDist resets all changes to the "label_dist" field.
  38544. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  38545. m.label_dist = nil
  38546. m.appendlabel_dist = nil
  38547. }
  38548. // SetConsumeCoin sets the "consume_coin" field.
  38549. func (m *UsageStatisticHourMutation) SetConsumeCoin(f float64) {
  38550. m.consume_coin = &f
  38551. m.addconsume_coin = nil
  38552. }
  38553. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  38554. func (m *UsageStatisticHourMutation) ConsumeCoin() (r float64, exists bool) {
  38555. v := m.consume_coin
  38556. if v == nil {
  38557. return
  38558. }
  38559. return *v, true
  38560. }
  38561. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  38562. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38564. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  38565. if !m.op.Is(OpUpdateOne) {
  38566. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  38567. }
  38568. if m.id == nil || m.oldValue == nil {
  38569. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  38570. }
  38571. oldValue, err := m.oldValue(ctx)
  38572. if err != nil {
  38573. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  38574. }
  38575. return oldValue.ConsumeCoin, nil
  38576. }
  38577. // AddConsumeCoin adds f to the "consume_coin" field.
  38578. func (m *UsageStatisticHourMutation) AddConsumeCoin(f float64) {
  38579. if m.addconsume_coin != nil {
  38580. *m.addconsume_coin += f
  38581. } else {
  38582. m.addconsume_coin = &f
  38583. }
  38584. }
  38585. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  38586. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r float64, exists bool) {
  38587. v := m.addconsume_coin
  38588. if v == nil {
  38589. return
  38590. }
  38591. return *v, true
  38592. }
  38593. // ClearConsumeCoin clears the value of the "consume_coin" field.
  38594. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  38595. m.consume_coin = nil
  38596. m.addconsume_coin = nil
  38597. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  38598. }
  38599. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  38600. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  38601. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  38602. return ok
  38603. }
  38604. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  38605. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  38606. m.consume_coin = nil
  38607. m.addconsume_coin = nil
  38608. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  38609. }
  38610. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  38611. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  38612. m.predicates = append(m.predicates, ps...)
  38613. }
  38614. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  38615. // users can use type-assertion to append predicates that do not depend on any generated package.
  38616. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  38617. p := make([]predicate.UsageStatisticHour, len(ps))
  38618. for i := range ps {
  38619. p[i] = ps[i]
  38620. }
  38621. m.Where(p...)
  38622. }
  38623. // Op returns the operation name.
  38624. func (m *UsageStatisticHourMutation) Op() Op {
  38625. return m.op
  38626. }
  38627. // SetOp allows setting the mutation operation.
  38628. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  38629. m.op = op
  38630. }
  38631. // Type returns the node type of this mutation (UsageStatisticHour).
  38632. func (m *UsageStatisticHourMutation) Type() string {
  38633. return m.typ
  38634. }
  38635. // Fields returns all fields that were changed during this mutation. Note that in
  38636. // order to get all numeric fields that were incremented/decremented, call
  38637. // AddedFields().
  38638. func (m *UsageStatisticHourMutation) Fields() []string {
  38639. fields := make([]string, 0, 18)
  38640. if m.created_at != nil {
  38641. fields = append(fields, usagestatistichour.FieldCreatedAt)
  38642. }
  38643. if m.updated_at != nil {
  38644. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  38645. }
  38646. if m.status != nil {
  38647. fields = append(fields, usagestatistichour.FieldStatus)
  38648. }
  38649. if m.deleted_at != nil {
  38650. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38651. }
  38652. if m.addtime != nil {
  38653. fields = append(fields, usagestatistichour.FieldAddtime)
  38654. }
  38655. if m._type != nil {
  38656. fields = append(fields, usagestatistichour.FieldType)
  38657. }
  38658. if m.bot_id != nil {
  38659. fields = append(fields, usagestatistichour.FieldBotID)
  38660. }
  38661. if m.organization_id != nil {
  38662. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38663. }
  38664. if m.ai_response != nil {
  38665. fields = append(fields, usagestatistichour.FieldAiResponse)
  38666. }
  38667. if m.sop_run != nil {
  38668. fields = append(fields, usagestatistichour.FieldSopRun)
  38669. }
  38670. if m.total_friend != nil {
  38671. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38672. }
  38673. if m.total_group != nil {
  38674. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38675. }
  38676. if m.account_balance != nil {
  38677. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38678. }
  38679. if m.consume_token != nil {
  38680. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38681. }
  38682. if m.active_user != nil {
  38683. fields = append(fields, usagestatistichour.FieldActiveUser)
  38684. }
  38685. if m.new_user != nil {
  38686. fields = append(fields, usagestatistichour.FieldNewUser)
  38687. }
  38688. if m.label_dist != nil {
  38689. fields = append(fields, usagestatistichour.FieldLabelDist)
  38690. }
  38691. if m.consume_coin != nil {
  38692. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38693. }
  38694. return fields
  38695. }
  38696. // Field returns the value of a field with the given name. The second boolean
  38697. // return value indicates that this field was not set, or was not defined in the
  38698. // schema.
  38699. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  38700. switch name {
  38701. case usagestatistichour.FieldCreatedAt:
  38702. return m.CreatedAt()
  38703. case usagestatistichour.FieldUpdatedAt:
  38704. return m.UpdatedAt()
  38705. case usagestatistichour.FieldStatus:
  38706. return m.Status()
  38707. case usagestatistichour.FieldDeletedAt:
  38708. return m.DeletedAt()
  38709. case usagestatistichour.FieldAddtime:
  38710. return m.Addtime()
  38711. case usagestatistichour.FieldType:
  38712. return m.GetType()
  38713. case usagestatistichour.FieldBotID:
  38714. return m.BotID()
  38715. case usagestatistichour.FieldOrganizationID:
  38716. return m.OrganizationID()
  38717. case usagestatistichour.FieldAiResponse:
  38718. return m.AiResponse()
  38719. case usagestatistichour.FieldSopRun:
  38720. return m.SopRun()
  38721. case usagestatistichour.FieldTotalFriend:
  38722. return m.TotalFriend()
  38723. case usagestatistichour.FieldTotalGroup:
  38724. return m.TotalGroup()
  38725. case usagestatistichour.FieldAccountBalance:
  38726. return m.AccountBalance()
  38727. case usagestatistichour.FieldConsumeToken:
  38728. return m.ConsumeToken()
  38729. case usagestatistichour.FieldActiveUser:
  38730. return m.ActiveUser()
  38731. case usagestatistichour.FieldNewUser:
  38732. return m.NewUser()
  38733. case usagestatistichour.FieldLabelDist:
  38734. return m.LabelDist()
  38735. case usagestatistichour.FieldConsumeCoin:
  38736. return m.ConsumeCoin()
  38737. }
  38738. return nil, false
  38739. }
  38740. // OldField returns the old value of the field from the database. An error is
  38741. // returned if the mutation operation is not UpdateOne, or the query to the
  38742. // database failed.
  38743. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38744. switch name {
  38745. case usagestatistichour.FieldCreatedAt:
  38746. return m.OldCreatedAt(ctx)
  38747. case usagestatistichour.FieldUpdatedAt:
  38748. return m.OldUpdatedAt(ctx)
  38749. case usagestatistichour.FieldStatus:
  38750. return m.OldStatus(ctx)
  38751. case usagestatistichour.FieldDeletedAt:
  38752. return m.OldDeletedAt(ctx)
  38753. case usagestatistichour.FieldAddtime:
  38754. return m.OldAddtime(ctx)
  38755. case usagestatistichour.FieldType:
  38756. return m.OldType(ctx)
  38757. case usagestatistichour.FieldBotID:
  38758. return m.OldBotID(ctx)
  38759. case usagestatistichour.FieldOrganizationID:
  38760. return m.OldOrganizationID(ctx)
  38761. case usagestatistichour.FieldAiResponse:
  38762. return m.OldAiResponse(ctx)
  38763. case usagestatistichour.FieldSopRun:
  38764. return m.OldSopRun(ctx)
  38765. case usagestatistichour.FieldTotalFriend:
  38766. return m.OldTotalFriend(ctx)
  38767. case usagestatistichour.FieldTotalGroup:
  38768. return m.OldTotalGroup(ctx)
  38769. case usagestatistichour.FieldAccountBalance:
  38770. return m.OldAccountBalance(ctx)
  38771. case usagestatistichour.FieldConsumeToken:
  38772. return m.OldConsumeToken(ctx)
  38773. case usagestatistichour.FieldActiveUser:
  38774. return m.OldActiveUser(ctx)
  38775. case usagestatistichour.FieldNewUser:
  38776. return m.OldNewUser(ctx)
  38777. case usagestatistichour.FieldLabelDist:
  38778. return m.OldLabelDist(ctx)
  38779. case usagestatistichour.FieldConsumeCoin:
  38780. return m.OldConsumeCoin(ctx)
  38781. }
  38782. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38783. }
  38784. // SetField sets the value of a field with the given name. It returns an error if
  38785. // the field is not defined in the schema, or if the type mismatched the field
  38786. // type.
  38787. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  38788. switch name {
  38789. case usagestatistichour.FieldCreatedAt:
  38790. v, ok := value.(time.Time)
  38791. if !ok {
  38792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38793. }
  38794. m.SetCreatedAt(v)
  38795. return nil
  38796. case usagestatistichour.FieldUpdatedAt:
  38797. v, ok := value.(time.Time)
  38798. if !ok {
  38799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38800. }
  38801. m.SetUpdatedAt(v)
  38802. return nil
  38803. case usagestatistichour.FieldStatus:
  38804. v, ok := value.(uint8)
  38805. if !ok {
  38806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38807. }
  38808. m.SetStatus(v)
  38809. return nil
  38810. case usagestatistichour.FieldDeletedAt:
  38811. v, ok := value.(time.Time)
  38812. if !ok {
  38813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38814. }
  38815. m.SetDeletedAt(v)
  38816. return nil
  38817. case usagestatistichour.FieldAddtime:
  38818. v, ok := value.(uint64)
  38819. if !ok {
  38820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38821. }
  38822. m.SetAddtime(v)
  38823. return nil
  38824. case usagestatistichour.FieldType:
  38825. v, ok := value.(int)
  38826. if !ok {
  38827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38828. }
  38829. m.SetType(v)
  38830. return nil
  38831. case usagestatistichour.FieldBotID:
  38832. v, ok := value.(string)
  38833. if !ok {
  38834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38835. }
  38836. m.SetBotID(v)
  38837. return nil
  38838. case usagestatistichour.FieldOrganizationID:
  38839. v, ok := value.(uint64)
  38840. if !ok {
  38841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38842. }
  38843. m.SetOrganizationID(v)
  38844. return nil
  38845. case usagestatistichour.FieldAiResponse:
  38846. v, ok := value.(uint64)
  38847. if !ok {
  38848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38849. }
  38850. m.SetAiResponse(v)
  38851. return nil
  38852. case usagestatistichour.FieldSopRun:
  38853. v, ok := value.(uint64)
  38854. if !ok {
  38855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38856. }
  38857. m.SetSopRun(v)
  38858. return nil
  38859. case usagestatistichour.FieldTotalFriend:
  38860. v, ok := value.(uint64)
  38861. if !ok {
  38862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38863. }
  38864. m.SetTotalFriend(v)
  38865. return nil
  38866. case usagestatistichour.FieldTotalGroup:
  38867. v, ok := value.(uint64)
  38868. if !ok {
  38869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38870. }
  38871. m.SetTotalGroup(v)
  38872. return nil
  38873. case usagestatistichour.FieldAccountBalance:
  38874. v, ok := value.(uint64)
  38875. if !ok {
  38876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38877. }
  38878. m.SetAccountBalance(v)
  38879. return nil
  38880. case usagestatistichour.FieldConsumeToken:
  38881. v, ok := value.(uint64)
  38882. if !ok {
  38883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38884. }
  38885. m.SetConsumeToken(v)
  38886. return nil
  38887. case usagestatistichour.FieldActiveUser:
  38888. v, ok := value.(uint64)
  38889. if !ok {
  38890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38891. }
  38892. m.SetActiveUser(v)
  38893. return nil
  38894. case usagestatistichour.FieldNewUser:
  38895. v, ok := value.(int64)
  38896. if !ok {
  38897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38898. }
  38899. m.SetNewUser(v)
  38900. return nil
  38901. case usagestatistichour.FieldLabelDist:
  38902. v, ok := value.([]custom_types.LabelDist)
  38903. if !ok {
  38904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38905. }
  38906. m.SetLabelDist(v)
  38907. return nil
  38908. case usagestatistichour.FieldConsumeCoin:
  38909. v, ok := value.(float64)
  38910. if !ok {
  38911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38912. }
  38913. m.SetConsumeCoin(v)
  38914. return nil
  38915. }
  38916. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38917. }
  38918. // AddedFields returns all numeric fields that were incremented/decremented during
  38919. // this mutation.
  38920. func (m *UsageStatisticHourMutation) AddedFields() []string {
  38921. var fields []string
  38922. if m.addstatus != nil {
  38923. fields = append(fields, usagestatistichour.FieldStatus)
  38924. }
  38925. if m.addaddtime != nil {
  38926. fields = append(fields, usagestatistichour.FieldAddtime)
  38927. }
  38928. if m.add_type != nil {
  38929. fields = append(fields, usagestatistichour.FieldType)
  38930. }
  38931. if m.addorganization_id != nil {
  38932. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38933. }
  38934. if m.addai_response != nil {
  38935. fields = append(fields, usagestatistichour.FieldAiResponse)
  38936. }
  38937. if m.addsop_run != nil {
  38938. fields = append(fields, usagestatistichour.FieldSopRun)
  38939. }
  38940. if m.addtotal_friend != nil {
  38941. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38942. }
  38943. if m.addtotal_group != nil {
  38944. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38945. }
  38946. if m.addaccount_balance != nil {
  38947. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38948. }
  38949. if m.addconsume_token != nil {
  38950. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38951. }
  38952. if m.addactive_user != nil {
  38953. fields = append(fields, usagestatistichour.FieldActiveUser)
  38954. }
  38955. if m.addnew_user != nil {
  38956. fields = append(fields, usagestatistichour.FieldNewUser)
  38957. }
  38958. if m.addconsume_coin != nil {
  38959. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38960. }
  38961. return fields
  38962. }
  38963. // AddedField returns the numeric value that was incremented/decremented on a field
  38964. // with the given name. The second boolean return value indicates that this field
  38965. // was not set, or was not defined in the schema.
  38966. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  38967. switch name {
  38968. case usagestatistichour.FieldStatus:
  38969. return m.AddedStatus()
  38970. case usagestatistichour.FieldAddtime:
  38971. return m.AddedAddtime()
  38972. case usagestatistichour.FieldType:
  38973. return m.AddedType()
  38974. case usagestatistichour.FieldOrganizationID:
  38975. return m.AddedOrganizationID()
  38976. case usagestatistichour.FieldAiResponse:
  38977. return m.AddedAiResponse()
  38978. case usagestatistichour.FieldSopRun:
  38979. return m.AddedSopRun()
  38980. case usagestatistichour.FieldTotalFriend:
  38981. return m.AddedTotalFriend()
  38982. case usagestatistichour.FieldTotalGroup:
  38983. return m.AddedTotalGroup()
  38984. case usagestatistichour.FieldAccountBalance:
  38985. return m.AddedAccountBalance()
  38986. case usagestatistichour.FieldConsumeToken:
  38987. return m.AddedConsumeToken()
  38988. case usagestatistichour.FieldActiveUser:
  38989. return m.AddedActiveUser()
  38990. case usagestatistichour.FieldNewUser:
  38991. return m.AddedNewUser()
  38992. case usagestatistichour.FieldConsumeCoin:
  38993. return m.AddedConsumeCoin()
  38994. }
  38995. return nil, false
  38996. }
  38997. // AddField adds the value to the field with the given name. It returns an error if
  38998. // the field is not defined in the schema, or if the type mismatched the field
  38999. // type.
  39000. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  39001. switch name {
  39002. case usagestatistichour.FieldStatus:
  39003. v, ok := value.(int8)
  39004. if !ok {
  39005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39006. }
  39007. m.AddStatus(v)
  39008. return nil
  39009. case usagestatistichour.FieldAddtime:
  39010. v, ok := value.(int64)
  39011. if !ok {
  39012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39013. }
  39014. m.AddAddtime(v)
  39015. return nil
  39016. case usagestatistichour.FieldType:
  39017. v, ok := value.(int)
  39018. if !ok {
  39019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39020. }
  39021. m.AddType(v)
  39022. return nil
  39023. case usagestatistichour.FieldOrganizationID:
  39024. v, ok := value.(int64)
  39025. if !ok {
  39026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39027. }
  39028. m.AddOrganizationID(v)
  39029. return nil
  39030. case usagestatistichour.FieldAiResponse:
  39031. v, ok := value.(int64)
  39032. if !ok {
  39033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39034. }
  39035. m.AddAiResponse(v)
  39036. return nil
  39037. case usagestatistichour.FieldSopRun:
  39038. v, ok := value.(int64)
  39039. if !ok {
  39040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39041. }
  39042. m.AddSopRun(v)
  39043. return nil
  39044. case usagestatistichour.FieldTotalFriend:
  39045. v, ok := value.(int64)
  39046. if !ok {
  39047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39048. }
  39049. m.AddTotalFriend(v)
  39050. return nil
  39051. case usagestatistichour.FieldTotalGroup:
  39052. v, ok := value.(int64)
  39053. if !ok {
  39054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39055. }
  39056. m.AddTotalGroup(v)
  39057. return nil
  39058. case usagestatistichour.FieldAccountBalance:
  39059. v, ok := value.(int64)
  39060. if !ok {
  39061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39062. }
  39063. m.AddAccountBalance(v)
  39064. return nil
  39065. case usagestatistichour.FieldConsumeToken:
  39066. v, ok := value.(int64)
  39067. if !ok {
  39068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39069. }
  39070. m.AddConsumeToken(v)
  39071. return nil
  39072. case usagestatistichour.FieldActiveUser:
  39073. v, ok := value.(int64)
  39074. if !ok {
  39075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39076. }
  39077. m.AddActiveUser(v)
  39078. return nil
  39079. case usagestatistichour.FieldNewUser:
  39080. v, ok := value.(int64)
  39081. if !ok {
  39082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39083. }
  39084. m.AddNewUser(v)
  39085. return nil
  39086. case usagestatistichour.FieldConsumeCoin:
  39087. v, ok := value.(float64)
  39088. if !ok {
  39089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39090. }
  39091. m.AddConsumeCoin(v)
  39092. return nil
  39093. }
  39094. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  39095. }
  39096. // ClearedFields returns all nullable fields that were cleared during this
  39097. // mutation.
  39098. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  39099. var fields []string
  39100. if m.FieldCleared(usagestatistichour.FieldStatus) {
  39101. fields = append(fields, usagestatistichour.FieldStatus)
  39102. }
  39103. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  39104. fields = append(fields, usagestatistichour.FieldDeletedAt)
  39105. }
  39106. if m.FieldCleared(usagestatistichour.FieldBotID) {
  39107. fields = append(fields, usagestatistichour.FieldBotID)
  39108. }
  39109. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  39110. fields = append(fields, usagestatistichour.FieldOrganizationID)
  39111. }
  39112. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  39113. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  39114. }
  39115. return fields
  39116. }
  39117. // FieldCleared returns a boolean indicating if a field with the given name was
  39118. // cleared in this mutation.
  39119. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  39120. _, ok := m.clearedFields[name]
  39121. return ok
  39122. }
  39123. // ClearField clears the value of the field with the given name. It returns an
  39124. // error if the field is not defined in the schema.
  39125. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  39126. switch name {
  39127. case usagestatistichour.FieldStatus:
  39128. m.ClearStatus()
  39129. return nil
  39130. case usagestatistichour.FieldDeletedAt:
  39131. m.ClearDeletedAt()
  39132. return nil
  39133. case usagestatistichour.FieldBotID:
  39134. m.ClearBotID()
  39135. return nil
  39136. case usagestatistichour.FieldOrganizationID:
  39137. m.ClearOrganizationID()
  39138. return nil
  39139. case usagestatistichour.FieldConsumeCoin:
  39140. m.ClearConsumeCoin()
  39141. return nil
  39142. }
  39143. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  39144. }
  39145. // ResetField resets all changes in the mutation for the field with the given name.
  39146. // It returns an error if the field is not defined in the schema.
  39147. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  39148. switch name {
  39149. case usagestatistichour.FieldCreatedAt:
  39150. m.ResetCreatedAt()
  39151. return nil
  39152. case usagestatistichour.FieldUpdatedAt:
  39153. m.ResetUpdatedAt()
  39154. return nil
  39155. case usagestatistichour.FieldStatus:
  39156. m.ResetStatus()
  39157. return nil
  39158. case usagestatistichour.FieldDeletedAt:
  39159. m.ResetDeletedAt()
  39160. return nil
  39161. case usagestatistichour.FieldAddtime:
  39162. m.ResetAddtime()
  39163. return nil
  39164. case usagestatistichour.FieldType:
  39165. m.ResetType()
  39166. return nil
  39167. case usagestatistichour.FieldBotID:
  39168. m.ResetBotID()
  39169. return nil
  39170. case usagestatistichour.FieldOrganizationID:
  39171. m.ResetOrganizationID()
  39172. return nil
  39173. case usagestatistichour.FieldAiResponse:
  39174. m.ResetAiResponse()
  39175. return nil
  39176. case usagestatistichour.FieldSopRun:
  39177. m.ResetSopRun()
  39178. return nil
  39179. case usagestatistichour.FieldTotalFriend:
  39180. m.ResetTotalFriend()
  39181. return nil
  39182. case usagestatistichour.FieldTotalGroup:
  39183. m.ResetTotalGroup()
  39184. return nil
  39185. case usagestatistichour.FieldAccountBalance:
  39186. m.ResetAccountBalance()
  39187. return nil
  39188. case usagestatistichour.FieldConsumeToken:
  39189. m.ResetConsumeToken()
  39190. return nil
  39191. case usagestatistichour.FieldActiveUser:
  39192. m.ResetActiveUser()
  39193. return nil
  39194. case usagestatistichour.FieldNewUser:
  39195. m.ResetNewUser()
  39196. return nil
  39197. case usagestatistichour.FieldLabelDist:
  39198. m.ResetLabelDist()
  39199. return nil
  39200. case usagestatistichour.FieldConsumeCoin:
  39201. m.ResetConsumeCoin()
  39202. return nil
  39203. }
  39204. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  39205. }
  39206. // AddedEdges returns all edge names that were set/added in this mutation.
  39207. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  39208. edges := make([]string, 0, 0)
  39209. return edges
  39210. }
  39211. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39212. // name in this mutation.
  39213. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  39214. return nil
  39215. }
  39216. // RemovedEdges returns all edge names that were removed in this mutation.
  39217. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  39218. edges := make([]string, 0, 0)
  39219. return edges
  39220. }
  39221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39222. // the given name in this mutation.
  39223. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  39224. return nil
  39225. }
  39226. // ClearedEdges returns all edge names that were cleared in this mutation.
  39227. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  39228. edges := make([]string, 0, 0)
  39229. return edges
  39230. }
  39231. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39232. // was cleared in this mutation.
  39233. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  39234. return false
  39235. }
  39236. // ClearEdge clears the value of the edge with the given name. It returns an error
  39237. // if that edge is not defined in the schema.
  39238. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  39239. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  39240. }
  39241. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39242. // It returns an error if the edge is not defined in the schema.
  39243. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  39244. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  39245. }
  39246. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  39247. type UsageStatisticMonthMutation struct {
  39248. config
  39249. op Op
  39250. typ string
  39251. id *uint64
  39252. created_at *time.Time
  39253. updated_at *time.Time
  39254. status *uint8
  39255. addstatus *int8
  39256. deleted_at *time.Time
  39257. addtime *uint64
  39258. addaddtime *int64
  39259. _type *int
  39260. add_type *int
  39261. bot_id *string
  39262. organization_id *uint64
  39263. addorganization_id *int64
  39264. ai_response *uint64
  39265. addai_response *int64
  39266. sop_run *uint64
  39267. addsop_run *int64
  39268. total_friend *uint64
  39269. addtotal_friend *int64
  39270. total_group *uint64
  39271. addtotal_group *int64
  39272. account_balance *uint64
  39273. addaccount_balance *int64
  39274. consume_token *uint64
  39275. addconsume_token *int64
  39276. active_user *uint64
  39277. addactive_user *int64
  39278. new_user *int64
  39279. addnew_user *int64
  39280. label_dist *[]custom_types.LabelDist
  39281. appendlabel_dist []custom_types.LabelDist
  39282. consume_coin *float64
  39283. addconsume_coin *float64
  39284. clearedFields map[string]struct{}
  39285. done bool
  39286. oldValue func(context.Context) (*UsageStatisticMonth, error)
  39287. predicates []predicate.UsageStatisticMonth
  39288. }
  39289. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  39290. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  39291. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  39292. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  39293. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  39294. m := &UsageStatisticMonthMutation{
  39295. config: c,
  39296. op: op,
  39297. typ: TypeUsageStatisticMonth,
  39298. clearedFields: make(map[string]struct{}),
  39299. }
  39300. for _, opt := range opts {
  39301. opt(m)
  39302. }
  39303. return m
  39304. }
  39305. // withUsageStatisticMonthID sets the ID field of the mutation.
  39306. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  39307. return func(m *UsageStatisticMonthMutation) {
  39308. var (
  39309. err error
  39310. once sync.Once
  39311. value *UsageStatisticMonth
  39312. )
  39313. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  39314. once.Do(func() {
  39315. if m.done {
  39316. err = errors.New("querying old values post mutation is not allowed")
  39317. } else {
  39318. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  39319. }
  39320. })
  39321. return value, err
  39322. }
  39323. m.id = &id
  39324. }
  39325. }
  39326. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  39327. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  39328. return func(m *UsageStatisticMonthMutation) {
  39329. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  39330. return node, nil
  39331. }
  39332. m.id = &node.ID
  39333. }
  39334. }
  39335. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39336. // executed in a transaction (ent.Tx), a transactional client is returned.
  39337. func (m UsageStatisticMonthMutation) Client() *Client {
  39338. client := &Client{config: m.config}
  39339. client.init()
  39340. return client
  39341. }
  39342. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39343. // it returns an error otherwise.
  39344. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  39345. if _, ok := m.driver.(*txDriver); !ok {
  39346. return nil, errors.New("ent: mutation is not running in a transaction")
  39347. }
  39348. tx := &Tx{config: m.config}
  39349. tx.init()
  39350. return tx, nil
  39351. }
  39352. // SetID sets the value of the id field. Note that this
  39353. // operation is only accepted on creation of UsageStatisticMonth entities.
  39354. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  39355. m.id = &id
  39356. }
  39357. // ID returns the ID value in the mutation. Note that the ID is only available
  39358. // if it was provided to the builder or after it was returned from the database.
  39359. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  39360. if m.id == nil {
  39361. return
  39362. }
  39363. return *m.id, true
  39364. }
  39365. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39366. // That means, if the mutation is applied within a transaction with an isolation level such
  39367. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39368. // or updated by the mutation.
  39369. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  39370. switch {
  39371. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39372. id, exists := m.ID()
  39373. if exists {
  39374. return []uint64{id}, nil
  39375. }
  39376. fallthrough
  39377. case m.op.Is(OpUpdate | OpDelete):
  39378. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  39379. default:
  39380. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39381. }
  39382. }
  39383. // SetCreatedAt sets the "created_at" field.
  39384. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  39385. m.created_at = &t
  39386. }
  39387. // CreatedAt returns the value of the "created_at" field in the mutation.
  39388. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  39389. v := m.created_at
  39390. if v == nil {
  39391. return
  39392. }
  39393. return *v, true
  39394. }
  39395. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  39396. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39398. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39399. if !m.op.Is(OpUpdateOne) {
  39400. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39401. }
  39402. if m.id == nil || m.oldValue == nil {
  39403. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39404. }
  39405. oldValue, err := m.oldValue(ctx)
  39406. if err != nil {
  39407. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39408. }
  39409. return oldValue.CreatedAt, nil
  39410. }
  39411. // ResetCreatedAt resets all changes to the "created_at" field.
  39412. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  39413. m.created_at = nil
  39414. }
  39415. // SetUpdatedAt sets the "updated_at" field.
  39416. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  39417. m.updated_at = &t
  39418. }
  39419. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39420. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  39421. v := m.updated_at
  39422. if v == nil {
  39423. return
  39424. }
  39425. return *v, true
  39426. }
  39427. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  39428. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39430. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39431. if !m.op.Is(OpUpdateOne) {
  39432. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39433. }
  39434. if m.id == nil || m.oldValue == nil {
  39435. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39436. }
  39437. oldValue, err := m.oldValue(ctx)
  39438. if err != nil {
  39439. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39440. }
  39441. return oldValue.UpdatedAt, nil
  39442. }
  39443. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39444. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  39445. m.updated_at = nil
  39446. }
  39447. // SetStatus sets the "status" field.
  39448. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  39449. m.status = &u
  39450. m.addstatus = nil
  39451. }
  39452. // Status returns the value of the "status" field in the mutation.
  39453. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  39454. v := m.status
  39455. if v == nil {
  39456. return
  39457. }
  39458. return *v, true
  39459. }
  39460. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  39461. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39463. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39464. if !m.op.Is(OpUpdateOne) {
  39465. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39466. }
  39467. if m.id == nil || m.oldValue == nil {
  39468. return v, errors.New("OldStatus requires an ID field in the mutation")
  39469. }
  39470. oldValue, err := m.oldValue(ctx)
  39471. if err != nil {
  39472. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39473. }
  39474. return oldValue.Status, nil
  39475. }
  39476. // AddStatus adds u to the "status" field.
  39477. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  39478. if m.addstatus != nil {
  39479. *m.addstatus += u
  39480. } else {
  39481. m.addstatus = &u
  39482. }
  39483. }
  39484. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39485. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  39486. v := m.addstatus
  39487. if v == nil {
  39488. return
  39489. }
  39490. return *v, true
  39491. }
  39492. // ClearStatus clears the value of the "status" field.
  39493. func (m *UsageStatisticMonthMutation) ClearStatus() {
  39494. m.status = nil
  39495. m.addstatus = nil
  39496. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  39497. }
  39498. // StatusCleared returns if the "status" field was cleared in this mutation.
  39499. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  39500. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  39501. return ok
  39502. }
  39503. // ResetStatus resets all changes to the "status" field.
  39504. func (m *UsageStatisticMonthMutation) ResetStatus() {
  39505. m.status = nil
  39506. m.addstatus = nil
  39507. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  39508. }
  39509. // SetDeletedAt sets the "deleted_at" field.
  39510. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  39511. m.deleted_at = &t
  39512. }
  39513. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39514. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  39515. v := m.deleted_at
  39516. if v == nil {
  39517. return
  39518. }
  39519. return *v, true
  39520. }
  39521. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  39522. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39524. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39525. if !m.op.Is(OpUpdateOne) {
  39526. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39527. }
  39528. if m.id == nil || m.oldValue == nil {
  39529. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39530. }
  39531. oldValue, err := m.oldValue(ctx)
  39532. if err != nil {
  39533. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39534. }
  39535. return oldValue.DeletedAt, nil
  39536. }
  39537. // ClearDeletedAt clears the value of the "deleted_at" field.
  39538. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  39539. m.deleted_at = nil
  39540. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  39541. }
  39542. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39543. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  39544. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  39545. return ok
  39546. }
  39547. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39548. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  39549. m.deleted_at = nil
  39550. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  39551. }
  39552. // SetAddtime sets the "addtime" field.
  39553. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  39554. m.addtime = &u
  39555. m.addaddtime = nil
  39556. }
  39557. // Addtime returns the value of the "addtime" field in the mutation.
  39558. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  39559. v := m.addtime
  39560. if v == nil {
  39561. return
  39562. }
  39563. return *v, true
  39564. }
  39565. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  39566. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39568. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  39569. if !m.op.Is(OpUpdateOne) {
  39570. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  39571. }
  39572. if m.id == nil || m.oldValue == nil {
  39573. return v, errors.New("OldAddtime requires an ID field in the mutation")
  39574. }
  39575. oldValue, err := m.oldValue(ctx)
  39576. if err != nil {
  39577. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  39578. }
  39579. return oldValue.Addtime, nil
  39580. }
  39581. // AddAddtime adds u to the "addtime" field.
  39582. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  39583. if m.addaddtime != nil {
  39584. *m.addaddtime += u
  39585. } else {
  39586. m.addaddtime = &u
  39587. }
  39588. }
  39589. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  39590. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  39591. v := m.addaddtime
  39592. if v == nil {
  39593. return
  39594. }
  39595. return *v, true
  39596. }
  39597. // ResetAddtime resets all changes to the "addtime" field.
  39598. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  39599. m.addtime = nil
  39600. m.addaddtime = nil
  39601. }
  39602. // SetType sets the "type" field.
  39603. func (m *UsageStatisticMonthMutation) SetType(i int) {
  39604. m._type = &i
  39605. m.add_type = nil
  39606. }
  39607. // GetType returns the value of the "type" field in the mutation.
  39608. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  39609. v := m._type
  39610. if v == nil {
  39611. return
  39612. }
  39613. return *v, true
  39614. }
  39615. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  39616. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39618. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  39619. if !m.op.Is(OpUpdateOne) {
  39620. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39621. }
  39622. if m.id == nil || m.oldValue == nil {
  39623. return v, errors.New("OldType requires an ID field in the mutation")
  39624. }
  39625. oldValue, err := m.oldValue(ctx)
  39626. if err != nil {
  39627. return v, fmt.Errorf("querying old value for OldType: %w", err)
  39628. }
  39629. return oldValue.Type, nil
  39630. }
  39631. // AddType adds i to the "type" field.
  39632. func (m *UsageStatisticMonthMutation) AddType(i int) {
  39633. if m.add_type != nil {
  39634. *m.add_type += i
  39635. } else {
  39636. m.add_type = &i
  39637. }
  39638. }
  39639. // AddedType returns the value that was added to the "type" field in this mutation.
  39640. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  39641. v := m.add_type
  39642. if v == nil {
  39643. return
  39644. }
  39645. return *v, true
  39646. }
  39647. // ResetType resets all changes to the "type" field.
  39648. func (m *UsageStatisticMonthMutation) ResetType() {
  39649. m._type = nil
  39650. m.add_type = nil
  39651. }
  39652. // SetBotID sets the "bot_id" field.
  39653. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  39654. m.bot_id = &s
  39655. }
  39656. // BotID returns the value of the "bot_id" field in the mutation.
  39657. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  39658. v := m.bot_id
  39659. if v == nil {
  39660. return
  39661. }
  39662. return *v, true
  39663. }
  39664. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  39665. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39667. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  39668. if !m.op.Is(OpUpdateOne) {
  39669. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39670. }
  39671. if m.id == nil || m.oldValue == nil {
  39672. return v, errors.New("OldBotID requires an ID field in the mutation")
  39673. }
  39674. oldValue, err := m.oldValue(ctx)
  39675. if err != nil {
  39676. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39677. }
  39678. return oldValue.BotID, nil
  39679. }
  39680. // ClearBotID clears the value of the "bot_id" field.
  39681. func (m *UsageStatisticMonthMutation) ClearBotID() {
  39682. m.bot_id = nil
  39683. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  39684. }
  39685. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  39686. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  39687. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  39688. return ok
  39689. }
  39690. // ResetBotID resets all changes to the "bot_id" field.
  39691. func (m *UsageStatisticMonthMutation) ResetBotID() {
  39692. m.bot_id = nil
  39693. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  39694. }
  39695. // SetOrganizationID sets the "organization_id" field.
  39696. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  39697. m.organization_id = &u
  39698. m.addorganization_id = nil
  39699. }
  39700. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39701. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  39702. v := m.organization_id
  39703. if v == nil {
  39704. return
  39705. }
  39706. return *v, true
  39707. }
  39708. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  39709. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39711. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39712. if !m.op.Is(OpUpdateOne) {
  39713. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39714. }
  39715. if m.id == nil || m.oldValue == nil {
  39716. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39717. }
  39718. oldValue, err := m.oldValue(ctx)
  39719. if err != nil {
  39720. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39721. }
  39722. return oldValue.OrganizationID, nil
  39723. }
  39724. // AddOrganizationID adds u to the "organization_id" field.
  39725. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  39726. if m.addorganization_id != nil {
  39727. *m.addorganization_id += u
  39728. } else {
  39729. m.addorganization_id = &u
  39730. }
  39731. }
  39732. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39733. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  39734. v := m.addorganization_id
  39735. if v == nil {
  39736. return
  39737. }
  39738. return *v, true
  39739. }
  39740. // ClearOrganizationID clears the value of the "organization_id" field.
  39741. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  39742. m.organization_id = nil
  39743. m.addorganization_id = nil
  39744. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  39745. }
  39746. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39747. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  39748. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  39749. return ok
  39750. }
  39751. // ResetOrganizationID resets all changes to the "organization_id" field.
  39752. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  39753. m.organization_id = nil
  39754. m.addorganization_id = nil
  39755. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  39756. }
  39757. // SetAiResponse sets the "ai_response" field.
  39758. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  39759. m.ai_response = &u
  39760. m.addai_response = nil
  39761. }
  39762. // AiResponse returns the value of the "ai_response" field in the mutation.
  39763. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  39764. v := m.ai_response
  39765. if v == nil {
  39766. return
  39767. }
  39768. return *v, true
  39769. }
  39770. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  39771. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39773. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  39774. if !m.op.Is(OpUpdateOne) {
  39775. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  39776. }
  39777. if m.id == nil || m.oldValue == nil {
  39778. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  39779. }
  39780. oldValue, err := m.oldValue(ctx)
  39781. if err != nil {
  39782. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  39783. }
  39784. return oldValue.AiResponse, nil
  39785. }
  39786. // AddAiResponse adds u to the "ai_response" field.
  39787. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  39788. if m.addai_response != nil {
  39789. *m.addai_response += u
  39790. } else {
  39791. m.addai_response = &u
  39792. }
  39793. }
  39794. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  39795. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  39796. v := m.addai_response
  39797. if v == nil {
  39798. return
  39799. }
  39800. return *v, true
  39801. }
  39802. // ResetAiResponse resets all changes to the "ai_response" field.
  39803. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  39804. m.ai_response = nil
  39805. m.addai_response = nil
  39806. }
  39807. // SetSopRun sets the "sop_run" field.
  39808. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  39809. m.sop_run = &u
  39810. m.addsop_run = nil
  39811. }
  39812. // SopRun returns the value of the "sop_run" field in the mutation.
  39813. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  39814. v := m.sop_run
  39815. if v == nil {
  39816. return
  39817. }
  39818. return *v, true
  39819. }
  39820. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  39821. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39823. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  39824. if !m.op.Is(OpUpdateOne) {
  39825. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  39826. }
  39827. if m.id == nil || m.oldValue == nil {
  39828. return v, errors.New("OldSopRun requires an ID field in the mutation")
  39829. }
  39830. oldValue, err := m.oldValue(ctx)
  39831. if err != nil {
  39832. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  39833. }
  39834. return oldValue.SopRun, nil
  39835. }
  39836. // AddSopRun adds u to the "sop_run" field.
  39837. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  39838. if m.addsop_run != nil {
  39839. *m.addsop_run += u
  39840. } else {
  39841. m.addsop_run = &u
  39842. }
  39843. }
  39844. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  39845. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  39846. v := m.addsop_run
  39847. if v == nil {
  39848. return
  39849. }
  39850. return *v, true
  39851. }
  39852. // ResetSopRun resets all changes to the "sop_run" field.
  39853. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  39854. m.sop_run = nil
  39855. m.addsop_run = nil
  39856. }
  39857. // SetTotalFriend sets the "total_friend" field.
  39858. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  39859. m.total_friend = &u
  39860. m.addtotal_friend = nil
  39861. }
  39862. // TotalFriend returns the value of the "total_friend" field in the mutation.
  39863. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  39864. v := m.total_friend
  39865. if v == nil {
  39866. return
  39867. }
  39868. return *v, true
  39869. }
  39870. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  39871. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39873. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  39874. if !m.op.Is(OpUpdateOne) {
  39875. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  39876. }
  39877. if m.id == nil || m.oldValue == nil {
  39878. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  39879. }
  39880. oldValue, err := m.oldValue(ctx)
  39881. if err != nil {
  39882. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  39883. }
  39884. return oldValue.TotalFriend, nil
  39885. }
  39886. // AddTotalFriend adds u to the "total_friend" field.
  39887. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  39888. if m.addtotal_friend != nil {
  39889. *m.addtotal_friend += u
  39890. } else {
  39891. m.addtotal_friend = &u
  39892. }
  39893. }
  39894. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  39895. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  39896. v := m.addtotal_friend
  39897. if v == nil {
  39898. return
  39899. }
  39900. return *v, true
  39901. }
  39902. // ResetTotalFriend resets all changes to the "total_friend" field.
  39903. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  39904. m.total_friend = nil
  39905. m.addtotal_friend = nil
  39906. }
  39907. // SetTotalGroup sets the "total_group" field.
  39908. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  39909. m.total_group = &u
  39910. m.addtotal_group = nil
  39911. }
  39912. // TotalGroup returns the value of the "total_group" field in the mutation.
  39913. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  39914. v := m.total_group
  39915. if v == nil {
  39916. return
  39917. }
  39918. return *v, true
  39919. }
  39920. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  39921. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39923. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  39924. if !m.op.Is(OpUpdateOne) {
  39925. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  39926. }
  39927. if m.id == nil || m.oldValue == nil {
  39928. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  39929. }
  39930. oldValue, err := m.oldValue(ctx)
  39931. if err != nil {
  39932. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  39933. }
  39934. return oldValue.TotalGroup, nil
  39935. }
  39936. // AddTotalGroup adds u to the "total_group" field.
  39937. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  39938. if m.addtotal_group != nil {
  39939. *m.addtotal_group += u
  39940. } else {
  39941. m.addtotal_group = &u
  39942. }
  39943. }
  39944. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  39945. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  39946. v := m.addtotal_group
  39947. if v == nil {
  39948. return
  39949. }
  39950. return *v, true
  39951. }
  39952. // ResetTotalGroup resets all changes to the "total_group" field.
  39953. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  39954. m.total_group = nil
  39955. m.addtotal_group = nil
  39956. }
  39957. // SetAccountBalance sets the "account_balance" field.
  39958. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  39959. m.account_balance = &u
  39960. m.addaccount_balance = nil
  39961. }
  39962. // AccountBalance returns the value of the "account_balance" field in the mutation.
  39963. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  39964. v := m.account_balance
  39965. if v == nil {
  39966. return
  39967. }
  39968. return *v, true
  39969. }
  39970. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  39971. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39973. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  39974. if !m.op.Is(OpUpdateOne) {
  39975. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  39976. }
  39977. if m.id == nil || m.oldValue == nil {
  39978. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  39979. }
  39980. oldValue, err := m.oldValue(ctx)
  39981. if err != nil {
  39982. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  39983. }
  39984. return oldValue.AccountBalance, nil
  39985. }
  39986. // AddAccountBalance adds u to the "account_balance" field.
  39987. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  39988. if m.addaccount_balance != nil {
  39989. *m.addaccount_balance += u
  39990. } else {
  39991. m.addaccount_balance = &u
  39992. }
  39993. }
  39994. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  39995. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  39996. v := m.addaccount_balance
  39997. if v == nil {
  39998. return
  39999. }
  40000. return *v, true
  40001. }
  40002. // ResetAccountBalance resets all changes to the "account_balance" field.
  40003. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  40004. m.account_balance = nil
  40005. m.addaccount_balance = nil
  40006. }
  40007. // SetConsumeToken sets the "consume_token" field.
  40008. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  40009. m.consume_token = &u
  40010. m.addconsume_token = nil
  40011. }
  40012. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  40013. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  40014. v := m.consume_token
  40015. if v == nil {
  40016. return
  40017. }
  40018. return *v, true
  40019. }
  40020. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  40021. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40023. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  40024. if !m.op.Is(OpUpdateOne) {
  40025. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  40026. }
  40027. if m.id == nil || m.oldValue == nil {
  40028. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  40029. }
  40030. oldValue, err := m.oldValue(ctx)
  40031. if err != nil {
  40032. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  40033. }
  40034. return oldValue.ConsumeToken, nil
  40035. }
  40036. // AddConsumeToken adds u to the "consume_token" field.
  40037. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  40038. if m.addconsume_token != nil {
  40039. *m.addconsume_token += u
  40040. } else {
  40041. m.addconsume_token = &u
  40042. }
  40043. }
  40044. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  40045. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  40046. v := m.addconsume_token
  40047. if v == nil {
  40048. return
  40049. }
  40050. return *v, true
  40051. }
  40052. // ResetConsumeToken resets all changes to the "consume_token" field.
  40053. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  40054. m.consume_token = nil
  40055. m.addconsume_token = nil
  40056. }
  40057. // SetActiveUser sets the "active_user" field.
  40058. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  40059. m.active_user = &u
  40060. m.addactive_user = nil
  40061. }
  40062. // ActiveUser returns the value of the "active_user" field in the mutation.
  40063. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  40064. v := m.active_user
  40065. if v == nil {
  40066. return
  40067. }
  40068. return *v, true
  40069. }
  40070. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  40071. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40073. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  40074. if !m.op.Is(OpUpdateOne) {
  40075. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  40076. }
  40077. if m.id == nil || m.oldValue == nil {
  40078. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  40079. }
  40080. oldValue, err := m.oldValue(ctx)
  40081. if err != nil {
  40082. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  40083. }
  40084. return oldValue.ActiveUser, nil
  40085. }
  40086. // AddActiveUser adds u to the "active_user" field.
  40087. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  40088. if m.addactive_user != nil {
  40089. *m.addactive_user += u
  40090. } else {
  40091. m.addactive_user = &u
  40092. }
  40093. }
  40094. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  40095. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  40096. v := m.addactive_user
  40097. if v == nil {
  40098. return
  40099. }
  40100. return *v, true
  40101. }
  40102. // ResetActiveUser resets all changes to the "active_user" field.
  40103. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  40104. m.active_user = nil
  40105. m.addactive_user = nil
  40106. }
  40107. // SetNewUser sets the "new_user" field.
  40108. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  40109. m.new_user = &i
  40110. m.addnew_user = nil
  40111. }
  40112. // NewUser returns the value of the "new_user" field in the mutation.
  40113. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  40114. v := m.new_user
  40115. if v == nil {
  40116. return
  40117. }
  40118. return *v, true
  40119. }
  40120. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  40121. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40123. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  40124. if !m.op.Is(OpUpdateOne) {
  40125. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  40126. }
  40127. if m.id == nil || m.oldValue == nil {
  40128. return v, errors.New("OldNewUser requires an ID field in the mutation")
  40129. }
  40130. oldValue, err := m.oldValue(ctx)
  40131. if err != nil {
  40132. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  40133. }
  40134. return oldValue.NewUser, nil
  40135. }
  40136. // AddNewUser adds i to the "new_user" field.
  40137. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  40138. if m.addnew_user != nil {
  40139. *m.addnew_user += i
  40140. } else {
  40141. m.addnew_user = &i
  40142. }
  40143. }
  40144. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  40145. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  40146. v := m.addnew_user
  40147. if v == nil {
  40148. return
  40149. }
  40150. return *v, true
  40151. }
  40152. // ResetNewUser resets all changes to the "new_user" field.
  40153. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  40154. m.new_user = nil
  40155. m.addnew_user = nil
  40156. }
  40157. // SetLabelDist sets the "label_dist" field.
  40158. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  40159. m.label_dist = &ctd
  40160. m.appendlabel_dist = nil
  40161. }
  40162. // LabelDist returns the value of the "label_dist" field in the mutation.
  40163. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  40164. v := m.label_dist
  40165. if v == nil {
  40166. return
  40167. }
  40168. return *v, true
  40169. }
  40170. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  40171. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40173. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  40174. if !m.op.Is(OpUpdateOne) {
  40175. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  40176. }
  40177. if m.id == nil || m.oldValue == nil {
  40178. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  40179. }
  40180. oldValue, err := m.oldValue(ctx)
  40181. if err != nil {
  40182. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  40183. }
  40184. return oldValue.LabelDist, nil
  40185. }
  40186. // AppendLabelDist adds ctd to the "label_dist" field.
  40187. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  40188. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  40189. }
  40190. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  40191. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  40192. if len(m.appendlabel_dist) == 0 {
  40193. return nil, false
  40194. }
  40195. return m.appendlabel_dist, true
  40196. }
  40197. // ResetLabelDist resets all changes to the "label_dist" field.
  40198. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  40199. m.label_dist = nil
  40200. m.appendlabel_dist = nil
  40201. }
  40202. // SetConsumeCoin sets the "consume_coin" field.
  40203. func (m *UsageStatisticMonthMutation) SetConsumeCoin(f float64) {
  40204. m.consume_coin = &f
  40205. m.addconsume_coin = nil
  40206. }
  40207. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  40208. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r float64, exists bool) {
  40209. v := m.consume_coin
  40210. if v == nil {
  40211. return
  40212. }
  40213. return *v, true
  40214. }
  40215. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  40216. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40218. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  40219. if !m.op.Is(OpUpdateOne) {
  40220. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  40221. }
  40222. if m.id == nil || m.oldValue == nil {
  40223. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  40224. }
  40225. oldValue, err := m.oldValue(ctx)
  40226. if err != nil {
  40227. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  40228. }
  40229. return oldValue.ConsumeCoin, nil
  40230. }
  40231. // AddConsumeCoin adds f to the "consume_coin" field.
  40232. func (m *UsageStatisticMonthMutation) AddConsumeCoin(f float64) {
  40233. if m.addconsume_coin != nil {
  40234. *m.addconsume_coin += f
  40235. } else {
  40236. m.addconsume_coin = &f
  40237. }
  40238. }
  40239. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  40240. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r float64, exists bool) {
  40241. v := m.addconsume_coin
  40242. if v == nil {
  40243. return
  40244. }
  40245. return *v, true
  40246. }
  40247. // ClearConsumeCoin clears the value of the "consume_coin" field.
  40248. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  40249. m.consume_coin = nil
  40250. m.addconsume_coin = nil
  40251. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  40252. }
  40253. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  40254. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  40255. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  40256. return ok
  40257. }
  40258. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  40259. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  40260. m.consume_coin = nil
  40261. m.addconsume_coin = nil
  40262. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  40263. }
  40264. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  40265. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  40266. m.predicates = append(m.predicates, ps...)
  40267. }
  40268. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  40269. // users can use type-assertion to append predicates that do not depend on any generated package.
  40270. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  40271. p := make([]predicate.UsageStatisticMonth, len(ps))
  40272. for i := range ps {
  40273. p[i] = ps[i]
  40274. }
  40275. m.Where(p...)
  40276. }
  40277. // Op returns the operation name.
  40278. func (m *UsageStatisticMonthMutation) Op() Op {
  40279. return m.op
  40280. }
  40281. // SetOp allows setting the mutation operation.
  40282. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  40283. m.op = op
  40284. }
  40285. // Type returns the node type of this mutation (UsageStatisticMonth).
  40286. func (m *UsageStatisticMonthMutation) Type() string {
  40287. return m.typ
  40288. }
  40289. // Fields returns all fields that were changed during this mutation. Note that in
  40290. // order to get all numeric fields that were incremented/decremented, call
  40291. // AddedFields().
  40292. func (m *UsageStatisticMonthMutation) Fields() []string {
  40293. fields := make([]string, 0, 18)
  40294. if m.created_at != nil {
  40295. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  40296. }
  40297. if m.updated_at != nil {
  40298. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  40299. }
  40300. if m.status != nil {
  40301. fields = append(fields, usagestatisticmonth.FieldStatus)
  40302. }
  40303. if m.deleted_at != nil {
  40304. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40305. }
  40306. if m.addtime != nil {
  40307. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40308. }
  40309. if m._type != nil {
  40310. fields = append(fields, usagestatisticmonth.FieldType)
  40311. }
  40312. if m.bot_id != nil {
  40313. fields = append(fields, usagestatisticmonth.FieldBotID)
  40314. }
  40315. if m.organization_id != nil {
  40316. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40317. }
  40318. if m.ai_response != nil {
  40319. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40320. }
  40321. if m.sop_run != nil {
  40322. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40323. }
  40324. if m.total_friend != nil {
  40325. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40326. }
  40327. if m.total_group != nil {
  40328. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40329. }
  40330. if m.account_balance != nil {
  40331. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40332. }
  40333. if m.consume_token != nil {
  40334. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40335. }
  40336. if m.active_user != nil {
  40337. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40338. }
  40339. if m.new_user != nil {
  40340. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40341. }
  40342. if m.label_dist != nil {
  40343. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  40344. }
  40345. if m.consume_coin != nil {
  40346. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40347. }
  40348. return fields
  40349. }
  40350. // Field returns the value of a field with the given name. The second boolean
  40351. // return value indicates that this field was not set, or was not defined in the
  40352. // schema.
  40353. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  40354. switch name {
  40355. case usagestatisticmonth.FieldCreatedAt:
  40356. return m.CreatedAt()
  40357. case usagestatisticmonth.FieldUpdatedAt:
  40358. return m.UpdatedAt()
  40359. case usagestatisticmonth.FieldStatus:
  40360. return m.Status()
  40361. case usagestatisticmonth.FieldDeletedAt:
  40362. return m.DeletedAt()
  40363. case usagestatisticmonth.FieldAddtime:
  40364. return m.Addtime()
  40365. case usagestatisticmonth.FieldType:
  40366. return m.GetType()
  40367. case usagestatisticmonth.FieldBotID:
  40368. return m.BotID()
  40369. case usagestatisticmonth.FieldOrganizationID:
  40370. return m.OrganizationID()
  40371. case usagestatisticmonth.FieldAiResponse:
  40372. return m.AiResponse()
  40373. case usagestatisticmonth.FieldSopRun:
  40374. return m.SopRun()
  40375. case usagestatisticmonth.FieldTotalFriend:
  40376. return m.TotalFriend()
  40377. case usagestatisticmonth.FieldTotalGroup:
  40378. return m.TotalGroup()
  40379. case usagestatisticmonth.FieldAccountBalance:
  40380. return m.AccountBalance()
  40381. case usagestatisticmonth.FieldConsumeToken:
  40382. return m.ConsumeToken()
  40383. case usagestatisticmonth.FieldActiveUser:
  40384. return m.ActiveUser()
  40385. case usagestatisticmonth.FieldNewUser:
  40386. return m.NewUser()
  40387. case usagestatisticmonth.FieldLabelDist:
  40388. return m.LabelDist()
  40389. case usagestatisticmonth.FieldConsumeCoin:
  40390. return m.ConsumeCoin()
  40391. }
  40392. return nil, false
  40393. }
  40394. // OldField returns the old value of the field from the database. An error is
  40395. // returned if the mutation operation is not UpdateOne, or the query to the
  40396. // database failed.
  40397. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40398. switch name {
  40399. case usagestatisticmonth.FieldCreatedAt:
  40400. return m.OldCreatedAt(ctx)
  40401. case usagestatisticmonth.FieldUpdatedAt:
  40402. return m.OldUpdatedAt(ctx)
  40403. case usagestatisticmonth.FieldStatus:
  40404. return m.OldStatus(ctx)
  40405. case usagestatisticmonth.FieldDeletedAt:
  40406. return m.OldDeletedAt(ctx)
  40407. case usagestatisticmonth.FieldAddtime:
  40408. return m.OldAddtime(ctx)
  40409. case usagestatisticmonth.FieldType:
  40410. return m.OldType(ctx)
  40411. case usagestatisticmonth.FieldBotID:
  40412. return m.OldBotID(ctx)
  40413. case usagestatisticmonth.FieldOrganizationID:
  40414. return m.OldOrganizationID(ctx)
  40415. case usagestatisticmonth.FieldAiResponse:
  40416. return m.OldAiResponse(ctx)
  40417. case usagestatisticmonth.FieldSopRun:
  40418. return m.OldSopRun(ctx)
  40419. case usagestatisticmonth.FieldTotalFriend:
  40420. return m.OldTotalFriend(ctx)
  40421. case usagestatisticmonth.FieldTotalGroup:
  40422. return m.OldTotalGroup(ctx)
  40423. case usagestatisticmonth.FieldAccountBalance:
  40424. return m.OldAccountBalance(ctx)
  40425. case usagestatisticmonth.FieldConsumeToken:
  40426. return m.OldConsumeToken(ctx)
  40427. case usagestatisticmonth.FieldActiveUser:
  40428. return m.OldActiveUser(ctx)
  40429. case usagestatisticmonth.FieldNewUser:
  40430. return m.OldNewUser(ctx)
  40431. case usagestatisticmonth.FieldLabelDist:
  40432. return m.OldLabelDist(ctx)
  40433. case usagestatisticmonth.FieldConsumeCoin:
  40434. return m.OldConsumeCoin(ctx)
  40435. }
  40436. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40437. }
  40438. // SetField sets the value of a field with the given name. It returns an error if
  40439. // the field is not defined in the schema, or if the type mismatched the field
  40440. // type.
  40441. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  40442. switch name {
  40443. case usagestatisticmonth.FieldCreatedAt:
  40444. v, ok := value.(time.Time)
  40445. if !ok {
  40446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40447. }
  40448. m.SetCreatedAt(v)
  40449. return nil
  40450. case usagestatisticmonth.FieldUpdatedAt:
  40451. v, ok := value.(time.Time)
  40452. if !ok {
  40453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40454. }
  40455. m.SetUpdatedAt(v)
  40456. return nil
  40457. case usagestatisticmonth.FieldStatus:
  40458. v, ok := value.(uint8)
  40459. if !ok {
  40460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40461. }
  40462. m.SetStatus(v)
  40463. return nil
  40464. case usagestatisticmonth.FieldDeletedAt:
  40465. v, ok := value.(time.Time)
  40466. if !ok {
  40467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40468. }
  40469. m.SetDeletedAt(v)
  40470. return nil
  40471. case usagestatisticmonth.FieldAddtime:
  40472. v, ok := value.(uint64)
  40473. if !ok {
  40474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40475. }
  40476. m.SetAddtime(v)
  40477. return nil
  40478. case usagestatisticmonth.FieldType:
  40479. v, ok := value.(int)
  40480. if !ok {
  40481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40482. }
  40483. m.SetType(v)
  40484. return nil
  40485. case usagestatisticmonth.FieldBotID:
  40486. v, ok := value.(string)
  40487. if !ok {
  40488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40489. }
  40490. m.SetBotID(v)
  40491. return nil
  40492. case usagestatisticmonth.FieldOrganizationID:
  40493. v, ok := value.(uint64)
  40494. if !ok {
  40495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40496. }
  40497. m.SetOrganizationID(v)
  40498. return nil
  40499. case usagestatisticmonth.FieldAiResponse:
  40500. v, ok := value.(uint64)
  40501. if !ok {
  40502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40503. }
  40504. m.SetAiResponse(v)
  40505. return nil
  40506. case usagestatisticmonth.FieldSopRun:
  40507. v, ok := value.(uint64)
  40508. if !ok {
  40509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40510. }
  40511. m.SetSopRun(v)
  40512. return nil
  40513. case usagestatisticmonth.FieldTotalFriend:
  40514. v, ok := value.(uint64)
  40515. if !ok {
  40516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40517. }
  40518. m.SetTotalFriend(v)
  40519. return nil
  40520. case usagestatisticmonth.FieldTotalGroup:
  40521. v, ok := value.(uint64)
  40522. if !ok {
  40523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40524. }
  40525. m.SetTotalGroup(v)
  40526. return nil
  40527. case usagestatisticmonth.FieldAccountBalance:
  40528. v, ok := value.(uint64)
  40529. if !ok {
  40530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40531. }
  40532. m.SetAccountBalance(v)
  40533. return nil
  40534. case usagestatisticmonth.FieldConsumeToken:
  40535. v, ok := value.(uint64)
  40536. if !ok {
  40537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40538. }
  40539. m.SetConsumeToken(v)
  40540. return nil
  40541. case usagestatisticmonth.FieldActiveUser:
  40542. v, ok := value.(uint64)
  40543. if !ok {
  40544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40545. }
  40546. m.SetActiveUser(v)
  40547. return nil
  40548. case usagestatisticmonth.FieldNewUser:
  40549. v, ok := value.(int64)
  40550. if !ok {
  40551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40552. }
  40553. m.SetNewUser(v)
  40554. return nil
  40555. case usagestatisticmonth.FieldLabelDist:
  40556. v, ok := value.([]custom_types.LabelDist)
  40557. if !ok {
  40558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40559. }
  40560. m.SetLabelDist(v)
  40561. return nil
  40562. case usagestatisticmonth.FieldConsumeCoin:
  40563. v, ok := value.(float64)
  40564. if !ok {
  40565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40566. }
  40567. m.SetConsumeCoin(v)
  40568. return nil
  40569. }
  40570. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40571. }
  40572. // AddedFields returns all numeric fields that were incremented/decremented during
  40573. // this mutation.
  40574. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  40575. var fields []string
  40576. if m.addstatus != nil {
  40577. fields = append(fields, usagestatisticmonth.FieldStatus)
  40578. }
  40579. if m.addaddtime != nil {
  40580. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40581. }
  40582. if m.add_type != nil {
  40583. fields = append(fields, usagestatisticmonth.FieldType)
  40584. }
  40585. if m.addorganization_id != nil {
  40586. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40587. }
  40588. if m.addai_response != nil {
  40589. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40590. }
  40591. if m.addsop_run != nil {
  40592. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40593. }
  40594. if m.addtotal_friend != nil {
  40595. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40596. }
  40597. if m.addtotal_group != nil {
  40598. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40599. }
  40600. if m.addaccount_balance != nil {
  40601. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40602. }
  40603. if m.addconsume_token != nil {
  40604. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40605. }
  40606. if m.addactive_user != nil {
  40607. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40608. }
  40609. if m.addnew_user != nil {
  40610. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40611. }
  40612. if m.addconsume_coin != nil {
  40613. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40614. }
  40615. return fields
  40616. }
  40617. // AddedField returns the numeric value that was incremented/decremented on a field
  40618. // with the given name. The second boolean return value indicates that this field
  40619. // was not set, or was not defined in the schema.
  40620. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  40621. switch name {
  40622. case usagestatisticmonth.FieldStatus:
  40623. return m.AddedStatus()
  40624. case usagestatisticmonth.FieldAddtime:
  40625. return m.AddedAddtime()
  40626. case usagestatisticmonth.FieldType:
  40627. return m.AddedType()
  40628. case usagestatisticmonth.FieldOrganizationID:
  40629. return m.AddedOrganizationID()
  40630. case usagestatisticmonth.FieldAiResponse:
  40631. return m.AddedAiResponse()
  40632. case usagestatisticmonth.FieldSopRun:
  40633. return m.AddedSopRun()
  40634. case usagestatisticmonth.FieldTotalFriend:
  40635. return m.AddedTotalFriend()
  40636. case usagestatisticmonth.FieldTotalGroup:
  40637. return m.AddedTotalGroup()
  40638. case usagestatisticmonth.FieldAccountBalance:
  40639. return m.AddedAccountBalance()
  40640. case usagestatisticmonth.FieldConsumeToken:
  40641. return m.AddedConsumeToken()
  40642. case usagestatisticmonth.FieldActiveUser:
  40643. return m.AddedActiveUser()
  40644. case usagestatisticmonth.FieldNewUser:
  40645. return m.AddedNewUser()
  40646. case usagestatisticmonth.FieldConsumeCoin:
  40647. return m.AddedConsumeCoin()
  40648. }
  40649. return nil, false
  40650. }
  40651. // AddField adds the value to the field with the given name. It returns an error if
  40652. // the field is not defined in the schema, or if the type mismatched the field
  40653. // type.
  40654. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  40655. switch name {
  40656. case usagestatisticmonth.FieldStatus:
  40657. v, ok := value.(int8)
  40658. if !ok {
  40659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40660. }
  40661. m.AddStatus(v)
  40662. return nil
  40663. case usagestatisticmonth.FieldAddtime:
  40664. v, ok := value.(int64)
  40665. if !ok {
  40666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40667. }
  40668. m.AddAddtime(v)
  40669. return nil
  40670. case usagestatisticmonth.FieldType:
  40671. v, ok := value.(int)
  40672. if !ok {
  40673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40674. }
  40675. m.AddType(v)
  40676. return nil
  40677. case usagestatisticmonth.FieldOrganizationID:
  40678. v, ok := value.(int64)
  40679. if !ok {
  40680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40681. }
  40682. m.AddOrganizationID(v)
  40683. return nil
  40684. case usagestatisticmonth.FieldAiResponse:
  40685. v, ok := value.(int64)
  40686. if !ok {
  40687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40688. }
  40689. m.AddAiResponse(v)
  40690. return nil
  40691. case usagestatisticmonth.FieldSopRun:
  40692. v, ok := value.(int64)
  40693. if !ok {
  40694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40695. }
  40696. m.AddSopRun(v)
  40697. return nil
  40698. case usagestatisticmonth.FieldTotalFriend:
  40699. v, ok := value.(int64)
  40700. if !ok {
  40701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40702. }
  40703. m.AddTotalFriend(v)
  40704. return nil
  40705. case usagestatisticmonth.FieldTotalGroup:
  40706. v, ok := value.(int64)
  40707. if !ok {
  40708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40709. }
  40710. m.AddTotalGroup(v)
  40711. return nil
  40712. case usagestatisticmonth.FieldAccountBalance:
  40713. v, ok := value.(int64)
  40714. if !ok {
  40715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40716. }
  40717. m.AddAccountBalance(v)
  40718. return nil
  40719. case usagestatisticmonth.FieldConsumeToken:
  40720. v, ok := value.(int64)
  40721. if !ok {
  40722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40723. }
  40724. m.AddConsumeToken(v)
  40725. return nil
  40726. case usagestatisticmonth.FieldActiveUser:
  40727. v, ok := value.(int64)
  40728. if !ok {
  40729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40730. }
  40731. m.AddActiveUser(v)
  40732. return nil
  40733. case usagestatisticmonth.FieldNewUser:
  40734. v, ok := value.(int64)
  40735. if !ok {
  40736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40737. }
  40738. m.AddNewUser(v)
  40739. return nil
  40740. case usagestatisticmonth.FieldConsumeCoin:
  40741. v, ok := value.(float64)
  40742. if !ok {
  40743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40744. }
  40745. m.AddConsumeCoin(v)
  40746. return nil
  40747. }
  40748. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  40749. }
  40750. // ClearedFields returns all nullable fields that were cleared during this
  40751. // mutation.
  40752. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  40753. var fields []string
  40754. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  40755. fields = append(fields, usagestatisticmonth.FieldStatus)
  40756. }
  40757. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  40758. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40759. }
  40760. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  40761. fields = append(fields, usagestatisticmonth.FieldBotID)
  40762. }
  40763. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  40764. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40765. }
  40766. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  40767. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40768. }
  40769. return fields
  40770. }
  40771. // FieldCleared returns a boolean indicating if a field with the given name was
  40772. // cleared in this mutation.
  40773. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  40774. _, ok := m.clearedFields[name]
  40775. return ok
  40776. }
  40777. // ClearField clears the value of the field with the given name. It returns an
  40778. // error if the field is not defined in the schema.
  40779. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  40780. switch name {
  40781. case usagestatisticmonth.FieldStatus:
  40782. m.ClearStatus()
  40783. return nil
  40784. case usagestatisticmonth.FieldDeletedAt:
  40785. m.ClearDeletedAt()
  40786. return nil
  40787. case usagestatisticmonth.FieldBotID:
  40788. m.ClearBotID()
  40789. return nil
  40790. case usagestatisticmonth.FieldOrganizationID:
  40791. m.ClearOrganizationID()
  40792. return nil
  40793. case usagestatisticmonth.FieldConsumeCoin:
  40794. m.ClearConsumeCoin()
  40795. return nil
  40796. }
  40797. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  40798. }
  40799. // ResetField resets all changes in the mutation for the field with the given name.
  40800. // It returns an error if the field is not defined in the schema.
  40801. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  40802. switch name {
  40803. case usagestatisticmonth.FieldCreatedAt:
  40804. m.ResetCreatedAt()
  40805. return nil
  40806. case usagestatisticmonth.FieldUpdatedAt:
  40807. m.ResetUpdatedAt()
  40808. return nil
  40809. case usagestatisticmonth.FieldStatus:
  40810. m.ResetStatus()
  40811. return nil
  40812. case usagestatisticmonth.FieldDeletedAt:
  40813. m.ResetDeletedAt()
  40814. return nil
  40815. case usagestatisticmonth.FieldAddtime:
  40816. m.ResetAddtime()
  40817. return nil
  40818. case usagestatisticmonth.FieldType:
  40819. m.ResetType()
  40820. return nil
  40821. case usagestatisticmonth.FieldBotID:
  40822. m.ResetBotID()
  40823. return nil
  40824. case usagestatisticmonth.FieldOrganizationID:
  40825. m.ResetOrganizationID()
  40826. return nil
  40827. case usagestatisticmonth.FieldAiResponse:
  40828. m.ResetAiResponse()
  40829. return nil
  40830. case usagestatisticmonth.FieldSopRun:
  40831. m.ResetSopRun()
  40832. return nil
  40833. case usagestatisticmonth.FieldTotalFriend:
  40834. m.ResetTotalFriend()
  40835. return nil
  40836. case usagestatisticmonth.FieldTotalGroup:
  40837. m.ResetTotalGroup()
  40838. return nil
  40839. case usagestatisticmonth.FieldAccountBalance:
  40840. m.ResetAccountBalance()
  40841. return nil
  40842. case usagestatisticmonth.FieldConsumeToken:
  40843. m.ResetConsumeToken()
  40844. return nil
  40845. case usagestatisticmonth.FieldActiveUser:
  40846. m.ResetActiveUser()
  40847. return nil
  40848. case usagestatisticmonth.FieldNewUser:
  40849. m.ResetNewUser()
  40850. return nil
  40851. case usagestatisticmonth.FieldLabelDist:
  40852. m.ResetLabelDist()
  40853. return nil
  40854. case usagestatisticmonth.FieldConsumeCoin:
  40855. m.ResetConsumeCoin()
  40856. return nil
  40857. }
  40858. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40859. }
  40860. // AddedEdges returns all edge names that were set/added in this mutation.
  40861. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  40862. edges := make([]string, 0, 0)
  40863. return edges
  40864. }
  40865. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40866. // name in this mutation.
  40867. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  40868. return nil
  40869. }
  40870. // RemovedEdges returns all edge names that were removed in this mutation.
  40871. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  40872. edges := make([]string, 0, 0)
  40873. return edges
  40874. }
  40875. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40876. // the given name in this mutation.
  40877. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  40878. return nil
  40879. }
  40880. // ClearedEdges returns all edge names that were cleared in this mutation.
  40881. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  40882. edges := make([]string, 0, 0)
  40883. return edges
  40884. }
  40885. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40886. // was cleared in this mutation.
  40887. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  40888. return false
  40889. }
  40890. // ClearEdge clears the value of the edge with the given name. It returns an error
  40891. // if that edge is not defined in the schema.
  40892. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  40893. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  40894. }
  40895. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40896. // It returns an error if the edge is not defined in the schema.
  40897. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  40898. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  40899. }
  40900. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  40901. type UsageTotalMutation struct {
  40902. config
  40903. op Op
  40904. typ string
  40905. id *uint64
  40906. created_at *time.Time
  40907. updated_at *time.Time
  40908. status *uint8
  40909. addstatus *int8
  40910. _type *int
  40911. add_type *int
  40912. bot_id *string
  40913. total_tokens *uint64
  40914. addtotal_tokens *int64
  40915. credits *float64
  40916. addcredits *float64
  40917. start_index *uint64
  40918. addstart_index *int64
  40919. end_index *uint64
  40920. addend_index *int64
  40921. organization_id *uint64
  40922. addorganization_id *int64
  40923. clearedFields map[string]struct{}
  40924. done bool
  40925. oldValue func(context.Context) (*UsageTotal, error)
  40926. predicates []predicate.UsageTotal
  40927. }
  40928. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  40929. // usagetotalOption allows management of the mutation configuration using functional options.
  40930. type usagetotalOption func(*UsageTotalMutation)
  40931. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  40932. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  40933. m := &UsageTotalMutation{
  40934. config: c,
  40935. op: op,
  40936. typ: TypeUsageTotal,
  40937. clearedFields: make(map[string]struct{}),
  40938. }
  40939. for _, opt := range opts {
  40940. opt(m)
  40941. }
  40942. return m
  40943. }
  40944. // withUsageTotalID sets the ID field of the mutation.
  40945. func withUsageTotalID(id uint64) usagetotalOption {
  40946. return func(m *UsageTotalMutation) {
  40947. var (
  40948. err error
  40949. once sync.Once
  40950. value *UsageTotal
  40951. )
  40952. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  40953. once.Do(func() {
  40954. if m.done {
  40955. err = errors.New("querying old values post mutation is not allowed")
  40956. } else {
  40957. value, err = m.Client().UsageTotal.Get(ctx, id)
  40958. }
  40959. })
  40960. return value, err
  40961. }
  40962. m.id = &id
  40963. }
  40964. }
  40965. // withUsageTotal sets the old UsageTotal of the mutation.
  40966. func withUsageTotal(node *UsageTotal) usagetotalOption {
  40967. return func(m *UsageTotalMutation) {
  40968. m.oldValue = func(context.Context) (*UsageTotal, error) {
  40969. return node, nil
  40970. }
  40971. m.id = &node.ID
  40972. }
  40973. }
  40974. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40975. // executed in a transaction (ent.Tx), a transactional client is returned.
  40976. func (m UsageTotalMutation) Client() *Client {
  40977. client := &Client{config: m.config}
  40978. client.init()
  40979. return client
  40980. }
  40981. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40982. // it returns an error otherwise.
  40983. func (m UsageTotalMutation) Tx() (*Tx, error) {
  40984. if _, ok := m.driver.(*txDriver); !ok {
  40985. return nil, errors.New("ent: mutation is not running in a transaction")
  40986. }
  40987. tx := &Tx{config: m.config}
  40988. tx.init()
  40989. return tx, nil
  40990. }
  40991. // SetID sets the value of the id field. Note that this
  40992. // operation is only accepted on creation of UsageTotal entities.
  40993. func (m *UsageTotalMutation) SetID(id uint64) {
  40994. m.id = &id
  40995. }
  40996. // ID returns the ID value in the mutation. Note that the ID is only available
  40997. // if it was provided to the builder or after it was returned from the database.
  40998. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  40999. if m.id == nil {
  41000. return
  41001. }
  41002. return *m.id, true
  41003. }
  41004. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41005. // That means, if the mutation is applied within a transaction with an isolation level such
  41006. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41007. // or updated by the mutation.
  41008. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  41009. switch {
  41010. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41011. id, exists := m.ID()
  41012. if exists {
  41013. return []uint64{id}, nil
  41014. }
  41015. fallthrough
  41016. case m.op.Is(OpUpdate | OpDelete):
  41017. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  41018. default:
  41019. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41020. }
  41021. }
  41022. // SetCreatedAt sets the "created_at" field.
  41023. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  41024. m.created_at = &t
  41025. }
  41026. // CreatedAt returns the value of the "created_at" field in the mutation.
  41027. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  41028. v := m.created_at
  41029. if v == nil {
  41030. return
  41031. }
  41032. return *v, true
  41033. }
  41034. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  41035. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41037. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41038. if !m.op.Is(OpUpdateOne) {
  41039. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41040. }
  41041. if m.id == nil || m.oldValue == nil {
  41042. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41043. }
  41044. oldValue, err := m.oldValue(ctx)
  41045. if err != nil {
  41046. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41047. }
  41048. return oldValue.CreatedAt, nil
  41049. }
  41050. // ResetCreatedAt resets all changes to the "created_at" field.
  41051. func (m *UsageTotalMutation) ResetCreatedAt() {
  41052. m.created_at = nil
  41053. }
  41054. // SetUpdatedAt sets the "updated_at" field.
  41055. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  41056. m.updated_at = &t
  41057. }
  41058. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41059. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  41060. v := m.updated_at
  41061. if v == nil {
  41062. return
  41063. }
  41064. return *v, true
  41065. }
  41066. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  41067. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41069. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41070. if !m.op.Is(OpUpdateOne) {
  41071. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41072. }
  41073. if m.id == nil || m.oldValue == nil {
  41074. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41075. }
  41076. oldValue, err := m.oldValue(ctx)
  41077. if err != nil {
  41078. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41079. }
  41080. return oldValue.UpdatedAt, nil
  41081. }
  41082. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41083. func (m *UsageTotalMutation) ResetUpdatedAt() {
  41084. m.updated_at = nil
  41085. }
  41086. // SetStatus sets the "status" field.
  41087. func (m *UsageTotalMutation) SetStatus(u uint8) {
  41088. m.status = &u
  41089. m.addstatus = nil
  41090. }
  41091. // Status returns the value of the "status" field in the mutation.
  41092. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  41093. v := m.status
  41094. if v == nil {
  41095. return
  41096. }
  41097. return *v, true
  41098. }
  41099. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  41100. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41102. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41103. if !m.op.Is(OpUpdateOne) {
  41104. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41105. }
  41106. if m.id == nil || m.oldValue == nil {
  41107. return v, errors.New("OldStatus requires an ID field in the mutation")
  41108. }
  41109. oldValue, err := m.oldValue(ctx)
  41110. if err != nil {
  41111. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41112. }
  41113. return oldValue.Status, nil
  41114. }
  41115. // AddStatus adds u to the "status" field.
  41116. func (m *UsageTotalMutation) AddStatus(u int8) {
  41117. if m.addstatus != nil {
  41118. *m.addstatus += u
  41119. } else {
  41120. m.addstatus = &u
  41121. }
  41122. }
  41123. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41124. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  41125. v := m.addstatus
  41126. if v == nil {
  41127. return
  41128. }
  41129. return *v, true
  41130. }
  41131. // ClearStatus clears the value of the "status" field.
  41132. func (m *UsageTotalMutation) ClearStatus() {
  41133. m.status = nil
  41134. m.addstatus = nil
  41135. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  41136. }
  41137. // StatusCleared returns if the "status" field was cleared in this mutation.
  41138. func (m *UsageTotalMutation) StatusCleared() bool {
  41139. _, ok := m.clearedFields[usagetotal.FieldStatus]
  41140. return ok
  41141. }
  41142. // ResetStatus resets all changes to the "status" field.
  41143. func (m *UsageTotalMutation) ResetStatus() {
  41144. m.status = nil
  41145. m.addstatus = nil
  41146. delete(m.clearedFields, usagetotal.FieldStatus)
  41147. }
  41148. // SetType sets the "type" field.
  41149. func (m *UsageTotalMutation) SetType(i int) {
  41150. m._type = &i
  41151. m.add_type = nil
  41152. }
  41153. // GetType returns the value of the "type" field in the mutation.
  41154. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  41155. v := m._type
  41156. if v == nil {
  41157. return
  41158. }
  41159. return *v, true
  41160. }
  41161. // OldType returns the old "type" field's value of the UsageTotal entity.
  41162. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41164. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  41165. if !m.op.Is(OpUpdateOne) {
  41166. return v, errors.New("OldType is only allowed on UpdateOne operations")
  41167. }
  41168. if m.id == nil || m.oldValue == nil {
  41169. return v, errors.New("OldType requires an ID field in the mutation")
  41170. }
  41171. oldValue, err := m.oldValue(ctx)
  41172. if err != nil {
  41173. return v, fmt.Errorf("querying old value for OldType: %w", err)
  41174. }
  41175. return oldValue.Type, nil
  41176. }
  41177. // AddType adds i to the "type" field.
  41178. func (m *UsageTotalMutation) AddType(i int) {
  41179. if m.add_type != nil {
  41180. *m.add_type += i
  41181. } else {
  41182. m.add_type = &i
  41183. }
  41184. }
  41185. // AddedType returns the value that was added to the "type" field in this mutation.
  41186. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  41187. v := m.add_type
  41188. if v == nil {
  41189. return
  41190. }
  41191. return *v, true
  41192. }
  41193. // ClearType clears the value of the "type" field.
  41194. func (m *UsageTotalMutation) ClearType() {
  41195. m._type = nil
  41196. m.add_type = nil
  41197. m.clearedFields[usagetotal.FieldType] = struct{}{}
  41198. }
  41199. // TypeCleared returns if the "type" field was cleared in this mutation.
  41200. func (m *UsageTotalMutation) TypeCleared() bool {
  41201. _, ok := m.clearedFields[usagetotal.FieldType]
  41202. return ok
  41203. }
  41204. // ResetType resets all changes to the "type" field.
  41205. func (m *UsageTotalMutation) ResetType() {
  41206. m._type = nil
  41207. m.add_type = nil
  41208. delete(m.clearedFields, usagetotal.FieldType)
  41209. }
  41210. // SetBotID sets the "bot_id" field.
  41211. func (m *UsageTotalMutation) SetBotID(s string) {
  41212. m.bot_id = &s
  41213. }
  41214. // BotID returns the value of the "bot_id" field in the mutation.
  41215. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  41216. v := m.bot_id
  41217. if v == nil {
  41218. return
  41219. }
  41220. return *v, true
  41221. }
  41222. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  41223. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41225. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  41226. if !m.op.Is(OpUpdateOne) {
  41227. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41228. }
  41229. if m.id == nil || m.oldValue == nil {
  41230. return v, errors.New("OldBotID requires an ID field in the mutation")
  41231. }
  41232. oldValue, err := m.oldValue(ctx)
  41233. if err != nil {
  41234. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41235. }
  41236. return oldValue.BotID, nil
  41237. }
  41238. // ResetBotID resets all changes to the "bot_id" field.
  41239. func (m *UsageTotalMutation) ResetBotID() {
  41240. m.bot_id = nil
  41241. }
  41242. // SetTotalTokens sets the "total_tokens" field.
  41243. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  41244. m.total_tokens = &u
  41245. m.addtotal_tokens = nil
  41246. }
  41247. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  41248. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  41249. v := m.total_tokens
  41250. if v == nil {
  41251. return
  41252. }
  41253. return *v, true
  41254. }
  41255. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  41256. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41258. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  41259. if !m.op.Is(OpUpdateOne) {
  41260. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  41261. }
  41262. if m.id == nil || m.oldValue == nil {
  41263. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  41264. }
  41265. oldValue, err := m.oldValue(ctx)
  41266. if err != nil {
  41267. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  41268. }
  41269. return oldValue.TotalTokens, nil
  41270. }
  41271. // AddTotalTokens adds u to the "total_tokens" field.
  41272. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  41273. if m.addtotal_tokens != nil {
  41274. *m.addtotal_tokens += u
  41275. } else {
  41276. m.addtotal_tokens = &u
  41277. }
  41278. }
  41279. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  41280. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  41281. v := m.addtotal_tokens
  41282. if v == nil {
  41283. return
  41284. }
  41285. return *v, true
  41286. }
  41287. // ClearTotalTokens clears the value of the "total_tokens" field.
  41288. func (m *UsageTotalMutation) ClearTotalTokens() {
  41289. m.total_tokens = nil
  41290. m.addtotal_tokens = nil
  41291. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  41292. }
  41293. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  41294. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  41295. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  41296. return ok
  41297. }
  41298. // ResetTotalTokens resets all changes to the "total_tokens" field.
  41299. func (m *UsageTotalMutation) ResetTotalTokens() {
  41300. m.total_tokens = nil
  41301. m.addtotal_tokens = nil
  41302. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  41303. }
  41304. // SetCredits sets the "credits" field.
  41305. func (m *UsageTotalMutation) SetCredits(f float64) {
  41306. m.credits = &f
  41307. m.addcredits = nil
  41308. }
  41309. // Credits returns the value of the "credits" field in the mutation.
  41310. func (m *UsageTotalMutation) Credits() (r float64, exists bool) {
  41311. v := m.credits
  41312. if v == nil {
  41313. return
  41314. }
  41315. return *v, true
  41316. }
  41317. // OldCredits returns the old "credits" field's value of the UsageTotal entity.
  41318. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41320. func (m *UsageTotalMutation) OldCredits(ctx context.Context) (v float64, err error) {
  41321. if !m.op.Is(OpUpdateOne) {
  41322. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  41323. }
  41324. if m.id == nil || m.oldValue == nil {
  41325. return v, errors.New("OldCredits requires an ID field in the mutation")
  41326. }
  41327. oldValue, err := m.oldValue(ctx)
  41328. if err != nil {
  41329. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  41330. }
  41331. return oldValue.Credits, nil
  41332. }
  41333. // AddCredits adds f to the "credits" field.
  41334. func (m *UsageTotalMutation) AddCredits(f float64) {
  41335. if m.addcredits != nil {
  41336. *m.addcredits += f
  41337. } else {
  41338. m.addcredits = &f
  41339. }
  41340. }
  41341. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  41342. func (m *UsageTotalMutation) AddedCredits() (r float64, exists bool) {
  41343. v := m.addcredits
  41344. if v == nil {
  41345. return
  41346. }
  41347. return *v, true
  41348. }
  41349. // ClearCredits clears the value of the "credits" field.
  41350. func (m *UsageTotalMutation) ClearCredits() {
  41351. m.credits = nil
  41352. m.addcredits = nil
  41353. m.clearedFields[usagetotal.FieldCredits] = struct{}{}
  41354. }
  41355. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  41356. func (m *UsageTotalMutation) CreditsCleared() bool {
  41357. _, ok := m.clearedFields[usagetotal.FieldCredits]
  41358. return ok
  41359. }
  41360. // ResetCredits resets all changes to the "credits" field.
  41361. func (m *UsageTotalMutation) ResetCredits() {
  41362. m.credits = nil
  41363. m.addcredits = nil
  41364. delete(m.clearedFields, usagetotal.FieldCredits)
  41365. }
  41366. // SetStartIndex sets the "start_index" field.
  41367. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  41368. m.start_index = &u
  41369. m.addstart_index = nil
  41370. }
  41371. // StartIndex returns the value of the "start_index" field in the mutation.
  41372. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  41373. v := m.start_index
  41374. if v == nil {
  41375. return
  41376. }
  41377. return *v, true
  41378. }
  41379. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  41380. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41382. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  41383. if !m.op.Is(OpUpdateOne) {
  41384. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  41385. }
  41386. if m.id == nil || m.oldValue == nil {
  41387. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  41388. }
  41389. oldValue, err := m.oldValue(ctx)
  41390. if err != nil {
  41391. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  41392. }
  41393. return oldValue.StartIndex, nil
  41394. }
  41395. // AddStartIndex adds u to the "start_index" field.
  41396. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  41397. if m.addstart_index != nil {
  41398. *m.addstart_index += u
  41399. } else {
  41400. m.addstart_index = &u
  41401. }
  41402. }
  41403. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  41404. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  41405. v := m.addstart_index
  41406. if v == nil {
  41407. return
  41408. }
  41409. return *v, true
  41410. }
  41411. // ClearStartIndex clears the value of the "start_index" field.
  41412. func (m *UsageTotalMutation) ClearStartIndex() {
  41413. m.start_index = nil
  41414. m.addstart_index = nil
  41415. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  41416. }
  41417. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  41418. func (m *UsageTotalMutation) StartIndexCleared() bool {
  41419. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  41420. return ok
  41421. }
  41422. // ResetStartIndex resets all changes to the "start_index" field.
  41423. func (m *UsageTotalMutation) ResetStartIndex() {
  41424. m.start_index = nil
  41425. m.addstart_index = nil
  41426. delete(m.clearedFields, usagetotal.FieldStartIndex)
  41427. }
  41428. // SetEndIndex sets the "end_index" field.
  41429. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  41430. m.end_index = &u
  41431. m.addend_index = nil
  41432. }
  41433. // EndIndex returns the value of the "end_index" field in the mutation.
  41434. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  41435. v := m.end_index
  41436. if v == nil {
  41437. return
  41438. }
  41439. return *v, true
  41440. }
  41441. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  41442. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41444. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  41445. if !m.op.Is(OpUpdateOne) {
  41446. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  41447. }
  41448. if m.id == nil || m.oldValue == nil {
  41449. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  41450. }
  41451. oldValue, err := m.oldValue(ctx)
  41452. if err != nil {
  41453. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  41454. }
  41455. return oldValue.EndIndex, nil
  41456. }
  41457. // AddEndIndex adds u to the "end_index" field.
  41458. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  41459. if m.addend_index != nil {
  41460. *m.addend_index += u
  41461. } else {
  41462. m.addend_index = &u
  41463. }
  41464. }
  41465. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  41466. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  41467. v := m.addend_index
  41468. if v == nil {
  41469. return
  41470. }
  41471. return *v, true
  41472. }
  41473. // ClearEndIndex clears the value of the "end_index" field.
  41474. func (m *UsageTotalMutation) ClearEndIndex() {
  41475. m.end_index = nil
  41476. m.addend_index = nil
  41477. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  41478. }
  41479. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  41480. func (m *UsageTotalMutation) EndIndexCleared() bool {
  41481. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  41482. return ok
  41483. }
  41484. // ResetEndIndex resets all changes to the "end_index" field.
  41485. func (m *UsageTotalMutation) ResetEndIndex() {
  41486. m.end_index = nil
  41487. m.addend_index = nil
  41488. delete(m.clearedFields, usagetotal.FieldEndIndex)
  41489. }
  41490. // SetOrganizationID sets the "organization_id" field.
  41491. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  41492. m.organization_id = &u
  41493. m.addorganization_id = nil
  41494. }
  41495. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41496. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  41497. v := m.organization_id
  41498. if v == nil {
  41499. return
  41500. }
  41501. return *v, true
  41502. }
  41503. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  41504. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41506. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41507. if !m.op.Is(OpUpdateOne) {
  41508. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41509. }
  41510. if m.id == nil || m.oldValue == nil {
  41511. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41512. }
  41513. oldValue, err := m.oldValue(ctx)
  41514. if err != nil {
  41515. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41516. }
  41517. return oldValue.OrganizationID, nil
  41518. }
  41519. // AddOrganizationID adds u to the "organization_id" field.
  41520. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  41521. if m.addorganization_id != nil {
  41522. *m.addorganization_id += u
  41523. } else {
  41524. m.addorganization_id = &u
  41525. }
  41526. }
  41527. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41528. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  41529. v := m.addorganization_id
  41530. if v == nil {
  41531. return
  41532. }
  41533. return *v, true
  41534. }
  41535. // ClearOrganizationID clears the value of the "organization_id" field.
  41536. func (m *UsageTotalMutation) ClearOrganizationID() {
  41537. m.organization_id = nil
  41538. m.addorganization_id = nil
  41539. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  41540. }
  41541. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41542. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  41543. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  41544. return ok
  41545. }
  41546. // ResetOrganizationID resets all changes to the "organization_id" field.
  41547. func (m *UsageTotalMutation) ResetOrganizationID() {
  41548. m.organization_id = nil
  41549. m.addorganization_id = nil
  41550. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  41551. }
  41552. // Where appends a list predicates to the UsageTotalMutation builder.
  41553. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  41554. m.predicates = append(m.predicates, ps...)
  41555. }
  41556. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  41557. // users can use type-assertion to append predicates that do not depend on any generated package.
  41558. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  41559. p := make([]predicate.UsageTotal, len(ps))
  41560. for i := range ps {
  41561. p[i] = ps[i]
  41562. }
  41563. m.Where(p...)
  41564. }
  41565. // Op returns the operation name.
  41566. func (m *UsageTotalMutation) Op() Op {
  41567. return m.op
  41568. }
  41569. // SetOp allows setting the mutation operation.
  41570. func (m *UsageTotalMutation) SetOp(op Op) {
  41571. m.op = op
  41572. }
  41573. // Type returns the node type of this mutation (UsageTotal).
  41574. func (m *UsageTotalMutation) Type() string {
  41575. return m.typ
  41576. }
  41577. // Fields returns all fields that were changed during this mutation. Note that in
  41578. // order to get all numeric fields that were incremented/decremented, call
  41579. // AddedFields().
  41580. func (m *UsageTotalMutation) Fields() []string {
  41581. fields := make([]string, 0, 10)
  41582. if m.created_at != nil {
  41583. fields = append(fields, usagetotal.FieldCreatedAt)
  41584. }
  41585. if m.updated_at != nil {
  41586. fields = append(fields, usagetotal.FieldUpdatedAt)
  41587. }
  41588. if m.status != nil {
  41589. fields = append(fields, usagetotal.FieldStatus)
  41590. }
  41591. if m._type != nil {
  41592. fields = append(fields, usagetotal.FieldType)
  41593. }
  41594. if m.bot_id != nil {
  41595. fields = append(fields, usagetotal.FieldBotID)
  41596. }
  41597. if m.total_tokens != nil {
  41598. fields = append(fields, usagetotal.FieldTotalTokens)
  41599. }
  41600. if m.credits != nil {
  41601. fields = append(fields, usagetotal.FieldCredits)
  41602. }
  41603. if m.start_index != nil {
  41604. fields = append(fields, usagetotal.FieldStartIndex)
  41605. }
  41606. if m.end_index != nil {
  41607. fields = append(fields, usagetotal.FieldEndIndex)
  41608. }
  41609. if m.organization_id != nil {
  41610. fields = append(fields, usagetotal.FieldOrganizationID)
  41611. }
  41612. return fields
  41613. }
  41614. // Field returns the value of a field with the given name. The second boolean
  41615. // return value indicates that this field was not set, or was not defined in the
  41616. // schema.
  41617. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  41618. switch name {
  41619. case usagetotal.FieldCreatedAt:
  41620. return m.CreatedAt()
  41621. case usagetotal.FieldUpdatedAt:
  41622. return m.UpdatedAt()
  41623. case usagetotal.FieldStatus:
  41624. return m.Status()
  41625. case usagetotal.FieldType:
  41626. return m.GetType()
  41627. case usagetotal.FieldBotID:
  41628. return m.BotID()
  41629. case usagetotal.FieldTotalTokens:
  41630. return m.TotalTokens()
  41631. case usagetotal.FieldCredits:
  41632. return m.Credits()
  41633. case usagetotal.FieldStartIndex:
  41634. return m.StartIndex()
  41635. case usagetotal.FieldEndIndex:
  41636. return m.EndIndex()
  41637. case usagetotal.FieldOrganizationID:
  41638. return m.OrganizationID()
  41639. }
  41640. return nil, false
  41641. }
  41642. // OldField returns the old value of the field from the database. An error is
  41643. // returned if the mutation operation is not UpdateOne, or the query to the
  41644. // database failed.
  41645. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41646. switch name {
  41647. case usagetotal.FieldCreatedAt:
  41648. return m.OldCreatedAt(ctx)
  41649. case usagetotal.FieldUpdatedAt:
  41650. return m.OldUpdatedAt(ctx)
  41651. case usagetotal.FieldStatus:
  41652. return m.OldStatus(ctx)
  41653. case usagetotal.FieldType:
  41654. return m.OldType(ctx)
  41655. case usagetotal.FieldBotID:
  41656. return m.OldBotID(ctx)
  41657. case usagetotal.FieldTotalTokens:
  41658. return m.OldTotalTokens(ctx)
  41659. case usagetotal.FieldCredits:
  41660. return m.OldCredits(ctx)
  41661. case usagetotal.FieldStartIndex:
  41662. return m.OldStartIndex(ctx)
  41663. case usagetotal.FieldEndIndex:
  41664. return m.OldEndIndex(ctx)
  41665. case usagetotal.FieldOrganizationID:
  41666. return m.OldOrganizationID(ctx)
  41667. }
  41668. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  41669. }
  41670. // SetField sets the value of a field with the given name. It returns an error if
  41671. // the field is not defined in the schema, or if the type mismatched the field
  41672. // type.
  41673. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  41674. switch name {
  41675. case usagetotal.FieldCreatedAt:
  41676. v, ok := value.(time.Time)
  41677. if !ok {
  41678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41679. }
  41680. m.SetCreatedAt(v)
  41681. return nil
  41682. case usagetotal.FieldUpdatedAt:
  41683. v, ok := value.(time.Time)
  41684. if !ok {
  41685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41686. }
  41687. m.SetUpdatedAt(v)
  41688. return nil
  41689. case usagetotal.FieldStatus:
  41690. v, ok := value.(uint8)
  41691. if !ok {
  41692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41693. }
  41694. m.SetStatus(v)
  41695. return nil
  41696. case usagetotal.FieldType:
  41697. v, ok := value.(int)
  41698. if !ok {
  41699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41700. }
  41701. m.SetType(v)
  41702. return nil
  41703. case usagetotal.FieldBotID:
  41704. v, ok := value.(string)
  41705. if !ok {
  41706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41707. }
  41708. m.SetBotID(v)
  41709. return nil
  41710. case usagetotal.FieldTotalTokens:
  41711. v, ok := value.(uint64)
  41712. if !ok {
  41713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41714. }
  41715. m.SetTotalTokens(v)
  41716. return nil
  41717. case usagetotal.FieldCredits:
  41718. v, ok := value.(float64)
  41719. if !ok {
  41720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41721. }
  41722. m.SetCredits(v)
  41723. return nil
  41724. case usagetotal.FieldStartIndex:
  41725. v, ok := value.(uint64)
  41726. if !ok {
  41727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41728. }
  41729. m.SetStartIndex(v)
  41730. return nil
  41731. case usagetotal.FieldEndIndex:
  41732. v, ok := value.(uint64)
  41733. if !ok {
  41734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41735. }
  41736. m.SetEndIndex(v)
  41737. return nil
  41738. case usagetotal.FieldOrganizationID:
  41739. v, ok := value.(uint64)
  41740. if !ok {
  41741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41742. }
  41743. m.SetOrganizationID(v)
  41744. return nil
  41745. }
  41746. return fmt.Errorf("unknown UsageTotal field %s", name)
  41747. }
  41748. // AddedFields returns all numeric fields that were incremented/decremented during
  41749. // this mutation.
  41750. func (m *UsageTotalMutation) AddedFields() []string {
  41751. var fields []string
  41752. if m.addstatus != nil {
  41753. fields = append(fields, usagetotal.FieldStatus)
  41754. }
  41755. if m.add_type != nil {
  41756. fields = append(fields, usagetotal.FieldType)
  41757. }
  41758. if m.addtotal_tokens != nil {
  41759. fields = append(fields, usagetotal.FieldTotalTokens)
  41760. }
  41761. if m.addcredits != nil {
  41762. fields = append(fields, usagetotal.FieldCredits)
  41763. }
  41764. if m.addstart_index != nil {
  41765. fields = append(fields, usagetotal.FieldStartIndex)
  41766. }
  41767. if m.addend_index != nil {
  41768. fields = append(fields, usagetotal.FieldEndIndex)
  41769. }
  41770. if m.addorganization_id != nil {
  41771. fields = append(fields, usagetotal.FieldOrganizationID)
  41772. }
  41773. return fields
  41774. }
  41775. // AddedField returns the numeric value that was incremented/decremented on a field
  41776. // with the given name. The second boolean return value indicates that this field
  41777. // was not set, or was not defined in the schema.
  41778. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  41779. switch name {
  41780. case usagetotal.FieldStatus:
  41781. return m.AddedStatus()
  41782. case usagetotal.FieldType:
  41783. return m.AddedType()
  41784. case usagetotal.FieldTotalTokens:
  41785. return m.AddedTotalTokens()
  41786. case usagetotal.FieldCredits:
  41787. return m.AddedCredits()
  41788. case usagetotal.FieldStartIndex:
  41789. return m.AddedStartIndex()
  41790. case usagetotal.FieldEndIndex:
  41791. return m.AddedEndIndex()
  41792. case usagetotal.FieldOrganizationID:
  41793. return m.AddedOrganizationID()
  41794. }
  41795. return nil, false
  41796. }
  41797. // AddField adds the value to the field with the given name. It returns an error if
  41798. // the field is not defined in the schema, or if the type mismatched the field
  41799. // type.
  41800. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  41801. switch name {
  41802. case usagetotal.FieldStatus:
  41803. v, ok := value.(int8)
  41804. if !ok {
  41805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41806. }
  41807. m.AddStatus(v)
  41808. return nil
  41809. case usagetotal.FieldType:
  41810. v, ok := value.(int)
  41811. if !ok {
  41812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41813. }
  41814. m.AddType(v)
  41815. return nil
  41816. case usagetotal.FieldTotalTokens:
  41817. v, ok := value.(int64)
  41818. if !ok {
  41819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41820. }
  41821. m.AddTotalTokens(v)
  41822. return nil
  41823. case usagetotal.FieldCredits:
  41824. v, ok := value.(float64)
  41825. if !ok {
  41826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41827. }
  41828. m.AddCredits(v)
  41829. return nil
  41830. case usagetotal.FieldStartIndex:
  41831. v, ok := value.(int64)
  41832. if !ok {
  41833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41834. }
  41835. m.AddStartIndex(v)
  41836. return nil
  41837. case usagetotal.FieldEndIndex:
  41838. v, ok := value.(int64)
  41839. if !ok {
  41840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41841. }
  41842. m.AddEndIndex(v)
  41843. return nil
  41844. case usagetotal.FieldOrganizationID:
  41845. v, ok := value.(int64)
  41846. if !ok {
  41847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41848. }
  41849. m.AddOrganizationID(v)
  41850. return nil
  41851. }
  41852. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  41853. }
  41854. // ClearedFields returns all nullable fields that were cleared during this
  41855. // mutation.
  41856. func (m *UsageTotalMutation) ClearedFields() []string {
  41857. var fields []string
  41858. if m.FieldCleared(usagetotal.FieldStatus) {
  41859. fields = append(fields, usagetotal.FieldStatus)
  41860. }
  41861. if m.FieldCleared(usagetotal.FieldType) {
  41862. fields = append(fields, usagetotal.FieldType)
  41863. }
  41864. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  41865. fields = append(fields, usagetotal.FieldTotalTokens)
  41866. }
  41867. if m.FieldCleared(usagetotal.FieldCredits) {
  41868. fields = append(fields, usagetotal.FieldCredits)
  41869. }
  41870. if m.FieldCleared(usagetotal.FieldStartIndex) {
  41871. fields = append(fields, usagetotal.FieldStartIndex)
  41872. }
  41873. if m.FieldCleared(usagetotal.FieldEndIndex) {
  41874. fields = append(fields, usagetotal.FieldEndIndex)
  41875. }
  41876. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  41877. fields = append(fields, usagetotal.FieldOrganizationID)
  41878. }
  41879. return fields
  41880. }
  41881. // FieldCleared returns a boolean indicating if a field with the given name was
  41882. // cleared in this mutation.
  41883. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  41884. _, ok := m.clearedFields[name]
  41885. return ok
  41886. }
  41887. // ClearField clears the value of the field with the given name. It returns an
  41888. // error if the field is not defined in the schema.
  41889. func (m *UsageTotalMutation) ClearField(name string) error {
  41890. switch name {
  41891. case usagetotal.FieldStatus:
  41892. m.ClearStatus()
  41893. return nil
  41894. case usagetotal.FieldType:
  41895. m.ClearType()
  41896. return nil
  41897. case usagetotal.FieldTotalTokens:
  41898. m.ClearTotalTokens()
  41899. return nil
  41900. case usagetotal.FieldCredits:
  41901. m.ClearCredits()
  41902. return nil
  41903. case usagetotal.FieldStartIndex:
  41904. m.ClearStartIndex()
  41905. return nil
  41906. case usagetotal.FieldEndIndex:
  41907. m.ClearEndIndex()
  41908. return nil
  41909. case usagetotal.FieldOrganizationID:
  41910. m.ClearOrganizationID()
  41911. return nil
  41912. }
  41913. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  41914. }
  41915. // ResetField resets all changes in the mutation for the field with the given name.
  41916. // It returns an error if the field is not defined in the schema.
  41917. func (m *UsageTotalMutation) ResetField(name string) error {
  41918. switch name {
  41919. case usagetotal.FieldCreatedAt:
  41920. m.ResetCreatedAt()
  41921. return nil
  41922. case usagetotal.FieldUpdatedAt:
  41923. m.ResetUpdatedAt()
  41924. return nil
  41925. case usagetotal.FieldStatus:
  41926. m.ResetStatus()
  41927. return nil
  41928. case usagetotal.FieldType:
  41929. m.ResetType()
  41930. return nil
  41931. case usagetotal.FieldBotID:
  41932. m.ResetBotID()
  41933. return nil
  41934. case usagetotal.FieldTotalTokens:
  41935. m.ResetTotalTokens()
  41936. return nil
  41937. case usagetotal.FieldCredits:
  41938. m.ResetCredits()
  41939. return nil
  41940. case usagetotal.FieldStartIndex:
  41941. m.ResetStartIndex()
  41942. return nil
  41943. case usagetotal.FieldEndIndex:
  41944. m.ResetEndIndex()
  41945. return nil
  41946. case usagetotal.FieldOrganizationID:
  41947. m.ResetOrganizationID()
  41948. return nil
  41949. }
  41950. return fmt.Errorf("unknown UsageTotal field %s", name)
  41951. }
  41952. // AddedEdges returns all edge names that were set/added in this mutation.
  41953. func (m *UsageTotalMutation) AddedEdges() []string {
  41954. edges := make([]string, 0, 0)
  41955. return edges
  41956. }
  41957. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41958. // name in this mutation.
  41959. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  41960. return nil
  41961. }
  41962. // RemovedEdges returns all edge names that were removed in this mutation.
  41963. func (m *UsageTotalMutation) RemovedEdges() []string {
  41964. edges := make([]string, 0, 0)
  41965. return edges
  41966. }
  41967. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41968. // the given name in this mutation.
  41969. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  41970. return nil
  41971. }
  41972. // ClearedEdges returns all edge names that were cleared in this mutation.
  41973. func (m *UsageTotalMutation) ClearedEdges() []string {
  41974. edges := make([]string, 0, 0)
  41975. return edges
  41976. }
  41977. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41978. // was cleared in this mutation.
  41979. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  41980. return false
  41981. }
  41982. // ClearEdge clears the value of the edge with the given name. It returns an error
  41983. // if that edge is not defined in the schema.
  41984. func (m *UsageTotalMutation) ClearEdge(name string) error {
  41985. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  41986. }
  41987. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41988. // It returns an error if the edge is not defined in the schema.
  41989. func (m *UsageTotalMutation) ResetEdge(name string) error {
  41990. return fmt.Errorf("unknown UsageTotal edge %s", name)
  41991. }
  41992. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  41993. type WhatsappMutation struct {
  41994. config
  41995. op Op
  41996. typ string
  41997. id *uint64
  41998. created_at *time.Time
  41999. updated_at *time.Time
  42000. status *uint8
  42001. addstatus *int8
  42002. deleted_at *time.Time
  42003. wa_id *string
  42004. wa_name *string
  42005. callback *string
  42006. account *string
  42007. cc *string
  42008. phone *string
  42009. cc_phone *string
  42010. phone_name *string
  42011. phone_status *int8
  42012. addphone_status *int8
  42013. organization_id *uint64
  42014. addorganization_id *int64
  42015. api_base *string
  42016. api_key *string
  42017. allow_list *[]string
  42018. appendallow_list []string
  42019. group_allow_list *[]string
  42020. appendgroup_allow_list []string
  42021. block_list *[]string
  42022. appendblock_list []string
  42023. group_block_list *[]string
  42024. appendgroup_block_list []string
  42025. clearedFields map[string]struct{}
  42026. agent *uint64
  42027. clearedagent bool
  42028. done bool
  42029. oldValue func(context.Context) (*Whatsapp, error)
  42030. predicates []predicate.Whatsapp
  42031. }
  42032. var _ ent.Mutation = (*WhatsappMutation)(nil)
  42033. // whatsappOption allows management of the mutation configuration using functional options.
  42034. type whatsappOption func(*WhatsappMutation)
  42035. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  42036. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  42037. m := &WhatsappMutation{
  42038. config: c,
  42039. op: op,
  42040. typ: TypeWhatsapp,
  42041. clearedFields: make(map[string]struct{}),
  42042. }
  42043. for _, opt := range opts {
  42044. opt(m)
  42045. }
  42046. return m
  42047. }
  42048. // withWhatsappID sets the ID field of the mutation.
  42049. func withWhatsappID(id uint64) whatsappOption {
  42050. return func(m *WhatsappMutation) {
  42051. var (
  42052. err error
  42053. once sync.Once
  42054. value *Whatsapp
  42055. )
  42056. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  42057. once.Do(func() {
  42058. if m.done {
  42059. err = errors.New("querying old values post mutation is not allowed")
  42060. } else {
  42061. value, err = m.Client().Whatsapp.Get(ctx, id)
  42062. }
  42063. })
  42064. return value, err
  42065. }
  42066. m.id = &id
  42067. }
  42068. }
  42069. // withWhatsapp sets the old Whatsapp of the mutation.
  42070. func withWhatsapp(node *Whatsapp) whatsappOption {
  42071. return func(m *WhatsappMutation) {
  42072. m.oldValue = func(context.Context) (*Whatsapp, error) {
  42073. return node, nil
  42074. }
  42075. m.id = &node.ID
  42076. }
  42077. }
  42078. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42079. // executed in a transaction (ent.Tx), a transactional client is returned.
  42080. func (m WhatsappMutation) Client() *Client {
  42081. client := &Client{config: m.config}
  42082. client.init()
  42083. return client
  42084. }
  42085. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42086. // it returns an error otherwise.
  42087. func (m WhatsappMutation) Tx() (*Tx, error) {
  42088. if _, ok := m.driver.(*txDriver); !ok {
  42089. return nil, errors.New("ent: mutation is not running in a transaction")
  42090. }
  42091. tx := &Tx{config: m.config}
  42092. tx.init()
  42093. return tx, nil
  42094. }
  42095. // SetID sets the value of the id field. Note that this
  42096. // operation is only accepted on creation of Whatsapp entities.
  42097. func (m *WhatsappMutation) SetID(id uint64) {
  42098. m.id = &id
  42099. }
  42100. // ID returns the ID value in the mutation. Note that the ID is only available
  42101. // if it was provided to the builder or after it was returned from the database.
  42102. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  42103. if m.id == nil {
  42104. return
  42105. }
  42106. return *m.id, true
  42107. }
  42108. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42109. // That means, if the mutation is applied within a transaction with an isolation level such
  42110. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42111. // or updated by the mutation.
  42112. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  42113. switch {
  42114. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42115. id, exists := m.ID()
  42116. if exists {
  42117. return []uint64{id}, nil
  42118. }
  42119. fallthrough
  42120. case m.op.Is(OpUpdate | OpDelete):
  42121. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  42122. default:
  42123. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42124. }
  42125. }
  42126. // SetCreatedAt sets the "created_at" field.
  42127. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  42128. m.created_at = &t
  42129. }
  42130. // CreatedAt returns the value of the "created_at" field in the mutation.
  42131. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  42132. v := m.created_at
  42133. if v == nil {
  42134. return
  42135. }
  42136. return *v, true
  42137. }
  42138. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  42139. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42141. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42142. if !m.op.Is(OpUpdateOne) {
  42143. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42144. }
  42145. if m.id == nil || m.oldValue == nil {
  42146. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42147. }
  42148. oldValue, err := m.oldValue(ctx)
  42149. if err != nil {
  42150. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42151. }
  42152. return oldValue.CreatedAt, nil
  42153. }
  42154. // ResetCreatedAt resets all changes to the "created_at" field.
  42155. func (m *WhatsappMutation) ResetCreatedAt() {
  42156. m.created_at = nil
  42157. }
  42158. // SetUpdatedAt sets the "updated_at" field.
  42159. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  42160. m.updated_at = &t
  42161. }
  42162. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42163. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  42164. v := m.updated_at
  42165. if v == nil {
  42166. return
  42167. }
  42168. return *v, true
  42169. }
  42170. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  42171. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42173. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42174. if !m.op.Is(OpUpdateOne) {
  42175. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42176. }
  42177. if m.id == nil || m.oldValue == nil {
  42178. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42179. }
  42180. oldValue, err := m.oldValue(ctx)
  42181. if err != nil {
  42182. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42183. }
  42184. return oldValue.UpdatedAt, nil
  42185. }
  42186. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42187. func (m *WhatsappMutation) ResetUpdatedAt() {
  42188. m.updated_at = nil
  42189. }
  42190. // SetStatus sets the "status" field.
  42191. func (m *WhatsappMutation) SetStatus(u uint8) {
  42192. m.status = &u
  42193. m.addstatus = nil
  42194. }
  42195. // Status returns the value of the "status" field in the mutation.
  42196. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  42197. v := m.status
  42198. if v == nil {
  42199. return
  42200. }
  42201. return *v, true
  42202. }
  42203. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  42204. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42206. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42207. if !m.op.Is(OpUpdateOne) {
  42208. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42209. }
  42210. if m.id == nil || m.oldValue == nil {
  42211. return v, errors.New("OldStatus requires an ID field in the mutation")
  42212. }
  42213. oldValue, err := m.oldValue(ctx)
  42214. if err != nil {
  42215. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42216. }
  42217. return oldValue.Status, nil
  42218. }
  42219. // AddStatus adds u to the "status" field.
  42220. func (m *WhatsappMutation) AddStatus(u int8) {
  42221. if m.addstatus != nil {
  42222. *m.addstatus += u
  42223. } else {
  42224. m.addstatus = &u
  42225. }
  42226. }
  42227. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42228. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  42229. v := m.addstatus
  42230. if v == nil {
  42231. return
  42232. }
  42233. return *v, true
  42234. }
  42235. // ClearStatus clears the value of the "status" field.
  42236. func (m *WhatsappMutation) ClearStatus() {
  42237. m.status = nil
  42238. m.addstatus = nil
  42239. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  42240. }
  42241. // StatusCleared returns if the "status" field was cleared in this mutation.
  42242. func (m *WhatsappMutation) StatusCleared() bool {
  42243. _, ok := m.clearedFields[whatsapp.FieldStatus]
  42244. return ok
  42245. }
  42246. // ResetStatus resets all changes to the "status" field.
  42247. func (m *WhatsappMutation) ResetStatus() {
  42248. m.status = nil
  42249. m.addstatus = nil
  42250. delete(m.clearedFields, whatsapp.FieldStatus)
  42251. }
  42252. // SetDeletedAt sets the "deleted_at" field.
  42253. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  42254. m.deleted_at = &t
  42255. }
  42256. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42257. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  42258. v := m.deleted_at
  42259. if v == nil {
  42260. return
  42261. }
  42262. return *v, true
  42263. }
  42264. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  42265. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42267. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42268. if !m.op.Is(OpUpdateOne) {
  42269. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42270. }
  42271. if m.id == nil || m.oldValue == nil {
  42272. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42273. }
  42274. oldValue, err := m.oldValue(ctx)
  42275. if err != nil {
  42276. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42277. }
  42278. return oldValue.DeletedAt, nil
  42279. }
  42280. // ClearDeletedAt clears the value of the "deleted_at" field.
  42281. func (m *WhatsappMutation) ClearDeletedAt() {
  42282. m.deleted_at = nil
  42283. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  42284. }
  42285. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42286. func (m *WhatsappMutation) DeletedAtCleared() bool {
  42287. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  42288. return ok
  42289. }
  42290. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42291. func (m *WhatsappMutation) ResetDeletedAt() {
  42292. m.deleted_at = nil
  42293. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  42294. }
  42295. // SetWaID sets the "wa_id" field.
  42296. func (m *WhatsappMutation) SetWaID(s string) {
  42297. m.wa_id = &s
  42298. }
  42299. // WaID returns the value of the "wa_id" field in the mutation.
  42300. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  42301. v := m.wa_id
  42302. if v == nil {
  42303. return
  42304. }
  42305. return *v, true
  42306. }
  42307. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  42308. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42310. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  42311. if !m.op.Is(OpUpdateOne) {
  42312. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  42313. }
  42314. if m.id == nil || m.oldValue == nil {
  42315. return v, errors.New("OldWaID requires an ID field in the mutation")
  42316. }
  42317. oldValue, err := m.oldValue(ctx)
  42318. if err != nil {
  42319. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42320. }
  42321. return oldValue.WaID, nil
  42322. }
  42323. // ClearWaID clears the value of the "wa_id" field.
  42324. func (m *WhatsappMutation) ClearWaID() {
  42325. m.wa_id = nil
  42326. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  42327. }
  42328. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42329. func (m *WhatsappMutation) WaIDCleared() bool {
  42330. _, ok := m.clearedFields[whatsapp.FieldWaID]
  42331. return ok
  42332. }
  42333. // ResetWaID resets all changes to the "wa_id" field.
  42334. func (m *WhatsappMutation) ResetWaID() {
  42335. m.wa_id = nil
  42336. delete(m.clearedFields, whatsapp.FieldWaID)
  42337. }
  42338. // SetWaName sets the "wa_name" field.
  42339. func (m *WhatsappMutation) SetWaName(s string) {
  42340. m.wa_name = &s
  42341. }
  42342. // WaName returns the value of the "wa_name" field in the mutation.
  42343. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  42344. v := m.wa_name
  42345. if v == nil {
  42346. return
  42347. }
  42348. return *v, true
  42349. }
  42350. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  42351. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42353. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  42354. if !m.op.Is(OpUpdateOne) {
  42355. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42356. }
  42357. if m.id == nil || m.oldValue == nil {
  42358. return v, errors.New("OldWaName requires an ID field in the mutation")
  42359. }
  42360. oldValue, err := m.oldValue(ctx)
  42361. if err != nil {
  42362. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42363. }
  42364. return oldValue.WaName, nil
  42365. }
  42366. // ClearWaName clears the value of the "wa_name" field.
  42367. func (m *WhatsappMutation) ClearWaName() {
  42368. m.wa_name = nil
  42369. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  42370. }
  42371. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42372. func (m *WhatsappMutation) WaNameCleared() bool {
  42373. _, ok := m.clearedFields[whatsapp.FieldWaName]
  42374. return ok
  42375. }
  42376. // ResetWaName resets all changes to the "wa_name" field.
  42377. func (m *WhatsappMutation) ResetWaName() {
  42378. m.wa_name = nil
  42379. delete(m.clearedFields, whatsapp.FieldWaName)
  42380. }
  42381. // SetCallback sets the "callback" field.
  42382. func (m *WhatsappMutation) SetCallback(s string) {
  42383. m.callback = &s
  42384. }
  42385. // Callback returns the value of the "callback" field in the mutation.
  42386. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  42387. v := m.callback
  42388. if v == nil {
  42389. return
  42390. }
  42391. return *v, true
  42392. }
  42393. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  42394. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42396. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  42397. if !m.op.Is(OpUpdateOne) {
  42398. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42399. }
  42400. if m.id == nil || m.oldValue == nil {
  42401. return v, errors.New("OldCallback requires an ID field in the mutation")
  42402. }
  42403. oldValue, err := m.oldValue(ctx)
  42404. if err != nil {
  42405. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42406. }
  42407. return oldValue.Callback, nil
  42408. }
  42409. // ClearCallback clears the value of the "callback" field.
  42410. func (m *WhatsappMutation) ClearCallback() {
  42411. m.callback = nil
  42412. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  42413. }
  42414. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  42415. func (m *WhatsappMutation) CallbackCleared() bool {
  42416. _, ok := m.clearedFields[whatsapp.FieldCallback]
  42417. return ok
  42418. }
  42419. // ResetCallback resets all changes to the "callback" field.
  42420. func (m *WhatsappMutation) ResetCallback() {
  42421. m.callback = nil
  42422. delete(m.clearedFields, whatsapp.FieldCallback)
  42423. }
  42424. // SetAgentID sets the "agent_id" field.
  42425. func (m *WhatsappMutation) SetAgentID(u uint64) {
  42426. m.agent = &u
  42427. }
  42428. // AgentID returns the value of the "agent_id" field in the mutation.
  42429. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  42430. v := m.agent
  42431. if v == nil {
  42432. return
  42433. }
  42434. return *v, true
  42435. }
  42436. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  42437. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42439. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42440. if !m.op.Is(OpUpdateOne) {
  42441. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42442. }
  42443. if m.id == nil || m.oldValue == nil {
  42444. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42445. }
  42446. oldValue, err := m.oldValue(ctx)
  42447. if err != nil {
  42448. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42449. }
  42450. return oldValue.AgentID, nil
  42451. }
  42452. // ResetAgentID resets all changes to the "agent_id" field.
  42453. func (m *WhatsappMutation) ResetAgentID() {
  42454. m.agent = nil
  42455. }
  42456. // SetAccount sets the "account" field.
  42457. func (m *WhatsappMutation) SetAccount(s string) {
  42458. m.account = &s
  42459. }
  42460. // Account returns the value of the "account" field in the mutation.
  42461. func (m *WhatsappMutation) Account() (r string, exists bool) {
  42462. v := m.account
  42463. if v == nil {
  42464. return
  42465. }
  42466. return *v, true
  42467. }
  42468. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  42469. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42471. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  42472. if !m.op.Is(OpUpdateOne) {
  42473. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42474. }
  42475. if m.id == nil || m.oldValue == nil {
  42476. return v, errors.New("OldAccount requires an ID field in the mutation")
  42477. }
  42478. oldValue, err := m.oldValue(ctx)
  42479. if err != nil {
  42480. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42481. }
  42482. return oldValue.Account, nil
  42483. }
  42484. // ClearAccount clears the value of the "account" field.
  42485. func (m *WhatsappMutation) ClearAccount() {
  42486. m.account = nil
  42487. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  42488. }
  42489. // AccountCleared returns if the "account" field was cleared in this mutation.
  42490. func (m *WhatsappMutation) AccountCleared() bool {
  42491. _, ok := m.clearedFields[whatsapp.FieldAccount]
  42492. return ok
  42493. }
  42494. // ResetAccount resets all changes to the "account" field.
  42495. func (m *WhatsappMutation) ResetAccount() {
  42496. m.account = nil
  42497. delete(m.clearedFields, whatsapp.FieldAccount)
  42498. }
  42499. // SetCc sets the "cc" field.
  42500. func (m *WhatsappMutation) SetCc(s string) {
  42501. m.cc = &s
  42502. }
  42503. // Cc returns the value of the "cc" field in the mutation.
  42504. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  42505. v := m.cc
  42506. if v == nil {
  42507. return
  42508. }
  42509. return *v, true
  42510. }
  42511. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  42512. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42514. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  42515. if !m.op.Is(OpUpdateOne) {
  42516. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  42517. }
  42518. if m.id == nil || m.oldValue == nil {
  42519. return v, errors.New("OldCc requires an ID field in the mutation")
  42520. }
  42521. oldValue, err := m.oldValue(ctx)
  42522. if err != nil {
  42523. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  42524. }
  42525. return oldValue.Cc, nil
  42526. }
  42527. // ResetCc resets all changes to the "cc" field.
  42528. func (m *WhatsappMutation) ResetCc() {
  42529. m.cc = nil
  42530. }
  42531. // SetPhone sets the "phone" field.
  42532. func (m *WhatsappMutation) SetPhone(s string) {
  42533. m.phone = &s
  42534. }
  42535. // Phone returns the value of the "phone" field in the mutation.
  42536. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  42537. v := m.phone
  42538. if v == nil {
  42539. return
  42540. }
  42541. return *v, true
  42542. }
  42543. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  42544. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42546. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  42547. if !m.op.Is(OpUpdateOne) {
  42548. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42549. }
  42550. if m.id == nil || m.oldValue == nil {
  42551. return v, errors.New("OldPhone requires an ID field in the mutation")
  42552. }
  42553. oldValue, err := m.oldValue(ctx)
  42554. if err != nil {
  42555. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42556. }
  42557. return oldValue.Phone, nil
  42558. }
  42559. // ResetPhone resets all changes to the "phone" field.
  42560. func (m *WhatsappMutation) ResetPhone() {
  42561. m.phone = nil
  42562. }
  42563. // SetCcPhone sets the "cc_phone" field.
  42564. func (m *WhatsappMutation) SetCcPhone(s string) {
  42565. m.cc_phone = &s
  42566. }
  42567. // CcPhone returns the value of the "cc_phone" field in the mutation.
  42568. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  42569. v := m.cc_phone
  42570. if v == nil {
  42571. return
  42572. }
  42573. return *v, true
  42574. }
  42575. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  42576. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42578. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  42579. if !m.op.Is(OpUpdateOne) {
  42580. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  42581. }
  42582. if m.id == nil || m.oldValue == nil {
  42583. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  42584. }
  42585. oldValue, err := m.oldValue(ctx)
  42586. if err != nil {
  42587. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  42588. }
  42589. return oldValue.CcPhone, nil
  42590. }
  42591. // ResetCcPhone resets all changes to the "cc_phone" field.
  42592. func (m *WhatsappMutation) ResetCcPhone() {
  42593. m.cc_phone = nil
  42594. }
  42595. // SetPhoneName sets the "phone_name" field.
  42596. func (m *WhatsappMutation) SetPhoneName(s string) {
  42597. m.phone_name = &s
  42598. }
  42599. // PhoneName returns the value of the "phone_name" field in the mutation.
  42600. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  42601. v := m.phone_name
  42602. if v == nil {
  42603. return
  42604. }
  42605. return *v, true
  42606. }
  42607. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  42608. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42610. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  42611. if !m.op.Is(OpUpdateOne) {
  42612. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  42613. }
  42614. if m.id == nil || m.oldValue == nil {
  42615. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  42616. }
  42617. oldValue, err := m.oldValue(ctx)
  42618. if err != nil {
  42619. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  42620. }
  42621. return oldValue.PhoneName, nil
  42622. }
  42623. // ResetPhoneName resets all changes to the "phone_name" field.
  42624. func (m *WhatsappMutation) ResetPhoneName() {
  42625. m.phone_name = nil
  42626. }
  42627. // SetPhoneStatus sets the "phone_status" field.
  42628. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  42629. m.phone_status = &i
  42630. m.addphone_status = nil
  42631. }
  42632. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  42633. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  42634. v := m.phone_status
  42635. if v == nil {
  42636. return
  42637. }
  42638. return *v, true
  42639. }
  42640. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  42641. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42643. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  42644. if !m.op.Is(OpUpdateOne) {
  42645. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  42646. }
  42647. if m.id == nil || m.oldValue == nil {
  42648. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  42649. }
  42650. oldValue, err := m.oldValue(ctx)
  42651. if err != nil {
  42652. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  42653. }
  42654. return oldValue.PhoneStatus, nil
  42655. }
  42656. // AddPhoneStatus adds i to the "phone_status" field.
  42657. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  42658. if m.addphone_status != nil {
  42659. *m.addphone_status += i
  42660. } else {
  42661. m.addphone_status = &i
  42662. }
  42663. }
  42664. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  42665. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  42666. v := m.addphone_status
  42667. if v == nil {
  42668. return
  42669. }
  42670. return *v, true
  42671. }
  42672. // ResetPhoneStatus resets all changes to the "phone_status" field.
  42673. func (m *WhatsappMutation) ResetPhoneStatus() {
  42674. m.phone_status = nil
  42675. m.addphone_status = nil
  42676. }
  42677. // SetOrganizationID sets the "organization_id" field.
  42678. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  42679. m.organization_id = &u
  42680. m.addorganization_id = nil
  42681. }
  42682. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42683. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  42684. v := m.organization_id
  42685. if v == nil {
  42686. return
  42687. }
  42688. return *v, true
  42689. }
  42690. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  42691. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42693. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42694. if !m.op.Is(OpUpdateOne) {
  42695. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42696. }
  42697. if m.id == nil || m.oldValue == nil {
  42698. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42699. }
  42700. oldValue, err := m.oldValue(ctx)
  42701. if err != nil {
  42702. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42703. }
  42704. return oldValue.OrganizationID, nil
  42705. }
  42706. // AddOrganizationID adds u to the "organization_id" field.
  42707. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  42708. if m.addorganization_id != nil {
  42709. *m.addorganization_id += u
  42710. } else {
  42711. m.addorganization_id = &u
  42712. }
  42713. }
  42714. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42715. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  42716. v := m.addorganization_id
  42717. if v == nil {
  42718. return
  42719. }
  42720. return *v, true
  42721. }
  42722. // ClearOrganizationID clears the value of the "organization_id" field.
  42723. func (m *WhatsappMutation) ClearOrganizationID() {
  42724. m.organization_id = nil
  42725. m.addorganization_id = nil
  42726. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  42727. }
  42728. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42729. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  42730. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  42731. return ok
  42732. }
  42733. // ResetOrganizationID resets all changes to the "organization_id" field.
  42734. func (m *WhatsappMutation) ResetOrganizationID() {
  42735. m.organization_id = nil
  42736. m.addorganization_id = nil
  42737. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  42738. }
  42739. // SetAPIBase sets the "api_base" field.
  42740. func (m *WhatsappMutation) SetAPIBase(s string) {
  42741. m.api_base = &s
  42742. }
  42743. // APIBase returns the value of the "api_base" field in the mutation.
  42744. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  42745. v := m.api_base
  42746. if v == nil {
  42747. return
  42748. }
  42749. return *v, true
  42750. }
  42751. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  42752. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42754. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42755. if !m.op.Is(OpUpdateOne) {
  42756. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42757. }
  42758. if m.id == nil || m.oldValue == nil {
  42759. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42760. }
  42761. oldValue, err := m.oldValue(ctx)
  42762. if err != nil {
  42763. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42764. }
  42765. return oldValue.APIBase, nil
  42766. }
  42767. // ClearAPIBase clears the value of the "api_base" field.
  42768. func (m *WhatsappMutation) ClearAPIBase() {
  42769. m.api_base = nil
  42770. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  42771. }
  42772. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42773. func (m *WhatsappMutation) APIBaseCleared() bool {
  42774. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  42775. return ok
  42776. }
  42777. // ResetAPIBase resets all changes to the "api_base" field.
  42778. func (m *WhatsappMutation) ResetAPIBase() {
  42779. m.api_base = nil
  42780. delete(m.clearedFields, whatsapp.FieldAPIBase)
  42781. }
  42782. // SetAPIKey sets the "api_key" field.
  42783. func (m *WhatsappMutation) SetAPIKey(s string) {
  42784. m.api_key = &s
  42785. }
  42786. // APIKey returns the value of the "api_key" field in the mutation.
  42787. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  42788. v := m.api_key
  42789. if v == nil {
  42790. return
  42791. }
  42792. return *v, true
  42793. }
  42794. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  42795. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42797. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42798. if !m.op.Is(OpUpdateOne) {
  42799. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42800. }
  42801. if m.id == nil || m.oldValue == nil {
  42802. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42803. }
  42804. oldValue, err := m.oldValue(ctx)
  42805. if err != nil {
  42806. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42807. }
  42808. return oldValue.APIKey, nil
  42809. }
  42810. // ClearAPIKey clears the value of the "api_key" field.
  42811. func (m *WhatsappMutation) ClearAPIKey() {
  42812. m.api_key = nil
  42813. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  42814. }
  42815. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42816. func (m *WhatsappMutation) APIKeyCleared() bool {
  42817. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  42818. return ok
  42819. }
  42820. // ResetAPIKey resets all changes to the "api_key" field.
  42821. func (m *WhatsappMutation) ResetAPIKey() {
  42822. m.api_key = nil
  42823. delete(m.clearedFields, whatsapp.FieldAPIKey)
  42824. }
  42825. // SetAllowList sets the "allow_list" field.
  42826. func (m *WhatsappMutation) SetAllowList(s []string) {
  42827. m.allow_list = &s
  42828. m.appendallow_list = nil
  42829. }
  42830. // AllowList returns the value of the "allow_list" field in the mutation.
  42831. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  42832. v := m.allow_list
  42833. if v == nil {
  42834. return
  42835. }
  42836. return *v, true
  42837. }
  42838. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  42839. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42841. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42842. if !m.op.Is(OpUpdateOne) {
  42843. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42844. }
  42845. if m.id == nil || m.oldValue == nil {
  42846. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42847. }
  42848. oldValue, err := m.oldValue(ctx)
  42849. if err != nil {
  42850. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42851. }
  42852. return oldValue.AllowList, nil
  42853. }
  42854. // AppendAllowList adds s to the "allow_list" field.
  42855. func (m *WhatsappMutation) AppendAllowList(s []string) {
  42856. m.appendallow_list = append(m.appendallow_list, s...)
  42857. }
  42858. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42859. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  42860. if len(m.appendallow_list) == 0 {
  42861. return nil, false
  42862. }
  42863. return m.appendallow_list, true
  42864. }
  42865. // ClearAllowList clears the value of the "allow_list" field.
  42866. func (m *WhatsappMutation) ClearAllowList() {
  42867. m.allow_list = nil
  42868. m.appendallow_list = nil
  42869. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  42870. }
  42871. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  42872. func (m *WhatsappMutation) AllowListCleared() bool {
  42873. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  42874. return ok
  42875. }
  42876. // ResetAllowList resets all changes to the "allow_list" field.
  42877. func (m *WhatsappMutation) ResetAllowList() {
  42878. m.allow_list = nil
  42879. m.appendallow_list = nil
  42880. delete(m.clearedFields, whatsapp.FieldAllowList)
  42881. }
  42882. // SetGroupAllowList sets the "group_allow_list" field.
  42883. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  42884. m.group_allow_list = &s
  42885. m.appendgroup_allow_list = nil
  42886. }
  42887. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42888. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  42889. v := m.group_allow_list
  42890. if v == nil {
  42891. return
  42892. }
  42893. return *v, true
  42894. }
  42895. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  42896. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42898. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42899. if !m.op.Is(OpUpdateOne) {
  42900. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42901. }
  42902. if m.id == nil || m.oldValue == nil {
  42903. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42904. }
  42905. oldValue, err := m.oldValue(ctx)
  42906. if err != nil {
  42907. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42908. }
  42909. return oldValue.GroupAllowList, nil
  42910. }
  42911. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42912. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  42913. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42914. }
  42915. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42916. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  42917. if len(m.appendgroup_allow_list) == 0 {
  42918. return nil, false
  42919. }
  42920. return m.appendgroup_allow_list, true
  42921. }
  42922. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  42923. func (m *WhatsappMutation) ClearGroupAllowList() {
  42924. m.group_allow_list = nil
  42925. m.appendgroup_allow_list = nil
  42926. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  42927. }
  42928. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  42929. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  42930. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  42931. return ok
  42932. }
  42933. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42934. func (m *WhatsappMutation) ResetGroupAllowList() {
  42935. m.group_allow_list = nil
  42936. m.appendgroup_allow_list = nil
  42937. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  42938. }
  42939. // SetBlockList sets the "block_list" field.
  42940. func (m *WhatsappMutation) SetBlockList(s []string) {
  42941. m.block_list = &s
  42942. m.appendblock_list = nil
  42943. }
  42944. // BlockList returns the value of the "block_list" field in the mutation.
  42945. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  42946. v := m.block_list
  42947. if v == nil {
  42948. return
  42949. }
  42950. return *v, true
  42951. }
  42952. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  42953. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42955. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42956. if !m.op.Is(OpUpdateOne) {
  42957. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42958. }
  42959. if m.id == nil || m.oldValue == nil {
  42960. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42961. }
  42962. oldValue, err := m.oldValue(ctx)
  42963. if err != nil {
  42964. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42965. }
  42966. return oldValue.BlockList, nil
  42967. }
  42968. // AppendBlockList adds s to the "block_list" field.
  42969. func (m *WhatsappMutation) AppendBlockList(s []string) {
  42970. m.appendblock_list = append(m.appendblock_list, s...)
  42971. }
  42972. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42973. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  42974. if len(m.appendblock_list) == 0 {
  42975. return nil, false
  42976. }
  42977. return m.appendblock_list, true
  42978. }
  42979. // ClearBlockList clears the value of the "block_list" field.
  42980. func (m *WhatsappMutation) ClearBlockList() {
  42981. m.block_list = nil
  42982. m.appendblock_list = nil
  42983. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  42984. }
  42985. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  42986. func (m *WhatsappMutation) BlockListCleared() bool {
  42987. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  42988. return ok
  42989. }
  42990. // ResetBlockList resets all changes to the "block_list" field.
  42991. func (m *WhatsappMutation) ResetBlockList() {
  42992. m.block_list = nil
  42993. m.appendblock_list = nil
  42994. delete(m.clearedFields, whatsapp.FieldBlockList)
  42995. }
  42996. // SetGroupBlockList sets the "group_block_list" field.
  42997. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  42998. m.group_block_list = &s
  42999. m.appendgroup_block_list = nil
  43000. }
  43001. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  43002. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  43003. v := m.group_block_list
  43004. if v == nil {
  43005. return
  43006. }
  43007. return *v, true
  43008. }
  43009. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  43010. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  43011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43012. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  43013. if !m.op.Is(OpUpdateOne) {
  43014. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  43015. }
  43016. if m.id == nil || m.oldValue == nil {
  43017. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  43018. }
  43019. oldValue, err := m.oldValue(ctx)
  43020. if err != nil {
  43021. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  43022. }
  43023. return oldValue.GroupBlockList, nil
  43024. }
  43025. // AppendGroupBlockList adds s to the "group_block_list" field.
  43026. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  43027. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  43028. }
  43029. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  43030. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  43031. if len(m.appendgroup_block_list) == 0 {
  43032. return nil, false
  43033. }
  43034. return m.appendgroup_block_list, true
  43035. }
  43036. // ClearGroupBlockList clears the value of the "group_block_list" field.
  43037. func (m *WhatsappMutation) ClearGroupBlockList() {
  43038. m.group_block_list = nil
  43039. m.appendgroup_block_list = nil
  43040. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  43041. }
  43042. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  43043. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  43044. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  43045. return ok
  43046. }
  43047. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  43048. func (m *WhatsappMutation) ResetGroupBlockList() {
  43049. m.group_block_list = nil
  43050. m.appendgroup_block_list = nil
  43051. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  43052. }
  43053. // ClearAgent clears the "agent" edge to the Agent entity.
  43054. func (m *WhatsappMutation) ClearAgent() {
  43055. m.clearedagent = true
  43056. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  43057. }
  43058. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  43059. func (m *WhatsappMutation) AgentCleared() bool {
  43060. return m.clearedagent
  43061. }
  43062. // AgentIDs returns the "agent" edge IDs in the mutation.
  43063. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43064. // AgentID instead. It exists only for internal usage by the builders.
  43065. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  43066. if id := m.agent; id != nil {
  43067. ids = append(ids, *id)
  43068. }
  43069. return
  43070. }
  43071. // ResetAgent resets all changes to the "agent" edge.
  43072. func (m *WhatsappMutation) ResetAgent() {
  43073. m.agent = nil
  43074. m.clearedagent = false
  43075. }
  43076. // Where appends a list predicates to the WhatsappMutation builder.
  43077. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  43078. m.predicates = append(m.predicates, ps...)
  43079. }
  43080. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  43081. // users can use type-assertion to append predicates that do not depend on any generated package.
  43082. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  43083. p := make([]predicate.Whatsapp, len(ps))
  43084. for i := range ps {
  43085. p[i] = ps[i]
  43086. }
  43087. m.Where(p...)
  43088. }
  43089. // Op returns the operation name.
  43090. func (m *WhatsappMutation) Op() Op {
  43091. return m.op
  43092. }
  43093. // SetOp allows setting the mutation operation.
  43094. func (m *WhatsappMutation) SetOp(op Op) {
  43095. m.op = op
  43096. }
  43097. // Type returns the node type of this mutation (Whatsapp).
  43098. func (m *WhatsappMutation) Type() string {
  43099. return m.typ
  43100. }
  43101. // Fields returns all fields that were changed during this mutation. Note that in
  43102. // order to get all numeric fields that were incremented/decremented, call
  43103. // AddedFields().
  43104. func (m *WhatsappMutation) Fields() []string {
  43105. fields := make([]string, 0, 21)
  43106. if m.created_at != nil {
  43107. fields = append(fields, whatsapp.FieldCreatedAt)
  43108. }
  43109. if m.updated_at != nil {
  43110. fields = append(fields, whatsapp.FieldUpdatedAt)
  43111. }
  43112. if m.status != nil {
  43113. fields = append(fields, whatsapp.FieldStatus)
  43114. }
  43115. if m.deleted_at != nil {
  43116. fields = append(fields, whatsapp.FieldDeletedAt)
  43117. }
  43118. if m.wa_id != nil {
  43119. fields = append(fields, whatsapp.FieldWaID)
  43120. }
  43121. if m.wa_name != nil {
  43122. fields = append(fields, whatsapp.FieldWaName)
  43123. }
  43124. if m.callback != nil {
  43125. fields = append(fields, whatsapp.FieldCallback)
  43126. }
  43127. if m.agent != nil {
  43128. fields = append(fields, whatsapp.FieldAgentID)
  43129. }
  43130. if m.account != nil {
  43131. fields = append(fields, whatsapp.FieldAccount)
  43132. }
  43133. if m.cc != nil {
  43134. fields = append(fields, whatsapp.FieldCc)
  43135. }
  43136. if m.phone != nil {
  43137. fields = append(fields, whatsapp.FieldPhone)
  43138. }
  43139. if m.cc_phone != nil {
  43140. fields = append(fields, whatsapp.FieldCcPhone)
  43141. }
  43142. if m.phone_name != nil {
  43143. fields = append(fields, whatsapp.FieldPhoneName)
  43144. }
  43145. if m.phone_status != nil {
  43146. fields = append(fields, whatsapp.FieldPhoneStatus)
  43147. }
  43148. if m.organization_id != nil {
  43149. fields = append(fields, whatsapp.FieldOrganizationID)
  43150. }
  43151. if m.api_base != nil {
  43152. fields = append(fields, whatsapp.FieldAPIBase)
  43153. }
  43154. if m.api_key != nil {
  43155. fields = append(fields, whatsapp.FieldAPIKey)
  43156. }
  43157. if m.allow_list != nil {
  43158. fields = append(fields, whatsapp.FieldAllowList)
  43159. }
  43160. if m.group_allow_list != nil {
  43161. fields = append(fields, whatsapp.FieldGroupAllowList)
  43162. }
  43163. if m.block_list != nil {
  43164. fields = append(fields, whatsapp.FieldBlockList)
  43165. }
  43166. if m.group_block_list != nil {
  43167. fields = append(fields, whatsapp.FieldGroupBlockList)
  43168. }
  43169. return fields
  43170. }
  43171. // Field returns the value of a field with the given name. The second boolean
  43172. // return value indicates that this field was not set, or was not defined in the
  43173. // schema.
  43174. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  43175. switch name {
  43176. case whatsapp.FieldCreatedAt:
  43177. return m.CreatedAt()
  43178. case whatsapp.FieldUpdatedAt:
  43179. return m.UpdatedAt()
  43180. case whatsapp.FieldStatus:
  43181. return m.Status()
  43182. case whatsapp.FieldDeletedAt:
  43183. return m.DeletedAt()
  43184. case whatsapp.FieldWaID:
  43185. return m.WaID()
  43186. case whatsapp.FieldWaName:
  43187. return m.WaName()
  43188. case whatsapp.FieldCallback:
  43189. return m.Callback()
  43190. case whatsapp.FieldAgentID:
  43191. return m.AgentID()
  43192. case whatsapp.FieldAccount:
  43193. return m.Account()
  43194. case whatsapp.FieldCc:
  43195. return m.Cc()
  43196. case whatsapp.FieldPhone:
  43197. return m.Phone()
  43198. case whatsapp.FieldCcPhone:
  43199. return m.CcPhone()
  43200. case whatsapp.FieldPhoneName:
  43201. return m.PhoneName()
  43202. case whatsapp.FieldPhoneStatus:
  43203. return m.PhoneStatus()
  43204. case whatsapp.FieldOrganizationID:
  43205. return m.OrganizationID()
  43206. case whatsapp.FieldAPIBase:
  43207. return m.APIBase()
  43208. case whatsapp.FieldAPIKey:
  43209. return m.APIKey()
  43210. case whatsapp.FieldAllowList:
  43211. return m.AllowList()
  43212. case whatsapp.FieldGroupAllowList:
  43213. return m.GroupAllowList()
  43214. case whatsapp.FieldBlockList:
  43215. return m.BlockList()
  43216. case whatsapp.FieldGroupBlockList:
  43217. return m.GroupBlockList()
  43218. }
  43219. return nil, false
  43220. }
  43221. // OldField returns the old value of the field from the database. An error is
  43222. // returned if the mutation operation is not UpdateOne, or the query to the
  43223. // database failed.
  43224. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43225. switch name {
  43226. case whatsapp.FieldCreatedAt:
  43227. return m.OldCreatedAt(ctx)
  43228. case whatsapp.FieldUpdatedAt:
  43229. return m.OldUpdatedAt(ctx)
  43230. case whatsapp.FieldStatus:
  43231. return m.OldStatus(ctx)
  43232. case whatsapp.FieldDeletedAt:
  43233. return m.OldDeletedAt(ctx)
  43234. case whatsapp.FieldWaID:
  43235. return m.OldWaID(ctx)
  43236. case whatsapp.FieldWaName:
  43237. return m.OldWaName(ctx)
  43238. case whatsapp.FieldCallback:
  43239. return m.OldCallback(ctx)
  43240. case whatsapp.FieldAgentID:
  43241. return m.OldAgentID(ctx)
  43242. case whatsapp.FieldAccount:
  43243. return m.OldAccount(ctx)
  43244. case whatsapp.FieldCc:
  43245. return m.OldCc(ctx)
  43246. case whatsapp.FieldPhone:
  43247. return m.OldPhone(ctx)
  43248. case whatsapp.FieldCcPhone:
  43249. return m.OldCcPhone(ctx)
  43250. case whatsapp.FieldPhoneName:
  43251. return m.OldPhoneName(ctx)
  43252. case whatsapp.FieldPhoneStatus:
  43253. return m.OldPhoneStatus(ctx)
  43254. case whatsapp.FieldOrganizationID:
  43255. return m.OldOrganizationID(ctx)
  43256. case whatsapp.FieldAPIBase:
  43257. return m.OldAPIBase(ctx)
  43258. case whatsapp.FieldAPIKey:
  43259. return m.OldAPIKey(ctx)
  43260. case whatsapp.FieldAllowList:
  43261. return m.OldAllowList(ctx)
  43262. case whatsapp.FieldGroupAllowList:
  43263. return m.OldGroupAllowList(ctx)
  43264. case whatsapp.FieldBlockList:
  43265. return m.OldBlockList(ctx)
  43266. case whatsapp.FieldGroupBlockList:
  43267. return m.OldGroupBlockList(ctx)
  43268. }
  43269. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  43270. }
  43271. // SetField sets the value of a field with the given name. It returns an error if
  43272. // the field is not defined in the schema, or if the type mismatched the field
  43273. // type.
  43274. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  43275. switch name {
  43276. case whatsapp.FieldCreatedAt:
  43277. v, ok := value.(time.Time)
  43278. if !ok {
  43279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43280. }
  43281. m.SetCreatedAt(v)
  43282. return nil
  43283. case whatsapp.FieldUpdatedAt:
  43284. v, ok := value.(time.Time)
  43285. if !ok {
  43286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43287. }
  43288. m.SetUpdatedAt(v)
  43289. return nil
  43290. case whatsapp.FieldStatus:
  43291. v, ok := value.(uint8)
  43292. if !ok {
  43293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43294. }
  43295. m.SetStatus(v)
  43296. return nil
  43297. case whatsapp.FieldDeletedAt:
  43298. v, ok := value.(time.Time)
  43299. if !ok {
  43300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43301. }
  43302. m.SetDeletedAt(v)
  43303. return nil
  43304. case whatsapp.FieldWaID:
  43305. v, ok := value.(string)
  43306. if !ok {
  43307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43308. }
  43309. m.SetWaID(v)
  43310. return nil
  43311. case whatsapp.FieldWaName:
  43312. v, ok := value.(string)
  43313. if !ok {
  43314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43315. }
  43316. m.SetWaName(v)
  43317. return nil
  43318. case whatsapp.FieldCallback:
  43319. v, ok := value.(string)
  43320. if !ok {
  43321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43322. }
  43323. m.SetCallback(v)
  43324. return nil
  43325. case whatsapp.FieldAgentID:
  43326. v, ok := value.(uint64)
  43327. if !ok {
  43328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43329. }
  43330. m.SetAgentID(v)
  43331. return nil
  43332. case whatsapp.FieldAccount:
  43333. v, ok := value.(string)
  43334. if !ok {
  43335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43336. }
  43337. m.SetAccount(v)
  43338. return nil
  43339. case whatsapp.FieldCc:
  43340. v, ok := value.(string)
  43341. if !ok {
  43342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43343. }
  43344. m.SetCc(v)
  43345. return nil
  43346. case whatsapp.FieldPhone:
  43347. v, ok := value.(string)
  43348. if !ok {
  43349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43350. }
  43351. m.SetPhone(v)
  43352. return nil
  43353. case whatsapp.FieldCcPhone:
  43354. v, ok := value.(string)
  43355. if !ok {
  43356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43357. }
  43358. m.SetCcPhone(v)
  43359. return nil
  43360. case whatsapp.FieldPhoneName:
  43361. v, ok := value.(string)
  43362. if !ok {
  43363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43364. }
  43365. m.SetPhoneName(v)
  43366. return nil
  43367. case whatsapp.FieldPhoneStatus:
  43368. v, ok := value.(int8)
  43369. if !ok {
  43370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43371. }
  43372. m.SetPhoneStatus(v)
  43373. return nil
  43374. case whatsapp.FieldOrganizationID:
  43375. v, ok := value.(uint64)
  43376. if !ok {
  43377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43378. }
  43379. m.SetOrganizationID(v)
  43380. return nil
  43381. case whatsapp.FieldAPIBase:
  43382. v, ok := value.(string)
  43383. if !ok {
  43384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43385. }
  43386. m.SetAPIBase(v)
  43387. return nil
  43388. case whatsapp.FieldAPIKey:
  43389. v, ok := value.(string)
  43390. if !ok {
  43391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43392. }
  43393. m.SetAPIKey(v)
  43394. return nil
  43395. case whatsapp.FieldAllowList:
  43396. v, ok := value.([]string)
  43397. if !ok {
  43398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43399. }
  43400. m.SetAllowList(v)
  43401. return nil
  43402. case whatsapp.FieldGroupAllowList:
  43403. v, ok := value.([]string)
  43404. if !ok {
  43405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43406. }
  43407. m.SetGroupAllowList(v)
  43408. return nil
  43409. case whatsapp.FieldBlockList:
  43410. v, ok := value.([]string)
  43411. if !ok {
  43412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43413. }
  43414. m.SetBlockList(v)
  43415. return nil
  43416. case whatsapp.FieldGroupBlockList:
  43417. v, ok := value.([]string)
  43418. if !ok {
  43419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43420. }
  43421. m.SetGroupBlockList(v)
  43422. return nil
  43423. }
  43424. return fmt.Errorf("unknown Whatsapp field %s", name)
  43425. }
  43426. // AddedFields returns all numeric fields that were incremented/decremented during
  43427. // this mutation.
  43428. func (m *WhatsappMutation) AddedFields() []string {
  43429. var fields []string
  43430. if m.addstatus != nil {
  43431. fields = append(fields, whatsapp.FieldStatus)
  43432. }
  43433. if m.addphone_status != nil {
  43434. fields = append(fields, whatsapp.FieldPhoneStatus)
  43435. }
  43436. if m.addorganization_id != nil {
  43437. fields = append(fields, whatsapp.FieldOrganizationID)
  43438. }
  43439. return fields
  43440. }
  43441. // AddedField returns the numeric value that was incremented/decremented on a field
  43442. // with the given name. The second boolean return value indicates that this field
  43443. // was not set, or was not defined in the schema.
  43444. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  43445. switch name {
  43446. case whatsapp.FieldStatus:
  43447. return m.AddedStatus()
  43448. case whatsapp.FieldPhoneStatus:
  43449. return m.AddedPhoneStatus()
  43450. case whatsapp.FieldOrganizationID:
  43451. return m.AddedOrganizationID()
  43452. }
  43453. return nil, false
  43454. }
  43455. // AddField adds the value to the field with the given name. It returns an error if
  43456. // the field is not defined in the schema, or if the type mismatched the field
  43457. // type.
  43458. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  43459. switch name {
  43460. case whatsapp.FieldStatus:
  43461. v, ok := value.(int8)
  43462. if !ok {
  43463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43464. }
  43465. m.AddStatus(v)
  43466. return nil
  43467. case whatsapp.FieldPhoneStatus:
  43468. v, ok := value.(int8)
  43469. if !ok {
  43470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43471. }
  43472. m.AddPhoneStatus(v)
  43473. return nil
  43474. case whatsapp.FieldOrganizationID:
  43475. v, ok := value.(int64)
  43476. if !ok {
  43477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43478. }
  43479. m.AddOrganizationID(v)
  43480. return nil
  43481. }
  43482. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  43483. }
  43484. // ClearedFields returns all nullable fields that were cleared during this
  43485. // mutation.
  43486. func (m *WhatsappMutation) ClearedFields() []string {
  43487. var fields []string
  43488. if m.FieldCleared(whatsapp.FieldStatus) {
  43489. fields = append(fields, whatsapp.FieldStatus)
  43490. }
  43491. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  43492. fields = append(fields, whatsapp.FieldDeletedAt)
  43493. }
  43494. if m.FieldCleared(whatsapp.FieldWaID) {
  43495. fields = append(fields, whatsapp.FieldWaID)
  43496. }
  43497. if m.FieldCleared(whatsapp.FieldWaName) {
  43498. fields = append(fields, whatsapp.FieldWaName)
  43499. }
  43500. if m.FieldCleared(whatsapp.FieldCallback) {
  43501. fields = append(fields, whatsapp.FieldCallback)
  43502. }
  43503. if m.FieldCleared(whatsapp.FieldAccount) {
  43504. fields = append(fields, whatsapp.FieldAccount)
  43505. }
  43506. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  43507. fields = append(fields, whatsapp.FieldOrganizationID)
  43508. }
  43509. if m.FieldCleared(whatsapp.FieldAPIBase) {
  43510. fields = append(fields, whatsapp.FieldAPIBase)
  43511. }
  43512. if m.FieldCleared(whatsapp.FieldAPIKey) {
  43513. fields = append(fields, whatsapp.FieldAPIKey)
  43514. }
  43515. if m.FieldCleared(whatsapp.FieldAllowList) {
  43516. fields = append(fields, whatsapp.FieldAllowList)
  43517. }
  43518. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  43519. fields = append(fields, whatsapp.FieldGroupAllowList)
  43520. }
  43521. if m.FieldCleared(whatsapp.FieldBlockList) {
  43522. fields = append(fields, whatsapp.FieldBlockList)
  43523. }
  43524. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  43525. fields = append(fields, whatsapp.FieldGroupBlockList)
  43526. }
  43527. return fields
  43528. }
  43529. // FieldCleared returns a boolean indicating if a field with the given name was
  43530. // cleared in this mutation.
  43531. func (m *WhatsappMutation) FieldCleared(name string) bool {
  43532. _, ok := m.clearedFields[name]
  43533. return ok
  43534. }
  43535. // ClearField clears the value of the field with the given name. It returns an
  43536. // error if the field is not defined in the schema.
  43537. func (m *WhatsappMutation) ClearField(name string) error {
  43538. switch name {
  43539. case whatsapp.FieldStatus:
  43540. m.ClearStatus()
  43541. return nil
  43542. case whatsapp.FieldDeletedAt:
  43543. m.ClearDeletedAt()
  43544. return nil
  43545. case whatsapp.FieldWaID:
  43546. m.ClearWaID()
  43547. return nil
  43548. case whatsapp.FieldWaName:
  43549. m.ClearWaName()
  43550. return nil
  43551. case whatsapp.FieldCallback:
  43552. m.ClearCallback()
  43553. return nil
  43554. case whatsapp.FieldAccount:
  43555. m.ClearAccount()
  43556. return nil
  43557. case whatsapp.FieldOrganizationID:
  43558. m.ClearOrganizationID()
  43559. return nil
  43560. case whatsapp.FieldAPIBase:
  43561. m.ClearAPIBase()
  43562. return nil
  43563. case whatsapp.FieldAPIKey:
  43564. m.ClearAPIKey()
  43565. return nil
  43566. case whatsapp.FieldAllowList:
  43567. m.ClearAllowList()
  43568. return nil
  43569. case whatsapp.FieldGroupAllowList:
  43570. m.ClearGroupAllowList()
  43571. return nil
  43572. case whatsapp.FieldBlockList:
  43573. m.ClearBlockList()
  43574. return nil
  43575. case whatsapp.FieldGroupBlockList:
  43576. m.ClearGroupBlockList()
  43577. return nil
  43578. }
  43579. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  43580. }
  43581. // ResetField resets all changes in the mutation for the field with the given name.
  43582. // It returns an error if the field is not defined in the schema.
  43583. func (m *WhatsappMutation) ResetField(name string) error {
  43584. switch name {
  43585. case whatsapp.FieldCreatedAt:
  43586. m.ResetCreatedAt()
  43587. return nil
  43588. case whatsapp.FieldUpdatedAt:
  43589. m.ResetUpdatedAt()
  43590. return nil
  43591. case whatsapp.FieldStatus:
  43592. m.ResetStatus()
  43593. return nil
  43594. case whatsapp.FieldDeletedAt:
  43595. m.ResetDeletedAt()
  43596. return nil
  43597. case whatsapp.FieldWaID:
  43598. m.ResetWaID()
  43599. return nil
  43600. case whatsapp.FieldWaName:
  43601. m.ResetWaName()
  43602. return nil
  43603. case whatsapp.FieldCallback:
  43604. m.ResetCallback()
  43605. return nil
  43606. case whatsapp.FieldAgentID:
  43607. m.ResetAgentID()
  43608. return nil
  43609. case whatsapp.FieldAccount:
  43610. m.ResetAccount()
  43611. return nil
  43612. case whatsapp.FieldCc:
  43613. m.ResetCc()
  43614. return nil
  43615. case whatsapp.FieldPhone:
  43616. m.ResetPhone()
  43617. return nil
  43618. case whatsapp.FieldCcPhone:
  43619. m.ResetCcPhone()
  43620. return nil
  43621. case whatsapp.FieldPhoneName:
  43622. m.ResetPhoneName()
  43623. return nil
  43624. case whatsapp.FieldPhoneStatus:
  43625. m.ResetPhoneStatus()
  43626. return nil
  43627. case whatsapp.FieldOrganizationID:
  43628. m.ResetOrganizationID()
  43629. return nil
  43630. case whatsapp.FieldAPIBase:
  43631. m.ResetAPIBase()
  43632. return nil
  43633. case whatsapp.FieldAPIKey:
  43634. m.ResetAPIKey()
  43635. return nil
  43636. case whatsapp.FieldAllowList:
  43637. m.ResetAllowList()
  43638. return nil
  43639. case whatsapp.FieldGroupAllowList:
  43640. m.ResetGroupAllowList()
  43641. return nil
  43642. case whatsapp.FieldBlockList:
  43643. m.ResetBlockList()
  43644. return nil
  43645. case whatsapp.FieldGroupBlockList:
  43646. m.ResetGroupBlockList()
  43647. return nil
  43648. }
  43649. return fmt.Errorf("unknown Whatsapp field %s", name)
  43650. }
  43651. // AddedEdges returns all edge names that were set/added in this mutation.
  43652. func (m *WhatsappMutation) AddedEdges() []string {
  43653. edges := make([]string, 0, 1)
  43654. if m.agent != nil {
  43655. edges = append(edges, whatsapp.EdgeAgent)
  43656. }
  43657. return edges
  43658. }
  43659. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43660. // name in this mutation.
  43661. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  43662. switch name {
  43663. case whatsapp.EdgeAgent:
  43664. if id := m.agent; id != nil {
  43665. return []ent.Value{*id}
  43666. }
  43667. }
  43668. return nil
  43669. }
  43670. // RemovedEdges returns all edge names that were removed in this mutation.
  43671. func (m *WhatsappMutation) RemovedEdges() []string {
  43672. edges := make([]string, 0, 1)
  43673. return edges
  43674. }
  43675. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43676. // the given name in this mutation.
  43677. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  43678. return nil
  43679. }
  43680. // ClearedEdges returns all edge names that were cleared in this mutation.
  43681. func (m *WhatsappMutation) ClearedEdges() []string {
  43682. edges := make([]string, 0, 1)
  43683. if m.clearedagent {
  43684. edges = append(edges, whatsapp.EdgeAgent)
  43685. }
  43686. return edges
  43687. }
  43688. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43689. // was cleared in this mutation.
  43690. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  43691. switch name {
  43692. case whatsapp.EdgeAgent:
  43693. return m.clearedagent
  43694. }
  43695. return false
  43696. }
  43697. // ClearEdge clears the value of the edge with the given name. It returns an error
  43698. // if that edge is not defined in the schema.
  43699. func (m *WhatsappMutation) ClearEdge(name string) error {
  43700. switch name {
  43701. case whatsapp.EdgeAgent:
  43702. m.ClearAgent()
  43703. return nil
  43704. }
  43705. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  43706. }
  43707. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43708. // It returns an error if the edge is not defined in the schema.
  43709. func (m *WhatsappMutation) ResetEdge(name string) error {
  43710. switch name {
  43711. case whatsapp.EdgeAgent:
  43712. m.ResetAgent()
  43713. return nil
  43714. }
  43715. return fmt.Errorf("unknown Whatsapp edge %s", name)
  43716. }
  43717. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  43718. type WhatsappChannelMutation struct {
  43719. config
  43720. op Op
  43721. typ string
  43722. id *uint64
  43723. created_at *time.Time
  43724. updated_at *time.Time
  43725. status *uint8
  43726. addstatus *int8
  43727. deleted_at *time.Time
  43728. ak *string
  43729. sk *string
  43730. wa_id *string
  43731. wa_name *string
  43732. waba_id *uint64
  43733. addwaba_id *int64
  43734. business_id *uint64
  43735. addbusiness_id *int64
  43736. organization_id *uint64
  43737. addorganization_id *int64
  43738. verify_account *string
  43739. clearedFields map[string]struct{}
  43740. done bool
  43741. oldValue func(context.Context) (*WhatsappChannel, error)
  43742. predicates []predicate.WhatsappChannel
  43743. }
  43744. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  43745. // whatsappchannelOption allows management of the mutation configuration using functional options.
  43746. type whatsappchannelOption func(*WhatsappChannelMutation)
  43747. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  43748. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  43749. m := &WhatsappChannelMutation{
  43750. config: c,
  43751. op: op,
  43752. typ: TypeWhatsappChannel,
  43753. clearedFields: make(map[string]struct{}),
  43754. }
  43755. for _, opt := range opts {
  43756. opt(m)
  43757. }
  43758. return m
  43759. }
  43760. // withWhatsappChannelID sets the ID field of the mutation.
  43761. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  43762. return func(m *WhatsappChannelMutation) {
  43763. var (
  43764. err error
  43765. once sync.Once
  43766. value *WhatsappChannel
  43767. )
  43768. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  43769. once.Do(func() {
  43770. if m.done {
  43771. err = errors.New("querying old values post mutation is not allowed")
  43772. } else {
  43773. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  43774. }
  43775. })
  43776. return value, err
  43777. }
  43778. m.id = &id
  43779. }
  43780. }
  43781. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  43782. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  43783. return func(m *WhatsappChannelMutation) {
  43784. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  43785. return node, nil
  43786. }
  43787. m.id = &node.ID
  43788. }
  43789. }
  43790. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43791. // executed in a transaction (ent.Tx), a transactional client is returned.
  43792. func (m WhatsappChannelMutation) Client() *Client {
  43793. client := &Client{config: m.config}
  43794. client.init()
  43795. return client
  43796. }
  43797. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43798. // it returns an error otherwise.
  43799. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  43800. if _, ok := m.driver.(*txDriver); !ok {
  43801. return nil, errors.New("ent: mutation is not running in a transaction")
  43802. }
  43803. tx := &Tx{config: m.config}
  43804. tx.init()
  43805. return tx, nil
  43806. }
  43807. // SetID sets the value of the id field. Note that this
  43808. // operation is only accepted on creation of WhatsappChannel entities.
  43809. func (m *WhatsappChannelMutation) SetID(id uint64) {
  43810. m.id = &id
  43811. }
  43812. // ID returns the ID value in the mutation. Note that the ID is only available
  43813. // if it was provided to the builder or after it was returned from the database.
  43814. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  43815. if m.id == nil {
  43816. return
  43817. }
  43818. return *m.id, true
  43819. }
  43820. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43821. // That means, if the mutation is applied within a transaction with an isolation level such
  43822. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43823. // or updated by the mutation.
  43824. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  43825. switch {
  43826. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43827. id, exists := m.ID()
  43828. if exists {
  43829. return []uint64{id}, nil
  43830. }
  43831. fallthrough
  43832. case m.op.Is(OpUpdate | OpDelete):
  43833. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  43834. default:
  43835. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43836. }
  43837. }
  43838. // SetCreatedAt sets the "created_at" field.
  43839. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  43840. m.created_at = &t
  43841. }
  43842. // CreatedAt returns the value of the "created_at" field in the mutation.
  43843. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  43844. v := m.created_at
  43845. if v == nil {
  43846. return
  43847. }
  43848. return *v, true
  43849. }
  43850. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  43851. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43853. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43854. if !m.op.Is(OpUpdateOne) {
  43855. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43856. }
  43857. if m.id == nil || m.oldValue == nil {
  43858. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43859. }
  43860. oldValue, err := m.oldValue(ctx)
  43861. if err != nil {
  43862. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43863. }
  43864. return oldValue.CreatedAt, nil
  43865. }
  43866. // ResetCreatedAt resets all changes to the "created_at" field.
  43867. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  43868. m.created_at = nil
  43869. }
  43870. // SetUpdatedAt sets the "updated_at" field.
  43871. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  43872. m.updated_at = &t
  43873. }
  43874. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43875. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  43876. v := m.updated_at
  43877. if v == nil {
  43878. return
  43879. }
  43880. return *v, true
  43881. }
  43882. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  43883. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43885. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43886. if !m.op.Is(OpUpdateOne) {
  43887. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43888. }
  43889. if m.id == nil || m.oldValue == nil {
  43890. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43891. }
  43892. oldValue, err := m.oldValue(ctx)
  43893. if err != nil {
  43894. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43895. }
  43896. return oldValue.UpdatedAt, nil
  43897. }
  43898. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43899. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  43900. m.updated_at = nil
  43901. }
  43902. // SetStatus sets the "status" field.
  43903. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  43904. m.status = &u
  43905. m.addstatus = nil
  43906. }
  43907. // Status returns the value of the "status" field in the mutation.
  43908. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  43909. v := m.status
  43910. if v == nil {
  43911. return
  43912. }
  43913. return *v, true
  43914. }
  43915. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  43916. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43918. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43919. if !m.op.Is(OpUpdateOne) {
  43920. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43921. }
  43922. if m.id == nil || m.oldValue == nil {
  43923. return v, errors.New("OldStatus requires an ID field in the mutation")
  43924. }
  43925. oldValue, err := m.oldValue(ctx)
  43926. if err != nil {
  43927. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43928. }
  43929. return oldValue.Status, nil
  43930. }
  43931. // AddStatus adds u to the "status" field.
  43932. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  43933. if m.addstatus != nil {
  43934. *m.addstatus += u
  43935. } else {
  43936. m.addstatus = &u
  43937. }
  43938. }
  43939. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43940. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  43941. v := m.addstatus
  43942. if v == nil {
  43943. return
  43944. }
  43945. return *v, true
  43946. }
  43947. // ClearStatus clears the value of the "status" field.
  43948. func (m *WhatsappChannelMutation) ClearStatus() {
  43949. m.status = nil
  43950. m.addstatus = nil
  43951. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  43952. }
  43953. // StatusCleared returns if the "status" field was cleared in this mutation.
  43954. func (m *WhatsappChannelMutation) StatusCleared() bool {
  43955. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  43956. return ok
  43957. }
  43958. // ResetStatus resets all changes to the "status" field.
  43959. func (m *WhatsappChannelMutation) ResetStatus() {
  43960. m.status = nil
  43961. m.addstatus = nil
  43962. delete(m.clearedFields, whatsappchannel.FieldStatus)
  43963. }
  43964. // SetDeletedAt sets the "deleted_at" field.
  43965. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  43966. m.deleted_at = &t
  43967. }
  43968. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43969. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  43970. v := m.deleted_at
  43971. if v == nil {
  43972. return
  43973. }
  43974. return *v, true
  43975. }
  43976. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  43977. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43979. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43980. if !m.op.Is(OpUpdateOne) {
  43981. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43982. }
  43983. if m.id == nil || m.oldValue == nil {
  43984. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43985. }
  43986. oldValue, err := m.oldValue(ctx)
  43987. if err != nil {
  43988. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43989. }
  43990. return oldValue.DeletedAt, nil
  43991. }
  43992. // ClearDeletedAt clears the value of the "deleted_at" field.
  43993. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  43994. m.deleted_at = nil
  43995. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  43996. }
  43997. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43998. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  43999. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  44000. return ok
  44001. }
  44002. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44003. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  44004. m.deleted_at = nil
  44005. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  44006. }
  44007. // SetAk sets the "ak" field.
  44008. func (m *WhatsappChannelMutation) SetAk(s string) {
  44009. m.ak = &s
  44010. }
  44011. // Ak returns the value of the "ak" field in the mutation.
  44012. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  44013. v := m.ak
  44014. if v == nil {
  44015. return
  44016. }
  44017. return *v, true
  44018. }
  44019. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  44020. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44022. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  44023. if !m.op.Is(OpUpdateOne) {
  44024. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  44025. }
  44026. if m.id == nil || m.oldValue == nil {
  44027. return v, errors.New("OldAk requires an ID field in the mutation")
  44028. }
  44029. oldValue, err := m.oldValue(ctx)
  44030. if err != nil {
  44031. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  44032. }
  44033. return oldValue.Ak, nil
  44034. }
  44035. // ClearAk clears the value of the "ak" field.
  44036. func (m *WhatsappChannelMutation) ClearAk() {
  44037. m.ak = nil
  44038. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  44039. }
  44040. // AkCleared returns if the "ak" field was cleared in this mutation.
  44041. func (m *WhatsappChannelMutation) AkCleared() bool {
  44042. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  44043. return ok
  44044. }
  44045. // ResetAk resets all changes to the "ak" field.
  44046. func (m *WhatsappChannelMutation) ResetAk() {
  44047. m.ak = nil
  44048. delete(m.clearedFields, whatsappchannel.FieldAk)
  44049. }
  44050. // SetSk sets the "sk" field.
  44051. func (m *WhatsappChannelMutation) SetSk(s string) {
  44052. m.sk = &s
  44053. }
  44054. // Sk returns the value of the "sk" field in the mutation.
  44055. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  44056. v := m.sk
  44057. if v == nil {
  44058. return
  44059. }
  44060. return *v, true
  44061. }
  44062. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  44063. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44065. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  44066. if !m.op.Is(OpUpdateOne) {
  44067. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  44068. }
  44069. if m.id == nil || m.oldValue == nil {
  44070. return v, errors.New("OldSk requires an ID field in the mutation")
  44071. }
  44072. oldValue, err := m.oldValue(ctx)
  44073. if err != nil {
  44074. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  44075. }
  44076. return oldValue.Sk, nil
  44077. }
  44078. // ResetSk resets all changes to the "sk" field.
  44079. func (m *WhatsappChannelMutation) ResetSk() {
  44080. m.sk = nil
  44081. }
  44082. // SetWaID sets the "wa_id" field.
  44083. func (m *WhatsappChannelMutation) SetWaID(s string) {
  44084. m.wa_id = &s
  44085. }
  44086. // WaID returns the value of the "wa_id" field in the mutation.
  44087. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  44088. v := m.wa_id
  44089. if v == nil {
  44090. return
  44091. }
  44092. return *v, true
  44093. }
  44094. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  44095. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44097. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  44098. if !m.op.Is(OpUpdateOne) {
  44099. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  44100. }
  44101. if m.id == nil || m.oldValue == nil {
  44102. return v, errors.New("OldWaID requires an ID field in the mutation")
  44103. }
  44104. oldValue, err := m.oldValue(ctx)
  44105. if err != nil {
  44106. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  44107. }
  44108. return oldValue.WaID, nil
  44109. }
  44110. // ClearWaID clears the value of the "wa_id" field.
  44111. func (m *WhatsappChannelMutation) ClearWaID() {
  44112. m.wa_id = nil
  44113. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  44114. }
  44115. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  44116. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  44117. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  44118. return ok
  44119. }
  44120. // ResetWaID resets all changes to the "wa_id" field.
  44121. func (m *WhatsappChannelMutation) ResetWaID() {
  44122. m.wa_id = nil
  44123. delete(m.clearedFields, whatsappchannel.FieldWaID)
  44124. }
  44125. // SetWaName sets the "wa_name" field.
  44126. func (m *WhatsappChannelMutation) SetWaName(s string) {
  44127. m.wa_name = &s
  44128. }
  44129. // WaName returns the value of the "wa_name" field in the mutation.
  44130. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  44131. v := m.wa_name
  44132. if v == nil {
  44133. return
  44134. }
  44135. return *v, true
  44136. }
  44137. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  44138. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44140. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  44141. if !m.op.Is(OpUpdateOne) {
  44142. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  44143. }
  44144. if m.id == nil || m.oldValue == nil {
  44145. return v, errors.New("OldWaName requires an ID field in the mutation")
  44146. }
  44147. oldValue, err := m.oldValue(ctx)
  44148. if err != nil {
  44149. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  44150. }
  44151. return oldValue.WaName, nil
  44152. }
  44153. // ClearWaName clears the value of the "wa_name" field.
  44154. func (m *WhatsappChannelMutation) ClearWaName() {
  44155. m.wa_name = nil
  44156. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  44157. }
  44158. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  44159. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  44160. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  44161. return ok
  44162. }
  44163. // ResetWaName resets all changes to the "wa_name" field.
  44164. func (m *WhatsappChannelMutation) ResetWaName() {
  44165. m.wa_name = nil
  44166. delete(m.clearedFields, whatsappchannel.FieldWaName)
  44167. }
  44168. // SetWabaID sets the "waba_id" field.
  44169. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  44170. m.waba_id = &u
  44171. m.addwaba_id = nil
  44172. }
  44173. // WabaID returns the value of the "waba_id" field in the mutation.
  44174. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  44175. v := m.waba_id
  44176. if v == nil {
  44177. return
  44178. }
  44179. return *v, true
  44180. }
  44181. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  44182. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44184. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  44185. if !m.op.Is(OpUpdateOne) {
  44186. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  44187. }
  44188. if m.id == nil || m.oldValue == nil {
  44189. return v, errors.New("OldWabaID requires an ID field in the mutation")
  44190. }
  44191. oldValue, err := m.oldValue(ctx)
  44192. if err != nil {
  44193. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  44194. }
  44195. return oldValue.WabaID, nil
  44196. }
  44197. // AddWabaID adds u to the "waba_id" field.
  44198. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  44199. if m.addwaba_id != nil {
  44200. *m.addwaba_id += u
  44201. } else {
  44202. m.addwaba_id = &u
  44203. }
  44204. }
  44205. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  44206. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  44207. v := m.addwaba_id
  44208. if v == nil {
  44209. return
  44210. }
  44211. return *v, true
  44212. }
  44213. // ResetWabaID resets all changes to the "waba_id" field.
  44214. func (m *WhatsappChannelMutation) ResetWabaID() {
  44215. m.waba_id = nil
  44216. m.addwaba_id = nil
  44217. }
  44218. // SetBusinessID sets the "business_id" field.
  44219. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  44220. m.business_id = &u
  44221. m.addbusiness_id = nil
  44222. }
  44223. // BusinessID returns the value of the "business_id" field in the mutation.
  44224. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  44225. v := m.business_id
  44226. if v == nil {
  44227. return
  44228. }
  44229. return *v, true
  44230. }
  44231. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  44232. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44234. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  44235. if !m.op.Is(OpUpdateOne) {
  44236. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  44237. }
  44238. if m.id == nil || m.oldValue == nil {
  44239. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  44240. }
  44241. oldValue, err := m.oldValue(ctx)
  44242. if err != nil {
  44243. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  44244. }
  44245. return oldValue.BusinessID, nil
  44246. }
  44247. // AddBusinessID adds u to the "business_id" field.
  44248. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  44249. if m.addbusiness_id != nil {
  44250. *m.addbusiness_id += u
  44251. } else {
  44252. m.addbusiness_id = &u
  44253. }
  44254. }
  44255. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  44256. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  44257. v := m.addbusiness_id
  44258. if v == nil {
  44259. return
  44260. }
  44261. return *v, true
  44262. }
  44263. // ResetBusinessID resets all changes to the "business_id" field.
  44264. func (m *WhatsappChannelMutation) ResetBusinessID() {
  44265. m.business_id = nil
  44266. m.addbusiness_id = nil
  44267. }
  44268. // SetOrganizationID sets the "organization_id" field.
  44269. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  44270. m.organization_id = &u
  44271. m.addorganization_id = nil
  44272. }
  44273. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44274. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  44275. v := m.organization_id
  44276. if v == nil {
  44277. return
  44278. }
  44279. return *v, true
  44280. }
  44281. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  44282. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44284. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44285. if !m.op.Is(OpUpdateOne) {
  44286. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44287. }
  44288. if m.id == nil || m.oldValue == nil {
  44289. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44290. }
  44291. oldValue, err := m.oldValue(ctx)
  44292. if err != nil {
  44293. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44294. }
  44295. return oldValue.OrganizationID, nil
  44296. }
  44297. // AddOrganizationID adds u to the "organization_id" field.
  44298. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  44299. if m.addorganization_id != nil {
  44300. *m.addorganization_id += u
  44301. } else {
  44302. m.addorganization_id = &u
  44303. }
  44304. }
  44305. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44306. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  44307. v := m.addorganization_id
  44308. if v == nil {
  44309. return
  44310. }
  44311. return *v, true
  44312. }
  44313. // ClearOrganizationID clears the value of the "organization_id" field.
  44314. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  44315. m.organization_id = nil
  44316. m.addorganization_id = nil
  44317. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  44318. }
  44319. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  44320. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  44321. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  44322. return ok
  44323. }
  44324. // ResetOrganizationID resets all changes to the "organization_id" field.
  44325. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  44326. m.organization_id = nil
  44327. m.addorganization_id = nil
  44328. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  44329. }
  44330. // SetVerifyAccount sets the "verify_account" field.
  44331. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  44332. m.verify_account = &s
  44333. }
  44334. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  44335. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  44336. v := m.verify_account
  44337. if v == nil {
  44338. return
  44339. }
  44340. return *v, true
  44341. }
  44342. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  44343. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44345. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  44346. if !m.op.Is(OpUpdateOne) {
  44347. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  44348. }
  44349. if m.id == nil || m.oldValue == nil {
  44350. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  44351. }
  44352. oldValue, err := m.oldValue(ctx)
  44353. if err != nil {
  44354. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  44355. }
  44356. return oldValue.VerifyAccount, nil
  44357. }
  44358. // ResetVerifyAccount resets all changes to the "verify_account" field.
  44359. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  44360. m.verify_account = nil
  44361. }
  44362. // Where appends a list predicates to the WhatsappChannelMutation builder.
  44363. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  44364. m.predicates = append(m.predicates, ps...)
  44365. }
  44366. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  44367. // users can use type-assertion to append predicates that do not depend on any generated package.
  44368. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  44369. p := make([]predicate.WhatsappChannel, len(ps))
  44370. for i := range ps {
  44371. p[i] = ps[i]
  44372. }
  44373. m.Where(p...)
  44374. }
  44375. // Op returns the operation name.
  44376. func (m *WhatsappChannelMutation) Op() Op {
  44377. return m.op
  44378. }
  44379. // SetOp allows setting the mutation operation.
  44380. func (m *WhatsappChannelMutation) SetOp(op Op) {
  44381. m.op = op
  44382. }
  44383. // Type returns the node type of this mutation (WhatsappChannel).
  44384. func (m *WhatsappChannelMutation) Type() string {
  44385. return m.typ
  44386. }
  44387. // Fields returns all fields that were changed during this mutation. Note that in
  44388. // order to get all numeric fields that were incremented/decremented, call
  44389. // AddedFields().
  44390. func (m *WhatsappChannelMutation) Fields() []string {
  44391. fields := make([]string, 0, 12)
  44392. if m.created_at != nil {
  44393. fields = append(fields, whatsappchannel.FieldCreatedAt)
  44394. }
  44395. if m.updated_at != nil {
  44396. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  44397. }
  44398. if m.status != nil {
  44399. fields = append(fields, whatsappchannel.FieldStatus)
  44400. }
  44401. if m.deleted_at != nil {
  44402. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44403. }
  44404. if m.ak != nil {
  44405. fields = append(fields, whatsappchannel.FieldAk)
  44406. }
  44407. if m.sk != nil {
  44408. fields = append(fields, whatsappchannel.FieldSk)
  44409. }
  44410. if m.wa_id != nil {
  44411. fields = append(fields, whatsappchannel.FieldWaID)
  44412. }
  44413. if m.wa_name != nil {
  44414. fields = append(fields, whatsappchannel.FieldWaName)
  44415. }
  44416. if m.waba_id != nil {
  44417. fields = append(fields, whatsappchannel.FieldWabaID)
  44418. }
  44419. if m.business_id != nil {
  44420. fields = append(fields, whatsappchannel.FieldBusinessID)
  44421. }
  44422. if m.organization_id != nil {
  44423. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44424. }
  44425. if m.verify_account != nil {
  44426. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  44427. }
  44428. return fields
  44429. }
  44430. // Field returns the value of a field with the given name. The second boolean
  44431. // return value indicates that this field was not set, or was not defined in the
  44432. // schema.
  44433. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  44434. switch name {
  44435. case whatsappchannel.FieldCreatedAt:
  44436. return m.CreatedAt()
  44437. case whatsappchannel.FieldUpdatedAt:
  44438. return m.UpdatedAt()
  44439. case whatsappchannel.FieldStatus:
  44440. return m.Status()
  44441. case whatsappchannel.FieldDeletedAt:
  44442. return m.DeletedAt()
  44443. case whatsappchannel.FieldAk:
  44444. return m.Ak()
  44445. case whatsappchannel.FieldSk:
  44446. return m.Sk()
  44447. case whatsappchannel.FieldWaID:
  44448. return m.WaID()
  44449. case whatsappchannel.FieldWaName:
  44450. return m.WaName()
  44451. case whatsappchannel.FieldWabaID:
  44452. return m.WabaID()
  44453. case whatsappchannel.FieldBusinessID:
  44454. return m.BusinessID()
  44455. case whatsappchannel.FieldOrganizationID:
  44456. return m.OrganizationID()
  44457. case whatsappchannel.FieldVerifyAccount:
  44458. return m.VerifyAccount()
  44459. }
  44460. return nil, false
  44461. }
  44462. // OldField returns the old value of the field from the database. An error is
  44463. // returned if the mutation operation is not UpdateOne, or the query to the
  44464. // database failed.
  44465. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44466. switch name {
  44467. case whatsappchannel.FieldCreatedAt:
  44468. return m.OldCreatedAt(ctx)
  44469. case whatsappchannel.FieldUpdatedAt:
  44470. return m.OldUpdatedAt(ctx)
  44471. case whatsappchannel.FieldStatus:
  44472. return m.OldStatus(ctx)
  44473. case whatsappchannel.FieldDeletedAt:
  44474. return m.OldDeletedAt(ctx)
  44475. case whatsappchannel.FieldAk:
  44476. return m.OldAk(ctx)
  44477. case whatsappchannel.FieldSk:
  44478. return m.OldSk(ctx)
  44479. case whatsappchannel.FieldWaID:
  44480. return m.OldWaID(ctx)
  44481. case whatsappchannel.FieldWaName:
  44482. return m.OldWaName(ctx)
  44483. case whatsappchannel.FieldWabaID:
  44484. return m.OldWabaID(ctx)
  44485. case whatsappchannel.FieldBusinessID:
  44486. return m.OldBusinessID(ctx)
  44487. case whatsappchannel.FieldOrganizationID:
  44488. return m.OldOrganizationID(ctx)
  44489. case whatsappchannel.FieldVerifyAccount:
  44490. return m.OldVerifyAccount(ctx)
  44491. }
  44492. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  44493. }
  44494. // SetField sets the value of a field with the given name. It returns an error if
  44495. // the field is not defined in the schema, or if the type mismatched the field
  44496. // type.
  44497. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  44498. switch name {
  44499. case whatsappchannel.FieldCreatedAt:
  44500. v, ok := value.(time.Time)
  44501. if !ok {
  44502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44503. }
  44504. m.SetCreatedAt(v)
  44505. return nil
  44506. case whatsappchannel.FieldUpdatedAt:
  44507. v, ok := value.(time.Time)
  44508. if !ok {
  44509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44510. }
  44511. m.SetUpdatedAt(v)
  44512. return nil
  44513. case whatsappchannel.FieldStatus:
  44514. v, ok := value.(uint8)
  44515. if !ok {
  44516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44517. }
  44518. m.SetStatus(v)
  44519. return nil
  44520. case whatsappchannel.FieldDeletedAt:
  44521. v, ok := value.(time.Time)
  44522. if !ok {
  44523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44524. }
  44525. m.SetDeletedAt(v)
  44526. return nil
  44527. case whatsappchannel.FieldAk:
  44528. v, ok := value.(string)
  44529. if !ok {
  44530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44531. }
  44532. m.SetAk(v)
  44533. return nil
  44534. case whatsappchannel.FieldSk:
  44535. v, ok := value.(string)
  44536. if !ok {
  44537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44538. }
  44539. m.SetSk(v)
  44540. return nil
  44541. case whatsappchannel.FieldWaID:
  44542. v, ok := value.(string)
  44543. if !ok {
  44544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44545. }
  44546. m.SetWaID(v)
  44547. return nil
  44548. case whatsappchannel.FieldWaName:
  44549. v, ok := value.(string)
  44550. if !ok {
  44551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44552. }
  44553. m.SetWaName(v)
  44554. return nil
  44555. case whatsappchannel.FieldWabaID:
  44556. v, ok := value.(uint64)
  44557. if !ok {
  44558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44559. }
  44560. m.SetWabaID(v)
  44561. return nil
  44562. case whatsappchannel.FieldBusinessID:
  44563. v, ok := value.(uint64)
  44564. if !ok {
  44565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44566. }
  44567. m.SetBusinessID(v)
  44568. return nil
  44569. case whatsappchannel.FieldOrganizationID:
  44570. v, ok := value.(uint64)
  44571. if !ok {
  44572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44573. }
  44574. m.SetOrganizationID(v)
  44575. return nil
  44576. case whatsappchannel.FieldVerifyAccount:
  44577. v, ok := value.(string)
  44578. if !ok {
  44579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44580. }
  44581. m.SetVerifyAccount(v)
  44582. return nil
  44583. }
  44584. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44585. }
  44586. // AddedFields returns all numeric fields that were incremented/decremented during
  44587. // this mutation.
  44588. func (m *WhatsappChannelMutation) AddedFields() []string {
  44589. var fields []string
  44590. if m.addstatus != nil {
  44591. fields = append(fields, whatsappchannel.FieldStatus)
  44592. }
  44593. if m.addwaba_id != nil {
  44594. fields = append(fields, whatsappchannel.FieldWabaID)
  44595. }
  44596. if m.addbusiness_id != nil {
  44597. fields = append(fields, whatsappchannel.FieldBusinessID)
  44598. }
  44599. if m.addorganization_id != nil {
  44600. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44601. }
  44602. return fields
  44603. }
  44604. // AddedField returns the numeric value that was incremented/decremented on a field
  44605. // with the given name. The second boolean return value indicates that this field
  44606. // was not set, or was not defined in the schema.
  44607. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  44608. switch name {
  44609. case whatsappchannel.FieldStatus:
  44610. return m.AddedStatus()
  44611. case whatsappchannel.FieldWabaID:
  44612. return m.AddedWabaID()
  44613. case whatsappchannel.FieldBusinessID:
  44614. return m.AddedBusinessID()
  44615. case whatsappchannel.FieldOrganizationID:
  44616. return m.AddedOrganizationID()
  44617. }
  44618. return nil, false
  44619. }
  44620. // AddField adds the value to the field with the given name. It returns an error if
  44621. // the field is not defined in the schema, or if the type mismatched the field
  44622. // type.
  44623. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  44624. switch name {
  44625. case whatsappchannel.FieldStatus:
  44626. v, ok := value.(int8)
  44627. if !ok {
  44628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44629. }
  44630. m.AddStatus(v)
  44631. return nil
  44632. case whatsappchannel.FieldWabaID:
  44633. v, ok := value.(int64)
  44634. if !ok {
  44635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44636. }
  44637. m.AddWabaID(v)
  44638. return nil
  44639. case whatsappchannel.FieldBusinessID:
  44640. v, ok := value.(int64)
  44641. if !ok {
  44642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44643. }
  44644. m.AddBusinessID(v)
  44645. return nil
  44646. case whatsappchannel.FieldOrganizationID:
  44647. v, ok := value.(int64)
  44648. if !ok {
  44649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44650. }
  44651. m.AddOrganizationID(v)
  44652. return nil
  44653. }
  44654. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  44655. }
  44656. // ClearedFields returns all nullable fields that were cleared during this
  44657. // mutation.
  44658. func (m *WhatsappChannelMutation) ClearedFields() []string {
  44659. var fields []string
  44660. if m.FieldCleared(whatsappchannel.FieldStatus) {
  44661. fields = append(fields, whatsappchannel.FieldStatus)
  44662. }
  44663. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  44664. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44665. }
  44666. if m.FieldCleared(whatsappchannel.FieldAk) {
  44667. fields = append(fields, whatsappchannel.FieldAk)
  44668. }
  44669. if m.FieldCleared(whatsappchannel.FieldWaID) {
  44670. fields = append(fields, whatsappchannel.FieldWaID)
  44671. }
  44672. if m.FieldCleared(whatsappchannel.FieldWaName) {
  44673. fields = append(fields, whatsappchannel.FieldWaName)
  44674. }
  44675. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  44676. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44677. }
  44678. return fields
  44679. }
  44680. // FieldCleared returns a boolean indicating if a field with the given name was
  44681. // cleared in this mutation.
  44682. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  44683. _, ok := m.clearedFields[name]
  44684. return ok
  44685. }
  44686. // ClearField clears the value of the field with the given name. It returns an
  44687. // error if the field is not defined in the schema.
  44688. func (m *WhatsappChannelMutation) ClearField(name string) error {
  44689. switch name {
  44690. case whatsappchannel.FieldStatus:
  44691. m.ClearStatus()
  44692. return nil
  44693. case whatsappchannel.FieldDeletedAt:
  44694. m.ClearDeletedAt()
  44695. return nil
  44696. case whatsappchannel.FieldAk:
  44697. m.ClearAk()
  44698. return nil
  44699. case whatsappchannel.FieldWaID:
  44700. m.ClearWaID()
  44701. return nil
  44702. case whatsappchannel.FieldWaName:
  44703. m.ClearWaName()
  44704. return nil
  44705. case whatsappchannel.FieldOrganizationID:
  44706. m.ClearOrganizationID()
  44707. return nil
  44708. }
  44709. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  44710. }
  44711. // ResetField resets all changes in the mutation for the field with the given name.
  44712. // It returns an error if the field is not defined in the schema.
  44713. func (m *WhatsappChannelMutation) ResetField(name string) error {
  44714. switch name {
  44715. case whatsappchannel.FieldCreatedAt:
  44716. m.ResetCreatedAt()
  44717. return nil
  44718. case whatsappchannel.FieldUpdatedAt:
  44719. m.ResetUpdatedAt()
  44720. return nil
  44721. case whatsappchannel.FieldStatus:
  44722. m.ResetStatus()
  44723. return nil
  44724. case whatsappchannel.FieldDeletedAt:
  44725. m.ResetDeletedAt()
  44726. return nil
  44727. case whatsappchannel.FieldAk:
  44728. m.ResetAk()
  44729. return nil
  44730. case whatsappchannel.FieldSk:
  44731. m.ResetSk()
  44732. return nil
  44733. case whatsappchannel.FieldWaID:
  44734. m.ResetWaID()
  44735. return nil
  44736. case whatsappchannel.FieldWaName:
  44737. m.ResetWaName()
  44738. return nil
  44739. case whatsappchannel.FieldWabaID:
  44740. m.ResetWabaID()
  44741. return nil
  44742. case whatsappchannel.FieldBusinessID:
  44743. m.ResetBusinessID()
  44744. return nil
  44745. case whatsappchannel.FieldOrganizationID:
  44746. m.ResetOrganizationID()
  44747. return nil
  44748. case whatsappchannel.FieldVerifyAccount:
  44749. m.ResetVerifyAccount()
  44750. return nil
  44751. }
  44752. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44753. }
  44754. // AddedEdges returns all edge names that were set/added in this mutation.
  44755. func (m *WhatsappChannelMutation) AddedEdges() []string {
  44756. edges := make([]string, 0, 0)
  44757. return edges
  44758. }
  44759. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44760. // name in this mutation.
  44761. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  44762. return nil
  44763. }
  44764. // RemovedEdges returns all edge names that were removed in this mutation.
  44765. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  44766. edges := make([]string, 0, 0)
  44767. return edges
  44768. }
  44769. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44770. // the given name in this mutation.
  44771. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  44772. return nil
  44773. }
  44774. // ClearedEdges returns all edge names that were cleared in this mutation.
  44775. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  44776. edges := make([]string, 0, 0)
  44777. return edges
  44778. }
  44779. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44780. // was cleared in this mutation.
  44781. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  44782. return false
  44783. }
  44784. // ClearEdge clears the value of the edge with the given name. It returns an error
  44785. // if that edge is not defined in the schema.
  44786. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  44787. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  44788. }
  44789. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44790. // It returns an error if the edge is not defined in the schema.
  44791. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  44792. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  44793. }
  44794. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  44795. type WorkExperienceMutation struct {
  44796. config
  44797. op Op
  44798. typ string
  44799. id *uint64
  44800. created_at *time.Time
  44801. updated_at *time.Time
  44802. deleted_at *time.Time
  44803. start_date *time.Time
  44804. end_date *time.Time
  44805. company *string
  44806. experience *string
  44807. organization_id *uint64
  44808. addorganization_id *int64
  44809. clearedFields map[string]struct{}
  44810. employee *uint64
  44811. clearedemployee bool
  44812. done bool
  44813. oldValue func(context.Context) (*WorkExperience, error)
  44814. predicates []predicate.WorkExperience
  44815. }
  44816. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  44817. // workexperienceOption allows management of the mutation configuration using functional options.
  44818. type workexperienceOption func(*WorkExperienceMutation)
  44819. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  44820. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  44821. m := &WorkExperienceMutation{
  44822. config: c,
  44823. op: op,
  44824. typ: TypeWorkExperience,
  44825. clearedFields: make(map[string]struct{}),
  44826. }
  44827. for _, opt := range opts {
  44828. opt(m)
  44829. }
  44830. return m
  44831. }
  44832. // withWorkExperienceID sets the ID field of the mutation.
  44833. func withWorkExperienceID(id uint64) workexperienceOption {
  44834. return func(m *WorkExperienceMutation) {
  44835. var (
  44836. err error
  44837. once sync.Once
  44838. value *WorkExperience
  44839. )
  44840. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  44841. once.Do(func() {
  44842. if m.done {
  44843. err = errors.New("querying old values post mutation is not allowed")
  44844. } else {
  44845. value, err = m.Client().WorkExperience.Get(ctx, id)
  44846. }
  44847. })
  44848. return value, err
  44849. }
  44850. m.id = &id
  44851. }
  44852. }
  44853. // withWorkExperience sets the old WorkExperience of the mutation.
  44854. func withWorkExperience(node *WorkExperience) workexperienceOption {
  44855. return func(m *WorkExperienceMutation) {
  44856. m.oldValue = func(context.Context) (*WorkExperience, error) {
  44857. return node, nil
  44858. }
  44859. m.id = &node.ID
  44860. }
  44861. }
  44862. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44863. // executed in a transaction (ent.Tx), a transactional client is returned.
  44864. func (m WorkExperienceMutation) Client() *Client {
  44865. client := &Client{config: m.config}
  44866. client.init()
  44867. return client
  44868. }
  44869. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44870. // it returns an error otherwise.
  44871. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  44872. if _, ok := m.driver.(*txDriver); !ok {
  44873. return nil, errors.New("ent: mutation is not running in a transaction")
  44874. }
  44875. tx := &Tx{config: m.config}
  44876. tx.init()
  44877. return tx, nil
  44878. }
  44879. // SetID sets the value of the id field. Note that this
  44880. // operation is only accepted on creation of WorkExperience entities.
  44881. func (m *WorkExperienceMutation) SetID(id uint64) {
  44882. m.id = &id
  44883. }
  44884. // ID returns the ID value in the mutation. Note that the ID is only available
  44885. // if it was provided to the builder or after it was returned from the database.
  44886. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  44887. if m.id == nil {
  44888. return
  44889. }
  44890. return *m.id, true
  44891. }
  44892. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44893. // That means, if the mutation is applied within a transaction with an isolation level such
  44894. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44895. // or updated by the mutation.
  44896. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  44897. switch {
  44898. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44899. id, exists := m.ID()
  44900. if exists {
  44901. return []uint64{id}, nil
  44902. }
  44903. fallthrough
  44904. case m.op.Is(OpUpdate | OpDelete):
  44905. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  44906. default:
  44907. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44908. }
  44909. }
  44910. // SetCreatedAt sets the "created_at" field.
  44911. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  44912. m.created_at = &t
  44913. }
  44914. // CreatedAt returns the value of the "created_at" field in the mutation.
  44915. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  44916. v := m.created_at
  44917. if v == nil {
  44918. return
  44919. }
  44920. return *v, true
  44921. }
  44922. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  44923. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44925. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44926. if !m.op.Is(OpUpdateOne) {
  44927. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44928. }
  44929. if m.id == nil || m.oldValue == nil {
  44930. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44931. }
  44932. oldValue, err := m.oldValue(ctx)
  44933. if err != nil {
  44934. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44935. }
  44936. return oldValue.CreatedAt, nil
  44937. }
  44938. // ResetCreatedAt resets all changes to the "created_at" field.
  44939. func (m *WorkExperienceMutation) ResetCreatedAt() {
  44940. m.created_at = nil
  44941. }
  44942. // SetUpdatedAt sets the "updated_at" field.
  44943. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  44944. m.updated_at = &t
  44945. }
  44946. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44947. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  44948. v := m.updated_at
  44949. if v == nil {
  44950. return
  44951. }
  44952. return *v, true
  44953. }
  44954. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  44955. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44957. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44958. if !m.op.Is(OpUpdateOne) {
  44959. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44960. }
  44961. if m.id == nil || m.oldValue == nil {
  44962. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44963. }
  44964. oldValue, err := m.oldValue(ctx)
  44965. if err != nil {
  44966. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44967. }
  44968. return oldValue.UpdatedAt, nil
  44969. }
  44970. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44971. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  44972. m.updated_at = nil
  44973. }
  44974. // SetDeletedAt sets the "deleted_at" field.
  44975. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  44976. m.deleted_at = &t
  44977. }
  44978. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44979. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  44980. v := m.deleted_at
  44981. if v == nil {
  44982. return
  44983. }
  44984. return *v, true
  44985. }
  44986. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  44987. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44989. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44990. if !m.op.Is(OpUpdateOne) {
  44991. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44992. }
  44993. if m.id == nil || m.oldValue == nil {
  44994. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44995. }
  44996. oldValue, err := m.oldValue(ctx)
  44997. if err != nil {
  44998. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44999. }
  45000. return oldValue.DeletedAt, nil
  45001. }
  45002. // ClearDeletedAt clears the value of the "deleted_at" field.
  45003. func (m *WorkExperienceMutation) ClearDeletedAt() {
  45004. m.deleted_at = nil
  45005. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  45006. }
  45007. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45008. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  45009. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  45010. return ok
  45011. }
  45012. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45013. func (m *WorkExperienceMutation) ResetDeletedAt() {
  45014. m.deleted_at = nil
  45015. delete(m.clearedFields, workexperience.FieldDeletedAt)
  45016. }
  45017. // SetEmployeeID sets the "employee_id" field.
  45018. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  45019. m.employee = &u
  45020. }
  45021. // EmployeeID returns the value of the "employee_id" field in the mutation.
  45022. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  45023. v := m.employee
  45024. if v == nil {
  45025. return
  45026. }
  45027. return *v, true
  45028. }
  45029. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  45030. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45032. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  45033. if !m.op.Is(OpUpdateOne) {
  45034. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  45035. }
  45036. if m.id == nil || m.oldValue == nil {
  45037. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  45038. }
  45039. oldValue, err := m.oldValue(ctx)
  45040. if err != nil {
  45041. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  45042. }
  45043. return oldValue.EmployeeID, nil
  45044. }
  45045. // ResetEmployeeID resets all changes to the "employee_id" field.
  45046. func (m *WorkExperienceMutation) ResetEmployeeID() {
  45047. m.employee = nil
  45048. }
  45049. // SetStartDate sets the "start_date" field.
  45050. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  45051. m.start_date = &t
  45052. }
  45053. // StartDate returns the value of the "start_date" field in the mutation.
  45054. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  45055. v := m.start_date
  45056. if v == nil {
  45057. return
  45058. }
  45059. return *v, true
  45060. }
  45061. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  45062. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45064. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  45065. if !m.op.Is(OpUpdateOne) {
  45066. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  45067. }
  45068. if m.id == nil || m.oldValue == nil {
  45069. return v, errors.New("OldStartDate requires an ID field in the mutation")
  45070. }
  45071. oldValue, err := m.oldValue(ctx)
  45072. if err != nil {
  45073. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  45074. }
  45075. return oldValue.StartDate, nil
  45076. }
  45077. // ResetStartDate resets all changes to the "start_date" field.
  45078. func (m *WorkExperienceMutation) ResetStartDate() {
  45079. m.start_date = nil
  45080. }
  45081. // SetEndDate sets the "end_date" field.
  45082. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  45083. m.end_date = &t
  45084. }
  45085. // EndDate returns the value of the "end_date" field in the mutation.
  45086. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  45087. v := m.end_date
  45088. if v == nil {
  45089. return
  45090. }
  45091. return *v, true
  45092. }
  45093. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  45094. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45096. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  45097. if !m.op.Is(OpUpdateOne) {
  45098. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  45099. }
  45100. if m.id == nil || m.oldValue == nil {
  45101. return v, errors.New("OldEndDate requires an ID field in the mutation")
  45102. }
  45103. oldValue, err := m.oldValue(ctx)
  45104. if err != nil {
  45105. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  45106. }
  45107. return oldValue.EndDate, nil
  45108. }
  45109. // ResetEndDate resets all changes to the "end_date" field.
  45110. func (m *WorkExperienceMutation) ResetEndDate() {
  45111. m.end_date = nil
  45112. }
  45113. // SetCompany sets the "company" field.
  45114. func (m *WorkExperienceMutation) SetCompany(s string) {
  45115. m.company = &s
  45116. }
  45117. // Company returns the value of the "company" field in the mutation.
  45118. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  45119. v := m.company
  45120. if v == nil {
  45121. return
  45122. }
  45123. return *v, true
  45124. }
  45125. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  45126. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45128. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  45129. if !m.op.Is(OpUpdateOne) {
  45130. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  45131. }
  45132. if m.id == nil || m.oldValue == nil {
  45133. return v, errors.New("OldCompany requires an ID field in the mutation")
  45134. }
  45135. oldValue, err := m.oldValue(ctx)
  45136. if err != nil {
  45137. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  45138. }
  45139. return oldValue.Company, nil
  45140. }
  45141. // ResetCompany resets all changes to the "company" field.
  45142. func (m *WorkExperienceMutation) ResetCompany() {
  45143. m.company = nil
  45144. }
  45145. // SetExperience sets the "experience" field.
  45146. func (m *WorkExperienceMutation) SetExperience(s string) {
  45147. m.experience = &s
  45148. }
  45149. // Experience returns the value of the "experience" field in the mutation.
  45150. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  45151. v := m.experience
  45152. if v == nil {
  45153. return
  45154. }
  45155. return *v, true
  45156. }
  45157. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  45158. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45160. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  45161. if !m.op.Is(OpUpdateOne) {
  45162. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  45163. }
  45164. if m.id == nil || m.oldValue == nil {
  45165. return v, errors.New("OldExperience requires an ID field in the mutation")
  45166. }
  45167. oldValue, err := m.oldValue(ctx)
  45168. if err != nil {
  45169. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  45170. }
  45171. return oldValue.Experience, nil
  45172. }
  45173. // ResetExperience resets all changes to the "experience" field.
  45174. func (m *WorkExperienceMutation) ResetExperience() {
  45175. m.experience = nil
  45176. }
  45177. // SetOrganizationID sets the "organization_id" field.
  45178. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  45179. m.organization_id = &u
  45180. m.addorganization_id = nil
  45181. }
  45182. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45183. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  45184. v := m.organization_id
  45185. if v == nil {
  45186. return
  45187. }
  45188. return *v, true
  45189. }
  45190. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  45191. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45193. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45194. if !m.op.Is(OpUpdateOne) {
  45195. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45196. }
  45197. if m.id == nil || m.oldValue == nil {
  45198. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45199. }
  45200. oldValue, err := m.oldValue(ctx)
  45201. if err != nil {
  45202. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45203. }
  45204. return oldValue.OrganizationID, nil
  45205. }
  45206. // AddOrganizationID adds u to the "organization_id" field.
  45207. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  45208. if m.addorganization_id != nil {
  45209. *m.addorganization_id += u
  45210. } else {
  45211. m.addorganization_id = &u
  45212. }
  45213. }
  45214. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45215. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  45216. v := m.addorganization_id
  45217. if v == nil {
  45218. return
  45219. }
  45220. return *v, true
  45221. }
  45222. // ResetOrganizationID resets all changes to the "organization_id" field.
  45223. func (m *WorkExperienceMutation) ResetOrganizationID() {
  45224. m.organization_id = nil
  45225. m.addorganization_id = nil
  45226. }
  45227. // ClearEmployee clears the "employee" edge to the Employee entity.
  45228. func (m *WorkExperienceMutation) ClearEmployee() {
  45229. m.clearedemployee = true
  45230. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  45231. }
  45232. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  45233. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  45234. return m.clearedemployee
  45235. }
  45236. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  45237. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45238. // EmployeeID instead. It exists only for internal usage by the builders.
  45239. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  45240. if id := m.employee; id != nil {
  45241. ids = append(ids, *id)
  45242. }
  45243. return
  45244. }
  45245. // ResetEmployee resets all changes to the "employee" edge.
  45246. func (m *WorkExperienceMutation) ResetEmployee() {
  45247. m.employee = nil
  45248. m.clearedemployee = false
  45249. }
  45250. // Where appends a list predicates to the WorkExperienceMutation builder.
  45251. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  45252. m.predicates = append(m.predicates, ps...)
  45253. }
  45254. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  45255. // users can use type-assertion to append predicates that do not depend on any generated package.
  45256. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  45257. p := make([]predicate.WorkExperience, len(ps))
  45258. for i := range ps {
  45259. p[i] = ps[i]
  45260. }
  45261. m.Where(p...)
  45262. }
  45263. // Op returns the operation name.
  45264. func (m *WorkExperienceMutation) Op() Op {
  45265. return m.op
  45266. }
  45267. // SetOp allows setting the mutation operation.
  45268. func (m *WorkExperienceMutation) SetOp(op Op) {
  45269. m.op = op
  45270. }
  45271. // Type returns the node type of this mutation (WorkExperience).
  45272. func (m *WorkExperienceMutation) Type() string {
  45273. return m.typ
  45274. }
  45275. // Fields returns all fields that were changed during this mutation. Note that in
  45276. // order to get all numeric fields that were incremented/decremented, call
  45277. // AddedFields().
  45278. func (m *WorkExperienceMutation) Fields() []string {
  45279. fields := make([]string, 0, 9)
  45280. if m.created_at != nil {
  45281. fields = append(fields, workexperience.FieldCreatedAt)
  45282. }
  45283. if m.updated_at != nil {
  45284. fields = append(fields, workexperience.FieldUpdatedAt)
  45285. }
  45286. if m.deleted_at != nil {
  45287. fields = append(fields, workexperience.FieldDeletedAt)
  45288. }
  45289. if m.employee != nil {
  45290. fields = append(fields, workexperience.FieldEmployeeID)
  45291. }
  45292. if m.start_date != nil {
  45293. fields = append(fields, workexperience.FieldStartDate)
  45294. }
  45295. if m.end_date != nil {
  45296. fields = append(fields, workexperience.FieldEndDate)
  45297. }
  45298. if m.company != nil {
  45299. fields = append(fields, workexperience.FieldCompany)
  45300. }
  45301. if m.experience != nil {
  45302. fields = append(fields, workexperience.FieldExperience)
  45303. }
  45304. if m.organization_id != nil {
  45305. fields = append(fields, workexperience.FieldOrganizationID)
  45306. }
  45307. return fields
  45308. }
  45309. // Field returns the value of a field with the given name. The second boolean
  45310. // return value indicates that this field was not set, or was not defined in the
  45311. // schema.
  45312. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  45313. switch name {
  45314. case workexperience.FieldCreatedAt:
  45315. return m.CreatedAt()
  45316. case workexperience.FieldUpdatedAt:
  45317. return m.UpdatedAt()
  45318. case workexperience.FieldDeletedAt:
  45319. return m.DeletedAt()
  45320. case workexperience.FieldEmployeeID:
  45321. return m.EmployeeID()
  45322. case workexperience.FieldStartDate:
  45323. return m.StartDate()
  45324. case workexperience.FieldEndDate:
  45325. return m.EndDate()
  45326. case workexperience.FieldCompany:
  45327. return m.Company()
  45328. case workexperience.FieldExperience:
  45329. return m.Experience()
  45330. case workexperience.FieldOrganizationID:
  45331. return m.OrganizationID()
  45332. }
  45333. return nil, false
  45334. }
  45335. // OldField returns the old value of the field from the database. An error is
  45336. // returned if the mutation operation is not UpdateOne, or the query to the
  45337. // database failed.
  45338. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45339. switch name {
  45340. case workexperience.FieldCreatedAt:
  45341. return m.OldCreatedAt(ctx)
  45342. case workexperience.FieldUpdatedAt:
  45343. return m.OldUpdatedAt(ctx)
  45344. case workexperience.FieldDeletedAt:
  45345. return m.OldDeletedAt(ctx)
  45346. case workexperience.FieldEmployeeID:
  45347. return m.OldEmployeeID(ctx)
  45348. case workexperience.FieldStartDate:
  45349. return m.OldStartDate(ctx)
  45350. case workexperience.FieldEndDate:
  45351. return m.OldEndDate(ctx)
  45352. case workexperience.FieldCompany:
  45353. return m.OldCompany(ctx)
  45354. case workexperience.FieldExperience:
  45355. return m.OldExperience(ctx)
  45356. case workexperience.FieldOrganizationID:
  45357. return m.OldOrganizationID(ctx)
  45358. }
  45359. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  45360. }
  45361. // SetField sets the value of a field with the given name. It returns an error if
  45362. // the field is not defined in the schema, or if the type mismatched the field
  45363. // type.
  45364. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  45365. switch name {
  45366. case workexperience.FieldCreatedAt:
  45367. v, ok := value.(time.Time)
  45368. if !ok {
  45369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45370. }
  45371. m.SetCreatedAt(v)
  45372. return nil
  45373. case workexperience.FieldUpdatedAt:
  45374. v, ok := value.(time.Time)
  45375. if !ok {
  45376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45377. }
  45378. m.SetUpdatedAt(v)
  45379. return nil
  45380. case workexperience.FieldDeletedAt:
  45381. v, ok := value.(time.Time)
  45382. if !ok {
  45383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45384. }
  45385. m.SetDeletedAt(v)
  45386. return nil
  45387. case workexperience.FieldEmployeeID:
  45388. v, ok := value.(uint64)
  45389. if !ok {
  45390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45391. }
  45392. m.SetEmployeeID(v)
  45393. return nil
  45394. case workexperience.FieldStartDate:
  45395. v, ok := value.(time.Time)
  45396. if !ok {
  45397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45398. }
  45399. m.SetStartDate(v)
  45400. return nil
  45401. case workexperience.FieldEndDate:
  45402. v, ok := value.(time.Time)
  45403. if !ok {
  45404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45405. }
  45406. m.SetEndDate(v)
  45407. return nil
  45408. case workexperience.FieldCompany:
  45409. v, ok := value.(string)
  45410. if !ok {
  45411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45412. }
  45413. m.SetCompany(v)
  45414. return nil
  45415. case workexperience.FieldExperience:
  45416. v, ok := value.(string)
  45417. if !ok {
  45418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45419. }
  45420. m.SetExperience(v)
  45421. return nil
  45422. case workexperience.FieldOrganizationID:
  45423. v, ok := value.(uint64)
  45424. if !ok {
  45425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45426. }
  45427. m.SetOrganizationID(v)
  45428. return nil
  45429. }
  45430. return fmt.Errorf("unknown WorkExperience field %s", name)
  45431. }
  45432. // AddedFields returns all numeric fields that were incremented/decremented during
  45433. // this mutation.
  45434. func (m *WorkExperienceMutation) AddedFields() []string {
  45435. var fields []string
  45436. if m.addorganization_id != nil {
  45437. fields = append(fields, workexperience.FieldOrganizationID)
  45438. }
  45439. return fields
  45440. }
  45441. // AddedField returns the numeric value that was incremented/decremented on a field
  45442. // with the given name. The second boolean return value indicates that this field
  45443. // was not set, or was not defined in the schema.
  45444. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  45445. switch name {
  45446. case workexperience.FieldOrganizationID:
  45447. return m.AddedOrganizationID()
  45448. }
  45449. return nil, false
  45450. }
  45451. // AddField adds the value to the field with the given name. It returns an error if
  45452. // the field is not defined in the schema, or if the type mismatched the field
  45453. // type.
  45454. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  45455. switch name {
  45456. case workexperience.FieldOrganizationID:
  45457. v, ok := value.(int64)
  45458. if !ok {
  45459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45460. }
  45461. m.AddOrganizationID(v)
  45462. return nil
  45463. }
  45464. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  45465. }
  45466. // ClearedFields returns all nullable fields that were cleared during this
  45467. // mutation.
  45468. func (m *WorkExperienceMutation) ClearedFields() []string {
  45469. var fields []string
  45470. if m.FieldCleared(workexperience.FieldDeletedAt) {
  45471. fields = append(fields, workexperience.FieldDeletedAt)
  45472. }
  45473. return fields
  45474. }
  45475. // FieldCleared returns a boolean indicating if a field with the given name was
  45476. // cleared in this mutation.
  45477. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  45478. _, ok := m.clearedFields[name]
  45479. return ok
  45480. }
  45481. // ClearField clears the value of the field with the given name. It returns an
  45482. // error if the field is not defined in the schema.
  45483. func (m *WorkExperienceMutation) ClearField(name string) error {
  45484. switch name {
  45485. case workexperience.FieldDeletedAt:
  45486. m.ClearDeletedAt()
  45487. return nil
  45488. }
  45489. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  45490. }
  45491. // ResetField resets all changes in the mutation for the field with the given name.
  45492. // It returns an error if the field is not defined in the schema.
  45493. func (m *WorkExperienceMutation) ResetField(name string) error {
  45494. switch name {
  45495. case workexperience.FieldCreatedAt:
  45496. m.ResetCreatedAt()
  45497. return nil
  45498. case workexperience.FieldUpdatedAt:
  45499. m.ResetUpdatedAt()
  45500. return nil
  45501. case workexperience.FieldDeletedAt:
  45502. m.ResetDeletedAt()
  45503. return nil
  45504. case workexperience.FieldEmployeeID:
  45505. m.ResetEmployeeID()
  45506. return nil
  45507. case workexperience.FieldStartDate:
  45508. m.ResetStartDate()
  45509. return nil
  45510. case workexperience.FieldEndDate:
  45511. m.ResetEndDate()
  45512. return nil
  45513. case workexperience.FieldCompany:
  45514. m.ResetCompany()
  45515. return nil
  45516. case workexperience.FieldExperience:
  45517. m.ResetExperience()
  45518. return nil
  45519. case workexperience.FieldOrganizationID:
  45520. m.ResetOrganizationID()
  45521. return nil
  45522. }
  45523. return fmt.Errorf("unknown WorkExperience field %s", name)
  45524. }
  45525. // AddedEdges returns all edge names that were set/added in this mutation.
  45526. func (m *WorkExperienceMutation) AddedEdges() []string {
  45527. edges := make([]string, 0, 1)
  45528. if m.employee != nil {
  45529. edges = append(edges, workexperience.EdgeEmployee)
  45530. }
  45531. return edges
  45532. }
  45533. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45534. // name in this mutation.
  45535. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  45536. switch name {
  45537. case workexperience.EdgeEmployee:
  45538. if id := m.employee; id != nil {
  45539. return []ent.Value{*id}
  45540. }
  45541. }
  45542. return nil
  45543. }
  45544. // RemovedEdges returns all edge names that were removed in this mutation.
  45545. func (m *WorkExperienceMutation) RemovedEdges() []string {
  45546. edges := make([]string, 0, 1)
  45547. return edges
  45548. }
  45549. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45550. // the given name in this mutation.
  45551. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  45552. return nil
  45553. }
  45554. // ClearedEdges returns all edge names that were cleared in this mutation.
  45555. func (m *WorkExperienceMutation) ClearedEdges() []string {
  45556. edges := make([]string, 0, 1)
  45557. if m.clearedemployee {
  45558. edges = append(edges, workexperience.EdgeEmployee)
  45559. }
  45560. return edges
  45561. }
  45562. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45563. // was cleared in this mutation.
  45564. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  45565. switch name {
  45566. case workexperience.EdgeEmployee:
  45567. return m.clearedemployee
  45568. }
  45569. return false
  45570. }
  45571. // ClearEdge clears the value of the edge with the given name. It returns an error
  45572. // if that edge is not defined in the schema.
  45573. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  45574. switch name {
  45575. case workexperience.EdgeEmployee:
  45576. m.ClearEmployee()
  45577. return nil
  45578. }
  45579. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  45580. }
  45581. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45582. // It returns an error if the edge is not defined in the schema.
  45583. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  45584. switch name {
  45585. case workexperience.EdgeEmployee:
  45586. m.ResetEmployee()
  45587. return nil
  45588. }
  45589. return fmt.Errorf("unknown WorkExperience edge %s", name)
  45590. }
  45591. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  45592. type WpChatroomMutation struct {
  45593. config
  45594. op Op
  45595. typ string
  45596. id *uint64
  45597. created_at *time.Time
  45598. updated_at *time.Time
  45599. status *uint8
  45600. addstatus *int8
  45601. wx_wxid *string
  45602. chatroom_id *string
  45603. nickname *string
  45604. owner *string
  45605. avatar *string
  45606. member_list *[]string
  45607. appendmember_list []string
  45608. clearedFields map[string]struct{}
  45609. done bool
  45610. oldValue func(context.Context) (*WpChatroom, error)
  45611. predicates []predicate.WpChatroom
  45612. }
  45613. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  45614. // wpchatroomOption allows management of the mutation configuration using functional options.
  45615. type wpchatroomOption func(*WpChatroomMutation)
  45616. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  45617. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  45618. m := &WpChatroomMutation{
  45619. config: c,
  45620. op: op,
  45621. typ: TypeWpChatroom,
  45622. clearedFields: make(map[string]struct{}),
  45623. }
  45624. for _, opt := range opts {
  45625. opt(m)
  45626. }
  45627. return m
  45628. }
  45629. // withWpChatroomID sets the ID field of the mutation.
  45630. func withWpChatroomID(id uint64) wpchatroomOption {
  45631. return func(m *WpChatroomMutation) {
  45632. var (
  45633. err error
  45634. once sync.Once
  45635. value *WpChatroom
  45636. )
  45637. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  45638. once.Do(func() {
  45639. if m.done {
  45640. err = errors.New("querying old values post mutation is not allowed")
  45641. } else {
  45642. value, err = m.Client().WpChatroom.Get(ctx, id)
  45643. }
  45644. })
  45645. return value, err
  45646. }
  45647. m.id = &id
  45648. }
  45649. }
  45650. // withWpChatroom sets the old WpChatroom of the mutation.
  45651. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  45652. return func(m *WpChatroomMutation) {
  45653. m.oldValue = func(context.Context) (*WpChatroom, error) {
  45654. return node, nil
  45655. }
  45656. m.id = &node.ID
  45657. }
  45658. }
  45659. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45660. // executed in a transaction (ent.Tx), a transactional client is returned.
  45661. func (m WpChatroomMutation) Client() *Client {
  45662. client := &Client{config: m.config}
  45663. client.init()
  45664. return client
  45665. }
  45666. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45667. // it returns an error otherwise.
  45668. func (m WpChatroomMutation) Tx() (*Tx, error) {
  45669. if _, ok := m.driver.(*txDriver); !ok {
  45670. return nil, errors.New("ent: mutation is not running in a transaction")
  45671. }
  45672. tx := &Tx{config: m.config}
  45673. tx.init()
  45674. return tx, nil
  45675. }
  45676. // SetID sets the value of the id field. Note that this
  45677. // operation is only accepted on creation of WpChatroom entities.
  45678. func (m *WpChatroomMutation) SetID(id uint64) {
  45679. m.id = &id
  45680. }
  45681. // ID returns the ID value in the mutation. Note that the ID is only available
  45682. // if it was provided to the builder or after it was returned from the database.
  45683. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  45684. if m.id == nil {
  45685. return
  45686. }
  45687. return *m.id, true
  45688. }
  45689. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45690. // That means, if the mutation is applied within a transaction with an isolation level such
  45691. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45692. // or updated by the mutation.
  45693. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  45694. switch {
  45695. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45696. id, exists := m.ID()
  45697. if exists {
  45698. return []uint64{id}, nil
  45699. }
  45700. fallthrough
  45701. case m.op.Is(OpUpdate | OpDelete):
  45702. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  45703. default:
  45704. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45705. }
  45706. }
  45707. // SetCreatedAt sets the "created_at" field.
  45708. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  45709. m.created_at = &t
  45710. }
  45711. // CreatedAt returns the value of the "created_at" field in the mutation.
  45712. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  45713. v := m.created_at
  45714. if v == nil {
  45715. return
  45716. }
  45717. return *v, true
  45718. }
  45719. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  45720. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45722. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45723. if !m.op.Is(OpUpdateOne) {
  45724. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45725. }
  45726. if m.id == nil || m.oldValue == nil {
  45727. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45728. }
  45729. oldValue, err := m.oldValue(ctx)
  45730. if err != nil {
  45731. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45732. }
  45733. return oldValue.CreatedAt, nil
  45734. }
  45735. // ResetCreatedAt resets all changes to the "created_at" field.
  45736. func (m *WpChatroomMutation) ResetCreatedAt() {
  45737. m.created_at = nil
  45738. }
  45739. // SetUpdatedAt sets the "updated_at" field.
  45740. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  45741. m.updated_at = &t
  45742. }
  45743. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45744. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  45745. v := m.updated_at
  45746. if v == nil {
  45747. return
  45748. }
  45749. return *v, true
  45750. }
  45751. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  45752. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45754. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45755. if !m.op.Is(OpUpdateOne) {
  45756. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45757. }
  45758. if m.id == nil || m.oldValue == nil {
  45759. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45760. }
  45761. oldValue, err := m.oldValue(ctx)
  45762. if err != nil {
  45763. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45764. }
  45765. return oldValue.UpdatedAt, nil
  45766. }
  45767. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45768. func (m *WpChatroomMutation) ResetUpdatedAt() {
  45769. m.updated_at = nil
  45770. }
  45771. // SetStatus sets the "status" field.
  45772. func (m *WpChatroomMutation) SetStatus(u uint8) {
  45773. m.status = &u
  45774. m.addstatus = nil
  45775. }
  45776. // Status returns the value of the "status" field in the mutation.
  45777. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  45778. v := m.status
  45779. if v == nil {
  45780. return
  45781. }
  45782. return *v, true
  45783. }
  45784. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  45785. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45787. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45788. if !m.op.Is(OpUpdateOne) {
  45789. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45790. }
  45791. if m.id == nil || m.oldValue == nil {
  45792. return v, errors.New("OldStatus requires an ID field in the mutation")
  45793. }
  45794. oldValue, err := m.oldValue(ctx)
  45795. if err != nil {
  45796. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45797. }
  45798. return oldValue.Status, nil
  45799. }
  45800. // AddStatus adds u to the "status" field.
  45801. func (m *WpChatroomMutation) AddStatus(u int8) {
  45802. if m.addstatus != nil {
  45803. *m.addstatus += u
  45804. } else {
  45805. m.addstatus = &u
  45806. }
  45807. }
  45808. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45809. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  45810. v := m.addstatus
  45811. if v == nil {
  45812. return
  45813. }
  45814. return *v, true
  45815. }
  45816. // ClearStatus clears the value of the "status" field.
  45817. func (m *WpChatroomMutation) ClearStatus() {
  45818. m.status = nil
  45819. m.addstatus = nil
  45820. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  45821. }
  45822. // StatusCleared returns if the "status" field was cleared in this mutation.
  45823. func (m *WpChatroomMutation) StatusCleared() bool {
  45824. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  45825. return ok
  45826. }
  45827. // ResetStatus resets all changes to the "status" field.
  45828. func (m *WpChatroomMutation) ResetStatus() {
  45829. m.status = nil
  45830. m.addstatus = nil
  45831. delete(m.clearedFields, wpchatroom.FieldStatus)
  45832. }
  45833. // SetWxWxid sets the "wx_wxid" field.
  45834. func (m *WpChatroomMutation) SetWxWxid(s string) {
  45835. m.wx_wxid = &s
  45836. }
  45837. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45838. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  45839. v := m.wx_wxid
  45840. if v == nil {
  45841. return
  45842. }
  45843. return *v, true
  45844. }
  45845. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  45846. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45848. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45849. if !m.op.Is(OpUpdateOne) {
  45850. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45851. }
  45852. if m.id == nil || m.oldValue == nil {
  45853. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45854. }
  45855. oldValue, err := m.oldValue(ctx)
  45856. if err != nil {
  45857. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45858. }
  45859. return oldValue.WxWxid, nil
  45860. }
  45861. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45862. func (m *WpChatroomMutation) ResetWxWxid() {
  45863. m.wx_wxid = nil
  45864. }
  45865. // SetChatroomID sets the "chatroom_id" field.
  45866. func (m *WpChatroomMutation) SetChatroomID(s string) {
  45867. m.chatroom_id = &s
  45868. }
  45869. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  45870. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  45871. v := m.chatroom_id
  45872. if v == nil {
  45873. return
  45874. }
  45875. return *v, true
  45876. }
  45877. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  45878. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45880. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  45881. if !m.op.Is(OpUpdateOne) {
  45882. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  45883. }
  45884. if m.id == nil || m.oldValue == nil {
  45885. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  45886. }
  45887. oldValue, err := m.oldValue(ctx)
  45888. if err != nil {
  45889. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  45890. }
  45891. return oldValue.ChatroomID, nil
  45892. }
  45893. // ResetChatroomID resets all changes to the "chatroom_id" field.
  45894. func (m *WpChatroomMutation) ResetChatroomID() {
  45895. m.chatroom_id = nil
  45896. }
  45897. // SetNickname sets the "nickname" field.
  45898. func (m *WpChatroomMutation) SetNickname(s string) {
  45899. m.nickname = &s
  45900. }
  45901. // Nickname returns the value of the "nickname" field in the mutation.
  45902. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  45903. v := m.nickname
  45904. if v == nil {
  45905. return
  45906. }
  45907. return *v, true
  45908. }
  45909. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  45910. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45912. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  45913. if !m.op.Is(OpUpdateOne) {
  45914. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45915. }
  45916. if m.id == nil || m.oldValue == nil {
  45917. return v, errors.New("OldNickname requires an ID field in the mutation")
  45918. }
  45919. oldValue, err := m.oldValue(ctx)
  45920. if err != nil {
  45921. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45922. }
  45923. return oldValue.Nickname, nil
  45924. }
  45925. // ResetNickname resets all changes to the "nickname" field.
  45926. func (m *WpChatroomMutation) ResetNickname() {
  45927. m.nickname = nil
  45928. }
  45929. // SetOwner sets the "owner" field.
  45930. func (m *WpChatroomMutation) SetOwner(s string) {
  45931. m.owner = &s
  45932. }
  45933. // Owner returns the value of the "owner" field in the mutation.
  45934. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  45935. v := m.owner
  45936. if v == nil {
  45937. return
  45938. }
  45939. return *v, true
  45940. }
  45941. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  45942. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45944. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  45945. if !m.op.Is(OpUpdateOne) {
  45946. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  45947. }
  45948. if m.id == nil || m.oldValue == nil {
  45949. return v, errors.New("OldOwner requires an ID field in the mutation")
  45950. }
  45951. oldValue, err := m.oldValue(ctx)
  45952. if err != nil {
  45953. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  45954. }
  45955. return oldValue.Owner, nil
  45956. }
  45957. // ResetOwner resets all changes to the "owner" field.
  45958. func (m *WpChatroomMutation) ResetOwner() {
  45959. m.owner = nil
  45960. }
  45961. // SetAvatar sets the "avatar" field.
  45962. func (m *WpChatroomMutation) SetAvatar(s string) {
  45963. m.avatar = &s
  45964. }
  45965. // Avatar returns the value of the "avatar" field in the mutation.
  45966. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  45967. v := m.avatar
  45968. if v == nil {
  45969. return
  45970. }
  45971. return *v, true
  45972. }
  45973. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  45974. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45976. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45977. if !m.op.Is(OpUpdateOne) {
  45978. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45979. }
  45980. if m.id == nil || m.oldValue == nil {
  45981. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45982. }
  45983. oldValue, err := m.oldValue(ctx)
  45984. if err != nil {
  45985. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45986. }
  45987. return oldValue.Avatar, nil
  45988. }
  45989. // ResetAvatar resets all changes to the "avatar" field.
  45990. func (m *WpChatroomMutation) ResetAvatar() {
  45991. m.avatar = nil
  45992. }
  45993. // SetMemberList sets the "member_list" field.
  45994. func (m *WpChatroomMutation) SetMemberList(s []string) {
  45995. m.member_list = &s
  45996. m.appendmember_list = nil
  45997. }
  45998. // MemberList returns the value of the "member_list" field in the mutation.
  45999. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  46000. v := m.member_list
  46001. if v == nil {
  46002. return
  46003. }
  46004. return *v, true
  46005. }
  46006. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  46007. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  46008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46009. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  46010. if !m.op.Is(OpUpdateOne) {
  46011. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  46012. }
  46013. if m.id == nil || m.oldValue == nil {
  46014. return v, errors.New("OldMemberList requires an ID field in the mutation")
  46015. }
  46016. oldValue, err := m.oldValue(ctx)
  46017. if err != nil {
  46018. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  46019. }
  46020. return oldValue.MemberList, nil
  46021. }
  46022. // AppendMemberList adds s to the "member_list" field.
  46023. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  46024. m.appendmember_list = append(m.appendmember_list, s...)
  46025. }
  46026. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  46027. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  46028. if len(m.appendmember_list) == 0 {
  46029. return nil, false
  46030. }
  46031. return m.appendmember_list, true
  46032. }
  46033. // ResetMemberList resets all changes to the "member_list" field.
  46034. func (m *WpChatroomMutation) ResetMemberList() {
  46035. m.member_list = nil
  46036. m.appendmember_list = nil
  46037. }
  46038. // Where appends a list predicates to the WpChatroomMutation builder.
  46039. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  46040. m.predicates = append(m.predicates, ps...)
  46041. }
  46042. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  46043. // users can use type-assertion to append predicates that do not depend on any generated package.
  46044. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  46045. p := make([]predicate.WpChatroom, len(ps))
  46046. for i := range ps {
  46047. p[i] = ps[i]
  46048. }
  46049. m.Where(p...)
  46050. }
  46051. // Op returns the operation name.
  46052. func (m *WpChatroomMutation) Op() Op {
  46053. return m.op
  46054. }
  46055. // SetOp allows setting the mutation operation.
  46056. func (m *WpChatroomMutation) SetOp(op Op) {
  46057. m.op = op
  46058. }
  46059. // Type returns the node type of this mutation (WpChatroom).
  46060. func (m *WpChatroomMutation) Type() string {
  46061. return m.typ
  46062. }
  46063. // Fields returns all fields that were changed during this mutation. Note that in
  46064. // order to get all numeric fields that were incremented/decremented, call
  46065. // AddedFields().
  46066. func (m *WpChatroomMutation) Fields() []string {
  46067. fields := make([]string, 0, 9)
  46068. if m.created_at != nil {
  46069. fields = append(fields, wpchatroom.FieldCreatedAt)
  46070. }
  46071. if m.updated_at != nil {
  46072. fields = append(fields, wpchatroom.FieldUpdatedAt)
  46073. }
  46074. if m.status != nil {
  46075. fields = append(fields, wpchatroom.FieldStatus)
  46076. }
  46077. if m.wx_wxid != nil {
  46078. fields = append(fields, wpchatroom.FieldWxWxid)
  46079. }
  46080. if m.chatroom_id != nil {
  46081. fields = append(fields, wpchatroom.FieldChatroomID)
  46082. }
  46083. if m.nickname != nil {
  46084. fields = append(fields, wpchatroom.FieldNickname)
  46085. }
  46086. if m.owner != nil {
  46087. fields = append(fields, wpchatroom.FieldOwner)
  46088. }
  46089. if m.avatar != nil {
  46090. fields = append(fields, wpchatroom.FieldAvatar)
  46091. }
  46092. if m.member_list != nil {
  46093. fields = append(fields, wpchatroom.FieldMemberList)
  46094. }
  46095. return fields
  46096. }
  46097. // Field returns the value of a field with the given name. The second boolean
  46098. // return value indicates that this field was not set, or was not defined in the
  46099. // schema.
  46100. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  46101. switch name {
  46102. case wpchatroom.FieldCreatedAt:
  46103. return m.CreatedAt()
  46104. case wpchatroom.FieldUpdatedAt:
  46105. return m.UpdatedAt()
  46106. case wpchatroom.FieldStatus:
  46107. return m.Status()
  46108. case wpchatroom.FieldWxWxid:
  46109. return m.WxWxid()
  46110. case wpchatroom.FieldChatroomID:
  46111. return m.ChatroomID()
  46112. case wpchatroom.FieldNickname:
  46113. return m.Nickname()
  46114. case wpchatroom.FieldOwner:
  46115. return m.Owner()
  46116. case wpchatroom.FieldAvatar:
  46117. return m.Avatar()
  46118. case wpchatroom.FieldMemberList:
  46119. return m.MemberList()
  46120. }
  46121. return nil, false
  46122. }
  46123. // OldField returns the old value of the field from the database. An error is
  46124. // returned if the mutation operation is not UpdateOne, or the query to the
  46125. // database failed.
  46126. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46127. switch name {
  46128. case wpchatroom.FieldCreatedAt:
  46129. return m.OldCreatedAt(ctx)
  46130. case wpchatroom.FieldUpdatedAt:
  46131. return m.OldUpdatedAt(ctx)
  46132. case wpchatroom.FieldStatus:
  46133. return m.OldStatus(ctx)
  46134. case wpchatroom.FieldWxWxid:
  46135. return m.OldWxWxid(ctx)
  46136. case wpchatroom.FieldChatroomID:
  46137. return m.OldChatroomID(ctx)
  46138. case wpchatroom.FieldNickname:
  46139. return m.OldNickname(ctx)
  46140. case wpchatroom.FieldOwner:
  46141. return m.OldOwner(ctx)
  46142. case wpchatroom.FieldAvatar:
  46143. return m.OldAvatar(ctx)
  46144. case wpchatroom.FieldMemberList:
  46145. return m.OldMemberList(ctx)
  46146. }
  46147. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  46148. }
  46149. // SetField sets the value of a field with the given name. It returns an error if
  46150. // the field is not defined in the schema, or if the type mismatched the field
  46151. // type.
  46152. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  46153. switch name {
  46154. case wpchatroom.FieldCreatedAt:
  46155. v, ok := value.(time.Time)
  46156. if !ok {
  46157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46158. }
  46159. m.SetCreatedAt(v)
  46160. return nil
  46161. case wpchatroom.FieldUpdatedAt:
  46162. v, ok := value.(time.Time)
  46163. if !ok {
  46164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46165. }
  46166. m.SetUpdatedAt(v)
  46167. return nil
  46168. case wpchatroom.FieldStatus:
  46169. v, ok := value.(uint8)
  46170. if !ok {
  46171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46172. }
  46173. m.SetStatus(v)
  46174. return nil
  46175. case wpchatroom.FieldWxWxid:
  46176. v, ok := value.(string)
  46177. if !ok {
  46178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46179. }
  46180. m.SetWxWxid(v)
  46181. return nil
  46182. case wpchatroom.FieldChatroomID:
  46183. v, ok := value.(string)
  46184. if !ok {
  46185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46186. }
  46187. m.SetChatroomID(v)
  46188. return nil
  46189. case wpchatroom.FieldNickname:
  46190. v, ok := value.(string)
  46191. if !ok {
  46192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46193. }
  46194. m.SetNickname(v)
  46195. return nil
  46196. case wpchatroom.FieldOwner:
  46197. v, ok := value.(string)
  46198. if !ok {
  46199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46200. }
  46201. m.SetOwner(v)
  46202. return nil
  46203. case wpchatroom.FieldAvatar:
  46204. v, ok := value.(string)
  46205. if !ok {
  46206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46207. }
  46208. m.SetAvatar(v)
  46209. return nil
  46210. case wpchatroom.FieldMemberList:
  46211. v, ok := value.([]string)
  46212. if !ok {
  46213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46214. }
  46215. m.SetMemberList(v)
  46216. return nil
  46217. }
  46218. return fmt.Errorf("unknown WpChatroom field %s", name)
  46219. }
  46220. // AddedFields returns all numeric fields that were incremented/decremented during
  46221. // this mutation.
  46222. func (m *WpChatroomMutation) AddedFields() []string {
  46223. var fields []string
  46224. if m.addstatus != nil {
  46225. fields = append(fields, wpchatroom.FieldStatus)
  46226. }
  46227. return fields
  46228. }
  46229. // AddedField returns the numeric value that was incremented/decremented on a field
  46230. // with the given name. The second boolean return value indicates that this field
  46231. // was not set, or was not defined in the schema.
  46232. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  46233. switch name {
  46234. case wpchatroom.FieldStatus:
  46235. return m.AddedStatus()
  46236. }
  46237. return nil, false
  46238. }
  46239. // AddField adds the value to the field with the given name. It returns an error if
  46240. // the field is not defined in the schema, or if the type mismatched the field
  46241. // type.
  46242. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  46243. switch name {
  46244. case wpchatroom.FieldStatus:
  46245. v, ok := value.(int8)
  46246. if !ok {
  46247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46248. }
  46249. m.AddStatus(v)
  46250. return nil
  46251. }
  46252. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  46253. }
  46254. // ClearedFields returns all nullable fields that were cleared during this
  46255. // mutation.
  46256. func (m *WpChatroomMutation) ClearedFields() []string {
  46257. var fields []string
  46258. if m.FieldCleared(wpchatroom.FieldStatus) {
  46259. fields = append(fields, wpchatroom.FieldStatus)
  46260. }
  46261. return fields
  46262. }
  46263. // FieldCleared returns a boolean indicating if a field with the given name was
  46264. // cleared in this mutation.
  46265. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  46266. _, ok := m.clearedFields[name]
  46267. return ok
  46268. }
  46269. // ClearField clears the value of the field with the given name. It returns an
  46270. // error if the field is not defined in the schema.
  46271. func (m *WpChatroomMutation) ClearField(name string) error {
  46272. switch name {
  46273. case wpchatroom.FieldStatus:
  46274. m.ClearStatus()
  46275. return nil
  46276. }
  46277. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  46278. }
  46279. // ResetField resets all changes in the mutation for the field with the given name.
  46280. // It returns an error if the field is not defined in the schema.
  46281. func (m *WpChatroomMutation) ResetField(name string) error {
  46282. switch name {
  46283. case wpchatroom.FieldCreatedAt:
  46284. m.ResetCreatedAt()
  46285. return nil
  46286. case wpchatroom.FieldUpdatedAt:
  46287. m.ResetUpdatedAt()
  46288. return nil
  46289. case wpchatroom.FieldStatus:
  46290. m.ResetStatus()
  46291. return nil
  46292. case wpchatroom.FieldWxWxid:
  46293. m.ResetWxWxid()
  46294. return nil
  46295. case wpchatroom.FieldChatroomID:
  46296. m.ResetChatroomID()
  46297. return nil
  46298. case wpchatroom.FieldNickname:
  46299. m.ResetNickname()
  46300. return nil
  46301. case wpchatroom.FieldOwner:
  46302. m.ResetOwner()
  46303. return nil
  46304. case wpchatroom.FieldAvatar:
  46305. m.ResetAvatar()
  46306. return nil
  46307. case wpchatroom.FieldMemberList:
  46308. m.ResetMemberList()
  46309. return nil
  46310. }
  46311. return fmt.Errorf("unknown WpChatroom field %s", name)
  46312. }
  46313. // AddedEdges returns all edge names that were set/added in this mutation.
  46314. func (m *WpChatroomMutation) AddedEdges() []string {
  46315. edges := make([]string, 0, 0)
  46316. return edges
  46317. }
  46318. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46319. // name in this mutation.
  46320. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  46321. return nil
  46322. }
  46323. // RemovedEdges returns all edge names that were removed in this mutation.
  46324. func (m *WpChatroomMutation) RemovedEdges() []string {
  46325. edges := make([]string, 0, 0)
  46326. return edges
  46327. }
  46328. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46329. // the given name in this mutation.
  46330. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  46331. return nil
  46332. }
  46333. // ClearedEdges returns all edge names that were cleared in this mutation.
  46334. func (m *WpChatroomMutation) ClearedEdges() []string {
  46335. edges := make([]string, 0, 0)
  46336. return edges
  46337. }
  46338. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46339. // was cleared in this mutation.
  46340. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  46341. return false
  46342. }
  46343. // ClearEdge clears the value of the edge with the given name. It returns an error
  46344. // if that edge is not defined in the schema.
  46345. func (m *WpChatroomMutation) ClearEdge(name string) error {
  46346. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  46347. }
  46348. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46349. // It returns an error if the edge is not defined in the schema.
  46350. func (m *WpChatroomMutation) ResetEdge(name string) error {
  46351. return fmt.Errorf("unknown WpChatroom edge %s", name)
  46352. }
  46353. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  46354. type WpChatroomMemberMutation struct {
  46355. config
  46356. op Op
  46357. typ string
  46358. id *uint64
  46359. created_at *time.Time
  46360. updated_at *time.Time
  46361. status *uint8
  46362. addstatus *int8
  46363. wx_wxid *string
  46364. wxid *string
  46365. nickname *string
  46366. avatar *string
  46367. clearedFields map[string]struct{}
  46368. done bool
  46369. oldValue func(context.Context) (*WpChatroomMember, error)
  46370. predicates []predicate.WpChatroomMember
  46371. }
  46372. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  46373. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  46374. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  46375. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  46376. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  46377. m := &WpChatroomMemberMutation{
  46378. config: c,
  46379. op: op,
  46380. typ: TypeWpChatroomMember,
  46381. clearedFields: make(map[string]struct{}),
  46382. }
  46383. for _, opt := range opts {
  46384. opt(m)
  46385. }
  46386. return m
  46387. }
  46388. // withWpChatroomMemberID sets the ID field of the mutation.
  46389. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  46390. return func(m *WpChatroomMemberMutation) {
  46391. var (
  46392. err error
  46393. once sync.Once
  46394. value *WpChatroomMember
  46395. )
  46396. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  46397. once.Do(func() {
  46398. if m.done {
  46399. err = errors.New("querying old values post mutation is not allowed")
  46400. } else {
  46401. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  46402. }
  46403. })
  46404. return value, err
  46405. }
  46406. m.id = &id
  46407. }
  46408. }
  46409. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  46410. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  46411. return func(m *WpChatroomMemberMutation) {
  46412. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  46413. return node, nil
  46414. }
  46415. m.id = &node.ID
  46416. }
  46417. }
  46418. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46419. // executed in a transaction (ent.Tx), a transactional client is returned.
  46420. func (m WpChatroomMemberMutation) Client() *Client {
  46421. client := &Client{config: m.config}
  46422. client.init()
  46423. return client
  46424. }
  46425. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46426. // it returns an error otherwise.
  46427. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  46428. if _, ok := m.driver.(*txDriver); !ok {
  46429. return nil, errors.New("ent: mutation is not running in a transaction")
  46430. }
  46431. tx := &Tx{config: m.config}
  46432. tx.init()
  46433. return tx, nil
  46434. }
  46435. // SetID sets the value of the id field. Note that this
  46436. // operation is only accepted on creation of WpChatroomMember entities.
  46437. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  46438. m.id = &id
  46439. }
  46440. // ID returns the ID value in the mutation. Note that the ID is only available
  46441. // if it was provided to the builder or after it was returned from the database.
  46442. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  46443. if m.id == nil {
  46444. return
  46445. }
  46446. return *m.id, true
  46447. }
  46448. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46449. // That means, if the mutation is applied within a transaction with an isolation level such
  46450. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46451. // or updated by the mutation.
  46452. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  46453. switch {
  46454. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46455. id, exists := m.ID()
  46456. if exists {
  46457. return []uint64{id}, nil
  46458. }
  46459. fallthrough
  46460. case m.op.Is(OpUpdate | OpDelete):
  46461. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  46462. default:
  46463. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46464. }
  46465. }
  46466. // SetCreatedAt sets the "created_at" field.
  46467. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  46468. m.created_at = &t
  46469. }
  46470. // CreatedAt returns the value of the "created_at" field in the mutation.
  46471. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  46472. v := m.created_at
  46473. if v == nil {
  46474. return
  46475. }
  46476. return *v, true
  46477. }
  46478. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  46479. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46481. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46482. if !m.op.Is(OpUpdateOne) {
  46483. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46484. }
  46485. if m.id == nil || m.oldValue == nil {
  46486. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46487. }
  46488. oldValue, err := m.oldValue(ctx)
  46489. if err != nil {
  46490. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46491. }
  46492. return oldValue.CreatedAt, nil
  46493. }
  46494. // ResetCreatedAt resets all changes to the "created_at" field.
  46495. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  46496. m.created_at = nil
  46497. }
  46498. // SetUpdatedAt sets the "updated_at" field.
  46499. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  46500. m.updated_at = &t
  46501. }
  46502. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46503. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  46504. v := m.updated_at
  46505. if v == nil {
  46506. return
  46507. }
  46508. return *v, true
  46509. }
  46510. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  46511. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46513. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46514. if !m.op.Is(OpUpdateOne) {
  46515. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46516. }
  46517. if m.id == nil || m.oldValue == nil {
  46518. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46519. }
  46520. oldValue, err := m.oldValue(ctx)
  46521. if err != nil {
  46522. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46523. }
  46524. return oldValue.UpdatedAt, nil
  46525. }
  46526. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46527. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  46528. m.updated_at = nil
  46529. }
  46530. // SetStatus sets the "status" field.
  46531. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  46532. m.status = &u
  46533. m.addstatus = nil
  46534. }
  46535. // Status returns the value of the "status" field in the mutation.
  46536. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  46537. v := m.status
  46538. if v == nil {
  46539. return
  46540. }
  46541. return *v, true
  46542. }
  46543. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  46544. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46546. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46547. if !m.op.Is(OpUpdateOne) {
  46548. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46549. }
  46550. if m.id == nil || m.oldValue == nil {
  46551. return v, errors.New("OldStatus requires an ID field in the mutation")
  46552. }
  46553. oldValue, err := m.oldValue(ctx)
  46554. if err != nil {
  46555. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46556. }
  46557. return oldValue.Status, nil
  46558. }
  46559. // AddStatus adds u to the "status" field.
  46560. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  46561. if m.addstatus != nil {
  46562. *m.addstatus += u
  46563. } else {
  46564. m.addstatus = &u
  46565. }
  46566. }
  46567. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46568. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  46569. v := m.addstatus
  46570. if v == nil {
  46571. return
  46572. }
  46573. return *v, true
  46574. }
  46575. // ClearStatus clears the value of the "status" field.
  46576. func (m *WpChatroomMemberMutation) ClearStatus() {
  46577. m.status = nil
  46578. m.addstatus = nil
  46579. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  46580. }
  46581. // StatusCleared returns if the "status" field was cleared in this mutation.
  46582. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  46583. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  46584. return ok
  46585. }
  46586. // ResetStatus resets all changes to the "status" field.
  46587. func (m *WpChatroomMemberMutation) ResetStatus() {
  46588. m.status = nil
  46589. m.addstatus = nil
  46590. delete(m.clearedFields, wpchatroommember.FieldStatus)
  46591. }
  46592. // SetWxWxid sets the "wx_wxid" field.
  46593. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  46594. m.wx_wxid = &s
  46595. }
  46596. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  46597. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  46598. v := m.wx_wxid
  46599. if v == nil {
  46600. return
  46601. }
  46602. return *v, true
  46603. }
  46604. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  46605. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46607. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  46608. if !m.op.Is(OpUpdateOne) {
  46609. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  46610. }
  46611. if m.id == nil || m.oldValue == nil {
  46612. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  46613. }
  46614. oldValue, err := m.oldValue(ctx)
  46615. if err != nil {
  46616. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  46617. }
  46618. return oldValue.WxWxid, nil
  46619. }
  46620. // ResetWxWxid resets all changes to the "wx_wxid" field.
  46621. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  46622. m.wx_wxid = nil
  46623. }
  46624. // SetWxid sets the "wxid" field.
  46625. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  46626. m.wxid = &s
  46627. }
  46628. // Wxid returns the value of the "wxid" field in the mutation.
  46629. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  46630. v := m.wxid
  46631. if v == nil {
  46632. return
  46633. }
  46634. return *v, true
  46635. }
  46636. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  46637. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46639. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  46640. if !m.op.Is(OpUpdateOne) {
  46641. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46642. }
  46643. if m.id == nil || m.oldValue == nil {
  46644. return v, errors.New("OldWxid requires an ID field in the mutation")
  46645. }
  46646. oldValue, err := m.oldValue(ctx)
  46647. if err != nil {
  46648. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46649. }
  46650. return oldValue.Wxid, nil
  46651. }
  46652. // ResetWxid resets all changes to the "wxid" field.
  46653. func (m *WpChatroomMemberMutation) ResetWxid() {
  46654. m.wxid = nil
  46655. }
  46656. // SetNickname sets the "nickname" field.
  46657. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  46658. m.nickname = &s
  46659. }
  46660. // Nickname returns the value of the "nickname" field in the mutation.
  46661. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  46662. v := m.nickname
  46663. if v == nil {
  46664. return
  46665. }
  46666. return *v, true
  46667. }
  46668. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  46669. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46671. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  46672. if !m.op.Is(OpUpdateOne) {
  46673. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46674. }
  46675. if m.id == nil || m.oldValue == nil {
  46676. return v, errors.New("OldNickname requires an ID field in the mutation")
  46677. }
  46678. oldValue, err := m.oldValue(ctx)
  46679. if err != nil {
  46680. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46681. }
  46682. return oldValue.Nickname, nil
  46683. }
  46684. // ResetNickname resets all changes to the "nickname" field.
  46685. func (m *WpChatroomMemberMutation) ResetNickname() {
  46686. m.nickname = nil
  46687. }
  46688. // SetAvatar sets the "avatar" field.
  46689. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  46690. m.avatar = &s
  46691. }
  46692. // Avatar returns the value of the "avatar" field in the mutation.
  46693. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  46694. v := m.avatar
  46695. if v == nil {
  46696. return
  46697. }
  46698. return *v, true
  46699. }
  46700. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  46701. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46703. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46704. if !m.op.Is(OpUpdateOne) {
  46705. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46706. }
  46707. if m.id == nil || m.oldValue == nil {
  46708. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46709. }
  46710. oldValue, err := m.oldValue(ctx)
  46711. if err != nil {
  46712. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46713. }
  46714. return oldValue.Avatar, nil
  46715. }
  46716. // ResetAvatar resets all changes to the "avatar" field.
  46717. func (m *WpChatroomMemberMutation) ResetAvatar() {
  46718. m.avatar = nil
  46719. }
  46720. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  46721. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  46722. m.predicates = append(m.predicates, ps...)
  46723. }
  46724. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  46725. // users can use type-assertion to append predicates that do not depend on any generated package.
  46726. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  46727. p := make([]predicate.WpChatroomMember, len(ps))
  46728. for i := range ps {
  46729. p[i] = ps[i]
  46730. }
  46731. m.Where(p...)
  46732. }
  46733. // Op returns the operation name.
  46734. func (m *WpChatroomMemberMutation) Op() Op {
  46735. return m.op
  46736. }
  46737. // SetOp allows setting the mutation operation.
  46738. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  46739. m.op = op
  46740. }
  46741. // Type returns the node type of this mutation (WpChatroomMember).
  46742. func (m *WpChatroomMemberMutation) Type() string {
  46743. return m.typ
  46744. }
  46745. // Fields returns all fields that were changed during this mutation. Note that in
  46746. // order to get all numeric fields that were incremented/decremented, call
  46747. // AddedFields().
  46748. func (m *WpChatroomMemberMutation) Fields() []string {
  46749. fields := make([]string, 0, 7)
  46750. if m.created_at != nil {
  46751. fields = append(fields, wpchatroommember.FieldCreatedAt)
  46752. }
  46753. if m.updated_at != nil {
  46754. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  46755. }
  46756. if m.status != nil {
  46757. fields = append(fields, wpchatroommember.FieldStatus)
  46758. }
  46759. if m.wx_wxid != nil {
  46760. fields = append(fields, wpchatroommember.FieldWxWxid)
  46761. }
  46762. if m.wxid != nil {
  46763. fields = append(fields, wpchatroommember.FieldWxid)
  46764. }
  46765. if m.nickname != nil {
  46766. fields = append(fields, wpchatroommember.FieldNickname)
  46767. }
  46768. if m.avatar != nil {
  46769. fields = append(fields, wpchatroommember.FieldAvatar)
  46770. }
  46771. return fields
  46772. }
  46773. // Field returns the value of a field with the given name. The second boolean
  46774. // return value indicates that this field was not set, or was not defined in the
  46775. // schema.
  46776. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  46777. switch name {
  46778. case wpchatroommember.FieldCreatedAt:
  46779. return m.CreatedAt()
  46780. case wpchatroommember.FieldUpdatedAt:
  46781. return m.UpdatedAt()
  46782. case wpchatroommember.FieldStatus:
  46783. return m.Status()
  46784. case wpchatroommember.FieldWxWxid:
  46785. return m.WxWxid()
  46786. case wpchatroommember.FieldWxid:
  46787. return m.Wxid()
  46788. case wpchatroommember.FieldNickname:
  46789. return m.Nickname()
  46790. case wpchatroommember.FieldAvatar:
  46791. return m.Avatar()
  46792. }
  46793. return nil, false
  46794. }
  46795. // OldField returns the old value of the field from the database. An error is
  46796. // returned if the mutation operation is not UpdateOne, or the query to the
  46797. // database failed.
  46798. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46799. switch name {
  46800. case wpchatroommember.FieldCreatedAt:
  46801. return m.OldCreatedAt(ctx)
  46802. case wpchatroommember.FieldUpdatedAt:
  46803. return m.OldUpdatedAt(ctx)
  46804. case wpchatroommember.FieldStatus:
  46805. return m.OldStatus(ctx)
  46806. case wpchatroommember.FieldWxWxid:
  46807. return m.OldWxWxid(ctx)
  46808. case wpchatroommember.FieldWxid:
  46809. return m.OldWxid(ctx)
  46810. case wpchatroommember.FieldNickname:
  46811. return m.OldNickname(ctx)
  46812. case wpchatroommember.FieldAvatar:
  46813. return m.OldAvatar(ctx)
  46814. }
  46815. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  46816. }
  46817. // SetField sets the value of a field with the given name. It returns an error if
  46818. // the field is not defined in the schema, or if the type mismatched the field
  46819. // type.
  46820. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  46821. switch name {
  46822. case wpchatroommember.FieldCreatedAt:
  46823. v, ok := value.(time.Time)
  46824. if !ok {
  46825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46826. }
  46827. m.SetCreatedAt(v)
  46828. return nil
  46829. case wpchatroommember.FieldUpdatedAt:
  46830. v, ok := value.(time.Time)
  46831. if !ok {
  46832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46833. }
  46834. m.SetUpdatedAt(v)
  46835. return nil
  46836. case wpchatroommember.FieldStatus:
  46837. v, ok := value.(uint8)
  46838. if !ok {
  46839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46840. }
  46841. m.SetStatus(v)
  46842. return nil
  46843. case wpchatroommember.FieldWxWxid:
  46844. v, ok := value.(string)
  46845. if !ok {
  46846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46847. }
  46848. m.SetWxWxid(v)
  46849. return nil
  46850. case wpchatroommember.FieldWxid:
  46851. v, ok := value.(string)
  46852. if !ok {
  46853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46854. }
  46855. m.SetWxid(v)
  46856. return nil
  46857. case wpchatroommember.FieldNickname:
  46858. v, ok := value.(string)
  46859. if !ok {
  46860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46861. }
  46862. m.SetNickname(v)
  46863. return nil
  46864. case wpchatroommember.FieldAvatar:
  46865. v, ok := value.(string)
  46866. if !ok {
  46867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46868. }
  46869. m.SetAvatar(v)
  46870. return nil
  46871. }
  46872. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46873. }
  46874. // AddedFields returns all numeric fields that were incremented/decremented during
  46875. // this mutation.
  46876. func (m *WpChatroomMemberMutation) AddedFields() []string {
  46877. var fields []string
  46878. if m.addstatus != nil {
  46879. fields = append(fields, wpchatroommember.FieldStatus)
  46880. }
  46881. return fields
  46882. }
  46883. // AddedField returns the numeric value that was incremented/decremented on a field
  46884. // with the given name. The second boolean return value indicates that this field
  46885. // was not set, or was not defined in the schema.
  46886. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  46887. switch name {
  46888. case wpchatroommember.FieldStatus:
  46889. return m.AddedStatus()
  46890. }
  46891. return nil, false
  46892. }
  46893. // AddField adds the value to the field with the given name. It returns an error if
  46894. // the field is not defined in the schema, or if the type mismatched the field
  46895. // type.
  46896. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  46897. switch name {
  46898. case wpchatroommember.FieldStatus:
  46899. v, ok := value.(int8)
  46900. if !ok {
  46901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46902. }
  46903. m.AddStatus(v)
  46904. return nil
  46905. }
  46906. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  46907. }
  46908. // ClearedFields returns all nullable fields that were cleared during this
  46909. // mutation.
  46910. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  46911. var fields []string
  46912. if m.FieldCleared(wpchatroommember.FieldStatus) {
  46913. fields = append(fields, wpchatroommember.FieldStatus)
  46914. }
  46915. return fields
  46916. }
  46917. // FieldCleared returns a boolean indicating if a field with the given name was
  46918. // cleared in this mutation.
  46919. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  46920. _, ok := m.clearedFields[name]
  46921. return ok
  46922. }
  46923. // ClearField clears the value of the field with the given name. It returns an
  46924. // error if the field is not defined in the schema.
  46925. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  46926. switch name {
  46927. case wpchatroommember.FieldStatus:
  46928. m.ClearStatus()
  46929. return nil
  46930. }
  46931. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  46932. }
  46933. // ResetField resets all changes in the mutation for the field with the given name.
  46934. // It returns an error if the field is not defined in the schema.
  46935. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  46936. switch name {
  46937. case wpchatroommember.FieldCreatedAt:
  46938. m.ResetCreatedAt()
  46939. return nil
  46940. case wpchatroommember.FieldUpdatedAt:
  46941. m.ResetUpdatedAt()
  46942. return nil
  46943. case wpchatroommember.FieldStatus:
  46944. m.ResetStatus()
  46945. return nil
  46946. case wpchatroommember.FieldWxWxid:
  46947. m.ResetWxWxid()
  46948. return nil
  46949. case wpchatroommember.FieldWxid:
  46950. m.ResetWxid()
  46951. return nil
  46952. case wpchatroommember.FieldNickname:
  46953. m.ResetNickname()
  46954. return nil
  46955. case wpchatroommember.FieldAvatar:
  46956. m.ResetAvatar()
  46957. return nil
  46958. }
  46959. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46960. }
  46961. // AddedEdges returns all edge names that were set/added in this mutation.
  46962. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  46963. edges := make([]string, 0, 0)
  46964. return edges
  46965. }
  46966. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46967. // name in this mutation.
  46968. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  46969. return nil
  46970. }
  46971. // RemovedEdges returns all edge names that were removed in this mutation.
  46972. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  46973. edges := make([]string, 0, 0)
  46974. return edges
  46975. }
  46976. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46977. // the given name in this mutation.
  46978. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  46979. return nil
  46980. }
  46981. // ClearedEdges returns all edge names that were cleared in this mutation.
  46982. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  46983. edges := make([]string, 0, 0)
  46984. return edges
  46985. }
  46986. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46987. // was cleared in this mutation.
  46988. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  46989. return false
  46990. }
  46991. // ClearEdge clears the value of the edge with the given name. It returns an error
  46992. // if that edge is not defined in the schema.
  46993. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  46994. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  46995. }
  46996. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46997. // It returns an error if the edge is not defined in the schema.
  46998. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  46999. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  47000. }
  47001. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  47002. type WxMutation struct {
  47003. config
  47004. op Op
  47005. typ string
  47006. id *uint64
  47007. created_at *time.Time
  47008. updated_at *time.Time
  47009. status *uint8
  47010. addstatus *int8
  47011. deleted_at *time.Time
  47012. port *string
  47013. process_id *string
  47014. callback *string
  47015. wxid *string
  47016. account *string
  47017. nickname *string
  47018. tel *string
  47019. head_big *string
  47020. organization_id *uint64
  47021. addorganization_id *int64
  47022. api_base *string
  47023. api_key *string
  47024. allow_list *[]string
  47025. appendallow_list []string
  47026. group_allow_list *[]string
  47027. appendgroup_allow_list []string
  47028. block_list *[]string
  47029. appendblock_list []string
  47030. group_block_list *[]string
  47031. appendgroup_block_list []string
  47032. ctype *uint64
  47033. addctype *int64
  47034. clearedFields map[string]struct{}
  47035. server *uint64
  47036. clearedserver bool
  47037. agent *uint64
  47038. clearedagent bool
  47039. done bool
  47040. oldValue func(context.Context) (*Wx, error)
  47041. predicates []predicate.Wx
  47042. }
  47043. var _ ent.Mutation = (*WxMutation)(nil)
  47044. // wxOption allows management of the mutation configuration using functional options.
  47045. type wxOption func(*WxMutation)
  47046. // newWxMutation creates new mutation for the Wx entity.
  47047. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  47048. m := &WxMutation{
  47049. config: c,
  47050. op: op,
  47051. typ: TypeWx,
  47052. clearedFields: make(map[string]struct{}),
  47053. }
  47054. for _, opt := range opts {
  47055. opt(m)
  47056. }
  47057. return m
  47058. }
  47059. // withWxID sets the ID field of the mutation.
  47060. func withWxID(id uint64) wxOption {
  47061. return func(m *WxMutation) {
  47062. var (
  47063. err error
  47064. once sync.Once
  47065. value *Wx
  47066. )
  47067. m.oldValue = func(ctx context.Context) (*Wx, error) {
  47068. once.Do(func() {
  47069. if m.done {
  47070. err = errors.New("querying old values post mutation is not allowed")
  47071. } else {
  47072. value, err = m.Client().Wx.Get(ctx, id)
  47073. }
  47074. })
  47075. return value, err
  47076. }
  47077. m.id = &id
  47078. }
  47079. }
  47080. // withWx sets the old Wx of the mutation.
  47081. func withWx(node *Wx) wxOption {
  47082. return func(m *WxMutation) {
  47083. m.oldValue = func(context.Context) (*Wx, error) {
  47084. return node, nil
  47085. }
  47086. m.id = &node.ID
  47087. }
  47088. }
  47089. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47090. // executed in a transaction (ent.Tx), a transactional client is returned.
  47091. func (m WxMutation) Client() *Client {
  47092. client := &Client{config: m.config}
  47093. client.init()
  47094. return client
  47095. }
  47096. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47097. // it returns an error otherwise.
  47098. func (m WxMutation) Tx() (*Tx, error) {
  47099. if _, ok := m.driver.(*txDriver); !ok {
  47100. return nil, errors.New("ent: mutation is not running in a transaction")
  47101. }
  47102. tx := &Tx{config: m.config}
  47103. tx.init()
  47104. return tx, nil
  47105. }
  47106. // SetID sets the value of the id field. Note that this
  47107. // operation is only accepted on creation of Wx entities.
  47108. func (m *WxMutation) SetID(id uint64) {
  47109. m.id = &id
  47110. }
  47111. // ID returns the ID value in the mutation. Note that the ID is only available
  47112. // if it was provided to the builder or after it was returned from the database.
  47113. func (m *WxMutation) ID() (id uint64, exists bool) {
  47114. if m.id == nil {
  47115. return
  47116. }
  47117. return *m.id, true
  47118. }
  47119. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47120. // That means, if the mutation is applied within a transaction with an isolation level such
  47121. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47122. // or updated by the mutation.
  47123. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  47124. switch {
  47125. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47126. id, exists := m.ID()
  47127. if exists {
  47128. return []uint64{id}, nil
  47129. }
  47130. fallthrough
  47131. case m.op.Is(OpUpdate | OpDelete):
  47132. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  47133. default:
  47134. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47135. }
  47136. }
  47137. // SetCreatedAt sets the "created_at" field.
  47138. func (m *WxMutation) SetCreatedAt(t time.Time) {
  47139. m.created_at = &t
  47140. }
  47141. // CreatedAt returns the value of the "created_at" field in the mutation.
  47142. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  47143. v := m.created_at
  47144. if v == nil {
  47145. return
  47146. }
  47147. return *v, true
  47148. }
  47149. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  47150. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47152. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47153. if !m.op.Is(OpUpdateOne) {
  47154. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47155. }
  47156. if m.id == nil || m.oldValue == nil {
  47157. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47158. }
  47159. oldValue, err := m.oldValue(ctx)
  47160. if err != nil {
  47161. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47162. }
  47163. return oldValue.CreatedAt, nil
  47164. }
  47165. // ResetCreatedAt resets all changes to the "created_at" field.
  47166. func (m *WxMutation) ResetCreatedAt() {
  47167. m.created_at = nil
  47168. }
  47169. // SetUpdatedAt sets the "updated_at" field.
  47170. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  47171. m.updated_at = &t
  47172. }
  47173. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47174. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  47175. v := m.updated_at
  47176. if v == nil {
  47177. return
  47178. }
  47179. return *v, true
  47180. }
  47181. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  47182. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47184. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47185. if !m.op.Is(OpUpdateOne) {
  47186. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47187. }
  47188. if m.id == nil || m.oldValue == nil {
  47189. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47190. }
  47191. oldValue, err := m.oldValue(ctx)
  47192. if err != nil {
  47193. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47194. }
  47195. return oldValue.UpdatedAt, nil
  47196. }
  47197. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47198. func (m *WxMutation) ResetUpdatedAt() {
  47199. m.updated_at = nil
  47200. }
  47201. // SetStatus sets the "status" field.
  47202. func (m *WxMutation) SetStatus(u uint8) {
  47203. m.status = &u
  47204. m.addstatus = nil
  47205. }
  47206. // Status returns the value of the "status" field in the mutation.
  47207. func (m *WxMutation) Status() (r uint8, exists bool) {
  47208. v := m.status
  47209. if v == nil {
  47210. return
  47211. }
  47212. return *v, true
  47213. }
  47214. // OldStatus returns the old "status" field's value of the Wx entity.
  47215. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47217. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  47218. if !m.op.Is(OpUpdateOne) {
  47219. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  47220. }
  47221. if m.id == nil || m.oldValue == nil {
  47222. return v, errors.New("OldStatus requires an ID field in the mutation")
  47223. }
  47224. oldValue, err := m.oldValue(ctx)
  47225. if err != nil {
  47226. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  47227. }
  47228. return oldValue.Status, nil
  47229. }
  47230. // AddStatus adds u to the "status" field.
  47231. func (m *WxMutation) AddStatus(u int8) {
  47232. if m.addstatus != nil {
  47233. *m.addstatus += u
  47234. } else {
  47235. m.addstatus = &u
  47236. }
  47237. }
  47238. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47239. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  47240. v := m.addstatus
  47241. if v == nil {
  47242. return
  47243. }
  47244. return *v, true
  47245. }
  47246. // ClearStatus clears the value of the "status" field.
  47247. func (m *WxMutation) ClearStatus() {
  47248. m.status = nil
  47249. m.addstatus = nil
  47250. m.clearedFields[wx.FieldStatus] = struct{}{}
  47251. }
  47252. // StatusCleared returns if the "status" field was cleared in this mutation.
  47253. func (m *WxMutation) StatusCleared() bool {
  47254. _, ok := m.clearedFields[wx.FieldStatus]
  47255. return ok
  47256. }
  47257. // ResetStatus resets all changes to the "status" field.
  47258. func (m *WxMutation) ResetStatus() {
  47259. m.status = nil
  47260. m.addstatus = nil
  47261. delete(m.clearedFields, wx.FieldStatus)
  47262. }
  47263. // SetDeletedAt sets the "deleted_at" field.
  47264. func (m *WxMutation) SetDeletedAt(t time.Time) {
  47265. m.deleted_at = &t
  47266. }
  47267. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47268. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  47269. v := m.deleted_at
  47270. if v == nil {
  47271. return
  47272. }
  47273. return *v, true
  47274. }
  47275. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  47276. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47278. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47279. if !m.op.Is(OpUpdateOne) {
  47280. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47281. }
  47282. if m.id == nil || m.oldValue == nil {
  47283. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47284. }
  47285. oldValue, err := m.oldValue(ctx)
  47286. if err != nil {
  47287. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47288. }
  47289. return oldValue.DeletedAt, nil
  47290. }
  47291. // ClearDeletedAt clears the value of the "deleted_at" field.
  47292. func (m *WxMutation) ClearDeletedAt() {
  47293. m.deleted_at = nil
  47294. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  47295. }
  47296. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47297. func (m *WxMutation) DeletedAtCleared() bool {
  47298. _, ok := m.clearedFields[wx.FieldDeletedAt]
  47299. return ok
  47300. }
  47301. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47302. func (m *WxMutation) ResetDeletedAt() {
  47303. m.deleted_at = nil
  47304. delete(m.clearedFields, wx.FieldDeletedAt)
  47305. }
  47306. // SetServerID sets the "server_id" field.
  47307. func (m *WxMutation) SetServerID(u uint64) {
  47308. m.server = &u
  47309. }
  47310. // ServerID returns the value of the "server_id" field in the mutation.
  47311. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  47312. v := m.server
  47313. if v == nil {
  47314. return
  47315. }
  47316. return *v, true
  47317. }
  47318. // OldServerID returns the old "server_id" field's value of the Wx entity.
  47319. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47321. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  47322. if !m.op.Is(OpUpdateOne) {
  47323. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  47324. }
  47325. if m.id == nil || m.oldValue == nil {
  47326. return v, errors.New("OldServerID requires an ID field in the mutation")
  47327. }
  47328. oldValue, err := m.oldValue(ctx)
  47329. if err != nil {
  47330. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  47331. }
  47332. return oldValue.ServerID, nil
  47333. }
  47334. // ClearServerID clears the value of the "server_id" field.
  47335. func (m *WxMutation) ClearServerID() {
  47336. m.server = nil
  47337. m.clearedFields[wx.FieldServerID] = struct{}{}
  47338. }
  47339. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  47340. func (m *WxMutation) ServerIDCleared() bool {
  47341. _, ok := m.clearedFields[wx.FieldServerID]
  47342. return ok
  47343. }
  47344. // ResetServerID resets all changes to the "server_id" field.
  47345. func (m *WxMutation) ResetServerID() {
  47346. m.server = nil
  47347. delete(m.clearedFields, wx.FieldServerID)
  47348. }
  47349. // SetPort sets the "port" field.
  47350. func (m *WxMutation) SetPort(s string) {
  47351. m.port = &s
  47352. }
  47353. // Port returns the value of the "port" field in the mutation.
  47354. func (m *WxMutation) Port() (r string, exists bool) {
  47355. v := m.port
  47356. if v == nil {
  47357. return
  47358. }
  47359. return *v, true
  47360. }
  47361. // OldPort returns the old "port" field's value of the Wx entity.
  47362. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47364. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  47365. if !m.op.Is(OpUpdateOne) {
  47366. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  47367. }
  47368. if m.id == nil || m.oldValue == nil {
  47369. return v, errors.New("OldPort requires an ID field in the mutation")
  47370. }
  47371. oldValue, err := m.oldValue(ctx)
  47372. if err != nil {
  47373. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  47374. }
  47375. return oldValue.Port, nil
  47376. }
  47377. // ResetPort resets all changes to the "port" field.
  47378. func (m *WxMutation) ResetPort() {
  47379. m.port = nil
  47380. }
  47381. // SetProcessID sets the "process_id" field.
  47382. func (m *WxMutation) SetProcessID(s string) {
  47383. m.process_id = &s
  47384. }
  47385. // ProcessID returns the value of the "process_id" field in the mutation.
  47386. func (m *WxMutation) ProcessID() (r string, exists bool) {
  47387. v := m.process_id
  47388. if v == nil {
  47389. return
  47390. }
  47391. return *v, true
  47392. }
  47393. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  47394. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47396. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  47397. if !m.op.Is(OpUpdateOne) {
  47398. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  47399. }
  47400. if m.id == nil || m.oldValue == nil {
  47401. return v, errors.New("OldProcessID requires an ID field in the mutation")
  47402. }
  47403. oldValue, err := m.oldValue(ctx)
  47404. if err != nil {
  47405. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  47406. }
  47407. return oldValue.ProcessID, nil
  47408. }
  47409. // ResetProcessID resets all changes to the "process_id" field.
  47410. func (m *WxMutation) ResetProcessID() {
  47411. m.process_id = nil
  47412. }
  47413. // SetCallback sets the "callback" field.
  47414. func (m *WxMutation) SetCallback(s string) {
  47415. m.callback = &s
  47416. }
  47417. // Callback returns the value of the "callback" field in the mutation.
  47418. func (m *WxMutation) Callback() (r string, exists bool) {
  47419. v := m.callback
  47420. if v == nil {
  47421. return
  47422. }
  47423. return *v, true
  47424. }
  47425. // OldCallback returns the old "callback" field's value of the Wx entity.
  47426. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47428. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  47429. if !m.op.Is(OpUpdateOne) {
  47430. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  47431. }
  47432. if m.id == nil || m.oldValue == nil {
  47433. return v, errors.New("OldCallback requires an ID field in the mutation")
  47434. }
  47435. oldValue, err := m.oldValue(ctx)
  47436. if err != nil {
  47437. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  47438. }
  47439. return oldValue.Callback, nil
  47440. }
  47441. // ResetCallback resets all changes to the "callback" field.
  47442. func (m *WxMutation) ResetCallback() {
  47443. m.callback = nil
  47444. }
  47445. // SetWxid sets the "wxid" field.
  47446. func (m *WxMutation) SetWxid(s string) {
  47447. m.wxid = &s
  47448. }
  47449. // Wxid returns the value of the "wxid" field in the mutation.
  47450. func (m *WxMutation) Wxid() (r string, exists bool) {
  47451. v := m.wxid
  47452. if v == nil {
  47453. return
  47454. }
  47455. return *v, true
  47456. }
  47457. // OldWxid returns the old "wxid" field's value of the Wx entity.
  47458. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47460. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  47461. if !m.op.Is(OpUpdateOne) {
  47462. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47463. }
  47464. if m.id == nil || m.oldValue == nil {
  47465. return v, errors.New("OldWxid requires an ID field in the mutation")
  47466. }
  47467. oldValue, err := m.oldValue(ctx)
  47468. if err != nil {
  47469. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47470. }
  47471. return oldValue.Wxid, nil
  47472. }
  47473. // ResetWxid resets all changes to the "wxid" field.
  47474. func (m *WxMutation) ResetWxid() {
  47475. m.wxid = nil
  47476. }
  47477. // SetAccount sets the "account" field.
  47478. func (m *WxMutation) SetAccount(s string) {
  47479. m.account = &s
  47480. }
  47481. // Account returns the value of the "account" field in the mutation.
  47482. func (m *WxMutation) Account() (r string, exists bool) {
  47483. v := m.account
  47484. if v == nil {
  47485. return
  47486. }
  47487. return *v, true
  47488. }
  47489. // OldAccount returns the old "account" field's value of the Wx entity.
  47490. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47492. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  47493. if !m.op.Is(OpUpdateOne) {
  47494. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47495. }
  47496. if m.id == nil || m.oldValue == nil {
  47497. return v, errors.New("OldAccount requires an ID field in the mutation")
  47498. }
  47499. oldValue, err := m.oldValue(ctx)
  47500. if err != nil {
  47501. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47502. }
  47503. return oldValue.Account, nil
  47504. }
  47505. // ResetAccount resets all changes to the "account" field.
  47506. func (m *WxMutation) ResetAccount() {
  47507. m.account = nil
  47508. }
  47509. // SetNickname sets the "nickname" field.
  47510. func (m *WxMutation) SetNickname(s string) {
  47511. m.nickname = &s
  47512. }
  47513. // Nickname returns the value of the "nickname" field in the mutation.
  47514. func (m *WxMutation) Nickname() (r string, exists bool) {
  47515. v := m.nickname
  47516. if v == nil {
  47517. return
  47518. }
  47519. return *v, true
  47520. }
  47521. // OldNickname returns the old "nickname" field's value of the Wx entity.
  47522. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47524. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  47525. if !m.op.Is(OpUpdateOne) {
  47526. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47527. }
  47528. if m.id == nil || m.oldValue == nil {
  47529. return v, errors.New("OldNickname requires an ID field in the mutation")
  47530. }
  47531. oldValue, err := m.oldValue(ctx)
  47532. if err != nil {
  47533. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47534. }
  47535. return oldValue.Nickname, nil
  47536. }
  47537. // ResetNickname resets all changes to the "nickname" field.
  47538. func (m *WxMutation) ResetNickname() {
  47539. m.nickname = nil
  47540. }
  47541. // SetTel sets the "tel" field.
  47542. func (m *WxMutation) SetTel(s string) {
  47543. m.tel = &s
  47544. }
  47545. // Tel returns the value of the "tel" field in the mutation.
  47546. func (m *WxMutation) Tel() (r string, exists bool) {
  47547. v := m.tel
  47548. if v == nil {
  47549. return
  47550. }
  47551. return *v, true
  47552. }
  47553. // OldTel returns the old "tel" field's value of the Wx entity.
  47554. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47556. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  47557. if !m.op.Is(OpUpdateOne) {
  47558. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  47559. }
  47560. if m.id == nil || m.oldValue == nil {
  47561. return v, errors.New("OldTel requires an ID field in the mutation")
  47562. }
  47563. oldValue, err := m.oldValue(ctx)
  47564. if err != nil {
  47565. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  47566. }
  47567. return oldValue.Tel, nil
  47568. }
  47569. // ResetTel resets all changes to the "tel" field.
  47570. func (m *WxMutation) ResetTel() {
  47571. m.tel = nil
  47572. }
  47573. // SetHeadBig sets the "head_big" field.
  47574. func (m *WxMutation) SetHeadBig(s string) {
  47575. m.head_big = &s
  47576. }
  47577. // HeadBig returns the value of the "head_big" field in the mutation.
  47578. func (m *WxMutation) HeadBig() (r string, exists bool) {
  47579. v := m.head_big
  47580. if v == nil {
  47581. return
  47582. }
  47583. return *v, true
  47584. }
  47585. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  47586. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47588. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  47589. if !m.op.Is(OpUpdateOne) {
  47590. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  47591. }
  47592. if m.id == nil || m.oldValue == nil {
  47593. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  47594. }
  47595. oldValue, err := m.oldValue(ctx)
  47596. if err != nil {
  47597. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  47598. }
  47599. return oldValue.HeadBig, nil
  47600. }
  47601. // ResetHeadBig resets all changes to the "head_big" field.
  47602. func (m *WxMutation) ResetHeadBig() {
  47603. m.head_big = nil
  47604. }
  47605. // SetOrganizationID sets the "organization_id" field.
  47606. func (m *WxMutation) SetOrganizationID(u uint64) {
  47607. m.organization_id = &u
  47608. m.addorganization_id = nil
  47609. }
  47610. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47611. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  47612. v := m.organization_id
  47613. if v == nil {
  47614. return
  47615. }
  47616. return *v, true
  47617. }
  47618. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  47619. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47621. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47622. if !m.op.Is(OpUpdateOne) {
  47623. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47624. }
  47625. if m.id == nil || m.oldValue == nil {
  47626. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47627. }
  47628. oldValue, err := m.oldValue(ctx)
  47629. if err != nil {
  47630. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47631. }
  47632. return oldValue.OrganizationID, nil
  47633. }
  47634. // AddOrganizationID adds u to the "organization_id" field.
  47635. func (m *WxMutation) AddOrganizationID(u int64) {
  47636. if m.addorganization_id != nil {
  47637. *m.addorganization_id += u
  47638. } else {
  47639. m.addorganization_id = &u
  47640. }
  47641. }
  47642. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47643. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  47644. v := m.addorganization_id
  47645. if v == nil {
  47646. return
  47647. }
  47648. return *v, true
  47649. }
  47650. // ClearOrganizationID clears the value of the "organization_id" field.
  47651. func (m *WxMutation) ClearOrganizationID() {
  47652. m.organization_id = nil
  47653. m.addorganization_id = nil
  47654. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  47655. }
  47656. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  47657. func (m *WxMutation) OrganizationIDCleared() bool {
  47658. _, ok := m.clearedFields[wx.FieldOrganizationID]
  47659. return ok
  47660. }
  47661. // ResetOrganizationID resets all changes to the "organization_id" field.
  47662. func (m *WxMutation) ResetOrganizationID() {
  47663. m.organization_id = nil
  47664. m.addorganization_id = nil
  47665. delete(m.clearedFields, wx.FieldOrganizationID)
  47666. }
  47667. // SetAgentID sets the "agent_id" field.
  47668. func (m *WxMutation) SetAgentID(u uint64) {
  47669. m.agent = &u
  47670. }
  47671. // AgentID returns the value of the "agent_id" field in the mutation.
  47672. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  47673. v := m.agent
  47674. if v == nil {
  47675. return
  47676. }
  47677. return *v, true
  47678. }
  47679. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  47680. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47682. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47683. if !m.op.Is(OpUpdateOne) {
  47684. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47685. }
  47686. if m.id == nil || m.oldValue == nil {
  47687. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47688. }
  47689. oldValue, err := m.oldValue(ctx)
  47690. if err != nil {
  47691. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47692. }
  47693. return oldValue.AgentID, nil
  47694. }
  47695. // ResetAgentID resets all changes to the "agent_id" field.
  47696. func (m *WxMutation) ResetAgentID() {
  47697. m.agent = nil
  47698. }
  47699. // SetAPIBase sets the "api_base" field.
  47700. func (m *WxMutation) SetAPIBase(s string) {
  47701. m.api_base = &s
  47702. }
  47703. // APIBase returns the value of the "api_base" field in the mutation.
  47704. func (m *WxMutation) APIBase() (r string, exists bool) {
  47705. v := m.api_base
  47706. if v == nil {
  47707. return
  47708. }
  47709. return *v, true
  47710. }
  47711. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  47712. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47714. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47715. if !m.op.Is(OpUpdateOne) {
  47716. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47717. }
  47718. if m.id == nil || m.oldValue == nil {
  47719. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47720. }
  47721. oldValue, err := m.oldValue(ctx)
  47722. if err != nil {
  47723. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47724. }
  47725. return oldValue.APIBase, nil
  47726. }
  47727. // ClearAPIBase clears the value of the "api_base" field.
  47728. func (m *WxMutation) ClearAPIBase() {
  47729. m.api_base = nil
  47730. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  47731. }
  47732. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47733. func (m *WxMutation) APIBaseCleared() bool {
  47734. _, ok := m.clearedFields[wx.FieldAPIBase]
  47735. return ok
  47736. }
  47737. // ResetAPIBase resets all changes to the "api_base" field.
  47738. func (m *WxMutation) ResetAPIBase() {
  47739. m.api_base = nil
  47740. delete(m.clearedFields, wx.FieldAPIBase)
  47741. }
  47742. // SetAPIKey sets the "api_key" field.
  47743. func (m *WxMutation) SetAPIKey(s string) {
  47744. m.api_key = &s
  47745. }
  47746. // APIKey returns the value of the "api_key" field in the mutation.
  47747. func (m *WxMutation) APIKey() (r string, exists bool) {
  47748. v := m.api_key
  47749. if v == nil {
  47750. return
  47751. }
  47752. return *v, true
  47753. }
  47754. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  47755. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47757. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47758. if !m.op.Is(OpUpdateOne) {
  47759. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47760. }
  47761. if m.id == nil || m.oldValue == nil {
  47762. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47763. }
  47764. oldValue, err := m.oldValue(ctx)
  47765. if err != nil {
  47766. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47767. }
  47768. return oldValue.APIKey, nil
  47769. }
  47770. // ClearAPIKey clears the value of the "api_key" field.
  47771. func (m *WxMutation) ClearAPIKey() {
  47772. m.api_key = nil
  47773. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  47774. }
  47775. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47776. func (m *WxMutation) APIKeyCleared() bool {
  47777. _, ok := m.clearedFields[wx.FieldAPIKey]
  47778. return ok
  47779. }
  47780. // ResetAPIKey resets all changes to the "api_key" field.
  47781. func (m *WxMutation) ResetAPIKey() {
  47782. m.api_key = nil
  47783. delete(m.clearedFields, wx.FieldAPIKey)
  47784. }
  47785. // SetAllowList sets the "allow_list" field.
  47786. func (m *WxMutation) SetAllowList(s []string) {
  47787. m.allow_list = &s
  47788. m.appendallow_list = nil
  47789. }
  47790. // AllowList returns the value of the "allow_list" field in the mutation.
  47791. func (m *WxMutation) AllowList() (r []string, exists bool) {
  47792. v := m.allow_list
  47793. if v == nil {
  47794. return
  47795. }
  47796. return *v, true
  47797. }
  47798. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  47799. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47801. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  47802. if !m.op.Is(OpUpdateOne) {
  47803. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  47804. }
  47805. if m.id == nil || m.oldValue == nil {
  47806. return v, errors.New("OldAllowList requires an ID field in the mutation")
  47807. }
  47808. oldValue, err := m.oldValue(ctx)
  47809. if err != nil {
  47810. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  47811. }
  47812. return oldValue.AllowList, nil
  47813. }
  47814. // AppendAllowList adds s to the "allow_list" field.
  47815. func (m *WxMutation) AppendAllowList(s []string) {
  47816. m.appendallow_list = append(m.appendallow_list, s...)
  47817. }
  47818. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  47819. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  47820. if len(m.appendallow_list) == 0 {
  47821. return nil, false
  47822. }
  47823. return m.appendallow_list, true
  47824. }
  47825. // ResetAllowList resets all changes to the "allow_list" field.
  47826. func (m *WxMutation) ResetAllowList() {
  47827. m.allow_list = nil
  47828. m.appendallow_list = nil
  47829. }
  47830. // SetGroupAllowList sets the "group_allow_list" field.
  47831. func (m *WxMutation) SetGroupAllowList(s []string) {
  47832. m.group_allow_list = &s
  47833. m.appendgroup_allow_list = nil
  47834. }
  47835. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  47836. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  47837. v := m.group_allow_list
  47838. if v == nil {
  47839. return
  47840. }
  47841. return *v, true
  47842. }
  47843. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  47844. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47846. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  47847. if !m.op.Is(OpUpdateOne) {
  47848. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  47849. }
  47850. if m.id == nil || m.oldValue == nil {
  47851. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  47852. }
  47853. oldValue, err := m.oldValue(ctx)
  47854. if err != nil {
  47855. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  47856. }
  47857. return oldValue.GroupAllowList, nil
  47858. }
  47859. // AppendGroupAllowList adds s to the "group_allow_list" field.
  47860. func (m *WxMutation) AppendGroupAllowList(s []string) {
  47861. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  47862. }
  47863. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  47864. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  47865. if len(m.appendgroup_allow_list) == 0 {
  47866. return nil, false
  47867. }
  47868. return m.appendgroup_allow_list, true
  47869. }
  47870. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  47871. func (m *WxMutation) ResetGroupAllowList() {
  47872. m.group_allow_list = nil
  47873. m.appendgroup_allow_list = nil
  47874. }
  47875. // SetBlockList sets the "block_list" field.
  47876. func (m *WxMutation) SetBlockList(s []string) {
  47877. m.block_list = &s
  47878. m.appendblock_list = nil
  47879. }
  47880. // BlockList returns the value of the "block_list" field in the mutation.
  47881. func (m *WxMutation) BlockList() (r []string, exists bool) {
  47882. v := m.block_list
  47883. if v == nil {
  47884. return
  47885. }
  47886. return *v, true
  47887. }
  47888. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  47889. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47891. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  47892. if !m.op.Is(OpUpdateOne) {
  47893. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  47894. }
  47895. if m.id == nil || m.oldValue == nil {
  47896. return v, errors.New("OldBlockList requires an ID field in the mutation")
  47897. }
  47898. oldValue, err := m.oldValue(ctx)
  47899. if err != nil {
  47900. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  47901. }
  47902. return oldValue.BlockList, nil
  47903. }
  47904. // AppendBlockList adds s to the "block_list" field.
  47905. func (m *WxMutation) AppendBlockList(s []string) {
  47906. m.appendblock_list = append(m.appendblock_list, s...)
  47907. }
  47908. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  47909. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  47910. if len(m.appendblock_list) == 0 {
  47911. return nil, false
  47912. }
  47913. return m.appendblock_list, true
  47914. }
  47915. // ResetBlockList resets all changes to the "block_list" field.
  47916. func (m *WxMutation) ResetBlockList() {
  47917. m.block_list = nil
  47918. m.appendblock_list = nil
  47919. }
  47920. // SetGroupBlockList sets the "group_block_list" field.
  47921. func (m *WxMutation) SetGroupBlockList(s []string) {
  47922. m.group_block_list = &s
  47923. m.appendgroup_block_list = nil
  47924. }
  47925. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  47926. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  47927. v := m.group_block_list
  47928. if v == nil {
  47929. return
  47930. }
  47931. return *v, true
  47932. }
  47933. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  47934. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47936. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  47937. if !m.op.Is(OpUpdateOne) {
  47938. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  47939. }
  47940. if m.id == nil || m.oldValue == nil {
  47941. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  47942. }
  47943. oldValue, err := m.oldValue(ctx)
  47944. if err != nil {
  47945. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  47946. }
  47947. return oldValue.GroupBlockList, nil
  47948. }
  47949. // AppendGroupBlockList adds s to the "group_block_list" field.
  47950. func (m *WxMutation) AppendGroupBlockList(s []string) {
  47951. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  47952. }
  47953. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  47954. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  47955. if len(m.appendgroup_block_list) == 0 {
  47956. return nil, false
  47957. }
  47958. return m.appendgroup_block_list, true
  47959. }
  47960. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  47961. func (m *WxMutation) ResetGroupBlockList() {
  47962. m.group_block_list = nil
  47963. m.appendgroup_block_list = nil
  47964. }
  47965. // SetCtype sets the "ctype" field.
  47966. func (m *WxMutation) SetCtype(u uint64) {
  47967. m.ctype = &u
  47968. m.addctype = nil
  47969. }
  47970. // Ctype returns the value of the "ctype" field in the mutation.
  47971. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  47972. v := m.ctype
  47973. if v == nil {
  47974. return
  47975. }
  47976. return *v, true
  47977. }
  47978. // OldCtype returns the old "ctype" field's value of the Wx entity.
  47979. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47981. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  47982. if !m.op.Is(OpUpdateOne) {
  47983. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  47984. }
  47985. if m.id == nil || m.oldValue == nil {
  47986. return v, errors.New("OldCtype requires an ID field in the mutation")
  47987. }
  47988. oldValue, err := m.oldValue(ctx)
  47989. if err != nil {
  47990. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  47991. }
  47992. return oldValue.Ctype, nil
  47993. }
  47994. // AddCtype adds u to the "ctype" field.
  47995. func (m *WxMutation) AddCtype(u int64) {
  47996. if m.addctype != nil {
  47997. *m.addctype += u
  47998. } else {
  47999. m.addctype = &u
  48000. }
  48001. }
  48002. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  48003. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  48004. v := m.addctype
  48005. if v == nil {
  48006. return
  48007. }
  48008. return *v, true
  48009. }
  48010. // ClearCtype clears the value of the "ctype" field.
  48011. func (m *WxMutation) ClearCtype() {
  48012. m.ctype = nil
  48013. m.addctype = nil
  48014. m.clearedFields[wx.FieldCtype] = struct{}{}
  48015. }
  48016. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  48017. func (m *WxMutation) CtypeCleared() bool {
  48018. _, ok := m.clearedFields[wx.FieldCtype]
  48019. return ok
  48020. }
  48021. // ResetCtype resets all changes to the "ctype" field.
  48022. func (m *WxMutation) ResetCtype() {
  48023. m.ctype = nil
  48024. m.addctype = nil
  48025. delete(m.clearedFields, wx.FieldCtype)
  48026. }
  48027. // ClearServer clears the "server" edge to the Server entity.
  48028. func (m *WxMutation) ClearServer() {
  48029. m.clearedserver = true
  48030. m.clearedFields[wx.FieldServerID] = struct{}{}
  48031. }
  48032. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  48033. func (m *WxMutation) ServerCleared() bool {
  48034. return m.ServerIDCleared() || m.clearedserver
  48035. }
  48036. // ServerIDs returns the "server" edge IDs in the mutation.
  48037. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  48038. // ServerID instead. It exists only for internal usage by the builders.
  48039. func (m *WxMutation) ServerIDs() (ids []uint64) {
  48040. if id := m.server; id != nil {
  48041. ids = append(ids, *id)
  48042. }
  48043. return
  48044. }
  48045. // ResetServer resets all changes to the "server" edge.
  48046. func (m *WxMutation) ResetServer() {
  48047. m.server = nil
  48048. m.clearedserver = false
  48049. }
  48050. // ClearAgent clears the "agent" edge to the Agent entity.
  48051. func (m *WxMutation) ClearAgent() {
  48052. m.clearedagent = true
  48053. m.clearedFields[wx.FieldAgentID] = struct{}{}
  48054. }
  48055. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  48056. func (m *WxMutation) AgentCleared() bool {
  48057. return m.clearedagent
  48058. }
  48059. // AgentIDs returns the "agent" edge IDs in the mutation.
  48060. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  48061. // AgentID instead. It exists only for internal usage by the builders.
  48062. func (m *WxMutation) AgentIDs() (ids []uint64) {
  48063. if id := m.agent; id != nil {
  48064. ids = append(ids, *id)
  48065. }
  48066. return
  48067. }
  48068. // ResetAgent resets all changes to the "agent" edge.
  48069. func (m *WxMutation) ResetAgent() {
  48070. m.agent = nil
  48071. m.clearedagent = false
  48072. }
  48073. // Where appends a list predicates to the WxMutation builder.
  48074. func (m *WxMutation) Where(ps ...predicate.Wx) {
  48075. m.predicates = append(m.predicates, ps...)
  48076. }
  48077. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  48078. // users can use type-assertion to append predicates that do not depend on any generated package.
  48079. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  48080. p := make([]predicate.Wx, len(ps))
  48081. for i := range ps {
  48082. p[i] = ps[i]
  48083. }
  48084. m.Where(p...)
  48085. }
  48086. // Op returns the operation name.
  48087. func (m *WxMutation) Op() Op {
  48088. return m.op
  48089. }
  48090. // SetOp allows setting the mutation operation.
  48091. func (m *WxMutation) SetOp(op Op) {
  48092. m.op = op
  48093. }
  48094. // Type returns the node type of this mutation (Wx).
  48095. func (m *WxMutation) Type() string {
  48096. return m.typ
  48097. }
  48098. // Fields returns all fields that were changed during this mutation. Note that in
  48099. // order to get all numeric fields that were incremented/decremented, call
  48100. // AddedFields().
  48101. func (m *WxMutation) Fields() []string {
  48102. fields := make([]string, 0, 22)
  48103. if m.created_at != nil {
  48104. fields = append(fields, wx.FieldCreatedAt)
  48105. }
  48106. if m.updated_at != nil {
  48107. fields = append(fields, wx.FieldUpdatedAt)
  48108. }
  48109. if m.status != nil {
  48110. fields = append(fields, wx.FieldStatus)
  48111. }
  48112. if m.deleted_at != nil {
  48113. fields = append(fields, wx.FieldDeletedAt)
  48114. }
  48115. if m.server != nil {
  48116. fields = append(fields, wx.FieldServerID)
  48117. }
  48118. if m.port != nil {
  48119. fields = append(fields, wx.FieldPort)
  48120. }
  48121. if m.process_id != nil {
  48122. fields = append(fields, wx.FieldProcessID)
  48123. }
  48124. if m.callback != nil {
  48125. fields = append(fields, wx.FieldCallback)
  48126. }
  48127. if m.wxid != nil {
  48128. fields = append(fields, wx.FieldWxid)
  48129. }
  48130. if m.account != nil {
  48131. fields = append(fields, wx.FieldAccount)
  48132. }
  48133. if m.nickname != nil {
  48134. fields = append(fields, wx.FieldNickname)
  48135. }
  48136. if m.tel != nil {
  48137. fields = append(fields, wx.FieldTel)
  48138. }
  48139. if m.head_big != nil {
  48140. fields = append(fields, wx.FieldHeadBig)
  48141. }
  48142. if m.organization_id != nil {
  48143. fields = append(fields, wx.FieldOrganizationID)
  48144. }
  48145. if m.agent != nil {
  48146. fields = append(fields, wx.FieldAgentID)
  48147. }
  48148. if m.api_base != nil {
  48149. fields = append(fields, wx.FieldAPIBase)
  48150. }
  48151. if m.api_key != nil {
  48152. fields = append(fields, wx.FieldAPIKey)
  48153. }
  48154. if m.allow_list != nil {
  48155. fields = append(fields, wx.FieldAllowList)
  48156. }
  48157. if m.group_allow_list != nil {
  48158. fields = append(fields, wx.FieldGroupAllowList)
  48159. }
  48160. if m.block_list != nil {
  48161. fields = append(fields, wx.FieldBlockList)
  48162. }
  48163. if m.group_block_list != nil {
  48164. fields = append(fields, wx.FieldGroupBlockList)
  48165. }
  48166. if m.ctype != nil {
  48167. fields = append(fields, wx.FieldCtype)
  48168. }
  48169. return fields
  48170. }
  48171. // Field returns the value of a field with the given name. The second boolean
  48172. // return value indicates that this field was not set, or was not defined in the
  48173. // schema.
  48174. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  48175. switch name {
  48176. case wx.FieldCreatedAt:
  48177. return m.CreatedAt()
  48178. case wx.FieldUpdatedAt:
  48179. return m.UpdatedAt()
  48180. case wx.FieldStatus:
  48181. return m.Status()
  48182. case wx.FieldDeletedAt:
  48183. return m.DeletedAt()
  48184. case wx.FieldServerID:
  48185. return m.ServerID()
  48186. case wx.FieldPort:
  48187. return m.Port()
  48188. case wx.FieldProcessID:
  48189. return m.ProcessID()
  48190. case wx.FieldCallback:
  48191. return m.Callback()
  48192. case wx.FieldWxid:
  48193. return m.Wxid()
  48194. case wx.FieldAccount:
  48195. return m.Account()
  48196. case wx.FieldNickname:
  48197. return m.Nickname()
  48198. case wx.FieldTel:
  48199. return m.Tel()
  48200. case wx.FieldHeadBig:
  48201. return m.HeadBig()
  48202. case wx.FieldOrganizationID:
  48203. return m.OrganizationID()
  48204. case wx.FieldAgentID:
  48205. return m.AgentID()
  48206. case wx.FieldAPIBase:
  48207. return m.APIBase()
  48208. case wx.FieldAPIKey:
  48209. return m.APIKey()
  48210. case wx.FieldAllowList:
  48211. return m.AllowList()
  48212. case wx.FieldGroupAllowList:
  48213. return m.GroupAllowList()
  48214. case wx.FieldBlockList:
  48215. return m.BlockList()
  48216. case wx.FieldGroupBlockList:
  48217. return m.GroupBlockList()
  48218. case wx.FieldCtype:
  48219. return m.Ctype()
  48220. }
  48221. return nil, false
  48222. }
  48223. // OldField returns the old value of the field from the database. An error is
  48224. // returned if the mutation operation is not UpdateOne, or the query to the
  48225. // database failed.
  48226. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48227. switch name {
  48228. case wx.FieldCreatedAt:
  48229. return m.OldCreatedAt(ctx)
  48230. case wx.FieldUpdatedAt:
  48231. return m.OldUpdatedAt(ctx)
  48232. case wx.FieldStatus:
  48233. return m.OldStatus(ctx)
  48234. case wx.FieldDeletedAt:
  48235. return m.OldDeletedAt(ctx)
  48236. case wx.FieldServerID:
  48237. return m.OldServerID(ctx)
  48238. case wx.FieldPort:
  48239. return m.OldPort(ctx)
  48240. case wx.FieldProcessID:
  48241. return m.OldProcessID(ctx)
  48242. case wx.FieldCallback:
  48243. return m.OldCallback(ctx)
  48244. case wx.FieldWxid:
  48245. return m.OldWxid(ctx)
  48246. case wx.FieldAccount:
  48247. return m.OldAccount(ctx)
  48248. case wx.FieldNickname:
  48249. return m.OldNickname(ctx)
  48250. case wx.FieldTel:
  48251. return m.OldTel(ctx)
  48252. case wx.FieldHeadBig:
  48253. return m.OldHeadBig(ctx)
  48254. case wx.FieldOrganizationID:
  48255. return m.OldOrganizationID(ctx)
  48256. case wx.FieldAgentID:
  48257. return m.OldAgentID(ctx)
  48258. case wx.FieldAPIBase:
  48259. return m.OldAPIBase(ctx)
  48260. case wx.FieldAPIKey:
  48261. return m.OldAPIKey(ctx)
  48262. case wx.FieldAllowList:
  48263. return m.OldAllowList(ctx)
  48264. case wx.FieldGroupAllowList:
  48265. return m.OldGroupAllowList(ctx)
  48266. case wx.FieldBlockList:
  48267. return m.OldBlockList(ctx)
  48268. case wx.FieldGroupBlockList:
  48269. return m.OldGroupBlockList(ctx)
  48270. case wx.FieldCtype:
  48271. return m.OldCtype(ctx)
  48272. }
  48273. return nil, fmt.Errorf("unknown Wx field %s", name)
  48274. }
  48275. // SetField sets the value of a field with the given name. It returns an error if
  48276. // the field is not defined in the schema, or if the type mismatched the field
  48277. // type.
  48278. func (m *WxMutation) SetField(name string, value ent.Value) error {
  48279. switch name {
  48280. case wx.FieldCreatedAt:
  48281. v, ok := value.(time.Time)
  48282. if !ok {
  48283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48284. }
  48285. m.SetCreatedAt(v)
  48286. return nil
  48287. case wx.FieldUpdatedAt:
  48288. v, ok := value.(time.Time)
  48289. if !ok {
  48290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48291. }
  48292. m.SetUpdatedAt(v)
  48293. return nil
  48294. case wx.FieldStatus:
  48295. v, ok := value.(uint8)
  48296. if !ok {
  48297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48298. }
  48299. m.SetStatus(v)
  48300. return nil
  48301. case wx.FieldDeletedAt:
  48302. v, ok := value.(time.Time)
  48303. if !ok {
  48304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48305. }
  48306. m.SetDeletedAt(v)
  48307. return nil
  48308. case wx.FieldServerID:
  48309. v, ok := value.(uint64)
  48310. if !ok {
  48311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48312. }
  48313. m.SetServerID(v)
  48314. return nil
  48315. case wx.FieldPort:
  48316. v, ok := value.(string)
  48317. if !ok {
  48318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48319. }
  48320. m.SetPort(v)
  48321. return nil
  48322. case wx.FieldProcessID:
  48323. v, ok := value.(string)
  48324. if !ok {
  48325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48326. }
  48327. m.SetProcessID(v)
  48328. return nil
  48329. case wx.FieldCallback:
  48330. v, ok := value.(string)
  48331. if !ok {
  48332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48333. }
  48334. m.SetCallback(v)
  48335. return nil
  48336. case wx.FieldWxid:
  48337. v, ok := value.(string)
  48338. if !ok {
  48339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48340. }
  48341. m.SetWxid(v)
  48342. return nil
  48343. case wx.FieldAccount:
  48344. v, ok := value.(string)
  48345. if !ok {
  48346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48347. }
  48348. m.SetAccount(v)
  48349. return nil
  48350. case wx.FieldNickname:
  48351. v, ok := value.(string)
  48352. if !ok {
  48353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48354. }
  48355. m.SetNickname(v)
  48356. return nil
  48357. case wx.FieldTel:
  48358. v, ok := value.(string)
  48359. if !ok {
  48360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48361. }
  48362. m.SetTel(v)
  48363. return nil
  48364. case wx.FieldHeadBig:
  48365. v, ok := value.(string)
  48366. if !ok {
  48367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48368. }
  48369. m.SetHeadBig(v)
  48370. return nil
  48371. case wx.FieldOrganizationID:
  48372. v, ok := value.(uint64)
  48373. if !ok {
  48374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48375. }
  48376. m.SetOrganizationID(v)
  48377. return nil
  48378. case wx.FieldAgentID:
  48379. v, ok := value.(uint64)
  48380. if !ok {
  48381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48382. }
  48383. m.SetAgentID(v)
  48384. return nil
  48385. case wx.FieldAPIBase:
  48386. v, ok := value.(string)
  48387. if !ok {
  48388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48389. }
  48390. m.SetAPIBase(v)
  48391. return nil
  48392. case wx.FieldAPIKey:
  48393. v, ok := value.(string)
  48394. if !ok {
  48395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48396. }
  48397. m.SetAPIKey(v)
  48398. return nil
  48399. case wx.FieldAllowList:
  48400. v, ok := value.([]string)
  48401. if !ok {
  48402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48403. }
  48404. m.SetAllowList(v)
  48405. return nil
  48406. case wx.FieldGroupAllowList:
  48407. v, ok := value.([]string)
  48408. if !ok {
  48409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48410. }
  48411. m.SetGroupAllowList(v)
  48412. return nil
  48413. case wx.FieldBlockList:
  48414. v, ok := value.([]string)
  48415. if !ok {
  48416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48417. }
  48418. m.SetBlockList(v)
  48419. return nil
  48420. case wx.FieldGroupBlockList:
  48421. v, ok := value.([]string)
  48422. if !ok {
  48423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48424. }
  48425. m.SetGroupBlockList(v)
  48426. return nil
  48427. case wx.FieldCtype:
  48428. v, ok := value.(uint64)
  48429. if !ok {
  48430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48431. }
  48432. m.SetCtype(v)
  48433. return nil
  48434. }
  48435. return fmt.Errorf("unknown Wx field %s", name)
  48436. }
  48437. // AddedFields returns all numeric fields that were incremented/decremented during
  48438. // this mutation.
  48439. func (m *WxMutation) AddedFields() []string {
  48440. var fields []string
  48441. if m.addstatus != nil {
  48442. fields = append(fields, wx.FieldStatus)
  48443. }
  48444. if m.addorganization_id != nil {
  48445. fields = append(fields, wx.FieldOrganizationID)
  48446. }
  48447. if m.addctype != nil {
  48448. fields = append(fields, wx.FieldCtype)
  48449. }
  48450. return fields
  48451. }
  48452. // AddedField returns the numeric value that was incremented/decremented on a field
  48453. // with the given name. The second boolean return value indicates that this field
  48454. // was not set, or was not defined in the schema.
  48455. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  48456. switch name {
  48457. case wx.FieldStatus:
  48458. return m.AddedStatus()
  48459. case wx.FieldOrganizationID:
  48460. return m.AddedOrganizationID()
  48461. case wx.FieldCtype:
  48462. return m.AddedCtype()
  48463. }
  48464. return nil, false
  48465. }
  48466. // AddField adds the value to the field with the given name. It returns an error if
  48467. // the field is not defined in the schema, or if the type mismatched the field
  48468. // type.
  48469. func (m *WxMutation) AddField(name string, value ent.Value) error {
  48470. switch name {
  48471. case wx.FieldStatus:
  48472. v, ok := value.(int8)
  48473. if !ok {
  48474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48475. }
  48476. m.AddStatus(v)
  48477. return nil
  48478. case wx.FieldOrganizationID:
  48479. v, ok := value.(int64)
  48480. if !ok {
  48481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48482. }
  48483. m.AddOrganizationID(v)
  48484. return nil
  48485. case wx.FieldCtype:
  48486. v, ok := value.(int64)
  48487. if !ok {
  48488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48489. }
  48490. m.AddCtype(v)
  48491. return nil
  48492. }
  48493. return fmt.Errorf("unknown Wx numeric field %s", name)
  48494. }
  48495. // ClearedFields returns all nullable fields that were cleared during this
  48496. // mutation.
  48497. func (m *WxMutation) ClearedFields() []string {
  48498. var fields []string
  48499. if m.FieldCleared(wx.FieldStatus) {
  48500. fields = append(fields, wx.FieldStatus)
  48501. }
  48502. if m.FieldCleared(wx.FieldDeletedAt) {
  48503. fields = append(fields, wx.FieldDeletedAt)
  48504. }
  48505. if m.FieldCleared(wx.FieldServerID) {
  48506. fields = append(fields, wx.FieldServerID)
  48507. }
  48508. if m.FieldCleared(wx.FieldOrganizationID) {
  48509. fields = append(fields, wx.FieldOrganizationID)
  48510. }
  48511. if m.FieldCleared(wx.FieldAPIBase) {
  48512. fields = append(fields, wx.FieldAPIBase)
  48513. }
  48514. if m.FieldCleared(wx.FieldAPIKey) {
  48515. fields = append(fields, wx.FieldAPIKey)
  48516. }
  48517. if m.FieldCleared(wx.FieldCtype) {
  48518. fields = append(fields, wx.FieldCtype)
  48519. }
  48520. return fields
  48521. }
  48522. // FieldCleared returns a boolean indicating if a field with the given name was
  48523. // cleared in this mutation.
  48524. func (m *WxMutation) FieldCleared(name string) bool {
  48525. _, ok := m.clearedFields[name]
  48526. return ok
  48527. }
  48528. // ClearField clears the value of the field with the given name. It returns an
  48529. // error if the field is not defined in the schema.
  48530. func (m *WxMutation) ClearField(name string) error {
  48531. switch name {
  48532. case wx.FieldStatus:
  48533. m.ClearStatus()
  48534. return nil
  48535. case wx.FieldDeletedAt:
  48536. m.ClearDeletedAt()
  48537. return nil
  48538. case wx.FieldServerID:
  48539. m.ClearServerID()
  48540. return nil
  48541. case wx.FieldOrganizationID:
  48542. m.ClearOrganizationID()
  48543. return nil
  48544. case wx.FieldAPIBase:
  48545. m.ClearAPIBase()
  48546. return nil
  48547. case wx.FieldAPIKey:
  48548. m.ClearAPIKey()
  48549. return nil
  48550. case wx.FieldCtype:
  48551. m.ClearCtype()
  48552. return nil
  48553. }
  48554. return fmt.Errorf("unknown Wx nullable field %s", name)
  48555. }
  48556. // ResetField resets all changes in the mutation for the field with the given name.
  48557. // It returns an error if the field is not defined in the schema.
  48558. func (m *WxMutation) ResetField(name string) error {
  48559. switch name {
  48560. case wx.FieldCreatedAt:
  48561. m.ResetCreatedAt()
  48562. return nil
  48563. case wx.FieldUpdatedAt:
  48564. m.ResetUpdatedAt()
  48565. return nil
  48566. case wx.FieldStatus:
  48567. m.ResetStatus()
  48568. return nil
  48569. case wx.FieldDeletedAt:
  48570. m.ResetDeletedAt()
  48571. return nil
  48572. case wx.FieldServerID:
  48573. m.ResetServerID()
  48574. return nil
  48575. case wx.FieldPort:
  48576. m.ResetPort()
  48577. return nil
  48578. case wx.FieldProcessID:
  48579. m.ResetProcessID()
  48580. return nil
  48581. case wx.FieldCallback:
  48582. m.ResetCallback()
  48583. return nil
  48584. case wx.FieldWxid:
  48585. m.ResetWxid()
  48586. return nil
  48587. case wx.FieldAccount:
  48588. m.ResetAccount()
  48589. return nil
  48590. case wx.FieldNickname:
  48591. m.ResetNickname()
  48592. return nil
  48593. case wx.FieldTel:
  48594. m.ResetTel()
  48595. return nil
  48596. case wx.FieldHeadBig:
  48597. m.ResetHeadBig()
  48598. return nil
  48599. case wx.FieldOrganizationID:
  48600. m.ResetOrganizationID()
  48601. return nil
  48602. case wx.FieldAgentID:
  48603. m.ResetAgentID()
  48604. return nil
  48605. case wx.FieldAPIBase:
  48606. m.ResetAPIBase()
  48607. return nil
  48608. case wx.FieldAPIKey:
  48609. m.ResetAPIKey()
  48610. return nil
  48611. case wx.FieldAllowList:
  48612. m.ResetAllowList()
  48613. return nil
  48614. case wx.FieldGroupAllowList:
  48615. m.ResetGroupAllowList()
  48616. return nil
  48617. case wx.FieldBlockList:
  48618. m.ResetBlockList()
  48619. return nil
  48620. case wx.FieldGroupBlockList:
  48621. m.ResetGroupBlockList()
  48622. return nil
  48623. case wx.FieldCtype:
  48624. m.ResetCtype()
  48625. return nil
  48626. }
  48627. return fmt.Errorf("unknown Wx field %s", name)
  48628. }
  48629. // AddedEdges returns all edge names that were set/added in this mutation.
  48630. func (m *WxMutation) AddedEdges() []string {
  48631. edges := make([]string, 0, 2)
  48632. if m.server != nil {
  48633. edges = append(edges, wx.EdgeServer)
  48634. }
  48635. if m.agent != nil {
  48636. edges = append(edges, wx.EdgeAgent)
  48637. }
  48638. return edges
  48639. }
  48640. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48641. // name in this mutation.
  48642. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  48643. switch name {
  48644. case wx.EdgeServer:
  48645. if id := m.server; id != nil {
  48646. return []ent.Value{*id}
  48647. }
  48648. case wx.EdgeAgent:
  48649. if id := m.agent; id != nil {
  48650. return []ent.Value{*id}
  48651. }
  48652. }
  48653. return nil
  48654. }
  48655. // RemovedEdges returns all edge names that were removed in this mutation.
  48656. func (m *WxMutation) RemovedEdges() []string {
  48657. edges := make([]string, 0, 2)
  48658. return edges
  48659. }
  48660. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48661. // the given name in this mutation.
  48662. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  48663. return nil
  48664. }
  48665. // ClearedEdges returns all edge names that were cleared in this mutation.
  48666. func (m *WxMutation) ClearedEdges() []string {
  48667. edges := make([]string, 0, 2)
  48668. if m.clearedserver {
  48669. edges = append(edges, wx.EdgeServer)
  48670. }
  48671. if m.clearedagent {
  48672. edges = append(edges, wx.EdgeAgent)
  48673. }
  48674. return edges
  48675. }
  48676. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48677. // was cleared in this mutation.
  48678. func (m *WxMutation) EdgeCleared(name string) bool {
  48679. switch name {
  48680. case wx.EdgeServer:
  48681. return m.clearedserver
  48682. case wx.EdgeAgent:
  48683. return m.clearedagent
  48684. }
  48685. return false
  48686. }
  48687. // ClearEdge clears the value of the edge with the given name. It returns an error
  48688. // if that edge is not defined in the schema.
  48689. func (m *WxMutation) ClearEdge(name string) error {
  48690. switch name {
  48691. case wx.EdgeServer:
  48692. m.ClearServer()
  48693. return nil
  48694. case wx.EdgeAgent:
  48695. m.ClearAgent()
  48696. return nil
  48697. }
  48698. return fmt.Errorf("unknown Wx unique edge %s", name)
  48699. }
  48700. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48701. // It returns an error if the edge is not defined in the schema.
  48702. func (m *WxMutation) ResetEdge(name string) error {
  48703. switch name {
  48704. case wx.EdgeServer:
  48705. m.ResetServer()
  48706. return nil
  48707. case wx.EdgeAgent:
  48708. m.ResetAgent()
  48709. return nil
  48710. }
  48711. return fmt.Errorf("unknown Wx edge %s", name)
  48712. }
  48713. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  48714. type WxCardMutation struct {
  48715. config
  48716. op Op
  48717. typ string
  48718. id *uint64
  48719. created_at *time.Time
  48720. updated_at *time.Time
  48721. deleted_at *time.Time
  48722. user_id *uint64
  48723. adduser_id *int64
  48724. wx_user_id *uint64
  48725. addwx_user_id *int64
  48726. avatar *string
  48727. logo *string
  48728. name *string
  48729. company *string
  48730. address *string
  48731. phone *string
  48732. official_account *string
  48733. wechat_account *string
  48734. email *string
  48735. api_base *string
  48736. api_key *string
  48737. ai_info *string
  48738. intro *string
  48739. clearedFields map[string]struct{}
  48740. done bool
  48741. oldValue func(context.Context) (*WxCard, error)
  48742. predicates []predicate.WxCard
  48743. }
  48744. var _ ent.Mutation = (*WxCardMutation)(nil)
  48745. // wxcardOption allows management of the mutation configuration using functional options.
  48746. type wxcardOption func(*WxCardMutation)
  48747. // newWxCardMutation creates new mutation for the WxCard entity.
  48748. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  48749. m := &WxCardMutation{
  48750. config: c,
  48751. op: op,
  48752. typ: TypeWxCard,
  48753. clearedFields: make(map[string]struct{}),
  48754. }
  48755. for _, opt := range opts {
  48756. opt(m)
  48757. }
  48758. return m
  48759. }
  48760. // withWxCardID sets the ID field of the mutation.
  48761. func withWxCardID(id uint64) wxcardOption {
  48762. return func(m *WxCardMutation) {
  48763. var (
  48764. err error
  48765. once sync.Once
  48766. value *WxCard
  48767. )
  48768. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  48769. once.Do(func() {
  48770. if m.done {
  48771. err = errors.New("querying old values post mutation is not allowed")
  48772. } else {
  48773. value, err = m.Client().WxCard.Get(ctx, id)
  48774. }
  48775. })
  48776. return value, err
  48777. }
  48778. m.id = &id
  48779. }
  48780. }
  48781. // withWxCard sets the old WxCard of the mutation.
  48782. func withWxCard(node *WxCard) wxcardOption {
  48783. return func(m *WxCardMutation) {
  48784. m.oldValue = func(context.Context) (*WxCard, error) {
  48785. return node, nil
  48786. }
  48787. m.id = &node.ID
  48788. }
  48789. }
  48790. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48791. // executed in a transaction (ent.Tx), a transactional client is returned.
  48792. func (m WxCardMutation) Client() *Client {
  48793. client := &Client{config: m.config}
  48794. client.init()
  48795. return client
  48796. }
  48797. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48798. // it returns an error otherwise.
  48799. func (m WxCardMutation) Tx() (*Tx, error) {
  48800. if _, ok := m.driver.(*txDriver); !ok {
  48801. return nil, errors.New("ent: mutation is not running in a transaction")
  48802. }
  48803. tx := &Tx{config: m.config}
  48804. tx.init()
  48805. return tx, nil
  48806. }
  48807. // SetID sets the value of the id field. Note that this
  48808. // operation is only accepted on creation of WxCard entities.
  48809. func (m *WxCardMutation) SetID(id uint64) {
  48810. m.id = &id
  48811. }
  48812. // ID returns the ID value in the mutation. Note that the ID is only available
  48813. // if it was provided to the builder or after it was returned from the database.
  48814. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  48815. if m.id == nil {
  48816. return
  48817. }
  48818. return *m.id, true
  48819. }
  48820. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48821. // That means, if the mutation is applied within a transaction with an isolation level such
  48822. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48823. // or updated by the mutation.
  48824. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  48825. switch {
  48826. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48827. id, exists := m.ID()
  48828. if exists {
  48829. return []uint64{id}, nil
  48830. }
  48831. fallthrough
  48832. case m.op.Is(OpUpdate | OpDelete):
  48833. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  48834. default:
  48835. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48836. }
  48837. }
  48838. // SetCreatedAt sets the "created_at" field.
  48839. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  48840. m.created_at = &t
  48841. }
  48842. // CreatedAt returns the value of the "created_at" field in the mutation.
  48843. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  48844. v := m.created_at
  48845. if v == nil {
  48846. return
  48847. }
  48848. return *v, true
  48849. }
  48850. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  48851. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48853. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48854. if !m.op.Is(OpUpdateOne) {
  48855. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48856. }
  48857. if m.id == nil || m.oldValue == nil {
  48858. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48859. }
  48860. oldValue, err := m.oldValue(ctx)
  48861. if err != nil {
  48862. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48863. }
  48864. return oldValue.CreatedAt, nil
  48865. }
  48866. // ResetCreatedAt resets all changes to the "created_at" field.
  48867. func (m *WxCardMutation) ResetCreatedAt() {
  48868. m.created_at = nil
  48869. }
  48870. // SetUpdatedAt sets the "updated_at" field.
  48871. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  48872. m.updated_at = &t
  48873. }
  48874. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48875. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  48876. v := m.updated_at
  48877. if v == nil {
  48878. return
  48879. }
  48880. return *v, true
  48881. }
  48882. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  48883. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48885. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48886. if !m.op.Is(OpUpdateOne) {
  48887. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48888. }
  48889. if m.id == nil || m.oldValue == nil {
  48890. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48891. }
  48892. oldValue, err := m.oldValue(ctx)
  48893. if err != nil {
  48894. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48895. }
  48896. return oldValue.UpdatedAt, nil
  48897. }
  48898. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48899. func (m *WxCardMutation) ResetUpdatedAt() {
  48900. m.updated_at = nil
  48901. }
  48902. // SetDeletedAt sets the "deleted_at" field.
  48903. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  48904. m.deleted_at = &t
  48905. }
  48906. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48907. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  48908. v := m.deleted_at
  48909. if v == nil {
  48910. return
  48911. }
  48912. return *v, true
  48913. }
  48914. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  48915. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48917. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48918. if !m.op.Is(OpUpdateOne) {
  48919. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48920. }
  48921. if m.id == nil || m.oldValue == nil {
  48922. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48923. }
  48924. oldValue, err := m.oldValue(ctx)
  48925. if err != nil {
  48926. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48927. }
  48928. return oldValue.DeletedAt, nil
  48929. }
  48930. // ClearDeletedAt clears the value of the "deleted_at" field.
  48931. func (m *WxCardMutation) ClearDeletedAt() {
  48932. m.deleted_at = nil
  48933. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  48934. }
  48935. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48936. func (m *WxCardMutation) DeletedAtCleared() bool {
  48937. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  48938. return ok
  48939. }
  48940. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48941. func (m *WxCardMutation) ResetDeletedAt() {
  48942. m.deleted_at = nil
  48943. delete(m.clearedFields, wxcard.FieldDeletedAt)
  48944. }
  48945. // SetUserID sets the "user_id" field.
  48946. func (m *WxCardMutation) SetUserID(u uint64) {
  48947. m.user_id = &u
  48948. m.adduser_id = nil
  48949. }
  48950. // UserID returns the value of the "user_id" field in the mutation.
  48951. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  48952. v := m.user_id
  48953. if v == nil {
  48954. return
  48955. }
  48956. return *v, true
  48957. }
  48958. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  48959. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48961. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48962. if !m.op.Is(OpUpdateOne) {
  48963. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48964. }
  48965. if m.id == nil || m.oldValue == nil {
  48966. return v, errors.New("OldUserID requires an ID field in the mutation")
  48967. }
  48968. oldValue, err := m.oldValue(ctx)
  48969. if err != nil {
  48970. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48971. }
  48972. return oldValue.UserID, nil
  48973. }
  48974. // AddUserID adds u to the "user_id" field.
  48975. func (m *WxCardMutation) AddUserID(u int64) {
  48976. if m.adduser_id != nil {
  48977. *m.adduser_id += u
  48978. } else {
  48979. m.adduser_id = &u
  48980. }
  48981. }
  48982. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48983. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  48984. v := m.adduser_id
  48985. if v == nil {
  48986. return
  48987. }
  48988. return *v, true
  48989. }
  48990. // ClearUserID clears the value of the "user_id" field.
  48991. func (m *WxCardMutation) ClearUserID() {
  48992. m.user_id = nil
  48993. m.adduser_id = nil
  48994. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  48995. }
  48996. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48997. func (m *WxCardMutation) UserIDCleared() bool {
  48998. _, ok := m.clearedFields[wxcard.FieldUserID]
  48999. return ok
  49000. }
  49001. // ResetUserID resets all changes to the "user_id" field.
  49002. func (m *WxCardMutation) ResetUserID() {
  49003. m.user_id = nil
  49004. m.adduser_id = nil
  49005. delete(m.clearedFields, wxcard.FieldUserID)
  49006. }
  49007. // SetWxUserID sets the "wx_user_id" field.
  49008. func (m *WxCardMutation) SetWxUserID(u uint64) {
  49009. m.wx_user_id = &u
  49010. m.addwx_user_id = nil
  49011. }
  49012. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  49013. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  49014. v := m.wx_user_id
  49015. if v == nil {
  49016. return
  49017. }
  49018. return *v, true
  49019. }
  49020. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  49021. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49023. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  49024. if !m.op.Is(OpUpdateOne) {
  49025. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  49026. }
  49027. if m.id == nil || m.oldValue == nil {
  49028. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  49029. }
  49030. oldValue, err := m.oldValue(ctx)
  49031. if err != nil {
  49032. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  49033. }
  49034. return oldValue.WxUserID, nil
  49035. }
  49036. // AddWxUserID adds u to the "wx_user_id" field.
  49037. func (m *WxCardMutation) AddWxUserID(u int64) {
  49038. if m.addwx_user_id != nil {
  49039. *m.addwx_user_id += u
  49040. } else {
  49041. m.addwx_user_id = &u
  49042. }
  49043. }
  49044. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  49045. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  49046. v := m.addwx_user_id
  49047. if v == nil {
  49048. return
  49049. }
  49050. return *v, true
  49051. }
  49052. // ClearWxUserID clears the value of the "wx_user_id" field.
  49053. func (m *WxCardMutation) ClearWxUserID() {
  49054. m.wx_user_id = nil
  49055. m.addwx_user_id = nil
  49056. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  49057. }
  49058. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  49059. func (m *WxCardMutation) WxUserIDCleared() bool {
  49060. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  49061. return ok
  49062. }
  49063. // ResetWxUserID resets all changes to the "wx_user_id" field.
  49064. func (m *WxCardMutation) ResetWxUserID() {
  49065. m.wx_user_id = nil
  49066. m.addwx_user_id = nil
  49067. delete(m.clearedFields, wxcard.FieldWxUserID)
  49068. }
  49069. // SetAvatar sets the "avatar" field.
  49070. func (m *WxCardMutation) SetAvatar(s string) {
  49071. m.avatar = &s
  49072. }
  49073. // Avatar returns the value of the "avatar" field in the mutation.
  49074. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  49075. v := m.avatar
  49076. if v == nil {
  49077. return
  49078. }
  49079. return *v, true
  49080. }
  49081. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  49082. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49084. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  49085. if !m.op.Is(OpUpdateOne) {
  49086. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  49087. }
  49088. if m.id == nil || m.oldValue == nil {
  49089. return v, errors.New("OldAvatar requires an ID field in the mutation")
  49090. }
  49091. oldValue, err := m.oldValue(ctx)
  49092. if err != nil {
  49093. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  49094. }
  49095. return oldValue.Avatar, nil
  49096. }
  49097. // ResetAvatar resets all changes to the "avatar" field.
  49098. func (m *WxCardMutation) ResetAvatar() {
  49099. m.avatar = nil
  49100. }
  49101. // SetLogo sets the "logo" field.
  49102. func (m *WxCardMutation) SetLogo(s string) {
  49103. m.logo = &s
  49104. }
  49105. // Logo returns the value of the "logo" field in the mutation.
  49106. func (m *WxCardMutation) Logo() (r string, exists bool) {
  49107. v := m.logo
  49108. if v == nil {
  49109. return
  49110. }
  49111. return *v, true
  49112. }
  49113. // OldLogo returns the old "logo" field's value of the WxCard entity.
  49114. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49116. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  49117. if !m.op.Is(OpUpdateOne) {
  49118. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  49119. }
  49120. if m.id == nil || m.oldValue == nil {
  49121. return v, errors.New("OldLogo requires an ID field in the mutation")
  49122. }
  49123. oldValue, err := m.oldValue(ctx)
  49124. if err != nil {
  49125. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  49126. }
  49127. return oldValue.Logo, nil
  49128. }
  49129. // ResetLogo resets all changes to the "logo" field.
  49130. func (m *WxCardMutation) ResetLogo() {
  49131. m.logo = nil
  49132. }
  49133. // SetName sets the "name" field.
  49134. func (m *WxCardMutation) SetName(s string) {
  49135. m.name = &s
  49136. }
  49137. // Name returns the value of the "name" field in the mutation.
  49138. func (m *WxCardMutation) Name() (r string, exists bool) {
  49139. v := m.name
  49140. if v == nil {
  49141. return
  49142. }
  49143. return *v, true
  49144. }
  49145. // OldName returns the old "name" field's value of the WxCard entity.
  49146. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49148. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  49149. if !m.op.Is(OpUpdateOne) {
  49150. return v, errors.New("OldName is only allowed on UpdateOne operations")
  49151. }
  49152. if m.id == nil || m.oldValue == nil {
  49153. return v, errors.New("OldName requires an ID field in the mutation")
  49154. }
  49155. oldValue, err := m.oldValue(ctx)
  49156. if err != nil {
  49157. return v, fmt.Errorf("querying old value for OldName: %w", err)
  49158. }
  49159. return oldValue.Name, nil
  49160. }
  49161. // ResetName resets all changes to the "name" field.
  49162. func (m *WxCardMutation) ResetName() {
  49163. m.name = nil
  49164. }
  49165. // SetCompany sets the "company" field.
  49166. func (m *WxCardMutation) SetCompany(s string) {
  49167. m.company = &s
  49168. }
  49169. // Company returns the value of the "company" field in the mutation.
  49170. func (m *WxCardMutation) Company() (r string, exists bool) {
  49171. v := m.company
  49172. if v == nil {
  49173. return
  49174. }
  49175. return *v, true
  49176. }
  49177. // OldCompany returns the old "company" field's value of the WxCard entity.
  49178. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49180. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  49181. if !m.op.Is(OpUpdateOne) {
  49182. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  49183. }
  49184. if m.id == nil || m.oldValue == nil {
  49185. return v, errors.New("OldCompany requires an ID field in the mutation")
  49186. }
  49187. oldValue, err := m.oldValue(ctx)
  49188. if err != nil {
  49189. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  49190. }
  49191. return oldValue.Company, nil
  49192. }
  49193. // ResetCompany resets all changes to the "company" field.
  49194. func (m *WxCardMutation) ResetCompany() {
  49195. m.company = nil
  49196. }
  49197. // SetAddress sets the "address" field.
  49198. func (m *WxCardMutation) SetAddress(s string) {
  49199. m.address = &s
  49200. }
  49201. // Address returns the value of the "address" field in the mutation.
  49202. func (m *WxCardMutation) Address() (r string, exists bool) {
  49203. v := m.address
  49204. if v == nil {
  49205. return
  49206. }
  49207. return *v, true
  49208. }
  49209. // OldAddress returns the old "address" field's value of the WxCard entity.
  49210. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49212. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  49213. if !m.op.Is(OpUpdateOne) {
  49214. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  49215. }
  49216. if m.id == nil || m.oldValue == nil {
  49217. return v, errors.New("OldAddress requires an ID field in the mutation")
  49218. }
  49219. oldValue, err := m.oldValue(ctx)
  49220. if err != nil {
  49221. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  49222. }
  49223. return oldValue.Address, nil
  49224. }
  49225. // ResetAddress resets all changes to the "address" field.
  49226. func (m *WxCardMutation) ResetAddress() {
  49227. m.address = nil
  49228. }
  49229. // SetPhone sets the "phone" field.
  49230. func (m *WxCardMutation) SetPhone(s string) {
  49231. m.phone = &s
  49232. }
  49233. // Phone returns the value of the "phone" field in the mutation.
  49234. func (m *WxCardMutation) Phone() (r string, exists bool) {
  49235. v := m.phone
  49236. if v == nil {
  49237. return
  49238. }
  49239. return *v, true
  49240. }
  49241. // OldPhone returns the old "phone" field's value of the WxCard entity.
  49242. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49244. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  49245. if !m.op.Is(OpUpdateOne) {
  49246. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  49247. }
  49248. if m.id == nil || m.oldValue == nil {
  49249. return v, errors.New("OldPhone requires an ID field in the mutation")
  49250. }
  49251. oldValue, err := m.oldValue(ctx)
  49252. if err != nil {
  49253. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  49254. }
  49255. return oldValue.Phone, nil
  49256. }
  49257. // ResetPhone resets all changes to the "phone" field.
  49258. func (m *WxCardMutation) ResetPhone() {
  49259. m.phone = nil
  49260. }
  49261. // SetOfficialAccount sets the "official_account" field.
  49262. func (m *WxCardMutation) SetOfficialAccount(s string) {
  49263. m.official_account = &s
  49264. }
  49265. // OfficialAccount returns the value of the "official_account" field in the mutation.
  49266. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  49267. v := m.official_account
  49268. if v == nil {
  49269. return
  49270. }
  49271. return *v, true
  49272. }
  49273. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  49274. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49276. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  49277. if !m.op.Is(OpUpdateOne) {
  49278. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  49279. }
  49280. if m.id == nil || m.oldValue == nil {
  49281. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  49282. }
  49283. oldValue, err := m.oldValue(ctx)
  49284. if err != nil {
  49285. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  49286. }
  49287. return oldValue.OfficialAccount, nil
  49288. }
  49289. // ResetOfficialAccount resets all changes to the "official_account" field.
  49290. func (m *WxCardMutation) ResetOfficialAccount() {
  49291. m.official_account = nil
  49292. }
  49293. // SetWechatAccount sets the "wechat_account" field.
  49294. func (m *WxCardMutation) SetWechatAccount(s string) {
  49295. m.wechat_account = &s
  49296. }
  49297. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  49298. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  49299. v := m.wechat_account
  49300. if v == nil {
  49301. return
  49302. }
  49303. return *v, true
  49304. }
  49305. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  49306. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49308. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  49309. if !m.op.Is(OpUpdateOne) {
  49310. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  49311. }
  49312. if m.id == nil || m.oldValue == nil {
  49313. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  49314. }
  49315. oldValue, err := m.oldValue(ctx)
  49316. if err != nil {
  49317. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  49318. }
  49319. return oldValue.WechatAccount, nil
  49320. }
  49321. // ResetWechatAccount resets all changes to the "wechat_account" field.
  49322. func (m *WxCardMutation) ResetWechatAccount() {
  49323. m.wechat_account = nil
  49324. }
  49325. // SetEmail sets the "email" field.
  49326. func (m *WxCardMutation) SetEmail(s string) {
  49327. m.email = &s
  49328. }
  49329. // Email returns the value of the "email" field in the mutation.
  49330. func (m *WxCardMutation) Email() (r string, exists bool) {
  49331. v := m.email
  49332. if v == nil {
  49333. return
  49334. }
  49335. return *v, true
  49336. }
  49337. // OldEmail returns the old "email" field's value of the WxCard entity.
  49338. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49340. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  49341. if !m.op.Is(OpUpdateOne) {
  49342. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  49343. }
  49344. if m.id == nil || m.oldValue == nil {
  49345. return v, errors.New("OldEmail requires an ID field in the mutation")
  49346. }
  49347. oldValue, err := m.oldValue(ctx)
  49348. if err != nil {
  49349. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  49350. }
  49351. return oldValue.Email, nil
  49352. }
  49353. // ClearEmail clears the value of the "email" field.
  49354. func (m *WxCardMutation) ClearEmail() {
  49355. m.email = nil
  49356. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  49357. }
  49358. // EmailCleared returns if the "email" field was cleared in this mutation.
  49359. func (m *WxCardMutation) EmailCleared() bool {
  49360. _, ok := m.clearedFields[wxcard.FieldEmail]
  49361. return ok
  49362. }
  49363. // ResetEmail resets all changes to the "email" field.
  49364. func (m *WxCardMutation) ResetEmail() {
  49365. m.email = nil
  49366. delete(m.clearedFields, wxcard.FieldEmail)
  49367. }
  49368. // SetAPIBase sets the "api_base" field.
  49369. func (m *WxCardMutation) SetAPIBase(s string) {
  49370. m.api_base = &s
  49371. }
  49372. // APIBase returns the value of the "api_base" field in the mutation.
  49373. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  49374. v := m.api_base
  49375. if v == nil {
  49376. return
  49377. }
  49378. return *v, true
  49379. }
  49380. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  49381. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49383. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49384. if !m.op.Is(OpUpdateOne) {
  49385. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49386. }
  49387. if m.id == nil || m.oldValue == nil {
  49388. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49389. }
  49390. oldValue, err := m.oldValue(ctx)
  49391. if err != nil {
  49392. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49393. }
  49394. return oldValue.APIBase, nil
  49395. }
  49396. // ClearAPIBase clears the value of the "api_base" field.
  49397. func (m *WxCardMutation) ClearAPIBase() {
  49398. m.api_base = nil
  49399. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  49400. }
  49401. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49402. func (m *WxCardMutation) APIBaseCleared() bool {
  49403. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  49404. return ok
  49405. }
  49406. // ResetAPIBase resets all changes to the "api_base" field.
  49407. func (m *WxCardMutation) ResetAPIBase() {
  49408. m.api_base = nil
  49409. delete(m.clearedFields, wxcard.FieldAPIBase)
  49410. }
  49411. // SetAPIKey sets the "api_key" field.
  49412. func (m *WxCardMutation) SetAPIKey(s string) {
  49413. m.api_key = &s
  49414. }
  49415. // APIKey returns the value of the "api_key" field in the mutation.
  49416. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  49417. v := m.api_key
  49418. if v == nil {
  49419. return
  49420. }
  49421. return *v, true
  49422. }
  49423. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  49424. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49426. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49427. if !m.op.Is(OpUpdateOne) {
  49428. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49429. }
  49430. if m.id == nil || m.oldValue == nil {
  49431. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49432. }
  49433. oldValue, err := m.oldValue(ctx)
  49434. if err != nil {
  49435. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49436. }
  49437. return oldValue.APIKey, nil
  49438. }
  49439. // ClearAPIKey clears the value of the "api_key" field.
  49440. func (m *WxCardMutation) ClearAPIKey() {
  49441. m.api_key = nil
  49442. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  49443. }
  49444. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49445. func (m *WxCardMutation) APIKeyCleared() bool {
  49446. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  49447. return ok
  49448. }
  49449. // ResetAPIKey resets all changes to the "api_key" field.
  49450. func (m *WxCardMutation) ResetAPIKey() {
  49451. m.api_key = nil
  49452. delete(m.clearedFields, wxcard.FieldAPIKey)
  49453. }
  49454. // SetAiInfo sets the "ai_info" field.
  49455. func (m *WxCardMutation) SetAiInfo(s string) {
  49456. m.ai_info = &s
  49457. }
  49458. // AiInfo returns the value of the "ai_info" field in the mutation.
  49459. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  49460. v := m.ai_info
  49461. if v == nil {
  49462. return
  49463. }
  49464. return *v, true
  49465. }
  49466. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  49467. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49469. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  49470. if !m.op.Is(OpUpdateOne) {
  49471. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  49472. }
  49473. if m.id == nil || m.oldValue == nil {
  49474. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  49475. }
  49476. oldValue, err := m.oldValue(ctx)
  49477. if err != nil {
  49478. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  49479. }
  49480. return oldValue.AiInfo, nil
  49481. }
  49482. // ClearAiInfo clears the value of the "ai_info" field.
  49483. func (m *WxCardMutation) ClearAiInfo() {
  49484. m.ai_info = nil
  49485. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  49486. }
  49487. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  49488. func (m *WxCardMutation) AiInfoCleared() bool {
  49489. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  49490. return ok
  49491. }
  49492. // ResetAiInfo resets all changes to the "ai_info" field.
  49493. func (m *WxCardMutation) ResetAiInfo() {
  49494. m.ai_info = nil
  49495. delete(m.clearedFields, wxcard.FieldAiInfo)
  49496. }
  49497. // SetIntro sets the "intro" field.
  49498. func (m *WxCardMutation) SetIntro(s string) {
  49499. m.intro = &s
  49500. }
  49501. // Intro returns the value of the "intro" field in the mutation.
  49502. func (m *WxCardMutation) Intro() (r string, exists bool) {
  49503. v := m.intro
  49504. if v == nil {
  49505. return
  49506. }
  49507. return *v, true
  49508. }
  49509. // OldIntro returns the old "intro" field's value of the WxCard entity.
  49510. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49512. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  49513. if !m.op.Is(OpUpdateOne) {
  49514. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  49515. }
  49516. if m.id == nil || m.oldValue == nil {
  49517. return v, errors.New("OldIntro requires an ID field in the mutation")
  49518. }
  49519. oldValue, err := m.oldValue(ctx)
  49520. if err != nil {
  49521. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  49522. }
  49523. return oldValue.Intro, nil
  49524. }
  49525. // ClearIntro clears the value of the "intro" field.
  49526. func (m *WxCardMutation) ClearIntro() {
  49527. m.intro = nil
  49528. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  49529. }
  49530. // IntroCleared returns if the "intro" field was cleared in this mutation.
  49531. func (m *WxCardMutation) IntroCleared() bool {
  49532. _, ok := m.clearedFields[wxcard.FieldIntro]
  49533. return ok
  49534. }
  49535. // ResetIntro resets all changes to the "intro" field.
  49536. func (m *WxCardMutation) ResetIntro() {
  49537. m.intro = nil
  49538. delete(m.clearedFields, wxcard.FieldIntro)
  49539. }
  49540. // Where appends a list predicates to the WxCardMutation builder.
  49541. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  49542. m.predicates = append(m.predicates, ps...)
  49543. }
  49544. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  49545. // users can use type-assertion to append predicates that do not depend on any generated package.
  49546. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  49547. p := make([]predicate.WxCard, len(ps))
  49548. for i := range ps {
  49549. p[i] = ps[i]
  49550. }
  49551. m.Where(p...)
  49552. }
  49553. // Op returns the operation name.
  49554. func (m *WxCardMutation) Op() Op {
  49555. return m.op
  49556. }
  49557. // SetOp allows setting the mutation operation.
  49558. func (m *WxCardMutation) SetOp(op Op) {
  49559. m.op = op
  49560. }
  49561. // Type returns the node type of this mutation (WxCard).
  49562. func (m *WxCardMutation) Type() string {
  49563. return m.typ
  49564. }
  49565. // Fields returns all fields that were changed during this mutation. Note that in
  49566. // order to get all numeric fields that were incremented/decremented, call
  49567. // AddedFields().
  49568. func (m *WxCardMutation) Fields() []string {
  49569. fields := make([]string, 0, 18)
  49570. if m.created_at != nil {
  49571. fields = append(fields, wxcard.FieldCreatedAt)
  49572. }
  49573. if m.updated_at != nil {
  49574. fields = append(fields, wxcard.FieldUpdatedAt)
  49575. }
  49576. if m.deleted_at != nil {
  49577. fields = append(fields, wxcard.FieldDeletedAt)
  49578. }
  49579. if m.user_id != nil {
  49580. fields = append(fields, wxcard.FieldUserID)
  49581. }
  49582. if m.wx_user_id != nil {
  49583. fields = append(fields, wxcard.FieldWxUserID)
  49584. }
  49585. if m.avatar != nil {
  49586. fields = append(fields, wxcard.FieldAvatar)
  49587. }
  49588. if m.logo != nil {
  49589. fields = append(fields, wxcard.FieldLogo)
  49590. }
  49591. if m.name != nil {
  49592. fields = append(fields, wxcard.FieldName)
  49593. }
  49594. if m.company != nil {
  49595. fields = append(fields, wxcard.FieldCompany)
  49596. }
  49597. if m.address != nil {
  49598. fields = append(fields, wxcard.FieldAddress)
  49599. }
  49600. if m.phone != nil {
  49601. fields = append(fields, wxcard.FieldPhone)
  49602. }
  49603. if m.official_account != nil {
  49604. fields = append(fields, wxcard.FieldOfficialAccount)
  49605. }
  49606. if m.wechat_account != nil {
  49607. fields = append(fields, wxcard.FieldWechatAccount)
  49608. }
  49609. if m.email != nil {
  49610. fields = append(fields, wxcard.FieldEmail)
  49611. }
  49612. if m.api_base != nil {
  49613. fields = append(fields, wxcard.FieldAPIBase)
  49614. }
  49615. if m.api_key != nil {
  49616. fields = append(fields, wxcard.FieldAPIKey)
  49617. }
  49618. if m.ai_info != nil {
  49619. fields = append(fields, wxcard.FieldAiInfo)
  49620. }
  49621. if m.intro != nil {
  49622. fields = append(fields, wxcard.FieldIntro)
  49623. }
  49624. return fields
  49625. }
  49626. // Field returns the value of a field with the given name. The second boolean
  49627. // return value indicates that this field was not set, or was not defined in the
  49628. // schema.
  49629. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  49630. switch name {
  49631. case wxcard.FieldCreatedAt:
  49632. return m.CreatedAt()
  49633. case wxcard.FieldUpdatedAt:
  49634. return m.UpdatedAt()
  49635. case wxcard.FieldDeletedAt:
  49636. return m.DeletedAt()
  49637. case wxcard.FieldUserID:
  49638. return m.UserID()
  49639. case wxcard.FieldWxUserID:
  49640. return m.WxUserID()
  49641. case wxcard.FieldAvatar:
  49642. return m.Avatar()
  49643. case wxcard.FieldLogo:
  49644. return m.Logo()
  49645. case wxcard.FieldName:
  49646. return m.Name()
  49647. case wxcard.FieldCompany:
  49648. return m.Company()
  49649. case wxcard.FieldAddress:
  49650. return m.Address()
  49651. case wxcard.FieldPhone:
  49652. return m.Phone()
  49653. case wxcard.FieldOfficialAccount:
  49654. return m.OfficialAccount()
  49655. case wxcard.FieldWechatAccount:
  49656. return m.WechatAccount()
  49657. case wxcard.FieldEmail:
  49658. return m.Email()
  49659. case wxcard.FieldAPIBase:
  49660. return m.APIBase()
  49661. case wxcard.FieldAPIKey:
  49662. return m.APIKey()
  49663. case wxcard.FieldAiInfo:
  49664. return m.AiInfo()
  49665. case wxcard.FieldIntro:
  49666. return m.Intro()
  49667. }
  49668. return nil, false
  49669. }
  49670. // OldField returns the old value of the field from the database. An error is
  49671. // returned if the mutation operation is not UpdateOne, or the query to the
  49672. // database failed.
  49673. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49674. switch name {
  49675. case wxcard.FieldCreatedAt:
  49676. return m.OldCreatedAt(ctx)
  49677. case wxcard.FieldUpdatedAt:
  49678. return m.OldUpdatedAt(ctx)
  49679. case wxcard.FieldDeletedAt:
  49680. return m.OldDeletedAt(ctx)
  49681. case wxcard.FieldUserID:
  49682. return m.OldUserID(ctx)
  49683. case wxcard.FieldWxUserID:
  49684. return m.OldWxUserID(ctx)
  49685. case wxcard.FieldAvatar:
  49686. return m.OldAvatar(ctx)
  49687. case wxcard.FieldLogo:
  49688. return m.OldLogo(ctx)
  49689. case wxcard.FieldName:
  49690. return m.OldName(ctx)
  49691. case wxcard.FieldCompany:
  49692. return m.OldCompany(ctx)
  49693. case wxcard.FieldAddress:
  49694. return m.OldAddress(ctx)
  49695. case wxcard.FieldPhone:
  49696. return m.OldPhone(ctx)
  49697. case wxcard.FieldOfficialAccount:
  49698. return m.OldOfficialAccount(ctx)
  49699. case wxcard.FieldWechatAccount:
  49700. return m.OldWechatAccount(ctx)
  49701. case wxcard.FieldEmail:
  49702. return m.OldEmail(ctx)
  49703. case wxcard.FieldAPIBase:
  49704. return m.OldAPIBase(ctx)
  49705. case wxcard.FieldAPIKey:
  49706. return m.OldAPIKey(ctx)
  49707. case wxcard.FieldAiInfo:
  49708. return m.OldAiInfo(ctx)
  49709. case wxcard.FieldIntro:
  49710. return m.OldIntro(ctx)
  49711. }
  49712. return nil, fmt.Errorf("unknown WxCard field %s", name)
  49713. }
  49714. // SetField sets the value of a field with the given name. It returns an error if
  49715. // the field is not defined in the schema, or if the type mismatched the field
  49716. // type.
  49717. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  49718. switch name {
  49719. case wxcard.FieldCreatedAt:
  49720. v, ok := value.(time.Time)
  49721. if !ok {
  49722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49723. }
  49724. m.SetCreatedAt(v)
  49725. return nil
  49726. case wxcard.FieldUpdatedAt:
  49727. v, ok := value.(time.Time)
  49728. if !ok {
  49729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49730. }
  49731. m.SetUpdatedAt(v)
  49732. return nil
  49733. case wxcard.FieldDeletedAt:
  49734. v, ok := value.(time.Time)
  49735. if !ok {
  49736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49737. }
  49738. m.SetDeletedAt(v)
  49739. return nil
  49740. case wxcard.FieldUserID:
  49741. v, ok := value.(uint64)
  49742. if !ok {
  49743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49744. }
  49745. m.SetUserID(v)
  49746. return nil
  49747. case wxcard.FieldWxUserID:
  49748. v, ok := value.(uint64)
  49749. if !ok {
  49750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49751. }
  49752. m.SetWxUserID(v)
  49753. return nil
  49754. case wxcard.FieldAvatar:
  49755. v, ok := value.(string)
  49756. if !ok {
  49757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49758. }
  49759. m.SetAvatar(v)
  49760. return nil
  49761. case wxcard.FieldLogo:
  49762. v, ok := value.(string)
  49763. if !ok {
  49764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49765. }
  49766. m.SetLogo(v)
  49767. return nil
  49768. case wxcard.FieldName:
  49769. v, ok := value.(string)
  49770. if !ok {
  49771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49772. }
  49773. m.SetName(v)
  49774. return nil
  49775. case wxcard.FieldCompany:
  49776. v, ok := value.(string)
  49777. if !ok {
  49778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49779. }
  49780. m.SetCompany(v)
  49781. return nil
  49782. case wxcard.FieldAddress:
  49783. v, ok := value.(string)
  49784. if !ok {
  49785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49786. }
  49787. m.SetAddress(v)
  49788. return nil
  49789. case wxcard.FieldPhone:
  49790. v, ok := value.(string)
  49791. if !ok {
  49792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49793. }
  49794. m.SetPhone(v)
  49795. return nil
  49796. case wxcard.FieldOfficialAccount:
  49797. v, ok := value.(string)
  49798. if !ok {
  49799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49800. }
  49801. m.SetOfficialAccount(v)
  49802. return nil
  49803. case wxcard.FieldWechatAccount:
  49804. v, ok := value.(string)
  49805. if !ok {
  49806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49807. }
  49808. m.SetWechatAccount(v)
  49809. return nil
  49810. case wxcard.FieldEmail:
  49811. v, ok := value.(string)
  49812. if !ok {
  49813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49814. }
  49815. m.SetEmail(v)
  49816. return nil
  49817. case wxcard.FieldAPIBase:
  49818. v, ok := value.(string)
  49819. if !ok {
  49820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49821. }
  49822. m.SetAPIBase(v)
  49823. return nil
  49824. case wxcard.FieldAPIKey:
  49825. v, ok := value.(string)
  49826. if !ok {
  49827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49828. }
  49829. m.SetAPIKey(v)
  49830. return nil
  49831. case wxcard.FieldAiInfo:
  49832. v, ok := value.(string)
  49833. if !ok {
  49834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49835. }
  49836. m.SetAiInfo(v)
  49837. return nil
  49838. case wxcard.FieldIntro:
  49839. v, ok := value.(string)
  49840. if !ok {
  49841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49842. }
  49843. m.SetIntro(v)
  49844. return nil
  49845. }
  49846. return fmt.Errorf("unknown WxCard field %s", name)
  49847. }
  49848. // AddedFields returns all numeric fields that were incremented/decremented during
  49849. // this mutation.
  49850. func (m *WxCardMutation) AddedFields() []string {
  49851. var fields []string
  49852. if m.adduser_id != nil {
  49853. fields = append(fields, wxcard.FieldUserID)
  49854. }
  49855. if m.addwx_user_id != nil {
  49856. fields = append(fields, wxcard.FieldWxUserID)
  49857. }
  49858. return fields
  49859. }
  49860. // AddedField returns the numeric value that was incremented/decremented on a field
  49861. // with the given name. The second boolean return value indicates that this field
  49862. // was not set, or was not defined in the schema.
  49863. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  49864. switch name {
  49865. case wxcard.FieldUserID:
  49866. return m.AddedUserID()
  49867. case wxcard.FieldWxUserID:
  49868. return m.AddedWxUserID()
  49869. }
  49870. return nil, false
  49871. }
  49872. // AddField adds the value to the field with the given name. It returns an error if
  49873. // the field is not defined in the schema, or if the type mismatched the field
  49874. // type.
  49875. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  49876. switch name {
  49877. case wxcard.FieldUserID:
  49878. v, ok := value.(int64)
  49879. if !ok {
  49880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49881. }
  49882. m.AddUserID(v)
  49883. return nil
  49884. case wxcard.FieldWxUserID:
  49885. v, ok := value.(int64)
  49886. if !ok {
  49887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49888. }
  49889. m.AddWxUserID(v)
  49890. return nil
  49891. }
  49892. return fmt.Errorf("unknown WxCard numeric field %s", name)
  49893. }
  49894. // ClearedFields returns all nullable fields that were cleared during this
  49895. // mutation.
  49896. func (m *WxCardMutation) ClearedFields() []string {
  49897. var fields []string
  49898. if m.FieldCleared(wxcard.FieldDeletedAt) {
  49899. fields = append(fields, wxcard.FieldDeletedAt)
  49900. }
  49901. if m.FieldCleared(wxcard.FieldUserID) {
  49902. fields = append(fields, wxcard.FieldUserID)
  49903. }
  49904. if m.FieldCleared(wxcard.FieldWxUserID) {
  49905. fields = append(fields, wxcard.FieldWxUserID)
  49906. }
  49907. if m.FieldCleared(wxcard.FieldEmail) {
  49908. fields = append(fields, wxcard.FieldEmail)
  49909. }
  49910. if m.FieldCleared(wxcard.FieldAPIBase) {
  49911. fields = append(fields, wxcard.FieldAPIBase)
  49912. }
  49913. if m.FieldCleared(wxcard.FieldAPIKey) {
  49914. fields = append(fields, wxcard.FieldAPIKey)
  49915. }
  49916. if m.FieldCleared(wxcard.FieldAiInfo) {
  49917. fields = append(fields, wxcard.FieldAiInfo)
  49918. }
  49919. if m.FieldCleared(wxcard.FieldIntro) {
  49920. fields = append(fields, wxcard.FieldIntro)
  49921. }
  49922. return fields
  49923. }
  49924. // FieldCleared returns a boolean indicating if a field with the given name was
  49925. // cleared in this mutation.
  49926. func (m *WxCardMutation) FieldCleared(name string) bool {
  49927. _, ok := m.clearedFields[name]
  49928. return ok
  49929. }
  49930. // ClearField clears the value of the field with the given name. It returns an
  49931. // error if the field is not defined in the schema.
  49932. func (m *WxCardMutation) ClearField(name string) error {
  49933. switch name {
  49934. case wxcard.FieldDeletedAt:
  49935. m.ClearDeletedAt()
  49936. return nil
  49937. case wxcard.FieldUserID:
  49938. m.ClearUserID()
  49939. return nil
  49940. case wxcard.FieldWxUserID:
  49941. m.ClearWxUserID()
  49942. return nil
  49943. case wxcard.FieldEmail:
  49944. m.ClearEmail()
  49945. return nil
  49946. case wxcard.FieldAPIBase:
  49947. m.ClearAPIBase()
  49948. return nil
  49949. case wxcard.FieldAPIKey:
  49950. m.ClearAPIKey()
  49951. return nil
  49952. case wxcard.FieldAiInfo:
  49953. m.ClearAiInfo()
  49954. return nil
  49955. case wxcard.FieldIntro:
  49956. m.ClearIntro()
  49957. return nil
  49958. }
  49959. return fmt.Errorf("unknown WxCard nullable field %s", name)
  49960. }
  49961. // ResetField resets all changes in the mutation for the field with the given name.
  49962. // It returns an error if the field is not defined in the schema.
  49963. func (m *WxCardMutation) ResetField(name string) error {
  49964. switch name {
  49965. case wxcard.FieldCreatedAt:
  49966. m.ResetCreatedAt()
  49967. return nil
  49968. case wxcard.FieldUpdatedAt:
  49969. m.ResetUpdatedAt()
  49970. return nil
  49971. case wxcard.FieldDeletedAt:
  49972. m.ResetDeletedAt()
  49973. return nil
  49974. case wxcard.FieldUserID:
  49975. m.ResetUserID()
  49976. return nil
  49977. case wxcard.FieldWxUserID:
  49978. m.ResetWxUserID()
  49979. return nil
  49980. case wxcard.FieldAvatar:
  49981. m.ResetAvatar()
  49982. return nil
  49983. case wxcard.FieldLogo:
  49984. m.ResetLogo()
  49985. return nil
  49986. case wxcard.FieldName:
  49987. m.ResetName()
  49988. return nil
  49989. case wxcard.FieldCompany:
  49990. m.ResetCompany()
  49991. return nil
  49992. case wxcard.FieldAddress:
  49993. m.ResetAddress()
  49994. return nil
  49995. case wxcard.FieldPhone:
  49996. m.ResetPhone()
  49997. return nil
  49998. case wxcard.FieldOfficialAccount:
  49999. m.ResetOfficialAccount()
  50000. return nil
  50001. case wxcard.FieldWechatAccount:
  50002. m.ResetWechatAccount()
  50003. return nil
  50004. case wxcard.FieldEmail:
  50005. m.ResetEmail()
  50006. return nil
  50007. case wxcard.FieldAPIBase:
  50008. m.ResetAPIBase()
  50009. return nil
  50010. case wxcard.FieldAPIKey:
  50011. m.ResetAPIKey()
  50012. return nil
  50013. case wxcard.FieldAiInfo:
  50014. m.ResetAiInfo()
  50015. return nil
  50016. case wxcard.FieldIntro:
  50017. m.ResetIntro()
  50018. return nil
  50019. }
  50020. return fmt.Errorf("unknown WxCard field %s", name)
  50021. }
  50022. // AddedEdges returns all edge names that were set/added in this mutation.
  50023. func (m *WxCardMutation) AddedEdges() []string {
  50024. edges := make([]string, 0, 0)
  50025. return edges
  50026. }
  50027. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50028. // name in this mutation.
  50029. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  50030. return nil
  50031. }
  50032. // RemovedEdges returns all edge names that were removed in this mutation.
  50033. func (m *WxCardMutation) RemovedEdges() []string {
  50034. edges := make([]string, 0, 0)
  50035. return edges
  50036. }
  50037. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50038. // the given name in this mutation.
  50039. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  50040. return nil
  50041. }
  50042. // ClearedEdges returns all edge names that were cleared in this mutation.
  50043. func (m *WxCardMutation) ClearedEdges() []string {
  50044. edges := make([]string, 0, 0)
  50045. return edges
  50046. }
  50047. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50048. // was cleared in this mutation.
  50049. func (m *WxCardMutation) EdgeCleared(name string) bool {
  50050. return false
  50051. }
  50052. // ClearEdge clears the value of the edge with the given name. It returns an error
  50053. // if that edge is not defined in the schema.
  50054. func (m *WxCardMutation) ClearEdge(name string) error {
  50055. return fmt.Errorf("unknown WxCard unique edge %s", name)
  50056. }
  50057. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50058. // It returns an error if the edge is not defined in the schema.
  50059. func (m *WxCardMutation) ResetEdge(name string) error {
  50060. return fmt.Errorf("unknown WxCard edge %s", name)
  50061. }
  50062. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  50063. type WxCardUserMutation struct {
  50064. config
  50065. op Op
  50066. typ string
  50067. id *uint64
  50068. created_at *time.Time
  50069. updated_at *time.Time
  50070. deleted_at *time.Time
  50071. wxid *string
  50072. account *string
  50073. avatar *string
  50074. nickname *string
  50075. remark *string
  50076. phone *string
  50077. open_id *string
  50078. union_id *string
  50079. session_key *string
  50080. is_vip *int
  50081. addis_vip *int
  50082. clearedFields map[string]struct{}
  50083. done bool
  50084. oldValue func(context.Context) (*WxCardUser, error)
  50085. predicates []predicate.WxCardUser
  50086. }
  50087. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  50088. // wxcarduserOption allows management of the mutation configuration using functional options.
  50089. type wxcarduserOption func(*WxCardUserMutation)
  50090. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  50091. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  50092. m := &WxCardUserMutation{
  50093. config: c,
  50094. op: op,
  50095. typ: TypeWxCardUser,
  50096. clearedFields: make(map[string]struct{}),
  50097. }
  50098. for _, opt := range opts {
  50099. opt(m)
  50100. }
  50101. return m
  50102. }
  50103. // withWxCardUserID sets the ID field of the mutation.
  50104. func withWxCardUserID(id uint64) wxcarduserOption {
  50105. return func(m *WxCardUserMutation) {
  50106. var (
  50107. err error
  50108. once sync.Once
  50109. value *WxCardUser
  50110. )
  50111. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  50112. once.Do(func() {
  50113. if m.done {
  50114. err = errors.New("querying old values post mutation is not allowed")
  50115. } else {
  50116. value, err = m.Client().WxCardUser.Get(ctx, id)
  50117. }
  50118. })
  50119. return value, err
  50120. }
  50121. m.id = &id
  50122. }
  50123. }
  50124. // withWxCardUser sets the old WxCardUser of the mutation.
  50125. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  50126. return func(m *WxCardUserMutation) {
  50127. m.oldValue = func(context.Context) (*WxCardUser, error) {
  50128. return node, nil
  50129. }
  50130. m.id = &node.ID
  50131. }
  50132. }
  50133. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50134. // executed in a transaction (ent.Tx), a transactional client is returned.
  50135. func (m WxCardUserMutation) Client() *Client {
  50136. client := &Client{config: m.config}
  50137. client.init()
  50138. return client
  50139. }
  50140. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50141. // it returns an error otherwise.
  50142. func (m WxCardUserMutation) Tx() (*Tx, error) {
  50143. if _, ok := m.driver.(*txDriver); !ok {
  50144. return nil, errors.New("ent: mutation is not running in a transaction")
  50145. }
  50146. tx := &Tx{config: m.config}
  50147. tx.init()
  50148. return tx, nil
  50149. }
  50150. // SetID sets the value of the id field. Note that this
  50151. // operation is only accepted on creation of WxCardUser entities.
  50152. func (m *WxCardUserMutation) SetID(id uint64) {
  50153. m.id = &id
  50154. }
  50155. // ID returns the ID value in the mutation. Note that the ID is only available
  50156. // if it was provided to the builder or after it was returned from the database.
  50157. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  50158. if m.id == nil {
  50159. return
  50160. }
  50161. return *m.id, true
  50162. }
  50163. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50164. // That means, if the mutation is applied within a transaction with an isolation level such
  50165. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50166. // or updated by the mutation.
  50167. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  50168. switch {
  50169. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50170. id, exists := m.ID()
  50171. if exists {
  50172. return []uint64{id}, nil
  50173. }
  50174. fallthrough
  50175. case m.op.Is(OpUpdate | OpDelete):
  50176. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  50177. default:
  50178. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50179. }
  50180. }
  50181. // SetCreatedAt sets the "created_at" field.
  50182. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  50183. m.created_at = &t
  50184. }
  50185. // CreatedAt returns the value of the "created_at" field in the mutation.
  50186. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  50187. v := m.created_at
  50188. if v == nil {
  50189. return
  50190. }
  50191. return *v, true
  50192. }
  50193. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  50194. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50196. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50197. if !m.op.Is(OpUpdateOne) {
  50198. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50199. }
  50200. if m.id == nil || m.oldValue == nil {
  50201. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50202. }
  50203. oldValue, err := m.oldValue(ctx)
  50204. if err != nil {
  50205. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50206. }
  50207. return oldValue.CreatedAt, nil
  50208. }
  50209. // ResetCreatedAt resets all changes to the "created_at" field.
  50210. func (m *WxCardUserMutation) ResetCreatedAt() {
  50211. m.created_at = nil
  50212. }
  50213. // SetUpdatedAt sets the "updated_at" field.
  50214. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  50215. m.updated_at = &t
  50216. }
  50217. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50218. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  50219. v := m.updated_at
  50220. if v == nil {
  50221. return
  50222. }
  50223. return *v, true
  50224. }
  50225. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  50226. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50228. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50229. if !m.op.Is(OpUpdateOne) {
  50230. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50231. }
  50232. if m.id == nil || m.oldValue == nil {
  50233. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50234. }
  50235. oldValue, err := m.oldValue(ctx)
  50236. if err != nil {
  50237. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50238. }
  50239. return oldValue.UpdatedAt, nil
  50240. }
  50241. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50242. func (m *WxCardUserMutation) ResetUpdatedAt() {
  50243. m.updated_at = nil
  50244. }
  50245. // SetDeletedAt sets the "deleted_at" field.
  50246. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  50247. m.deleted_at = &t
  50248. }
  50249. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50250. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  50251. v := m.deleted_at
  50252. if v == nil {
  50253. return
  50254. }
  50255. return *v, true
  50256. }
  50257. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  50258. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50260. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50261. if !m.op.Is(OpUpdateOne) {
  50262. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50263. }
  50264. if m.id == nil || m.oldValue == nil {
  50265. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50266. }
  50267. oldValue, err := m.oldValue(ctx)
  50268. if err != nil {
  50269. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50270. }
  50271. return oldValue.DeletedAt, nil
  50272. }
  50273. // ClearDeletedAt clears the value of the "deleted_at" field.
  50274. func (m *WxCardUserMutation) ClearDeletedAt() {
  50275. m.deleted_at = nil
  50276. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  50277. }
  50278. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50279. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  50280. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  50281. return ok
  50282. }
  50283. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50284. func (m *WxCardUserMutation) ResetDeletedAt() {
  50285. m.deleted_at = nil
  50286. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  50287. }
  50288. // SetWxid sets the "wxid" field.
  50289. func (m *WxCardUserMutation) SetWxid(s string) {
  50290. m.wxid = &s
  50291. }
  50292. // Wxid returns the value of the "wxid" field in the mutation.
  50293. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  50294. v := m.wxid
  50295. if v == nil {
  50296. return
  50297. }
  50298. return *v, true
  50299. }
  50300. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  50301. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50303. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  50304. if !m.op.Is(OpUpdateOne) {
  50305. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  50306. }
  50307. if m.id == nil || m.oldValue == nil {
  50308. return v, errors.New("OldWxid requires an ID field in the mutation")
  50309. }
  50310. oldValue, err := m.oldValue(ctx)
  50311. if err != nil {
  50312. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  50313. }
  50314. return oldValue.Wxid, nil
  50315. }
  50316. // ResetWxid resets all changes to the "wxid" field.
  50317. func (m *WxCardUserMutation) ResetWxid() {
  50318. m.wxid = nil
  50319. }
  50320. // SetAccount sets the "account" field.
  50321. func (m *WxCardUserMutation) SetAccount(s string) {
  50322. m.account = &s
  50323. }
  50324. // Account returns the value of the "account" field in the mutation.
  50325. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  50326. v := m.account
  50327. if v == nil {
  50328. return
  50329. }
  50330. return *v, true
  50331. }
  50332. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  50333. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50335. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  50336. if !m.op.Is(OpUpdateOne) {
  50337. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  50338. }
  50339. if m.id == nil || m.oldValue == nil {
  50340. return v, errors.New("OldAccount requires an ID field in the mutation")
  50341. }
  50342. oldValue, err := m.oldValue(ctx)
  50343. if err != nil {
  50344. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  50345. }
  50346. return oldValue.Account, nil
  50347. }
  50348. // ResetAccount resets all changes to the "account" field.
  50349. func (m *WxCardUserMutation) ResetAccount() {
  50350. m.account = nil
  50351. }
  50352. // SetAvatar sets the "avatar" field.
  50353. func (m *WxCardUserMutation) SetAvatar(s string) {
  50354. m.avatar = &s
  50355. }
  50356. // Avatar returns the value of the "avatar" field in the mutation.
  50357. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  50358. v := m.avatar
  50359. if v == nil {
  50360. return
  50361. }
  50362. return *v, true
  50363. }
  50364. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  50365. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50367. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  50368. if !m.op.Is(OpUpdateOne) {
  50369. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  50370. }
  50371. if m.id == nil || m.oldValue == nil {
  50372. return v, errors.New("OldAvatar requires an ID field in the mutation")
  50373. }
  50374. oldValue, err := m.oldValue(ctx)
  50375. if err != nil {
  50376. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  50377. }
  50378. return oldValue.Avatar, nil
  50379. }
  50380. // ResetAvatar resets all changes to the "avatar" field.
  50381. func (m *WxCardUserMutation) ResetAvatar() {
  50382. m.avatar = nil
  50383. }
  50384. // SetNickname sets the "nickname" field.
  50385. func (m *WxCardUserMutation) SetNickname(s string) {
  50386. m.nickname = &s
  50387. }
  50388. // Nickname returns the value of the "nickname" field in the mutation.
  50389. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  50390. v := m.nickname
  50391. if v == nil {
  50392. return
  50393. }
  50394. return *v, true
  50395. }
  50396. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  50397. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50399. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  50400. if !m.op.Is(OpUpdateOne) {
  50401. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  50402. }
  50403. if m.id == nil || m.oldValue == nil {
  50404. return v, errors.New("OldNickname requires an ID field in the mutation")
  50405. }
  50406. oldValue, err := m.oldValue(ctx)
  50407. if err != nil {
  50408. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  50409. }
  50410. return oldValue.Nickname, nil
  50411. }
  50412. // ResetNickname resets all changes to the "nickname" field.
  50413. func (m *WxCardUserMutation) ResetNickname() {
  50414. m.nickname = nil
  50415. }
  50416. // SetRemark sets the "remark" field.
  50417. func (m *WxCardUserMutation) SetRemark(s string) {
  50418. m.remark = &s
  50419. }
  50420. // Remark returns the value of the "remark" field in the mutation.
  50421. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  50422. v := m.remark
  50423. if v == nil {
  50424. return
  50425. }
  50426. return *v, true
  50427. }
  50428. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  50429. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50431. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  50432. if !m.op.Is(OpUpdateOne) {
  50433. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  50434. }
  50435. if m.id == nil || m.oldValue == nil {
  50436. return v, errors.New("OldRemark requires an ID field in the mutation")
  50437. }
  50438. oldValue, err := m.oldValue(ctx)
  50439. if err != nil {
  50440. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  50441. }
  50442. return oldValue.Remark, nil
  50443. }
  50444. // ResetRemark resets all changes to the "remark" field.
  50445. func (m *WxCardUserMutation) ResetRemark() {
  50446. m.remark = nil
  50447. }
  50448. // SetPhone sets the "phone" field.
  50449. func (m *WxCardUserMutation) SetPhone(s string) {
  50450. m.phone = &s
  50451. }
  50452. // Phone returns the value of the "phone" field in the mutation.
  50453. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  50454. v := m.phone
  50455. if v == nil {
  50456. return
  50457. }
  50458. return *v, true
  50459. }
  50460. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  50461. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50463. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  50464. if !m.op.Is(OpUpdateOne) {
  50465. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  50466. }
  50467. if m.id == nil || m.oldValue == nil {
  50468. return v, errors.New("OldPhone requires an ID field in the mutation")
  50469. }
  50470. oldValue, err := m.oldValue(ctx)
  50471. if err != nil {
  50472. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  50473. }
  50474. return oldValue.Phone, nil
  50475. }
  50476. // ResetPhone resets all changes to the "phone" field.
  50477. func (m *WxCardUserMutation) ResetPhone() {
  50478. m.phone = nil
  50479. }
  50480. // SetOpenID sets the "open_id" field.
  50481. func (m *WxCardUserMutation) SetOpenID(s string) {
  50482. m.open_id = &s
  50483. }
  50484. // OpenID returns the value of the "open_id" field in the mutation.
  50485. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  50486. v := m.open_id
  50487. if v == nil {
  50488. return
  50489. }
  50490. return *v, true
  50491. }
  50492. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  50493. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50495. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  50496. if !m.op.Is(OpUpdateOne) {
  50497. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  50498. }
  50499. if m.id == nil || m.oldValue == nil {
  50500. return v, errors.New("OldOpenID requires an ID field in the mutation")
  50501. }
  50502. oldValue, err := m.oldValue(ctx)
  50503. if err != nil {
  50504. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  50505. }
  50506. return oldValue.OpenID, nil
  50507. }
  50508. // ResetOpenID resets all changes to the "open_id" field.
  50509. func (m *WxCardUserMutation) ResetOpenID() {
  50510. m.open_id = nil
  50511. }
  50512. // SetUnionID sets the "union_id" field.
  50513. func (m *WxCardUserMutation) SetUnionID(s string) {
  50514. m.union_id = &s
  50515. }
  50516. // UnionID returns the value of the "union_id" field in the mutation.
  50517. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  50518. v := m.union_id
  50519. if v == nil {
  50520. return
  50521. }
  50522. return *v, true
  50523. }
  50524. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  50525. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50527. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  50528. if !m.op.Is(OpUpdateOne) {
  50529. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  50530. }
  50531. if m.id == nil || m.oldValue == nil {
  50532. return v, errors.New("OldUnionID requires an ID field in the mutation")
  50533. }
  50534. oldValue, err := m.oldValue(ctx)
  50535. if err != nil {
  50536. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  50537. }
  50538. return oldValue.UnionID, nil
  50539. }
  50540. // ResetUnionID resets all changes to the "union_id" field.
  50541. func (m *WxCardUserMutation) ResetUnionID() {
  50542. m.union_id = nil
  50543. }
  50544. // SetSessionKey sets the "session_key" field.
  50545. func (m *WxCardUserMutation) SetSessionKey(s string) {
  50546. m.session_key = &s
  50547. }
  50548. // SessionKey returns the value of the "session_key" field in the mutation.
  50549. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  50550. v := m.session_key
  50551. if v == nil {
  50552. return
  50553. }
  50554. return *v, true
  50555. }
  50556. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  50557. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50559. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  50560. if !m.op.Is(OpUpdateOne) {
  50561. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  50562. }
  50563. if m.id == nil || m.oldValue == nil {
  50564. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  50565. }
  50566. oldValue, err := m.oldValue(ctx)
  50567. if err != nil {
  50568. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  50569. }
  50570. return oldValue.SessionKey, nil
  50571. }
  50572. // ResetSessionKey resets all changes to the "session_key" field.
  50573. func (m *WxCardUserMutation) ResetSessionKey() {
  50574. m.session_key = nil
  50575. }
  50576. // SetIsVip sets the "is_vip" field.
  50577. func (m *WxCardUserMutation) SetIsVip(i int) {
  50578. m.is_vip = &i
  50579. m.addis_vip = nil
  50580. }
  50581. // IsVip returns the value of the "is_vip" field in the mutation.
  50582. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  50583. v := m.is_vip
  50584. if v == nil {
  50585. return
  50586. }
  50587. return *v, true
  50588. }
  50589. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  50590. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50592. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  50593. if !m.op.Is(OpUpdateOne) {
  50594. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  50595. }
  50596. if m.id == nil || m.oldValue == nil {
  50597. return v, errors.New("OldIsVip requires an ID field in the mutation")
  50598. }
  50599. oldValue, err := m.oldValue(ctx)
  50600. if err != nil {
  50601. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  50602. }
  50603. return oldValue.IsVip, nil
  50604. }
  50605. // AddIsVip adds i to the "is_vip" field.
  50606. func (m *WxCardUserMutation) AddIsVip(i int) {
  50607. if m.addis_vip != nil {
  50608. *m.addis_vip += i
  50609. } else {
  50610. m.addis_vip = &i
  50611. }
  50612. }
  50613. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  50614. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  50615. v := m.addis_vip
  50616. if v == nil {
  50617. return
  50618. }
  50619. return *v, true
  50620. }
  50621. // ResetIsVip resets all changes to the "is_vip" field.
  50622. func (m *WxCardUserMutation) ResetIsVip() {
  50623. m.is_vip = nil
  50624. m.addis_vip = nil
  50625. }
  50626. // Where appends a list predicates to the WxCardUserMutation builder.
  50627. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  50628. m.predicates = append(m.predicates, ps...)
  50629. }
  50630. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  50631. // users can use type-assertion to append predicates that do not depend on any generated package.
  50632. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  50633. p := make([]predicate.WxCardUser, len(ps))
  50634. for i := range ps {
  50635. p[i] = ps[i]
  50636. }
  50637. m.Where(p...)
  50638. }
  50639. // Op returns the operation name.
  50640. func (m *WxCardUserMutation) Op() Op {
  50641. return m.op
  50642. }
  50643. // SetOp allows setting the mutation operation.
  50644. func (m *WxCardUserMutation) SetOp(op Op) {
  50645. m.op = op
  50646. }
  50647. // Type returns the node type of this mutation (WxCardUser).
  50648. func (m *WxCardUserMutation) Type() string {
  50649. return m.typ
  50650. }
  50651. // Fields returns all fields that were changed during this mutation. Note that in
  50652. // order to get all numeric fields that were incremented/decremented, call
  50653. // AddedFields().
  50654. func (m *WxCardUserMutation) Fields() []string {
  50655. fields := make([]string, 0, 13)
  50656. if m.created_at != nil {
  50657. fields = append(fields, wxcarduser.FieldCreatedAt)
  50658. }
  50659. if m.updated_at != nil {
  50660. fields = append(fields, wxcarduser.FieldUpdatedAt)
  50661. }
  50662. if m.deleted_at != nil {
  50663. fields = append(fields, wxcarduser.FieldDeletedAt)
  50664. }
  50665. if m.wxid != nil {
  50666. fields = append(fields, wxcarduser.FieldWxid)
  50667. }
  50668. if m.account != nil {
  50669. fields = append(fields, wxcarduser.FieldAccount)
  50670. }
  50671. if m.avatar != nil {
  50672. fields = append(fields, wxcarduser.FieldAvatar)
  50673. }
  50674. if m.nickname != nil {
  50675. fields = append(fields, wxcarduser.FieldNickname)
  50676. }
  50677. if m.remark != nil {
  50678. fields = append(fields, wxcarduser.FieldRemark)
  50679. }
  50680. if m.phone != nil {
  50681. fields = append(fields, wxcarduser.FieldPhone)
  50682. }
  50683. if m.open_id != nil {
  50684. fields = append(fields, wxcarduser.FieldOpenID)
  50685. }
  50686. if m.union_id != nil {
  50687. fields = append(fields, wxcarduser.FieldUnionID)
  50688. }
  50689. if m.session_key != nil {
  50690. fields = append(fields, wxcarduser.FieldSessionKey)
  50691. }
  50692. if m.is_vip != nil {
  50693. fields = append(fields, wxcarduser.FieldIsVip)
  50694. }
  50695. return fields
  50696. }
  50697. // Field returns the value of a field with the given name. The second boolean
  50698. // return value indicates that this field was not set, or was not defined in the
  50699. // schema.
  50700. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  50701. switch name {
  50702. case wxcarduser.FieldCreatedAt:
  50703. return m.CreatedAt()
  50704. case wxcarduser.FieldUpdatedAt:
  50705. return m.UpdatedAt()
  50706. case wxcarduser.FieldDeletedAt:
  50707. return m.DeletedAt()
  50708. case wxcarduser.FieldWxid:
  50709. return m.Wxid()
  50710. case wxcarduser.FieldAccount:
  50711. return m.Account()
  50712. case wxcarduser.FieldAvatar:
  50713. return m.Avatar()
  50714. case wxcarduser.FieldNickname:
  50715. return m.Nickname()
  50716. case wxcarduser.FieldRemark:
  50717. return m.Remark()
  50718. case wxcarduser.FieldPhone:
  50719. return m.Phone()
  50720. case wxcarduser.FieldOpenID:
  50721. return m.OpenID()
  50722. case wxcarduser.FieldUnionID:
  50723. return m.UnionID()
  50724. case wxcarduser.FieldSessionKey:
  50725. return m.SessionKey()
  50726. case wxcarduser.FieldIsVip:
  50727. return m.IsVip()
  50728. }
  50729. return nil, false
  50730. }
  50731. // OldField returns the old value of the field from the database. An error is
  50732. // returned if the mutation operation is not UpdateOne, or the query to the
  50733. // database failed.
  50734. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50735. switch name {
  50736. case wxcarduser.FieldCreatedAt:
  50737. return m.OldCreatedAt(ctx)
  50738. case wxcarduser.FieldUpdatedAt:
  50739. return m.OldUpdatedAt(ctx)
  50740. case wxcarduser.FieldDeletedAt:
  50741. return m.OldDeletedAt(ctx)
  50742. case wxcarduser.FieldWxid:
  50743. return m.OldWxid(ctx)
  50744. case wxcarduser.FieldAccount:
  50745. return m.OldAccount(ctx)
  50746. case wxcarduser.FieldAvatar:
  50747. return m.OldAvatar(ctx)
  50748. case wxcarduser.FieldNickname:
  50749. return m.OldNickname(ctx)
  50750. case wxcarduser.FieldRemark:
  50751. return m.OldRemark(ctx)
  50752. case wxcarduser.FieldPhone:
  50753. return m.OldPhone(ctx)
  50754. case wxcarduser.FieldOpenID:
  50755. return m.OldOpenID(ctx)
  50756. case wxcarduser.FieldUnionID:
  50757. return m.OldUnionID(ctx)
  50758. case wxcarduser.FieldSessionKey:
  50759. return m.OldSessionKey(ctx)
  50760. case wxcarduser.FieldIsVip:
  50761. return m.OldIsVip(ctx)
  50762. }
  50763. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  50764. }
  50765. // SetField sets the value of a field with the given name. It returns an error if
  50766. // the field is not defined in the schema, or if the type mismatched the field
  50767. // type.
  50768. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  50769. switch name {
  50770. case wxcarduser.FieldCreatedAt:
  50771. v, ok := value.(time.Time)
  50772. if !ok {
  50773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50774. }
  50775. m.SetCreatedAt(v)
  50776. return nil
  50777. case wxcarduser.FieldUpdatedAt:
  50778. v, ok := value.(time.Time)
  50779. if !ok {
  50780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50781. }
  50782. m.SetUpdatedAt(v)
  50783. return nil
  50784. case wxcarduser.FieldDeletedAt:
  50785. v, ok := value.(time.Time)
  50786. if !ok {
  50787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50788. }
  50789. m.SetDeletedAt(v)
  50790. return nil
  50791. case wxcarduser.FieldWxid:
  50792. v, ok := value.(string)
  50793. if !ok {
  50794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50795. }
  50796. m.SetWxid(v)
  50797. return nil
  50798. case wxcarduser.FieldAccount:
  50799. v, ok := value.(string)
  50800. if !ok {
  50801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50802. }
  50803. m.SetAccount(v)
  50804. return nil
  50805. case wxcarduser.FieldAvatar:
  50806. v, ok := value.(string)
  50807. if !ok {
  50808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50809. }
  50810. m.SetAvatar(v)
  50811. return nil
  50812. case wxcarduser.FieldNickname:
  50813. v, ok := value.(string)
  50814. if !ok {
  50815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50816. }
  50817. m.SetNickname(v)
  50818. return nil
  50819. case wxcarduser.FieldRemark:
  50820. v, ok := value.(string)
  50821. if !ok {
  50822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50823. }
  50824. m.SetRemark(v)
  50825. return nil
  50826. case wxcarduser.FieldPhone:
  50827. v, ok := value.(string)
  50828. if !ok {
  50829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50830. }
  50831. m.SetPhone(v)
  50832. return nil
  50833. case wxcarduser.FieldOpenID:
  50834. v, ok := value.(string)
  50835. if !ok {
  50836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50837. }
  50838. m.SetOpenID(v)
  50839. return nil
  50840. case wxcarduser.FieldUnionID:
  50841. v, ok := value.(string)
  50842. if !ok {
  50843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50844. }
  50845. m.SetUnionID(v)
  50846. return nil
  50847. case wxcarduser.FieldSessionKey:
  50848. v, ok := value.(string)
  50849. if !ok {
  50850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50851. }
  50852. m.SetSessionKey(v)
  50853. return nil
  50854. case wxcarduser.FieldIsVip:
  50855. v, ok := value.(int)
  50856. if !ok {
  50857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50858. }
  50859. m.SetIsVip(v)
  50860. return nil
  50861. }
  50862. return fmt.Errorf("unknown WxCardUser field %s", name)
  50863. }
  50864. // AddedFields returns all numeric fields that were incremented/decremented during
  50865. // this mutation.
  50866. func (m *WxCardUserMutation) AddedFields() []string {
  50867. var fields []string
  50868. if m.addis_vip != nil {
  50869. fields = append(fields, wxcarduser.FieldIsVip)
  50870. }
  50871. return fields
  50872. }
  50873. // AddedField returns the numeric value that was incremented/decremented on a field
  50874. // with the given name. The second boolean return value indicates that this field
  50875. // was not set, or was not defined in the schema.
  50876. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  50877. switch name {
  50878. case wxcarduser.FieldIsVip:
  50879. return m.AddedIsVip()
  50880. }
  50881. return nil, false
  50882. }
  50883. // AddField adds the value to the field with the given name. It returns an error if
  50884. // the field is not defined in the schema, or if the type mismatched the field
  50885. // type.
  50886. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  50887. switch name {
  50888. case wxcarduser.FieldIsVip:
  50889. v, ok := value.(int)
  50890. if !ok {
  50891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50892. }
  50893. m.AddIsVip(v)
  50894. return nil
  50895. }
  50896. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  50897. }
  50898. // ClearedFields returns all nullable fields that were cleared during this
  50899. // mutation.
  50900. func (m *WxCardUserMutation) ClearedFields() []string {
  50901. var fields []string
  50902. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  50903. fields = append(fields, wxcarduser.FieldDeletedAt)
  50904. }
  50905. return fields
  50906. }
  50907. // FieldCleared returns a boolean indicating if a field with the given name was
  50908. // cleared in this mutation.
  50909. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  50910. _, ok := m.clearedFields[name]
  50911. return ok
  50912. }
  50913. // ClearField clears the value of the field with the given name. It returns an
  50914. // error if the field is not defined in the schema.
  50915. func (m *WxCardUserMutation) ClearField(name string) error {
  50916. switch name {
  50917. case wxcarduser.FieldDeletedAt:
  50918. m.ClearDeletedAt()
  50919. return nil
  50920. }
  50921. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  50922. }
  50923. // ResetField resets all changes in the mutation for the field with the given name.
  50924. // It returns an error if the field is not defined in the schema.
  50925. func (m *WxCardUserMutation) ResetField(name string) error {
  50926. switch name {
  50927. case wxcarduser.FieldCreatedAt:
  50928. m.ResetCreatedAt()
  50929. return nil
  50930. case wxcarduser.FieldUpdatedAt:
  50931. m.ResetUpdatedAt()
  50932. return nil
  50933. case wxcarduser.FieldDeletedAt:
  50934. m.ResetDeletedAt()
  50935. return nil
  50936. case wxcarduser.FieldWxid:
  50937. m.ResetWxid()
  50938. return nil
  50939. case wxcarduser.FieldAccount:
  50940. m.ResetAccount()
  50941. return nil
  50942. case wxcarduser.FieldAvatar:
  50943. m.ResetAvatar()
  50944. return nil
  50945. case wxcarduser.FieldNickname:
  50946. m.ResetNickname()
  50947. return nil
  50948. case wxcarduser.FieldRemark:
  50949. m.ResetRemark()
  50950. return nil
  50951. case wxcarduser.FieldPhone:
  50952. m.ResetPhone()
  50953. return nil
  50954. case wxcarduser.FieldOpenID:
  50955. m.ResetOpenID()
  50956. return nil
  50957. case wxcarduser.FieldUnionID:
  50958. m.ResetUnionID()
  50959. return nil
  50960. case wxcarduser.FieldSessionKey:
  50961. m.ResetSessionKey()
  50962. return nil
  50963. case wxcarduser.FieldIsVip:
  50964. m.ResetIsVip()
  50965. return nil
  50966. }
  50967. return fmt.Errorf("unknown WxCardUser field %s", name)
  50968. }
  50969. // AddedEdges returns all edge names that were set/added in this mutation.
  50970. func (m *WxCardUserMutation) AddedEdges() []string {
  50971. edges := make([]string, 0, 0)
  50972. return edges
  50973. }
  50974. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50975. // name in this mutation.
  50976. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  50977. return nil
  50978. }
  50979. // RemovedEdges returns all edge names that were removed in this mutation.
  50980. func (m *WxCardUserMutation) RemovedEdges() []string {
  50981. edges := make([]string, 0, 0)
  50982. return edges
  50983. }
  50984. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50985. // the given name in this mutation.
  50986. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  50987. return nil
  50988. }
  50989. // ClearedEdges returns all edge names that were cleared in this mutation.
  50990. func (m *WxCardUserMutation) ClearedEdges() []string {
  50991. edges := make([]string, 0, 0)
  50992. return edges
  50993. }
  50994. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50995. // was cleared in this mutation.
  50996. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  50997. return false
  50998. }
  50999. // ClearEdge clears the value of the edge with the given name. It returns an error
  51000. // if that edge is not defined in the schema.
  51001. func (m *WxCardUserMutation) ClearEdge(name string) error {
  51002. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  51003. }
  51004. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51005. // It returns an error if the edge is not defined in the schema.
  51006. func (m *WxCardUserMutation) ResetEdge(name string) error {
  51007. return fmt.Errorf("unknown WxCardUser edge %s", name)
  51008. }
  51009. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  51010. type WxCardVisitMutation struct {
  51011. config
  51012. op Op
  51013. typ string
  51014. id *uint64
  51015. created_at *time.Time
  51016. updated_at *time.Time
  51017. deleted_at *time.Time
  51018. user_id *uint64
  51019. adduser_id *int64
  51020. bot_id *uint64
  51021. addbot_id *int64
  51022. bot_type *uint8
  51023. addbot_type *int8
  51024. clearedFields map[string]struct{}
  51025. done bool
  51026. oldValue func(context.Context) (*WxCardVisit, error)
  51027. predicates []predicate.WxCardVisit
  51028. }
  51029. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  51030. // wxcardvisitOption allows management of the mutation configuration using functional options.
  51031. type wxcardvisitOption func(*WxCardVisitMutation)
  51032. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  51033. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  51034. m := &WxCardVisitMutation{
  51035. config: c,
  51036. op: op,
  51037. typ: TypeWxCardVisit,
  51038. clearedFields: make(map[string]struct{}),
  51039. }
  51040. for _, opt := range opts {
  51041. opt(m)
  51042. }
  51043. return m
  51044. }
  51045. // withWxCardVisitID sets the ID field of the mutation.
  51046. func withWxCardVisitID(id uint64) wxcardvisitOption {
  51047. return func(m *WxCardVisitMutation) {
  51048. var (
  51049. err error
  51050. once sync.Once
  51051. value *WxCardVisit
  51052. )
  51053. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  51054. once.Do(func() {
  51055. if m.done {
  51056. err = errors.New("querying old values post mutation is not allowed")
  51057. } else {
  51058. value, err = m.Client().WxCardVisit.Get(ctx, id)
  51059. }
  51060. })
  51061. return value, err
  51062. }
  51063. m.id = &id
  51064. }
  51065. }
  51066. // withWxCardVisit sets the old WxCardVisit of the mutation.
  51067. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  51068. return func(m *WxCardVisitMutation) {
  51069. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  51070. return node, nil
  51071. }
  51072. m.id = &node.ID
  51073. }
  51074. }
  51075. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51076. // executed in a transaction (ent.Tx), a transactional client is returned.
  51077. func (m WxCardVisitMutation) Client() *Client {
  51078. client := &Client{config: m.config}
  51079. client.init()
  51080. return client
  51081. }
  51082. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51083. // it returns an error otherwise.
  51084. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  51085. if _, ok := m.driver.(*txDriver); !ok {
  51086. return nil, errors.New("ent: mutation is not running in a transaction")
  51087. }
  51088. tx := &Tx{config: m.config}
  51089. tx.init()
  51090. return tx, nil
  51091. }
  51092. // SetID sets the value of the id field. Note that this
  51093. // operation is only accepted on creation of WxCardVisit entities.
  51094. func (m *WxCardVisitMutation) SetID(id uint64) {
  51095. m.id = &id
  51096. }
  51097. // ID returns the ID value in the mutation. Note that the ID is only available
  51098. // if it was provided to the builder or after it was returned from the database.
  51099. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  51100. if m.id == nil {
  51101. return
  51102. }
  51103. return *m.id, true
  51104. }
  51105. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51106. // That means, if the mutation is applied within a transaction with an isolation level such
  51107. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51108. // or updated by the mutation.
  51109. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  51110. switch {
  51111. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51112. id, exists := m.ID()
  51113. if exists {
  51114. return []uint64{id}, nil
  51115. }
  51116. fallthrough
  51117. case m.op.Is(OpUpdate | OpDelete):
  51118. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  51119. default:
  51120. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51121. }
  51122. }
  51123. // SetCreatedAt sets the "created_at" field.
  51124. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  51125. m.created_at = &t
  51126. }
  51127. // CreatedAt returns the value of the "created_at" field in the mutation.
  51128. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  51129. v := m.created_at
  51130. if v == nil {
  51131. return
  51132. }
  51133. return *v, true
  51134. }
  51135. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  51136. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51138. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51139. if !m.op.Is(OpUpdateOne) {
  51140. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51141. }
  51142. if m.id == nil || m.oldValue == nil {
  51143. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51144. }
  51145. oldValue, err := m.oldValue(ctx)
  51146. if err != nil {
  51147. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51148. }
  51149. return oldValue.CreatedAt, nil
  51150. }
  51151. // ResetCreatedAt resets all changes to the "created_at" field.
  51152. func (m *WxCardVisitMutation) ResetCreatedAt() {
  51153. m.created_at = nil
  51154. }
  51155. // SetUpdatedAt sets the "updated_at" field.
  51156. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  51157. m.updated_at = &t
  51158. }
  51159. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51160. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  51161. v := m.updated_at
  51162. if v == nil {
  51163. return
  51164. }
  51165. return *v, true
  51166. }
  51167. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  51168. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51170. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51171. if !m.op.Is(OpUpdateOne) {
  51172. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51173. }
  51174. if m.id == nil || m.oldValue == nil {
  51175. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51176. }
  51177. oldValue, err := m.oldValue(ctx)
  51178. if err != nil {
  51179. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51180. }
  51181. return oldValue.UpdatedAt, nil
  51182. }
  51183. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51184. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  51185. m.updated_at = nil
  51186. }
  51187. // SetDeletedAt sets the "deleted_at" field.
  51188. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  51189. m.deleted_at = &t
  51190. }
  51191. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51192. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  51193. v := m.deleted_at
  51194. if v == nil {
  51195. return
  51196. }
  51197. return *v, true
  51198. }
  51199. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  51200. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51202. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51203. if !m.op.Is(OpUpdateOne) {
  51204. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51205. }
  51206. if m.id == nil || m.oldValue == nil {
  51207. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51208. }
  51209. oldValue, err := m.oldValue(ctx)
  51210. if err != nil {
  51211. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51212. }
  51213. return oldValue.DeletedAt, nil
  51214. }
  51215. // ClearDeletedAt clears the value of the "deleted_at" field.
  51216. func (m *WxCardVisitMutation) ClearDeletedAt() {
  51217. m.deleted_at = nil
  51218. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  51219. }
  51220. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51221. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  51222. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  51223. return ok
  51224. }
  51225. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51226. func (m *WxCardVisitMutation) ResetDeletedAt() {
  51227. m.deleted_at = nil
  51228. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  51229. }
  51230. // SetUserID sets the "user_id" field.
  51231. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  51232. m.user_id = &u
  51233. m.adduser_id = nil
  51234. }
  51235. // UserID returns the value of the "user_id" field in the mutation.
  51236. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  51237. v := m.user_id
  51238. if v == nil {
  51239. return
  51240. }
  51241. return *v, true
  51242. }
  51243. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  51244. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51246. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  51247. if !m.op.Is(OpUpdateOne) {
  51248. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  51249. }
  51250. if m.id == nil || m.oldValue == nil {
  51251. return v, errors.New("OldUserID requires an ID field in the mutation")
  51252. }
  51253. oldValue, err := m.oldValue(ctx)
  51254. if err != nil {
  51255. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  51256. }
  51257. return oldValue.UserID, nil
  51258. }
  51259. // AddUserID adds u to the "user_id" field.
  51260. func (m *WxCardVisitMutation) AddUserID(u int64) {
  51261. if m.adduser_id != nil {
  51262. *m.adduser_id += u
  51263. } else {
  51264. m.adduser_id = &u
  51265. }
  51266. }
  51267. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  51268. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  51269. v := m.adduser_id
  51270. if v == nil {
  51271. return
  51272. }
  51273. return *v, true
  51274. }
  51275. // ClearUserID clears the value of the "user_id" field.
  51276. func (m *WxCardVisitMutation) ClearUserID() {
  51277. m.user_id = nil
  51278. m.adduser_id = nil
  51279. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  51280. }
  51281. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  51282. func (m *WxCardVisitMutation) UserIDCleared() bool {
  51283. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  51284. return ok
  51285. }
  51286. // ResetUserID resets all changes to the "user_id" field.
  51287. func (m *WxCardVisitMutation) ResetUserID() {
  51288. m.user_id = nil
  51289. m.adduser_id = nil
  51290. delete(m.clearedFields, wxcardvisit.FieldUserID)
  51291. }
  51292. // SetBotID sets the "bot_id" field.
  51293. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  51294. m.bot_id = &u
  51295. m.addbot_id = nil
  51296. }
  51297. // BotID returns the value of the "bot_id" field in the mutation.
  51298. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  51299. v := m.bot_id
  51300. if v == nil {
  51301. return
  51302. }
  51303. return *v, true
  51304. }
  51305. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  51306. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51308. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  51309. if !m.op.Is(OpUpdateOne) {
  51310. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  51311. }
  51312. if m.id == nil || m.oldValue == nil {
  51313. return v, errors.New("OldBotID requires an ID field in the mutation")
  51314. }
  51315. oldValue, err := m.oldValue(ctx)
  51316. if err != nil {
  51317. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  51318. }
  51319. return oldValue.BotID, nil
  51320. }
  51321. // AddBotID adds u to the "bot_id" field.
  51322. func (m *WxCardVisitMutation) AddBotID(u int64) {
  51323. if m.addbot_id != nil {
  51324. *m.addbot_id += u
  51325. } else {
  51326. m.addbot_id = &u
  51327. }
  51328. }
  51329. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  51330. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  51331. v := m.addbot_id
  51332. if v == nil {
  51333. return
  51334. }
  51335. return *v, true
  51336. }
  51337. // ResetBotID resets all changes to the "bot_id" field.
  51338. func (m *WxCardVisitMutation) ResetBotID() {
  51339. m.bot_id = nil
  51340. m.addbot_id = nil
  51341. }
  51342. // SetBotType sets the "bot_type" field.
  51343. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  51344. m.bot_type = &u
  51345. m.addbot_type = nil
  51346. }
  51347. // BotType returns the value of the "bot_type" field in the mutation.
  51348. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  51349. v := m.bot_type
  51350. if v == nil {
  51351. return
  51352. }
  51353. return *v, true
  51354. }
  51355. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  51356. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51358. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  51359. if !m.op.Is(OpUpdateOne) {
  51360. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  51361. }
  51362. if m.id == nil || m.oldValue == nil {
  51363. return v, errors.New("OldBotType requires an ID field in the mutation")
  51364. }
  51365. oldValue, err := m.oldValue(ctx)
  51366. if err != nil {
  51367. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  51368. }
  51369. return oldValue.BotType, nil
  51370. }
  51371. // AddBotType adds u to the "bot_type" field.
  51372. func (m *WxCardVisitMutation) AddBotType(u int8) {
  51373. if m.addbot_type != nil {
  51374. *m.addbot_type += u
  51375. } else {
  51376. m.addbot_type = &u
  51377. }
  51378. }
  51379. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  51380. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  51381. v := m.addbot_type
  51382. if v == nil {
  51383. return
  51384. }
  51385. return *v, true
  51386. }
  51387. // ResetBotType resets all changes to the "bot_type" field.
  51388. func (m *WxCardVisitMutation) ResetBotType() {
  51389. m.bot_type = nil
  51390. m.addbot_type = nil
  51391. }
  51392. // Where appends a list predicates to the WxCardVisitMutation builder.
  51393. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  51394. m.predicates = append(m.predicates, ps...)
  51395. }
  51396. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  51397. // users can use type-assertion to append predicates that do not depend on any generated package.
  51398. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  51399. p := make([]predicate.WxCardVisit, len(ps))
  51400. for i := range ps {
  51401. p[i] = ps[i]
  51402. }
  51403. m.Where(p...)
  51404. }
  51405. // Op returns the operation name.
  51406. func (m *WxCardVisitMutation) Op() Op {
  51407. return m.op
  51408. }
  51409. // SetOp allows setting the mutation operation.
  51410. func (m *WxCardVisitMutation) SetOp(op Op) {
  51411. m.op = op
  51412. }
  51413. // Type returns the node type of this mutation (WxCardVisit).
  51414. func (m *WxCardVisitMutation) Type() string {
  51415. return m.typ
  51416. }
  51417. // Fields returns all fields that were changed during this mutation. Note that in
  51418. // order to get all numeric fields that were incremented/decremented, call
  51419. // AddedFields().
  51420. func (m *WxCardVisitMutation) Fields() []string {
  51421. fields := make([]string, 0, 6)
  51422. if m.created_at != nil {
  51423. fields = append(fields, wxcardvisit.FieldCreatedAt)
  51424. }
  51425. if m.updated_at != nil {
  51426. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  51427. }
  51428. if m.deleted_at != nil {
  51429. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51430. }
  51431. if m.user_id != nil {
  51432. fields = append(fields, wxcardvisit.FieldUserID)
  51433. }
  51434. if m.bot_id != nil {
  51435. fields = append(fields, wxcardvisit.FieldBotID)
  51436. }
  51437. if m.bot_type != nil {
  51438. fields = append(fields, wxcardvisit.FieldBotType)
  51439. }
  51440. return fields
  51441. }
  51442. // Field returns the value of a field with the given name. The second boolean
  51443. // return value indicates that this field was not set, or was not defined in the
  51444. // schema.
  51445. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  51446. switch name {
  51447. case wxcardvisit.FieldCreatedAt:
  51448. return m.CreatedAt()
  51449. case wxcardvisit.FieldUpdatedAt:
  51450. return m.UpdatedAt()
  51451. case wxcardvisit.FieldDeletedAt:
  51452. return m.DeletedAt()
  51453. case wxcardvisit.FieldUserID:
  51454. return m.UserID()
  51455. case wxcardvisit.FieldBotID:
  51456. return m.BotID()
  51457. case wxcardvisit.FieldBotType:
  51458. return m.BotType()
  51459. }
  51460. return nil, false
  51461. }
  51462. // OldField returns the old value of the field from the database. An error is
  51463. // returned if the mutation operation is not UpdateOne, or the query to the
  51464. // database failed.
  51465. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51466. switch name {
  51467. case wxcardvisit.FieldCreatedAt:
  51468. return m.OldCreatedAt(ctx)
  51469. case wxcardvisit.FieldUpdatedAt:
  51470. return m.OldUpdatedAt(ctx)
  51471. case wxcardvisit.FieldDeletedAt:
  51472. return m.OldDeletedAt(ctx)
  51473. case wxcardvisit.FieldUserID:
  51474. return m.OldUserID(ctx)
  51475. case wxcardvisit.FieldBotID:
  51476. return m.OldBotID(ctx)
  51477. case wxcardvisit.FieldBotType:
  51478. return m.OldBotType(ctx)
  51479. }
  51480. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  51481. }
  51482. // SetField sets the value of a field with the given name. It returns an error if
  51483. // the field is not defined in the schema, or if the type mismatched the field
  51484. // type.
  51485. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  51486. switch name {
  51487. case wxcardvisit.FieldCreatedAt:
  51488. v, ok := value.(time.Time)
  51489. if !ok {
  51490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51491. }
  51492. m.SetCreatedAt(v)
  51493. return nil
  51494. case wxcardvisit.FieldUpdatedAt:
  51495. v, ok := value.(time.Time)
  51496. if !ok {
  51497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51498. }
  51499. m.SetUpdatedAt(v)
  51500. return nil
  51501. case wxcardvisit.FieldDeletedAt:
  51502. v, ok := value.(time.Time)
  51503. if !ok {
  51504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51505. }
  51506. m.SetDeletedAt(v)
  51507. return nil
  51508. case wxcardvisit.FieldUserID:
  51509. v, ok := value.(uint64)
  51510. if !ok {
  51511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51512. }
  51513. m.SetUserID(v)
  51514. return nil
  51515. case wxcardvisit.FieldBotID:
  51516. v, ok := value.(uint64)
  51517. if !ok {
  51518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51519. }
  51520. m.SetBotID(v)
  51521. return nil
  51522. case wxcardvisit.FieldBotType:
  51523. v, ok := value.(uint8)
  51524. if !ok {
  51525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51526. }
  51527. m.SetBotType(v)
  51528. return nil
  51529. }
  51530. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51531. }
  51532. // AddedFields returns all numeric fields that were incremented/decremented during
  51533. // this mutation.
  51534. func (m *WxCardVisitMutation) AddedFields() []string {
  51535. var fields []string
  51536. if m.adduser_id != nil {
  51537. fields = append(fields, wxcardvisit.FieldUserID)
  51538. }
  51539. if m.addbot_id != nil {
  51540. fields = append(fields, wxcardvisit.FieldBotID)
  51541. }
  51542. if m.addbot_type != nil {
  51543. fields = append(fields, wxcardvisit.FieldBotType)
  51544. }
  51545. return fields
  51546. }
  51547. // AddedField returns the numeric value that was incremented/decremented on a field
  51548. // with the given name. The second boolean return value indicates that this field
  51549. // was not set, or was not defined in the schema.
  51550. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  51551. switch name {
  51552. case wxcardvisit.FieldUserID:
  51553. return m.AddedUserID()
  51554. case wxcardvisit.FieldBotID:
  51555. return m.AddedBotID()
  51556. case wxcardvisit.FieldBotType:
  51557. return m.AddedBotType()
  51558. }
  51559. return nil, false
  51560. }
  51561. // AddField adds the value to the field with the given name. It returns an error if
  51562. // the field is not defined in the schema, or if the type mismatched the field
  51563. // type.
  51564. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  51565. switch name {
  51566. case wxcardvisit.FieldUserID:
  51567. v, ok := value.(int64)
  51568. if !ok {
  51569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51570. }
  51571. m.AddUserID(v)
  51572. return nil
  51573. case wxcardvisit.FieldBotID:
  51574. v, ok := value.(int64)
  51575. if !ok {
  51576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51577. }
  51578. m.AddBotID(v)
  51579. return nil
  51580. case wxcardvisit.FieldBotType:
  51581. v, ok := value.(int8)
  51582. if !ok {
  51583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51584. }
  51585. m.AddBotType(v)
  51586. return nil
  51587. }
  51588. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  51589. }
  51590. // ClearedFields returns all nullable fields that were cleared during this
  51591. // mutation.
  51592. func (m *WxCardVisitMutation) ClearedFields() []string {
  51593. var fields []string
  51594. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  51595. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51596. }
  51597. if m.FieldCleared(wxcardvisit.FieldUserID) {
  51598. fields = append(fields, wxcardvisit.FieldUserID)
  51599. }
  51600. return fields
  51601. }
  51602. // FieldCleared returns a boolean indicating if a field with the given name was
  51603. // cleared in this mutation.
  51604. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  51605. _, ok := m.clearedFields[name]
  51606. return ok
  51607. }
  51608. // ClearField clears the value of the field with the given name. It returns an
  51609. // error if the field is not defined in the schema.
  51610. func (m *WxCardVisitMutation) ClearField(name string) error {
  51611. switch name {
  51612. case wxcardvisit.FieldDeletedAt:
  51613. m.ClearDeletedAt()
  51614. return nil
  51615. case wxcardvisit.FieldUserID:
  51616. m.ClearUserID()
  51617. return nil
  51618. }
  51619. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  51620. }
  51621. // ResetField resets all changes in the mutation for the field with the given name.
  51622. // It returns an error if the field is not defined in the schema.
  51623. func (m *WxCardVisitMutation) ResetField(name string) error {
  51624. switch name {
  51625. case wxcardvisit.FieldCreatedAt:
  51626. m.ResetCreatedAt()
  51627. return nil
  51628. case wxcardvisit.FieldUpdatedAt:
  51629. m.ResetUpdatedAt()
  51630. return nil
  51631. case wxcardvisit.FieldDeletedAt:
  51632. m.ResetDeletedAt()
  51633. return nil
  51634. case wxcardvisit.FieldUserID:
  51635. m.ResetUserID()
  51636. return nil
  51637. case wxcardvisit.FieldBotID:
  51638. m.ResetBotID()
  51639. return nil
  51640. case wxcardvisit.FieldBotType:
  51641. m.ResetBotType()
  51642. return nil
  51643. }
  51644. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51645. }
  51646. // AddedEdges returns all edge names that were set/added in this mutation.
  51647. func (m *WxCardVisitMutation) AddedEdges() []string {
  51648. edges := make([]string, 0, 0)
  51649. return edges
  51650. }
  51651. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51652. // name in this mutation.
  51653. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  51654. return nil
  51655. }
  51656. // RemovedEdges returns all edge names that were removed in this mutation.
  51657. func (m *WxCardVisitMutation) RemovedEdges() []string {
  51658. edges := make([]string, 0, 0)
  51659. return edges
  51660. }
  51661. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51662. // the given name in this mutation.
  51663. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  51664. return nil
  51665. }
  51666. // ClearedEdges returns all edge names that were cleared in this mutation.
  51667. func (m *WxCardVisitMutation) ClearedEdges() []string {
  51668. edges := make([]string, 0, 0)
  51669. return edges
  51670. }
  51671. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51672. // was cleared in this mutation.
  51673. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  51674. return false
  51675. }
  51676. // ClearEdge clears the value of the edge with the given name. It returns an error
  51677. // if that edge is not defined in the schema.
  51678. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  51679. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  51680. }
  51681. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51682. // It returns an error if the edge is not defined in the schema.
  51683. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  51684. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  51685. }
  51686. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  51687. type XunjiMutation struct {
  51688. config
  51689. op Op
  51690. typ string
  51691. id *uint64
  51692. created_at *time.Time
  51693. updated_at *time.Time
  51694. status *uint8
  51695. addstatus *int8
  51696. deleted_at *time.Time
  51697. app_key *string
  51698. app_secret *string
  51699. token *string
  51700. encoding_key *string
  51701. organization_id *uint64
  51702. addorganization_id *int64
  51703. clearedFields map[string]struct{}
  51704. done bool
  51705. oldValue func(context.Context) (*Xunji, error)
  51706. predicates []predicate.Xunji
  51707. }
  51708. var _ ent.Mutation = (*XunjiMutation)(nil)
  51709. // xunjiOption allows management of the mutation configuration using functional options.
  51710. type xunjiOption func(*XunjiMutation)
  51711. // newXunjiMutation creates new mutation for the Xunji entity.
  51712. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  51713. m := &XunjiMutation{
  51714. config: c,
  51715. op: op,
  51716. typ: TypeXunji,
  51717. clearedFields: make(map[string]struct{}),
  51718. }
  51719. for _, opt := range opts {
  51720. opt(m)
  51721. }
  51722. return m
  51723. }
  51724. // withXunjiID sets the ID field of the mutation.
  51725. func withXunjiID(id uint64) xunjiOption {
  51726. return func(m *XunjiMutation) {
  51727. var (
  51728. err error
  51729. once sync.Once
  51730. value *Xunji
  51731. )
  51732. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  51733. once.Do(func() {
  51734. if m.done {
  51735. err = errors.New("querying old values post mutation is not allowed")
  51736. } else {
  51737. value, err = m.Client().Xunji.Get(ctx, id)
  51738. }
  51739. })
  51740. return value, err
  51741. }
  51742. m.id = &id
  51743. }
  51744. }
  51745. // withXunji sets the old Xunji of the mutation.
  51746. func withXunji(node *Xunji) xunjiOption {
  51747. return func(m *XunjiMutation) {
  51748. m.oldValue = func(context.Context) (*Xunji, error) {
  51749. return node, nil
  51750. }
  51751. m.id = &node.ID
  51752. }
  51753. }
  51754. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51755. // executed in a transaction (ent.Tx), a transactional client is returned.
  51756. func (m XunjiMutation) Client() *Client {
  51757. client := &Client{config: m.config}
  51758. client.init()
  51759. return client
  51760. }
  51761. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51762. // it returns an error otherwise.
  51763. func (m XunjiMutation) Tx() (*Tx, error) {
  51764. if _, ok := m.driver.(*txDriver); !ok {
  51765. return nil, errors.New("ent: mutation is not running in a transaction")
  51766. }
  51767. tx := &Tx{config: m.config}
  51768. tx.init()
  51769. return tx, nil
  51770. }
  51771. // SetID sets the value of the id field. Note that this
  51772. // operation is only accepted on creation of Xunji entities.
  51773. func (m *XunjiMutation) SetID(id uint64) {
  51774. m.id = &id
  51775. }
  51776. // ID returns the ID value in the mutation. Note that the ID is only available
  51777. // if it was provided to the builder or after it was returned from the database.
  51778. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  51779. if m.id == nil {
  51780. return
  51781. }
  51782. return *m.id, true
  51783. }
  51784. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51785. // That means, if the mutation is applied within a transaction with an isolation level such
  51786. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51787. // or updated by the mutation.
  51788. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  51789. switch {
  51790. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51791. id, exists := m.ID()
  51792. if exists {
  51793. return []uint64{id}, nil
  51794. }
  51795. fallthrough
  51796. case m.op.Is(OpUpdate | OpDelete):
  51797. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  51798. default:
  51799. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51800. }
  51801. }
  51802. // SetCreatedAt sets the "created_at" field.
  51803. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  51804. m.created_at = &t
  51805. }
  51806. // CreatedAt returns the value of the "created_at" field in the mutation.
  51807. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  51808. v := m.created_at
  51809. if v == nil {
  51810. return
  51811. }
  51812. return *v, true
  51813. }
  51814. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  51815. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51817. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51818. if !m.op.Is(OpUpdateOne) {
  51819. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51820. }
  51821. if m.id == nil || m.oldValue == nil {
  51822. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51823. }
  51824. oldValue, err := m.oldValue(ctx)
  51825. if err != nil {
  51826. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51827. }
  51828. return oldValue.CreatedAt, nil
  51829. }
  51830. // ResetCreatedAt resets all changes to the "created_at" field.
  51831. func (m *XunjiMutation) ResetCreatedAt() {
  51832. m.created_at = nil
  51833. }
  51834. // SetUpdatedAt sets the "updated_at" field.
  51835. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  51836. m.updated_at = &t
  51837. }
  51838. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51839. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  51840. v := m.updated_at
  51841. if v == nil {
  51842. return
  51843. }
  51844. return *v, true
  51845. }
  51846. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  51847. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51849. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51850. if !m.op.Is(OpUpdateOne) {
  51851. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51852. }
  51853. if m.id == nil || m.oldValue == nil {
  51854. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51855. }
  51856. oldValue, err := m.oldValue(ctx)
  51857. if err != nil {
  51858. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51859. }
  51860. return oldValue.UpdatedAt, nil
  51861. }
  51862. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51863. func (m *XunjiMutation) ResetUpdatedAt() {
  51864. m.updated_at = nil
  51865. }
  51866. // SetStatus sets the "status" field.
  51867. func (m *XunjiMutation) SetStatus(u uint8) {
  51868. m.status = &u
  51869. m.addstatus = nil
  51870. }
  51871. // Status returns the value of the "status" field in the mutation.
  51872. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  51873. v := m.status
  51874. if v == nil {
  51875. return
  51876. }
  51877. return *v, true
  51878. }
  51879. // OldStatus returns the old "status" field's value of the Xunji entity.
  51880. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51882. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51883. if !m.op.Is(OpUpdateOne) {
  51884. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51885. }
  51886. if m.id == nil || m.oldValue == nil {
  51887. return v, errors.New("OldStatus requires an ID field in the mutation")
  51888. }
  51889. oldValue, err := m.oldValue(ctx)
  51890. if err != nil {
  51891. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51892. }
  51893. return oldValue.Status, nil
  51894. }
  51895. // AddStatus adds u to the "status" field.
  51896. func (m *XunjiMutation) AddStatus(u int8) {
  51897. if m.addstatus != nil {
  51898. *m.addstatus += u
  51899. } else {
  51900. m.addstatus = &u
  51901. }
  51902. }
  51903. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51904. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  51905. v := m.addstatus
  51906. if v == nil {
  51907. return
  51908. }
  51909. return *v, true
  51910. }
  51911. // ClearStatus clears the value of the "status" field.
  51912. func (m *XunjiMutation) ClearStatus() {
  51913. m.status = nil
  51914. m.addstatus = nil
  51915. m.clearedFields[xunji.FieldStatus] = struct{}{}
  51916. }
  51917. // StatusCleared returns if the "status" field was cleared in this mutation.
  51918. func (m *XunjiMutation) StatusCleared() bool {
  51919. _, ok := m.clearedFields[xunji.FieldStatus]
  51920. return ok
  51921. }
  51922. // ResetStatus resets all changes to the "status" field.
  51923. func (m *XunjiMutation) ResetStatus() {
  51924. m.status = nil
  51925. m.addstatus = nil
  51926. delete(m.clearedFields, xunji.FieldStatus)
  51927. }
  51928. // SetDeletedAt sets the "deleted_at" field.
  51929. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  51930. m.deleted_at = &t
  51931. }
  51932. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51933. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  51934. v := m.deleted_at
  51935. if v == nil {
  51936. return
  51937. }
  51938. return *v, true
  51939. }
  51940. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  51941. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51943. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51944. if !m.op.Is(OpUpdateOne) {
  51945. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51946. }
  51947. if m.id == nil || m.oldValue == nil {
  51948. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51949. }
  51950. oldValue, err := m.oldValue(ctx)
  51951. if err != nil {
  51952. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51953. }
  51954. return oldValue.DeletedAt, nil
  51955. }
  51956. // ClearDeletedAt clears the value of the "deleted_at" field.
  51957. func (m *XunjiMutation) ClearDeletedAt() {
  51958. m.deleted_at = nil
  51959. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  51960. }
  51961. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51962. func (m *XunjiMutation) DeletedAtCleared() bool {
  51963. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  51964. return ok
  51965. }
  51966. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51967. func (m *XunjiMutation) ResetDeletedAt() {
  51968. m.deleted_at = nil
  51969. delete(m.clearedFields, xunji.FieldDeletedAt)
  51970. }
  51971. // SetAppKey sets the "app_key" field.
  51972. func (m *XunjiMutation) SetAppKey(s string) {
  51973. m.app_key = &s
  51974. }
  51975. // AppKey returns the value of the "app_key" field in the mutation.
  51976. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  51977. v := m.app_key
  51978. if v == nil {
  51979. return
  51980. }
  51981. return *v, true
  51982. }
  51983. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  51984. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51986. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  51987. if !m.op.Is(OpUpdateOne) {
  51988. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  51989. }
  51990. if m.id == nil || m.oldValue == nil {
  51991. return v, errors.New("OldAppKey requires an ID field in the mutation")
  51992. }
  51993. oldValue, err := m.oldValue(ctx)
  51994. if err != nil {
  51995. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  51996. }
  51997. return oldValue.AppKey, nil
  51998. }
  51999. // ClearAppKey clears the value of the "app_key" field.
  52000. func (m *XunjiMutation) ClearAppKey() {
  52001. m.app_key = nil
  52002. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  52003. }
  52004. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  52005. func (m *XunjiMutation) AppKeyCleared() bool {
  52006. _, ok := m.clearedFields[xunji.FieldAppKey]
  52007. return ok
  52008. }
  52009. // ResetAppKey resets all changes to the "app_key" field.
  52010. func (m *XunjiMutation) ResetAppKey() {
  52011. m.app_key = nil
  52012. delete(m.clearedFields, xunji.FieldAppKey)
  52013. }
  52014. // SetAppSecret sets the "app_secret" field.
  52015. func (m *XunjiMutation) SetAppSecret(s string) {
  52016. m.app_secret = &s
  52017. }
  52018. // AppSecret returns the value of the "app_secret" field in the mutation.
  52019. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  52020. v := m.app_secret
  52021. if v == nil {
  52022. return
  52023. }
  52024. return *v, true
  52025. }
  52026. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  52027. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52029. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  52030. if !m.op.Is(OpUpdateOne) {
  52031. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  52032. }
  52033. if m.id == nil || m.oldValue == nil {
  52034. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  52035. }
  52036. oldValue, err := m.oldValue(ctx)
  52037. if err != nil {
  52038. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  52039. }
  52040. return oldValue.AppSecret, nil
  52041. }
  52042. // ClearAppSecret clears the value of the "app_secret" field.
  52043. func (m *XunjiMutation) ClearAppSecret() {
  52044. m.app_secret = nil
  52045. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  52046. }
  52047. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  52048. func (m *XunjiMutation) AppSecretCleared() bool {
  52049. _, ok := m.clearedFields[xunji.FieldAppSecret]
  52050. return ok
  52051. }
  52052. // ResetAppSecret resets all changes to the "app_secret" field.
  52053. func (m *XunjiMutation) ResetAppSecret() {
  52054. m.app_secret = nil
  52055. delete(m.clearedFields, xunji.FieldAppSecret)
  52056. }
  52057. // SetToken sets the "token" field.
  52058. func (m *XunjiMutation) SetToken(s string) {
  52059. m.token = &s
  52060. }
  52061. // Token returns the value of the "token" field in the mutation.
  52062. func (m *XunjiMutation) Token() (r string, exists bool) {
  52063. v := m.token
  52064. if v == nil {
  52065. return
  52066. }
  52067. return *v, true
  52068. }
  52069. // OldToken returns the old "token" field's value of the Xunji entity.
  52070. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52072. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  52073. if !m.op.Is(OpUpdateOne) {
  52074. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  52075. }
  52076. if m.id == nil || m.oldValue == nil {
  52077. return v, errors.New("OldToken requires an ID field in the mutation")
  52078. }
  52079. oldValue, err := m.oldValue(ctx)
  52080. if err != nil {
  52081. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  52082. }
  52083. return oldValue.Token, nil
  52084. }
  52085. // ClearToken clears the value of the "token" field.
  52086. func (m *XunjiMutation) ClearToken() {
  52087. m.token = nil
  52088. m.clearedFields[xunji.FieldToken] = struct{}{}
  52089. }
  52090. // TokenCleared returns if the "token" field was cleared in this mutation.
  52091. func (m *XunjiMutation) TokenCleared() bool {
  52092. _, ok := m.clearedFields[xunji.FieldToken]
  52093. return ok
  52094. }
  52095. // ResetToken resets all changes to the "token" field.
  52096. func (m *XunjiMutation) ResetToken() {
  52097. m.token = nil
  52098. delete(m.clearedFields, xunji.FieldToken)
  52099. }
  52100. // SetEncodingKey sets the "encoding_key" field.
  52101. func (m *XunjiMutation) SetEncodingKey(s string) {
  52102. m.encoding_key = &s
  52103. }
  52104. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  52105. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  52106. v := m.encoding_key
  52107. if v == nil {
  52108. return
  52109. }
  52110. return *v, true
  52111. }
  52112. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  52113. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52115. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  52116. if !m.op.Is(OpUpdateOne) {
  52117. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  52118. }
  52119. if m.id == nil || m.oldValue == nil {
  52120. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  52121. }
  52122. oldValue, err := m.oldValue(ctx)
  52123. if err != nil {
  52124. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  52125. }
  52126. return oldValue.EncodingKey, nil
  52127. }
  52128. // ClearEncodingKey clears the value of the "encoding_key" field.
  52129. func (m *XunjiMutation) ClearEncodingKey() {
  52130. m.encoding_key = nil
  52131. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  52132. }
  52133. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  52134. func (m *XunjiMutation) EncodingKeyCleared() bool {
  52135. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  52136. return ok
  52137. }
  52138. // ResetEncodingKey resets all changes to the "encoding_key" field.
  52139. func (m *XunjiMutation) ResetEncodingKey() {
  52140. m.encoding_key = nil
  52141. delete(m.clearedFields, xunji.FieldEncodingKey)
  52142. }
  52143. // SetOrganizationID sets the "organization_id" field.
  52144. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  52145. m.organization_id = &u
  52146. m.addorganization_id = nil
  52147. }
  52148. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52149. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  52150. v := m.organization_id
  52151. if v == nil {
  52152. return
  52153. }
  52154. return *v, true
  52155. }
  52156. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  52157. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52159. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52160. if !m.op.Is(OpUpdateOne) {
  52161. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52162. }
  52163. if m.id == nil || m.oldValue == nil {
  52164. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52165. }
  52166. oldValue, err := m.oldValue(ctx)
  52167. if err != nil {
  52168. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52169. }
  52170. return oldValue.OrganizationID, nil
  52171. }
  52172. // AddOrganizationID adds u to the "organization_id" field.
  52173. func (m *XunjiMutation) AddOrganizationID(u int64) {
  52174. if m.addorganization_id != nil {
  52175. *m.addorganization_id += u
  52176. } else {
  52177. m.addorganization_id = &u
  52178. }
  52179. }
  52180. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52181. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  52182. v := m.addorganization_id
  52183. if v == nil {
  52184. return
  52185. }
  52186. return *v, true
  52187. }
  52188. // ResetOrganizationID resets all changes to the "organization_id" field.
  52189. func (m *XunjiMutation) ResetOrganizationID() {
  52190. m.organization_id = nil
  52191. m.addorganization_id = nil
  52192. }
  52193. // Where appends a list predicates to the XunjiMutation builder.
  52194. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  52195. m.predicates = append(m.predicates, ps...)
  52196. }
  52197. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  52198. // users can use type-assertion to append predicates that do not depend on any generated package.
  52199. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  52200. p := make([]predicate.Xunji, len(ps))
  52201. for i := range ps {
  52202. p[i] = ps[i]
  52203. }
  52204. m.Where(p...)
  52205. }
  52206. // Op returns the operation name.
  52207. func (m *XunjiMutation) Op() Op {
  52208. return m.op
  52209. }
  52210. // SetOp allows setting the mutation operation.
  52211. func (m *XunjiMutation) SetOp(op Op) {
  52212. m.op = op
  52213. }
  52214. // Type returns the node type of this mutation (Xunji).
  52215. func (m *XunjiMutation) Type() string {
  52216. return m.typ
  52217. }
  52218. // Fields returns all fields that were changed during this mutation. Note that in
  52219. // order to get all numeric fields that were incremented/decremented, call
  52220. // AddedFields().
  52221. func (m *XunjiMutation) Fields() []string {
  52222. fields := make([]string, 0, 9)
  52223. if m.created_at != nil {
  52224. fields = append(fields, xunji.FieldCreatedAt)
  52225. }
  52226. if m.updated_at != nil {
  52227. fields = append(fields, xunji.FieldUpdatedAt)
  52228. }
  52229. if m.status != nil {
  52230. fields = append(fields, xunji.FieldStatus)
  52231. }
  52232. if m.deleted_at != nil {
  52233. fields = append(fields, xunji.FieldDeletedAt)
  52234. }
  52235. if m.app_key != nil {
  52236. fields = append(fields, xunji.FieldAppKey)
  52237. }
  52238. if m.app_secret != nil {
  52239. fields = append(fields, xunji.FieldAppSecret)
  52240. }
  52241. if m.token != nil {
  52242. fields = append(fields, xunji.FieldToken)
  52243. }
  52244. if m.encoding_key != nil {
  52245. fields = append(fields, xunji.FieldEncodingKey)
  52246. }
  52247. if m.organization_id != nil {
  52248. fields = append(fields, xunji.FieldOrganizationID)
  52249. }
  52250. return fields
  52251. }
  52252. // Field returns the value of a field with the given name. The second boolean
  52253. // return value indicates that this field was not set, or was not defined in the
  52254. // schema.
  52255. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  52256. switch name {
  52257. case xunji.FieldCreatedAt:
  52258. return m.CreatedAt()
  52259. case xunji.FieldUpdatedAt:
  52260. return m.UpdatedAt()
  52261. case xunji.FieldStatus:
  52262. return m.Status()
  52263. case xunji.FieldDeletedAt:
  52264. return m.DeletedAt()
  52265. case xunji.FieldAppKey:
  52266. return m.AppKey()
  52267. case xunji.FieldAppSecret:
  52268. return m.AppSecret()
  52269. case xunji.FieldToken:
  52270. return m.Token()
  52271. case xunji.FieldEncodingKey:
  52272. return m.EncodingKey()
  52273. case xunji.FieldOrganizationID:
  52274. return m.OrganizationID()
  52275. }
  52276. return nil, false
  52277. }
  52278. // OldField returns the old value of the field from the database. An error is
  52279. // returned if the mutation operation is not UpdateOne, or the query to the
  52280. // database failed.
  52281. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52282. switch name {
  52283. case xunji.FieldCreatedAt:
  52284. return m.OldCreatedAt(ctx)
  52285. case xunji.FieldUpdatedAt:
  52286. return m.OldUpdatedAt(ctx)
  52287. case xunji.FieldStatus:
  52288. return m.OldStatus(ctx)
  52289. case xunji.FieldDeletedAt:
  52290. return m.OldDeletedAt(ctx)
  52291. case xunji.FieldAppKey:
  52292. return m.OldAppKey(ctx)
  52293. case xunji.FieldAppSecret:
  52294. return m.OldAppSecret(ctx)
  52295. case xunji.FieldToken:
  52296. return m.OldToken(ctx)
  52297. case xunji.FieldEncodingKey:
  52298. return m.OldEncodingKey(ctx)
  52299. case xunji.FieldOrganizationID:
  52300. return m.OldOrganizationID(ctx)
  52301. }
  52302. return nil, fmt.Errorf("unknown Xunji field %s", name)
  52303. }
  52304. // SetField sets the value of a field with the given name. It returns an error if
  52305. // the field is not defined in the schema, or if the type mismatched the field
  52306. // type.
  52307. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  52308. switch name {
  52309. case xunji.FieldCreatedAt:
  52310. v, ok := value.(time.Time)
  52311. if !ok {
  52312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52313. }
  52314. m.SetCreatedAt(v)
  52315. return nil
  52316. case xunji.FieldUpdatedAt:
  52317. v, ok := value.(time.Time)
  52318. if !ok {
  52319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52320. }
  52321. m.SetUpdatedAt(v)
  52322. return nil
  52323. case xunji.FieldStatus:
  52324. v, ok := value.(uint8)
  52325. if !ok {
  52326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52327. }
  52328. m.SetStatus(v)
  52329. return nil
  52330. case xunji.FieldDeletedAt:
  52331. v, ok := value.(time.Time)
  52332. if !ok {
  52333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52334. }
  52335. m.SetDeletedAt(v)
  52336. return nil
  52337. case xunji.FieldAppKey:
  52338. v, ok := value.(string)
  52339. if !ok {
  52340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52341. }
  52342. m.SetAppKey(v)
  52343. return nil
  52344. case xunji.FieldAppSecret:
  52345. v, ok := value.(string)
  52346. if !ok {
  52347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52348. }
  52349. m.SetAppSecret(v)
  52350. return nil
  52351. case xunji.FieldToken:
  52352. v, ok := value.(string)
  52353. if !ok {
  52354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52355. }
  52356. m.SetToken(v)
  52357. return nil
  52358. case xunji.FieldEncodingKey:
  52359. v, ok := value.(string)
  52360. if !ok {
  52361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52362. }
  52363. m.SetEncodingKey(v)
  52364. return nil
  52365. case xunji.FieldOrganizationID:
  52366. v, ok := value.(uint64)
  52367. if !ok {
  52368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52369. }
  52370. m.SetOrganizationID(v)
  52371. return nil
  52372. }
  52373. return fmt.Errorf("unknown Xunji field %s", name)
  52374. }
  52375. // AddedFields returns all numeric fields that were incremented/decremented during
  52376. // this mutation.
  52377. func (m *XunjiMutation) AddedFields() []string {
  52378. var fields []string
  52379. if m.addstatus != nil {
  52380. fields = append(fields, xunji.FieldStatus)
  52381. }
  52382. if m.addorganization_id != nil {
  52383. fields = append(fields, xunji.FieldOrganizationID)
  52384. }
  52385. return fields
  52386. }
  52387. // AddedField returns the numeric value that was incremented/decremented on a field
  52388. // with the given name. The second boolean return value indicates that this field
  52389. // was not set, or was not defined in the schema.
  52390. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  52391. switch name {
  52392. case xunji.FieldStatus:
  52393. return m.AddedStatus()
  52394. case xunji.FieldOrganizationID:
  52395. return m.AddedOrganizationID()
  52396. }
  52397. return nil, false
  52398. }
  52399. // AddField adds the value to the field with the given name. It returns an error if
  52400. // the field is not defined in the schema, or if the type mismatched the field
  52401. // type.
  52402. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  52403. switch name {
  52404. case xunji.FieldStatus:
  52405. v, ok := value.(int8)
  52406. if !ok {
  52407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52408. }
  52409. m.AddStatus(v)
  52410. return nil
  52411. case xunji.FieldOrganizationID:
  52412. v, ok := value.(int64)
  52413. if !ok {
  52414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52415. }
  52416. m.AddOrganizationID(v)
  52417. return nil
  52418. }
  52419. return fmt.Errorf("unknown Xunji numeric field %s", name)
  52420. }
  52421. // ClearedFields returns all nullable fields that were cleared during this
  52422. // mutation.
  52423. func (m *XunjiMutation) ClearedFields() []string {
  52424. var fields []string
  52425. if m.FieldCleared(xunji.FieldStatus) {
  52426. fields = append(fields, xunji.FieldStatus)
  52427. }
  52428. if m.FieldCleared(xunji.FieldDeletedAt) {
  52429. fields = append(fields, xunji.FieldDeletedAt)
  52430. }
  52431. if m.FieldCleared(xunji.FieldAppKey) {
  52432. fields = append(fields, xunji.FieldAppKey)
  52433. }
  52434. if m.FieldCleared(xunji.FieldAppSecret) {
  52435. fields = append(fields, xunji.FieldAppSecret)
  52436. }
  52437. if m.FieldCleared(xunji.FieldToken) {
  52438. fields = append(fields, xunji.FieldToken)
  52439. }
  52440. if m.FieldCleared(xunji.FieldEncodingKey) {
  52441. fields = append(fields, xunji.FieldEncodingKey)
  52442. }
  52443. return fields
  52444. }
  52445. // FieldCleared returns a boolean indicating if a field with the given name was
  52446. // cleared in this mutation.
  52447. func (m *XunjiMutation) FieldCleared(name string) bool {
  52448. _, ok := m.clearedFields[name]
  52449. return ok
  52450. }
  52451. // ClearField clears the value of the field with the given name. It returns an
  52452. // error if the field is not defined in the schema.
  52453. func (m *XunjiMutation) ClearField(name string) error {
  52454. switch name {
  52455. case xunji.FieldStatus:
  52456. m.ClearStatus()
  52457. return nil
  52458. case xunji.FieldDeletedAt:
  52459. m.ClearDeletedAt()
  52460. return nil
  52461. case xunji.FieldAppKey:
  52462. m.ClearAppKey()
  52463. return nil
  52464. case xunji.FieldAppSecret:
  52465. m.ClearAppSecret()
  52466. return nil
  52467. case xunji.FieldToken:
  52468. m.ClearToken()
  52469. return nil
  52470. case xunji.FieldEncodingKey:
  52471. m.ClearEncodingKey()
  52472. return nil
  52473. }
  52474. return fmt.Errorf("unknown Xunji nullable field %s", name)
  52475. }
  52476. // ResetField resets all changes in the mutation for the field with the given name.
  52477. // It returns an error if the field is not defined in the schema.
  52478. func (m *XunjiMutation) ResetField(name string) error {
  52479. switch name {
  52480. case xunji.FieldCreatedAt:
  52481. m.ResetCreatedAt()
  52482. return nil
  52483. case xunji.FieldUpdatedAt:
  52484. m.ResetUpdatedAt()
  52485. return nil
  52486. case xunji.FieldStatus:
  52487. m.ResetStatus()
  52488. return nil
  52489. case xunji.FieldDeletedAt:
  52490. m.ResetDeletedAt()
  52491. return nil
  52492. case xunji.FieldAppKey:
  52493. m.ResetAppKey()
  52494. return nil
  52495. case xunji.FieldAppSecret:
  52496. m.ResetAppSecret()
  52497. return nil
  52498. case xunji.FieldToken:
  52499. m.ResetToken()
  52500. return nil
  52501. case xunji.FieldEncodingKey:
  52502. m.ResetEncodingKey()
  52503. return nil
  52504. case xunji.FieldOrganizationID:
  52505. m.ResetOrganizationID()
  52506. return nil
  52507. }
  52508. return fmt.Errorf("unknown Xunji field %s", name)
  52509. }
  52510. // AddedEdges returns all edge names that were set/added in this mutation.
  52511. func (m *XunjiMutation) AddedEdges() []string {
  52512. edges := make([]string, 0, 0)
  52513. return edges
  52514. }
  52515. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52516. // name in this mutation.
  52517. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  52518. return nil
  52519. }
  52520. // RemovedEdges returns all edge names that were removed in this mutation.
  52521. func (m *XunjiMutation) RemovedEdges() []string {
  52522. edges := make([]string, 0, 0)
  52523. return edges
  52524. }
  52525. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52526. // the given name in this mutation.
  52527. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  52528. return nil
  52529. }
  52530. // ClearedEdges returns all edge names that were cleared in this mutation.
  52531. func (m *XunjiMutation) ClearedEdges() []string {
  52532. edges := make([]string, 0, 0)
  52533. return edges
  52534. }
  52535. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52536. // was cleared in this mutation.
  52537. func (m *XunjiMutation) EdgeCleared(name string) bool {
  52538. return false
  52539. }
  52540. // ClearEdge clears the value of the edge with the given name. It returns an error
  52541. // if that edge is not defined in the schema.
  52542. func (m *XunjiMutation) ClearEdge(name string) error {
  52543. return fmt.Errorf("unknown Xunji unique edge %s", name)
  52544. }
  52545. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52546. // It returns an error if the edge is not defined in the schema.
  52547. func (m *XunjiMutation) ResetEdge(name string) error {
  52548. return fmt.Errorf("unknown Xunji edge %s", name)
  52549. }
  52550. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  52551. type XunjiServiceMutation struct {
  52552. config
  52553. op Op
  52554. typ string
  52555. id *uint64
  52556. created_at *time.Time
  52557. updated_at *time.Time
  52558. status *uint8
  52559. addstatus *int8
  52560. deleted_at *time.Time
  52561. xunji_id *uint64
  52562. addxunji_id *int64
  52563. organization_id *uint64
  52564. addorganization_id *int64
  52565. wxid *string
  52566. api_base *string
  52567. api_key *string
  52568. clearedFields map[string]struct{}
  52569. agent *uint64
  52570. clearedagent bool
  52571. done bool
  52572. oldValue func(context.Context) (*XunjiService, error)
  52573. predicates []predicate.XunjiService
  52574. }
  52575. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  52576. // xunjiserviceOption allows management of the mutation configuration using functional options.
  52577. type xunjiserviceOption func(*XunjiServiceMutation)
  52578. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  52579. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  52580. m := &XunjiServiceMutation{
  52581. config: c,
  52582. op: op,
  52583. typ: TypeXunjiService,
  52584. clearedFields: make(map[string]struct{}),
  52585. }
  52586. for _, opt := range opts {
  52587. opt(m)
  52588. }
  52589. return m
  52590. }
  52591. // withXunjiServiceID sets the ID field of the mutation.
  52592. func withXunjiServiceID(id uint64) xunjiserviceOption {
  52593. return func(m *XunjiServiceMutation) {
  52594. var (
  52595. err error
  52596. once sync.Once
  52597. value *XunjiService
  52598. )
  52599. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  52600. once.Do(func() {
  52601. if m.done {
  52602. err = errors.New("querying old values post mutation is not allowed")
  52603. } else {
  52604. value, err = m.Client().XunjiService.Get(ctx, id)
  52605. }
  52606. })
  52607. return value, err
  52608. }
  52609. m.id = &id
  52610. }
  52611. }
  52612. // withXunjiService sets the old XunjiService of the mutation.
  52613. func withXunjiService(node *XunjiService) xunjiserviceOption {
  52614. return func(m *XunjiServiceMutation) {
  52615. m.oldValue = func(context.Context) (*XunjiService, error) {
  52616. return node, nil
  52617. }
  52618. m.id = &node.ID
  52619. }
  52620. }
  52621. // Client returns a new `ent.Client` from the mutation. If the mutation was
  52622. // executed in a transaction (ent.Tx), a transactional client is returned.
  52623. func (m XunjiServiceMutation) Client() *Client {
  52624. client := &Client{config: m.config}
  52625. client.init()
  52626. return client
  52627. }
  52628. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  52629. // it returns an error otherwise.
  52630. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  52631. if _, ok := m.driver.(*txDriver); !ok {
  52632. return nil, errors.New("ent: mutation is not running in a transaction")
  52633. }
  52634. tx := &Tx{config: m.config}
  52635. tx.init()
  52636. return tx, nil
  52637. }
  52638. // SetID sets the value of the id field. Note that this
  52639. // operation is only accepted on creation of XunjiService entities.
  52640. func (m *XunjiServiceMutation) SetID(id uint64) {
  52641. m.id = &id
  52642. }
  52643. // ID returns the ID value in the mutation. Note that the ID is only available
  52644. // if it was provided to the builder or after it was returned from the database.
  52645. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  52646. if m.id == nil {
  52647. return
  52648. }
  52649. return *m.id, true
  52650. }
  52651. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  52652. // That means, if the mutation is applied within a transaction with an isolation level such
  52653. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  52654. // or updated by the mutation.
  52655. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  52656. switch {
  52657. case m.op.Is(OpUpdateOne | OpDeleteOne):
  52658. id, exists := m.ID()
  52659. if exists {
  52660. return []uint64{id}, nil
  52661. }
  52662. fallthrough
  52663. case m.op.Is(OpUpdate | OpDelete):
  52664. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  52665. default:
  52666. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  52667. }
  52668. }
  52669. // SetCreatedAt sets the "created_at" field.
  52670. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  52671. m.created_at = &t
  52672. }
  52673. // CreatedAt returns the value of the "created_at" field in the mutation.
  52674. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  52675. v := m.created_at
  52676. if v == nil {
  52677. return
  52678. }
  52679. return *v, true
  52680. }
  52681. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  52682. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52684. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  52685. if !m.op.Is(OpUpdateOne) {
  52686. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  52687. }
  52688. if m.id == nil || m.oldValue == nil {
  52689. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  52690. }
  52691. oldValue, err := m.oldValue(ctx)
  52692. if err != nil {
  52693. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  52694. }
  52695. return oldValue.CreatedAt, nil
  52696. }
  52697. // ResetCreatedAt resets all changes to the "created_at" field.
  52698. func (m *XunjiServiceMutation) ResetCreatedAt() {
  52699. m.created_at = nil
  52700. }
  52701. // SetUpdatedAt sets the "updated_at" field.
  52702. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  52703. m.updated_at = &t
  52704. }
  52705. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  52706. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  52707. v := m.updated_at
  52708. if v == nil {
  52709. return
  52710. }
  52711. return *v, true
  52712. }
  52713. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  52714. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52716. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  52717. if !m.op.Is(OpUpdateOne) {
  52718. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  52719. }
  52720. if m.id == nil || m.oldValue == nil {
  52721. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  52722. }
  52723. oldValue, err := m.oldValue(ctx)
  52724. if err != nil {
  52725. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  52726. }
  52727. return oldValue.UpdatedAt, nil
  52728. }
  52729. // ResetUpdatedAt resets all changes to the "updated_at" field.
  52730. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  52731. m.updated_at = nil
  52732. }
  52733. // SetStatus sets the "status" field.
  52734. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  52735. m.status = &u
  52736. m.addstatus = nil
  52737. }
  52738. // Status returns the value of the "status" field in the mutation.
  52739. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  52740. v := m.status
  52741. if v == nil {
  52742. return
  52743. }
  52744. return *v, true
  52745. }
  52746. // OldStatus returns the old "status" field's value of the XunjiService entity.
  52747. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52749. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  52750. if !m.op.Is(OpUpdateOne) {
  52751. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  52752. }
  52753. if m.id == nil || m.oldValue == nil {
  52754. return v, errors.New("OldStatus requires an ID field in the mutation")
  52755. }
  52756. oldValue, err := m.oldValue(ctx)
  52757. if err != nil {
  52758. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  52759. }
  52760. return oldValue.Status, nil
  52761. }
  52762. // AddStatus adds u to the "status" field.
  52763. func (m *XunjiServiceMutation) AddStatus(u int8) {
  52764. if m.addstatus != nil {
  52765. *m.addstatus += u
  52766. } else {
  52767. m.addstatus = &u
  52768. }
  52769. }
  52770. // AddedStatus returns the value that was added to the "status" field in this mutation.
  52771. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  52772. v := m.addstatus
  52773. if v == nil {
  52774. return
  52775. }
  52776. return *v, true
  52777. }
  52778. // ClearStatus clears the value of the "status" field.
  52779. func (m *XunjiServiceMutation) ClearStatus() {
  52780. m.status = nil
  52781. m.addstatus = nil
  52782. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  52783. }
  52784. // StatusCleared returns if the "status" field was cleared in this mutation.
  52785. func (m *XunjiServiceMutation) StatusCleared() bool {
  52786. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  52787. return ok
  52788. }
  52789. // ResetStatus resets all changes to the "status" field.
  52790. func (m *XunjiServiceMutation) ResetStatus() {
  52791. m.status = nil
  52792. m.addstatus = nil
  52793. delete(m.clearedFields, xunjiservice.FieldStatus)
  52794. }
  52795. // SetDeletedAt sets the "deleted_at" field.
  52796. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  52797. m.deleted_at = &t
  52798. }
  52799. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  52800. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  52801. v := m.deleted_at
  52802. if v == nil {
  52803. return
  52804. }
  52805. return *v, true
  52806. }
  52807. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  52808. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52810. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  52811. if !m.op.Is(OpUpdateOne) {
  52812. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  52813. }
  52814. if m.id == nil || m.oldValue == nil {
  52815. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  52816. }
  52817. oldValue, err := m.oldValue(ctx)
  52818. if err != nil {
  52819. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  52820. }
  52821. return oldValue.DeletedAt, nil
  52822. }
  52823. // ClearDeletedAt clears the value of the "deleted_at" field.
  52824. func (m *XunjiServiceMutation) ClearDeletedAt() {
  52825. m.deleted_at = nil
  52826. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  52827. }
  52828. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  52829. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  52830. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  52831. return ok
  52832. }
  52833. // ResetDeletedAt resets all changes to the "deleted_at" field.
  52834. func (m *XunjiServiceMutation) ResetDeletedAt() {
  52835. m.deleted_at = nil
  52836. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  52837. }
  52838. // SetXunjiID sets the "xunji_id" field.
  52839. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  52840. m.xunji_id = &u
  52841. m.addxunji_id = nil
  52842. }
  52843. // XunjiID returns the value of the "xunji_id" field in the mutation.
  52844. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  52845. v := m.xunji_id
  52846. if v == nil {
  52847. return
  52848. }
  52849. return *v, true
  52850. }
  52851. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  52852. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52854. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  52855. if !m.op.Is(OpUpdateOne) {
  52856. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  52857. }
  52858. if m.id == nil || m.oldValue == nil {
  52859. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  52860. }
  52861. oldValue, err := m.oldValue(ctx)
  52862. if err != nil {
  52863. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  52864. }
  52865. return oldValue.XunjiID, nil
  52866. }
  52867. // AddXunjiID adds u to the "xunji_id" field.
  52868. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  52869. if m.addxunji_id != nil {
  52870. *m.addxunji_id += u
  52871. } else {
  52872. m.addxunji_id = &u
  52873. }
  52874. }
  52875. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  52876. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  52877. v := m.addxunji_id
  52878. if v == nil {
  52879. return
  52880. }
  52881. return *v, true
  52882. }
  52883. // ResetXunjiID resets all changes to the "xunji_id" field.
  52884. func (m *XunjiServiceMutation) ResetXunjiID() {
  52885. m.xunji_id = nil
  52886. m.addxunji_id = nil
  52887. }
  52888. // SetAgentID sets the "agent_id" field.
  52889. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  52890. m.agent = &u
  52891. }
  52892. // AgentID returns the value of the "agent_id" field in the mutation.
  52893. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  52894. v := m.agent
  52895. if v == nil {
  52896. return
  52897. }
  52898. return *v, true
  52899. }
  52900. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  52901. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52903. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  52904. if !m.op.Is(OpUpdateOne) {
  52905. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  52906. }
  52907. if m.id == nil || m.oldValue == nil {
  52908. return v, errors.New("OldAgentID requires an ID field in the mutation")
  52909. }
  52910. oldValue, err := m.oldValue(ctx)
  52911. if err != nil {
  52912. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  52913. }
  52914. return oldValue.AgentID, nil
  52915. }
  52916. // ResetAgentID resets all changes to the "agent_id" field.
  52917. func (m *XunjiServiceMutation) ResetAgentID() {
  52918. m.agent = nil
  52919. }
  52920. // SetOrganizationID sets the "organization_id" field.
  52921. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  52922. m.organization_id = &u
  52923. m.addorganization_id = nil
  52924. }
  52925. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52926. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  52927. v := m.organization_id
  52928. if v == nil {
  52929. return
  52930. }
  52931. return *v, true
  52932. }
  52933. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  52934. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52936. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52937. if !m.op.Is(OpUpdateOne) {
  52938. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52939. }
  52940. if m.id == nil || m.oldValue == nil {
  52941. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52942. }
  52943. oldValue, err := m.oldValue(ctx)
  52944. if err != nil {
  52945. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52946. }
  52947. return oldValue.OrganizationID, nil
  52948. }
  52949. // AddOrganizationID adds u to the "organization_id" field.
  52950. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  52951. if m.addorganization_id != nil {
  52952. *m.addorganization_id += u
  52953. } else {
  52954. m.addorganization_id = &u
  52955. }
  52956. }
  52957. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52958. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  52959. v := m.addorganization_id
  52960. if v == nil {
  52961. return
  52962. }
  52963. return *v, true
  52964. }
  52965. // ResetOrganizationID resets all changes to the "organization_id" field.
  52966. func (m *XunjiServiceMutation) ResetOrganizationID() {
  52967. m.organization_id = nil
  52968. m.addorganization_id = nil
  52969. }
  52970. // SetWxid sets the "wxid" field.
  52971. func (m *XunjiServiceMutation) SetWxid(s string) {
  52972. m.wxid = &s
  52973. }
  52974. // Wxid returns the value of the "wxid" field in the mutation.
  52975. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  52976. v := m.wxid
  52977. if v == nil {
  52978. return
  52979. }
  52980. return *v, true
  52981. }
  52982. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  52983. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52985. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  52986. if !m.op.Is(OpUpdateOne) {
  52987. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  52988. }
  52989. if m.id == nil || m.oldValue == nil {
  52990. return v, errors.New("OldWxid requires an ID field in the mutation")
  52991. }
  52992. oldValue, err := m.oldValue(ctx)
  52993. if err != nil {
  52994. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  52995. }
  52996. return oldValue.Wxid, nil
  52997. }
  52998. // ResetWxid resets all changes to the "wxid" field.
  52999. func (m *XunjiServiceMutation) ResetWxid() {
  53000. m.wxid = nil
  53001. }
  53002. // SetAPIBase sets the "api_base" field.
  53003. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  53004. m.api_base = &s
  53005. }
  53006. // APIBase returns the value of the "api_base" field in the mutation.
  53007. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  53008. v := m.api_base
  53009. if v == nil {
  53010. return
  53011. }
  53012. return *v, true
  53013. }
  53014. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  53015. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  53016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  53017. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  53018. if !m.op.Is(OpUpdateOne) {
  53019. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  53020. }
  53021. if m.id == nil || m.oldValue == nil {
  53022. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  53023. }
  53024. oldValue, err := m.oldValue(ctx)
  53025. if err != nil {
  53026. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  53027. }
  53028. return oldValue.APIBase, nil
  53029. }
  53030. // ClearAPIBase clears the value of the "api_base" field.
  53031. func (m *XunjiServiceMutation) ClearAPIBase() {
  53032. m.api_base = nil
  53033. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  53034. }
  53035. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  53036. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  53037. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  53038. return ok
  53039. }
  53040. // ResetAPIBase resets all changes to the "api_base" field.
  53041. func (m *XunjiServiceMutation) ResetAPIBase() {
  53042. m.api_base = nil
  53043. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  53044. }
  53045. // SetAPIKey sets the "api_key" field.
  53046. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  53047. m.api_key = &s
  53048. }
  53049. // APIKey returns the value of the "api_key" field in the mutation.
  53050. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  53051. v := m.api_key
  53052. if v == nil {
  53053. return
  53054. }
  53055. return *v, true
  53056. }
  53057. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  53058. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  53059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  53060. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  53061. if !m.op.Is(OpUpdateOne) {
  53062. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  53063. }
  53064. if m.id == nil || m.oldValue == nil {
  53065. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  53066. }
  53067. oldValue, err := m.oldValue(ctx)
  53068. if err != nil {
  53069. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  53070. }
  53071. return oldValue.APIKey, nil
  53072. }
  53073. // ClearAPIKey clears the value of the "api_key" field.
  53074. func (m *XunjiServiceMutation) ClearAPIKey() {
  53075. m.api_key = nil
  53076. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  53077. }
  53078. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  53079. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  53080. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  53081. return ok
  53082. }
  53083. // ResetAPIKey resets all changes to the "api_key" field.
  53084. func (m *XunjiServiceMutation) ResetAPIKey() {
  53085. m.api_key = nil
  53086. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  53087. }
  53088. // ClearAgent clears the "agent" edge to the Agent entity.
  53089. func (m *XunjiServiceMutation) ClearAgent() {
  53090. m.clearedagent = true
  53091. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  53092. }
  53093. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  53094. func (m *XunjiServiceMutation) AgentCleared() bool {
  53095. return m.clearedagent
  53096. }
  53097. // AgentIDs returns the "agent" edge IDs in the mutation.
  53098. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  53099. // AgentID instead. It exists only for internal usage by the builders.
  53100. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  53101. if id := m.agent; id != nil {
  53102. ids = append(ids, *id)
  53103. }
  53104. return
  53105. }
  53106. // ResetAgent resets all changes to the "agent" edge.
  53107. func (m *XunjiServiceMutation) ResetAgent() {
  53108. m.agent = nil
  53109. m.clearedagent = false
  53110. }
  53111. // Where appends a list predicates to the XunjiServiceMutation builder.
  53112. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  53113. m.predicates = append(m.predicates, ps...)
  53114. }
  53115. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  53116. // users can use type-assertion to append predicates that do not depend on any generated package.
  53117. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  53118. p := make([]predicate.XunjiService, len(ps))
  53119. for i := range ps {
  53120. p[i] = ps[i]
  53121. }
  53122. m.Where(p...)
  53123. }
  53124. // Op returns the operation name.
  53125. func (m *XunjiServiceMutation) Op() Op {
  53126. return m.op
  53127. }
  53128. // SetOp allows setting the mutation operation.
  53129. func (m *XunjiServiceMutation) SetOp(op Op) {
  53130. m.op = op
  53131. }
  53132. // Type returns the node type of this mutation (XunjiService).
  53133. func (m *XunjiServiceMutation) Type() string {
  53134. return m.typ
  53135. }
  53136. // Fields returns all fields that were changed during this mutation. Note that in
  53137. // order to get all numeric fields that were incremented/decremented, call
  53138. // AddedFields().
  53139. func (m *XunjiServiceMutation) Fields() []string {
  53140. fields := make([]string, 0, 10)
  53141. if m.created_at != nil {
  53142. fields = append(fields, xunjiservice.FieldCreatedAt)
  53143. }
  53144. if m.updated_at != nil {
  53145. fields = append(fields, xunjiservice.FieldUpdatedAt)
  53146. }
  53147. if m.status != nil {
  53148. fields = append(fields, xunjiservice.FieldStatus)
  53149. }
  53150. if m.deleted_at != nil {
  53151. fields = append(fields, xunjiservice.FieldDeletedAt)
  53152. }
  53153. if m.xunji_id != nil {
  53154. fields = append(fields, xunjiservice.FieldXunjiID)
  53155. }
  53156. if m.agent != nil {
  53157. fields = append(fields, xunjiservice.FieldAgentID)
  53158. }
  53159. if m.organization_id != nil {
  53160. fields = append(fields, xunjiservice.FieldOrganizationID)
  53161. }
  53162. if m.wxid != nil {
  53163. fields = append(fields, xunjiservice.FieldWxid)
  53164. }
  53165. if m.api_base != nil {
  53166. fields = append(fields, xunjiservice.FieldAPIBase)
  53167. }
  53168. if m.api_key != nil {
  53169. fields = append(fields, xunjiservice.FieldAPIKey)
  53170. }
  53171. return fields
  53172. }
  53173. // Field returns the value of a field with the given name. The second boolean
  53174. // return value indicates that this field was not set, or was not defined in the
  53175. // schema.
  53176. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  53177. switch name {
  53178. case xunjiservice.FieldCreatedAt:
  53179. return m.CreatedAt()
  53180. case xunjiservice.FieldUpdatedAt:
  53181. return m.UpdatedAt()
  53182. case xunjiservice.FieldStatus:
  53183. return m.Status()
  53184. case xunjiservice.FieldDeletedAt:
  53185. return m.DeletedAt()
  53186. case xunjiservice.FieldXunjiID:
  53187. return m.XunjiID()
  53188. case xunjiservice.FieldAgentID:
  53189. return m.AgentID()
  53190. case xunjiservice.FieldOrganizationID:
  53191. return m.OrganizationID()
  53192. case xunjiservice.FieldWxid:
  53193. return m.Wxid()
  53194. case xunjiservice.FieldAPIBase:
  53195. return m.APIBase()
  53196. case xunjiservice.FieldAPIKey:
  53197. return m.APIKey()
  53198. }
  53199. return nil, false
  53200. }
  53201. // OldField returns the old value of the field from the database. An error is
  53202. // returned if the mutation operation is not UpdateOne, or the query to the
  53203. // database failed.
  53204. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  53205. switch name {
  53206. case xunjiservice.FieldCreatedAt:
  53207. return m.OldCreatedAt(ctx)
  53208. case xunjiservice.FieldUpdatedAt:
  53209. return m.OldUpdatedAt(ctx)
  53210. case xunjiservice.FieldStatus:
  53211. return m.OldStatus(ctx)
  53212. case xunjiservice.FieldDeletedAt:
  53213. return m.OldDeletedAt(ctx)
  53214. case xunjiservice.FieldXunjiID:
  53215. return m.OldXunjiID(ctx)
  53216. case xunjiservice.FieldAgentID:
  53217. return m.OldAgentID(ctx)
  53218. case xunjiservice.FieldOrganizationID:
  53219. return m.OldOrganizationID(ctx)
  53220. case xunjiservice.FieldWxid:
  53221. return m.OldWxid(ctx)
  53222. case xunjiservice.FieldAPIBase:
  53223. return m.OldAPIBase(ctx)
  53224. case xunjiservice.FieldAPIKey:
  53225. return m.OldAPIKey(ctx)
  53226. }
  53227. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  53228. }
  53229. // SetField sets the value of a field with the given name. It returns an error if
  53230. // the field is not defined in the schema, or if the type mismatched the field
  53231. // type.
  53232. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  53233. switch name {
  53234. case xunjiservice.FieldCreatedAt:
  53235. v, ok := value.(time.Time)
  53236. if !ok {
  53237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53238. }
  53239. m.SetCreatedAt(v)
  53240. return nil
  53241. case xunjiservice.FieldUpdatedAt:
  53242. v, ok := value.(time.Time)
  53243. if !ok {
  53244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53245. }
  53246. m.SetUpdatedAt(v)
  53247. return nil
  53248. case xunjiservice.FieldStatus:
  53249. v, ok := value.(uint8)
  53250. if !ok {
  53251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53252. }
  53253. m.SetStatus(v)
  53254. return nil
  53255. case xunjiservice.FieldDeletedAt:
  53256. v, ok := value.(time.Time)
  53257. if !ok {
  53258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53259. }
  53260. m.SetDeletedAt(v)
  53261. return nil
  53262. case xunjiservice.FieldXunjiID:
  53263. v, ok := value.(uint64)
  53264. if !ok {
  53265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53266. }
  53267. m.SetXunjiID(v)
  53268. return nil
  53269. case xunjiservice.FieldAgentID:
  53270. v, ok := value.(uint64)
  53271. if !ok {
  53272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53273. }
  53274. m.SetAgentID(v)
  53275. return nil
  53276. case xunjiservice.FieldOrganizationID:
  53277. v, ok := value.(uint64)
  53278. if !ok {
  53279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53280. }
  53281. m.SetOrganizationID(v)
  53282. return nil
  53283. case xunjiservice.FieldWxid:
  53284. v, ok := value.(string)
  53285. if !ok {
  53286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53287. }
  53288. m.SetWxid(v)
  53289. return nil
  53290. case xunjiservice.FieldAPIBase:
  53291. v, ok := value.(string)
  53292. if !ok {
  53293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53294. }
  53295. m.SetAPIBase(v)
  53296. return nil
  53297. case xunjiservice.FieldAPIKey:
  53298. v, ok := value.(string)
  53299. if !ok {
  53300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53301. }
  53302. m.SetAPIKey(v)
  53303. return nil
  53304. }
  53305. return fmt.Errorf("unknown XunjiService field %s", name)
  53306. }
  53307. // AddedFields returns all numeric fields that were incremented/decremented during
  53308. // this mutation.
  53309. func (m *XunjiServiceMutation) AddedFields() []string {
  53310. var fields []string
  53311. if m.addstatus != nil {
  53312. fields = append(fields, xunjiservice.FieldStatus)
  53313. }
  53314. if m.addxunji_id != nil {
  53315. fields = append(fields, xunjiservice.FieldXunjiID)
  53316. }
  53317. if m.addorganization_id != nil {
  53318. fields = append(fields, xunjiservice.FieldOrganizationID)
  53319. }
  53320. return fields
  53321. }
  53322. // AddedField returns the numeric value that was incremented/decremented on a field
  53323. // with the given name. The second boolean return value indicates that this field
  53324. // was not set, or was not defined in the schema.
  53325. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  53326. switch name {
  53327. case xunjiservice.FieldStatus:
  53328. return m.AddedStatus()
  53329. case xunjiservice.FieldXunjiID:
  53330. return m.AddedXunjiID()
  53331. case xunjiservice.FieldOrganizationID:
  53332. return m.AddedOrganizationID()
  53333. }
  53334. return nil, false
  53335. }
  53336. // AddField adds the value to the field with the given name. It returns an error if
  53337. // the field is not defined in the schema, or if the type mismatched the field
  53338. // type.
  53339. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  53340. switch name {
  53341. case xunjiservice.FieldStatus:
  53342. v, ok := value.(int8)
  53343. if !ok {
  53344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53345. }
  53346. m.AddStatus(v)
  53347. return nil
  53348. case xunjiservice.FieldXunjiID:
  53349. v, ok := value.(int64)
  53350. if !ok {
  53351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53352. }
  53353. m.AddXunjiID(v)
  53354. return nil
  53355. case xunjiservice.FieldOrganizationID:
  53356. v, ok := value.(int64)
  53357. if !ok {
  53358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53359. }
  53360. m.AddOrganizationID(v)
  53361. return nil
  53362. }
  53363. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  53364. }
  53365. // ClearedFields returns all nullable fields that were cleared during this
  53366. // mutation.
  53367. func (m *XunjiServiceMutation) ClearedFields() []string {
  53368. var fields []string
  53369. if m.FieldCleared(xunjiservice.FieldStatus) {
  53370. fields = append(fields, xunjiservice.FieldStatus)
  53371. }
  53372. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  53373. fields = append(fields, xunjiservice.FieldDeletedAt)
  53374. }
  53375. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  53376. fields = append(fields, xunjiservice.FieldAPIBase)
  53377. }
  53378. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  53379. fields = append(fields, xunjiservice.FieldAPIKey)
  53380. }
  53381. return fields
  53382. }
  53383. // FieldCleared returns a boolean indicating if a field with the given name was
  53384. // cleared in this mutation.
  53385. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  53386. _, ok := m.clearedFields[name]
  53387. return ok
  53388. }
  53389. // ClearField clears the value of the field with the given name. It returns an
  53390. // error if the field is not defined in the schema.
  53391. func (m *XunjiServiceMutation) ClearField(name string) error {
  53392. switch name {
  53393. case xunjiservice.FieldStatus:
  53394. m.ClearStatus()
  53395. return nil
  53396. case xunjiservice.FieldDeletedAt:
  53397. m.ClearDeletedAt()
  53398. return nil
  53399. case xunjiservice.FieldAPIBase:
  53400. m.ClearAPIBase()
  53401. return nil
  53402. case xunjiservice.FieldAPIKey:
  53403. m.ClearAPIKey()
  53404. return nil
  53405. }
  53406. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  53407. }
  53408. // ResetField resets all changes in the mutation for the field with the given name.
  53409. // It returns an error if the field is not defined in the schema.
  53410. func (m *XunjiServiceMutation) ResetField(name string) error {
  53411. switch name {
  53412. case xunjiservice.FieldCreatedAt:
  53413. m.ResetCreatedAt()
  53414. return nil
  53415. case xunjiservice.FieldUpdatedAt:
  53416. m.ResetUpdatedAt()
  53417. return nil
  53418. case xunjiservice.FieldStatus:
  53419. m.ResetStatus()
  53420. return nil
  53421. case xunjiservice.FieldDeletedAt:
  53422. m.ResetDeletedAt()
  53423. return nil
  53424. case xunjiservice.FieldXunjiID:
  53425. m.ResetXunjiID()
  53426. return nil
  53427. case xunjiservice.FieldAgentID:
  53428. m.ResetAgentID()
  53429. return nil
  53430. case xunjiservice.FieldOrganizationID:
  53431. m.ResetOrganizationID()
  53432. return nil
  53433. case xunjiservice.FieldWxid:
  53434. m.ResetWxid()
  53435. return nil
  53436. case xunjiservice.FieldAPIBase:
  53437. m.ResetAPIBase()
  53438. return nil
  53439. case xunjiservice.FieldAPIKey:
  53440. m.ResetAPIKey()
  53441. return nil
  53442. }
  53443. return fmt.Errorf("unknown XunjiService field %s", name)
  53444. }
  53445. // AddedEdges returns all edge names that were set/added in this mutation.
  53446. func (m *XunjiServiceMutation) AddedEdges() []string {
  53447. edges := make([]string, 0, 1)
  53448. if m.agent != nil {
  53449. edges = append(edges, xunjiservice.EdgeAgent)
  53450. }
  53451. return edges
  53452. }
  53453. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  53454. // name in this mutation.
  53455. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  53456. switch name {
  53457. case xunjiservice.EdgeAgent:
  53458. if id := m.agent; id != nil {
  53459. return []ent.Value{*id}
  53460. }
  53461. }
  53462. return nil
  53463. }
  53464. // RemovedEdges returns all edge names that were removed in this mutation.
  53465. func (m *XunjiServiceMutation) RemovedEdges() []string {
  53466. edges := make([]string, 0, 1)
  53467. return edges
  53468. }
  53469. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  53470. // the given name in this mutation.
  53471. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  53472. return nil
  53473. }
  53474. // ClearedEdges returns all edge names that were cleared in this mutation.
  53475. func (m *XunjiServiceMutation) ClearedEdges() []string {
  53476. edges := make([]string, 0, 1)
  53477. if m.clearedagent {
  53478. edges = append(edges, xunjiservice.EdgeAgent)
  53479. }
  53480. return edges
  53481. }
  53482. // EdgeCleared returns a boolean which indicates if the edge with the given name
  53483. // was cleared in this mutation.
  53484. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  53485. switch name {
  53486. case xunjiservice.EdgeAgent:
  53487. return m.clearedagent
  53488. }
  53489. return false
  53490. }
  53491. // ClearEdge clears the value of the edge with the given name. It returns an error
  53492. // if that edge is not defined in the schema.
  53493. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  53494. switch name {
  53495. case xunjiservice.EdgeAgent:
  53496. m.ClearAgent()
  53497. return nil
  53498. }
  53499. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  53500. }
  53501. // ResetEdge resets all changes to the edge with the given name in this mutation.
  53502. // It returns an error if the edge is not defined in the schema.
  53503. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  53504. switch name {
  53505. case xunjiservice.EdgeAgent:
  53506. m.ResetAgent()
  53507. return nil
  53508. }
  53509. return fmt.Errorf("unknown XunjiService edge %s", name)
  53510. }